@@ -34,7 +34,8 @@ static void *xmalloc(size_t size)
34
34
return ret ;
35
35
}
36
36
37
- static WCHAR * wusername , * password , * protocol , * host , * path , target [1024 ];
37
+ static WCHAR * wusername , * password , * protocol , * host , * path , target [1024 ],
38
+ * password_expiry_utc ;
38
39
39
40
static void write_item (const char * what , LPCWSTR wbuf , int wlen )
40
41
{
@@ -126,6 +127,7 @@ static void get_credential(void)
126
127
CREDENTIALW * * creds ;
127
128
DWORD num_creds ;
128
129
int i ;
130
+ CREDENTIAL_ATTRIBUTEW * attr ;
129
131
130
132
if (!CredEnumerateW (L"git:*" , 0 , & num_creds , & creds ))
131
133
return ;
@@ -138,6 +140,14 @@ static void get_credential(void)
138
140
write_item ("password" ,
139
141
(LPCWSTR )creds [i ]-> CredentialBlob ,
140
142
creds [i ]-> CredentialBlobSize / sizeof (WCHAR ));
143
+ for (int j = 0 ; j < creds [i ]-> AttributeCount ; j ++ ) {
144
+ attr = creds [i ]-> Attributes + j ;
145
+ if (!wcscmp (attr -> Keyword , L"git_password_expiry_utc" )) {
146
+ write_item ("password_expiry_utc" , (LPCWSTR )attr -> Value ,
147
+ attr -> ValueSize / sizeof (WCHAR ));
148
+ break ;
149
+ }
150
+ }
141
151
break ;
142
152
}
143
153
@@ -147,6 +157,7 @@ static void get_credential(void)
147
157
static void store_credential (void )
148
158
{
149
159
CREDENTIALW cred ;
160
+ CREDENTIAL_ATTRIBUTEW expiry_attr ;
150
161
151
162
if (!wusername || !password )
152
163
return ;
@@ -160,6 +171,14 @@ static void store_credential(void)
160
171
cred .Persist = CRED_PERSIST_LOCAL_MACHINE ;
161
172
cred .AttributeCount = 0 ;
162
173
cred .Attributes = NULL ;
174
+ if (password_expiry_utc != NULL ) {
175
+ expiry_attr .Keyword = L"git_password_expiry_utc" ;
176
+ expiry_attr .Value = (LPVOID )password_expiry_utc ;
177
+ expiry_attr .ValueSize = (wcslen (password_expiry_utc )) * sizeof (WCHAR );
178
+ expiry_attr .Flags = 0 ;
179
+ cred .Attributes = & expiry_attr ;
180
+ cred .AttributeCount = 1 ;
181
+ }
163
182
cred .TargetAlias = NULL ;
164
183
cred .UserName = wusername ;
165
184
@@ -232,6 +251,8 @@ static void read_credential(void)
232
251
wusername = utf8_to_utf16_dup (v );
233
252
} else if (!strcmp (buf , "password" ))
234
253
password = utf8_to_utf16_dup (v );
254
+ else if (!strcmp (buf , "password_expiry_utc" ))
255
+ password_expiry_utc = utf8_to_utf16_dup (v );
235
256
/*
236
257
* Ignore other lines; we don't know what they mean, but
237
258
* this future-proofs us when later versions of git do
@@ -248,7 +269,7 @@ int main(int argc, char *argv[])
248
269
"usage: git credential-wincred <get|store|erase>\n" ;
249
270
250
271
if (!argv [1 ])
251
- die (usage );
272
+ die ("%s" , usage );
252
273
253
274
/* git use binary pipes to avoid CRLF-issues */
254
275
_setmode (_fileno (stdin ), _O_BINARY );
0 commit comments