@@ -91,7 +91,8 @@ static void load_cred_funcs(void)
91
91
die ("failed to load functions" );
92
92
}
93
93
94
- static WCHAR * wusername , * password , * protocol , * host , * path , target [1024 ];
94
+ static WCHAR * wusername , * password , * protocol , * host , * path , target [1024 ],
95
+ * password_expiry_utc ;
95
96
96
97
static void write_item (const char * what , LPCWSTR wbuf , int wlen )
97
98
{
@@ -183,6 +184,7 @@ static void get_credential(void)
183
184
CREDENTIALW * * creds ;
184
185
DWORD num_creds ;
185
186
int i ;
187
+ CREDENTIAL_ATTRIBUTEW * attr ;
186
188
187
189
if (!CredEnumerateW (L"git:*" , 0 , & num_creds , & creds ))
188
190
return ;
@@ -195,6 +197,14 @@ static void get_credential(void)
195
197
write_item ("password" ,
196
198
(LPCWSTR )creds [i ]-> CredentialBlob ,
197
199
creds [i ]-> CredentialBlobSize / sizeof (WCHAR ));
200
+ for (int j = 0 ; j < creds [i ]-> AttributeCount ; j ++ ) {
201
+ attr = creds [i ]-> Attributes + j ;
202
+ if (!wcscmp (attr -> Keyword , L"git_password_expiry_utc" )) {
203
+ write_item ("password_expiry_utc" , (LPCWSTR )attr -> Value ,
204
+ attr -> ValueSize / sizeof (WCHAR ));
205
+ break ;
206
+ }
207
+ }
198
208
break ;
199
209
}
200
210
@@ -204,6 +214,7 @@ static void get_credential(void)
204
214
static void store_credential (void )
205
215
{
206
216
CREDENTIALW cred ;
217
+ CREDENTIAL_ATTRIBUTEW expiry_attr ;
207
218
208
219
if (!wusername || !password )
209
220
return ;
@@ -217,6 +228,14 @@ static void store_credential(void)
217
228
cred .Persist = CRED_PERSIST_LOCAL_MACHINE ;
218
229
cred .AttributeCount = 0 ;
219
230
cred .Attributes = NULL ;
231
+ if (password_expiry_utc != NULL ) {
232
+ expiry_attr .Keyword = L"git_password_expiry_utc" ;
233
+ expiry_attr .Value = (LPVOID )password_expiry_utc ;
234
+ expiry_attr .ValueSize = (wcslen (password_expiry_utc )) * sizeof (WCHAR );
235
+ expiry_attr .Flags = 0 ;
236
+ cred .Attributes = & expiry_attr ;
237
+ cred .AttributeCount = 1 ;
238
+ }
220
239
cred .TargetAlias = NULL ;
221
240
cred .UserName = wusername ;
222
241
@@ -278,6 +297,8 @@ static void read_credential(void)
278
297
wusername = utf8_to_utf16_dup (v );
279
298
} else if (!strcmp (buf , "password" ))
280
299
password = utf8_to_utf16_dup (v );
300
+ else if (!strcmp (buf , "password_expiry_utc" ))
301
+ password_expiry_utc = utf8_to_utf16_dup (v );
281
302
/*
282
303
* Ignore other lines; we don't know what they mean, but
283
304
* this future-proofs us when later versions of git do
@@ -292,7 +313,7 @@ int main(int argc, char *argv[])
292
313
"usage: git credential-wincred <get|store|erase>\n" ;
293
314
294
315
if (!argv [1 ])
295
- die (usage );
316
+ die ("%s" , usage );
296
317
297
318
/* git use binary pipes to avoid CRLF-issues */
298
319
_setmode (_fileno (stdin ), _O_BINARY );
0 commit comments