Skip to content

Commit 07659b1

Browse files
committed
Revert "osxkeychain: state to skip unnecessary store operations"
This reverts commit e1ab45b. That commit was trying to skip to store a credential returned by "git-credential-osxkeychain get" by setting "state[]=osxkeychain:seen=1". However, this state[] is kept even if a credential returned by "git-credential-osxkeychain get" is invalid and another subsequent helper's "get" returns a valid credential. Another subsequent helper (such as [1]) may expect git-credential-osxkeychain to store the valid credential so that "store" cannot be skipped by just checking "state[]=osxkeychain:seen=1". In order to solve this issue, the state[] mechanism can be refined or "osxkeychain:seen" can encode the whole information of the last "get". For now, let's revert the change. [1]: https://github.com/hickford/git-credential-oauth Reported-by: Petter Sælen <petter@saelen.eu> Signed-off-by: Koji Nakamaru <koji.nakamaru@gree.net>
1 parent 4badef0 commit 07659b1

1 file changed

Lines changed: 0 additions & 11 deletions

File tree

contrib/credential/osxkeychain/git-credential-osxkeychain.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ static CFStringRef username;
1212
static CFDataRef password;
1313
static CFDataRef password_expiry_utc;
1414
static CFDataRef oauth_refresh_token;
15-
static int state_seen;
1615

1716
static void clear_credential(void)
1817
{
@@ -172,9 +171,6 @@ static OSStatus find_internet_password(void)
172171

173172
CFRelease(item);
174173

175-
write_item("capability[]", "state", strlen("state"));
176-
write_item("state[]", "osxkeychain:seen=1", strlen("osxkeychain:seen=1"));
177-
178174
out:
179175
CFRelease(attrs);
180176

@@ -288,9 +284,6 @@ static OSStatus add_internet_password(void)
288284
CFDictionaryRef attrs;
289285
OSStatus result;
290286

291-
if (state_seen)
292-
return errSecSuccess;
293-
294287
/* Only store complete credentials */
295288
if (!protocol || !host || !username || !password)
296289
return -1;
@@ -402,10 +395,6 @@ static void read_credential(void)
402395
oauth_refresh_token = CFDataCreate(kCFAllocatorDefault,
403396
(UInt8 *)v,
404397
strlen(v));
405-
else if (!strcmp(buf, "state[]")) {
406-
if (!strcmp(v, "osxkeychain:seen=1"))
407-
state_seen = 1;
408-
}
409398
/*
410399
* Ignore other lines; we don't know what they mean, but
411400
* this future-proofs us when later versions of git do

0 commit comments

Comments
 (0)