<pre style='margin:0'>
Herby Gillot (herbygillot) pushed a commit to branch master
in repository macports-ports.
</pre>
<p><a href="https://github.com/macports/macports-ports/commit/c1e452d2c002e4aef4c4104e213ad57f75d5dcac">https://github.com/macports/macports-ports/commit/c1e452d2c002e4aef4c4104e213ad57f75d5dcac</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'> new c1e452d2c00 git: move devel osxkeychain patch to release
</span>c1e452d2c00 is described below
<span style='display:block; white-space:pre;color:#808000;'>commit c1e452d2c002e4aef4c4104e213ad57f75d5dcac
</span>Author: Herby Gillot <herby.gillot@gmail.com>
AuthorDate: Mon Jul 29 20:50:25 2024 -0400
<span style='display:block; white-space:pre;color:#404040;'> git: move devel osxkeychain patch to release
</span>---
devel/git/Portfile | 8 +-
.../patch-Revert-breaking-osxkeychain-devel.diff | 532 ---------------------
.../files/patch-Revert-breaking-osxkeychain.diff | 62 ++-
3 files changed, 39 insertions(+), 563 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/devel/git/Portfile b/devel/git/Portfile
</span><span style='display:block; white-space:pre;color:#808080;'>index 7ef26b7f366..79efb9a3147 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/devel/git/Portfile
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/devel/git/Portfile
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -118,13 +118,7 @@ patch.pre_args-replace -p0 -p1
</span> # Reverts breakage introduced by:
# https://github.com/git/git/commit/51c15ac1b6ab15d8e29651d0bd364d8f62dc6509
if {${os.platform} eq "darwin" && ${os.major} < 11} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {${subport} eq "${name}-devel"} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- patchfiles-append \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- patch-Revert-breaking-osxkeychain-devel.diff
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- patchfiles-append \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- patch-Revert-breaking-osxkeychain.diff
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ patchfiles-append patch-Revert-breaking-osxkeychain.diff
</span> }
# Git 2.36.0 implements a new FSEvent listener that uses
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/devel/git/files/patch-Revert-breaking-osxkeychain-devel.diff b/devel/git/files/patch-Revert-breaking-osxkeychain-devel.diff
</span>deleted file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 1cb6949f63c..00000000000
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/devel/git/files/patch-Revert-breaking-osxkeychain-devel.diff
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1,532 +0,0 @@
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-From b03bfe5fdf5e7d19b90afd268f6aaf3fee69a845 Mon Sep 17 00:00:00 2001
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-From: Sergey Fedorov <barracuda@macos-powerpc.org>
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-Date: Fri, 19 Jul 2024 08:54:09 +0800
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-Subject: [PATCH] Revert commits breaking macOS keychain
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-This reverts commit e1ab45b2dab51f94db9548666dfd7af626d2aa7e.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-This reverts commit fcf5b74e59c1c0d18a8e8e939475007b3b5f83ad.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-This reverts commit d5b35bba86e6fdf0484ea71bf5b8ef1167f14015.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-This reverts commit e3cef40db89f5a7c91f4e9d6c4959ca1e41f4647.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-This reverts commit 9032bcad82f45a403e4a8de86e1fcb4bfd1ab282.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-This reverts commit 9abe31f5f161be4d69118bdfae00103cd6efa510.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>----
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- contrib/credential/osxkeychain/Makefile | 3 +-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- .../osxkeychain/git-credential-osxkeychain.c | 390 +++---------------
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- 2 files changed, 69 insertions(+), 324 deletions(-)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-diff --git contrib/credential/osxkeychain/Makefile contrib/credential/osxkeychain/Makefile
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-index 238f5f8c36..4b3a08a2ba 100644
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>---- a/contrib/credential/osxkeychain/Makefile
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+++ b/contrib/credential/osxkeychain/Makefile
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-@@ -8,8 +8,7 @@ CFLAGS = -g -O2 -Wall
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- -include ../../../config.mak
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- git-credential-osxkeychain: git-credential-osxkeychain.o
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- -framework Security -framework CoreFoundation
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) -Wl,-framework -Wl,Security
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- git-credential-osxkeychain.o: git-credential-osxkeychain.c
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- $(CC) -c $(CFLAGS) $<
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-diff --git contrib/credential/osxkeychain/git-credential-osxkeychain.c contrib/credential/osxkeychain/git-credential-osxkeychain.c
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-index 6ce22a28ed..5f2e5f16c8 100644
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>---- a/contrib/credential/osxkeychain/git-credential-osxkeychain.c
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+++ b/contrib/credential/osxkeychain/git-credential-osxkeychain.c
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-@@ -3,52 +3,14 @@
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- #include <stdlib.h>
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- #include <Security/Security.h>
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--#define ENCODING kCFStringEncodingUTF8
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static CFStringRef protocol; /* Stores constant strings - not memory managed */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static CFStringRef host;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static CFNumberRef port;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static CFStringRef path;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static CFStringRef username;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static CFDataRef password;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static CFDataRef password_expiry_utc;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static CFDataRef oauth_refresh_token;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static int state_seen;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static void clear_credential(void)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--{
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (host) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(host);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- host = NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (port) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(port);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- port = NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (path) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(path);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- path = NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (username) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(username);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- username = NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (password) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(password);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- password = NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (password_expiry_utc) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(password_expiry_utc);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- password_expiry_utc = NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (oauth_refresh_token) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(oauth_refresh_token);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- oauth_refresh_token = NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--#define STRING_WITH_LENGTH(s) s, sizeof(s) - 1
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--__attribute__((format (printf, 1, 2), __noreturn__))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+static SecProtocolType protocol;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+static char *host;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+static char *path;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+static char *username;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+static char *password;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+static UInt16 port;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+__attribute__((format (printf, 1, 2)))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- static void die(const char *err, ...)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- char msg[4096];
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-@@ -57,202 +19,70 @@ static void die(const char *err, ...)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- vsnprintf(msg, sizeof(msg), err, params);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- fprintf(stderr, "%s\n", msg);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- va_end(params);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- clear_credential();
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- exit(1);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static void *xmalloc(size_t len)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+static void *xstrdup(const char *s1)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- void *ret = malloc(len);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ void *ret = strdup(s1);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (!ret)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- die("Out of memory");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return ret;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static CFDictionaryRef create_dictionary(CFAllocatorRef allocator, ...)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--{
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- va_list args;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- const void *key;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFMutableDictionaryRef result;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- result = CFDictionaryCreateMutable(allocator,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- 0,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- &kCFTypeDictionaryKeyCallBacks,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- &kCFTypeDictionaryValueCallBacks);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- va_start(args, allocator);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- while ((key = va_arg(args, const void *)) != NULL) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- const void *value;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- value = va_arg(args, const void *);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (value)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDictionarySetValue(result, key, value);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- va_end(args);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- return result;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--#define CREATE_SEC_ATTRIBUTES(...) \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- create_dictionary(kCFAllocatorDefault, \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kSecClass, kSecClassInternetPassword, \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kSecAttrServer, host, \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kSecAttrAccount, username, \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kSecAttrPath, path, \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kSecAttrPort, port, \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kSecAttrProtocol, protocol, \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kSecAttrAuthenticationType, \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kSecAttrAuthenticationTypeDefault, \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- __VA_ARGS__);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static void write_item(const char *what, const char *buf, size_t len)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+#define KEYCHAIN_ITEM(x) (x ? strlen(x) : 0), x
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+#define KEYCHAIN_ARGS \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ NULL, /* default keychain */ \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ KEYCHAIN_ITEM(host), \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ 0, NULL, /* account domain */ \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ KEYCHAIN_ITEM(username), \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ KEYCHAIN_ITEM(path), \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ port, \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ protocol, \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ kSecAuthenticationTypeDefault
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+static void write_item(const char *what, const char *buf, int len)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- printf("%s=", what);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- fwrite(buf, 1, len, stdout);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- putchar('\n');
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static void find_username_in_item(CFDictionaryRef item)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+static void find_username_in_item(SecKeychainItemRef item)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFStringRef account_ref;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- char *username_buf;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFIndex buffer_len;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ SecKeychainAttributeList list;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ SecKeychainAttribute attr;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- account_ref = CFDictionaryGetValue(item, kSecAttrAccount);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (!account_ref)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- write_item("username", "", 0);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- return;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ list.count = 1;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ list.attr = &attr;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ attr.tag = kSecAccountItemAttr;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- username_buf = (char *)CFStringGetCStringPtr(account_ref, ENCODING);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (username_buf)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- write_item("username", username_buf, strlen(username_buf));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ if (SecKeychainItemCopyContent(item, NULL, &list, NULL, NULL))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- /* If we can't get a CString pointer then
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- * we need to allocate our own buffer */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- buffer_len = CFStringGetMaximumSizeForEncoding(
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFStringGetLength(account_ref), ENCODING) + 1;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- username_buf = xmalloc(buffer_len);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (CFStringGetCString(account_ref,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- username_buf,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- buffer_len,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- ENCODING)) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- write_item("username", username_buf, buffer_len - 1);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- free(username_buf);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ write_item("username", attr.data, attr.length);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ SecKeychainItemFreeContent(&list, NULL);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static OSStatus find_internet_password(void)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+static void find_internet_password(void)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDictionaryRef attrs;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDictionaryRef item;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDataRef data;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- OSStatus result;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ void *buf;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ UInt32 len;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ SecKeychainItemRef item;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- attrs = CREATE_SEC_ATTRIBUTES(kSecMatchLimit, kSecMatchLimitOne,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kSecReturnAttributes, kCFBooleanTrue,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kSecReturnData, kCFBooleanTrue,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- NULL);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- result = SecItemCopyMatching(attrs, (CFTypeRef *)&item);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (result) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- goto out;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- data = CFDictionaryGetValue(item, kSecValueData);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ if (SecKeychainFindInternetPassword(KEYCHAIN_ARGS, &len, &buf, &item))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ return;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- write_item("password",
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- (const char *)CFDataGetBytePtr(data),
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDataGetLength(data));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ write_item("password", buf, len);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (!username)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- find_username_in_item(item);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(item);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- write_item("capability[]", "state", strlen("state"));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- write_item("state[]", "osxkeychain:seen=1", strlen("osxkeychain:seen=1"));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--out:
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(attrs);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- /* We consider not found to not be an error */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (result == errSecItemNotFound)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- result = errSecSuccess;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- return result;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static OSStatus delete_ref(const void *itemRef)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--{
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFArrayRef item_ref_list;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDictionaryRef delete_query;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- OSStatus result;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- item_ref_list = CFArrayCreate(kCFAllocatorDefault,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- &itemRef,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- 1,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- &kCFTypeArrayCallBacks);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- delete_query = create_dictionary(kCFAllocatorDefault,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kSecClass, kSecClassInternetPassword,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kSecMatchItemList, item_ref_list,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- NULL);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (password) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- /* We only want to delete items with a matching password */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFIndex capacity;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFMutableDictionaryRef query;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDataRef data;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- capacity = CFDictionaryGetCount(delete_query) + 1;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- query = CFDictionaryCreateMutableCopy(kCFAllocatorDefault,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- capacity,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- delete_query);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDictionarySetValue(query, kSecReturnData, kCFBooleanTrue);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- result = SecItemCopyMatching(query, (CFTypeRef *)&data);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (!result) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDataRef kc_password;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- const UInt8 *raw_data;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- const UInt8 *line;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- /* Don't match appended metadata */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- raw_data = CFDataGetBytePtr(data);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- line = memchr(raw_data, '\n', CFDataGetLength(data));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (line)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kc_password = CFDataCreateWithBytesNoCopy(
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kCFAllocatorDefault,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- raw_data,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- line - raw_data,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kCFAllocatorNull);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- else
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kc_password = data;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (CFEqual(kc_password, password))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- result = SecItemDelete(delete_query);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (line)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(kc_password);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(data);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(query);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- result = SecItemDelete(delete_query);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(delete_query);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(item_ref_list);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- return result;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ SecKeychainItemFreeContent(NULL, buf);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static OSStatus delete_internet_password(void)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+static void delete_internet_password(void)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDictionaryRef attrs;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFArrayRef refs;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- OSStatus result;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ SecKeychainItemRef item;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- /*
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * Require at least a protocol and host for removal, which is what git
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-@@ -260,72 +90,25 @@ static OSStatus delete_internet_password(void)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * Keychain manager.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (!protocol || !host)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- return -1;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- attrs = CREATE_SEC_ATTRIBUTES(kSecMatchLimit, kSecMatchLimitAll,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kSecReturnRef, kCFBooleanTrue,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- NULL);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- result = SecItemCopyMatching(attrs, (CFTypeRef *)&refs);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(attrs);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (!result) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- for (CFIndex i = 0; !result && i < CFArrayGetCount(refs); i++)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- result = delete_ref(CFArrayGetValueAtIndex(refs, i));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(refs);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ return;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- /* We consider not found to not be an error */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (result == errSecItemNotFound)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- result = errSecSuccess;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ if (SecKeychainFindInternetPassword(KEYCHAIN_ARGS, 0, NULL, &item))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ return;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- return result;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ SecKeychainItemDelete(item);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--static OSStatus add_internet_password(void)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+static void add_internet_password(void)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFMutableDataRef data;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDictionaryRef attrs;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- OSStatus result;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (state_seen)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- return errSecSuccess;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- /* Only store complete credentials */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (!protocol || !host || !username || !password)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- return -1;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- data = CFDataCreateMutableCopy(kCFAllocatorDefault, 0, password);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (password_expiry_utc) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDataAppendBytes(data,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- (const UInt8 *)STRING_WITH_LENGTH("\npassword_expiry_utc="));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDataAppendBytes(data,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDataGetBytePtr(password_expiry_utc),
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDataGetLength(password_expiry_utc));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (oauth_refresh_token) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDataAppendBytes(data,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- (const UInt8 *)STRING_WITH_LENGTH("\noauth_refresh_token="));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDataAppendBytes(data,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDataGetBytePtr(oauth_refresh_token),
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDataGetLength(oauth_refresh_token));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- attrs = CREATE_SEC_ATTRIBUTES(kSecValueData, data,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- NULL);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- result = SecItemAdd(attrs, NULL);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (result == errSecDuplicateItem) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFDictionaryRef query;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- query = CREATE_SEC_ATTRIBUTES(NULL);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- result = SecItemUpdate(query, attrs);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(query);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(data);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- CFRelease(attrs);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ return;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- return result;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ if (SecKeychainAddInternetPassword(
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ KEYCHAIN_ARGS,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ KEYCHAIN_ITEM(password),
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ NULL))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ return;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- static void read_credential(void)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-@@ -348,64 +131,36 @@ static void read_credential(void)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (!strcmp(buf, "protocol")) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (!strcmp(v, "imap"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- protocol = kSecAttrProtocolIMAP;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ protocol = kSecProtocolTypeIMAP;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- else if (!strcmp(v, "imaps"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- protocol = kSecAttrProtocolIMAPS;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ protocol = kSecProtocolTypeIMAPS;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- else if (!strcmp(v, "ftp"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- protocol = kSecAttrProtocolFTP;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ protocol = kSecProtocolTypeFTP;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- else if (!strcmp(v, "ftps"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- protocol = kSecAttrProtocolFTPS;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ protocol = kSecProtocolTypeFTPS;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- else if (!strcmp(v, "https"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- protocol = kSecAttrProtocolHTTPS;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ protocol = kSecProtocolTypeHTTPS;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- else if (!strcmp(v, "http"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- protocol = kSecAttrProtocolHTTP;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ protocol = kSecProtocolTypeHTTP;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- else if (!strcmp(v, "smtp"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- protocol = kSecAttrProtocolSMTP;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- /* we don't yet handle other protocols */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- clear_credential();
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ protocol = kSecProtocolTypeSMTP;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ else /* we don't yet handle other protocols */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- exit(0);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- else if (!strcmp(buf, "host")) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- char *colon = strchr(v, ':');
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (colon) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- UInt16 port_i;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- *colon++ = '\0';
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- port_i = atoi(colon);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- port = CFNumberCreate(kCFAllocatorDefault,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kCFNumberShortType,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- &port_i);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ port = atoi(colon);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- host = CFStringCreateWithCString(kCFAllocatorDefault,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- v,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- ENCODING);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ host = xstrdup(v);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- else if (!strcmp(buf, "path"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- path = CFStringCreateWithCString(kCFAllocatorDefault,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- v,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- ENCODING);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ path = xstrdup(v);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- else if (!strcmp(buf, "username"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- username = CFStringCreateWithCString(
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- kCFAllocatorDefault,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- v,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- ENCODING);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ username = xstrdup(v);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- else if (!strcmp(buf, "password"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- password = CFDataCreate(kCFAllocatorDefault,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- (UInt8 *)v,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- strlen(v));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- else if (!strcmp(buf, "password_expiry_utc"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- password_expiry_utc = CFDataCreate(kCFAllocatorDefault,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- (UInt8 *)v,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- strlen(v));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- else if (!strcmp(buf, "oauth_refresh_token"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- oauth_refresh_token = CFDataCreate(kCFAllocatorDefault,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- (UInt8 *)v,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- strlen(v));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- else if (!strcmp(buf, "state[]")) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (!strcmp(v, "osxkeychain:seen=1"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- state_seen = 1;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ password = xstrdup(v);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- /*
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * Ignore other lines; we don't know what they mean, but
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * this future-proofs us when later versions of git do
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-@@ -418,30 +173,21 @@ static void read_credential(void)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- int main(int argc, const char **argv)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- OSStatus result = 0;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- const char *usage =
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- "usage: git credential-osxkeychain <get|store|erase>";
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (!argv[1])
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- die("%s", usage);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (open(argv[0], O_RDONLY | O_EXLOCK) == -1)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- die("failed to lock %s", argv[0]);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- read_credential();
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (!strcmp(argv[1], "get"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- result = find_internet_password();
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ find_internet_password();
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- else if (!strcmp(argv[1], "store"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- result = add_internet_password();
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ add_internet_password();
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- else if (!strcmp(argv[1], "erase"))
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- result = delete_internet_password();
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ delete_internet_password();
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- /* otherwise, ignore unknown action */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- if (result)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- die("failed to %s: %d", argv[1], (int)result);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- clear_credential();
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 0;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/devel/git/files/patch-Revert-breaking-osxkeychain.diff b/devel/git/files/patch-Revert-breaking-osxkeychain.diff
</span><span style='display:block; white-space:pre;color:#808080;'>index a056945c435..1cb6949f63c 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/devel/git/files/patch-Revert-breaking-osxkeychain.diff
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/devel/git/files/patch-Revert-breaking-osxkeychain.diff
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1,25 +1,23 @@
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-From d467d79c362cb07dc10df074d94c3b13ae547d0d Mon Sep 17 00:00:00 2001
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-From: Sergey Fedorov <vital.had@gmail.com>
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-Date: Tue, 30 Apr 2024 06:53:17 +0800
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-Subject: [PATCH] Revert "osxkeychain: store new attributes"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+From b03bfe5fdf5e7d19b90afd268f6aaf3fee69a845 Mon Sep 17 00:00:00 2001
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+From: Sergey Fedorov <barracuda@macos-powerpc.org>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Date: Fri, 19 Jul 2024 08:54:09 +0800
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Subject: [PATCH] Revert commits breaking macOS keychain
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-This reverts commit d5b35bba86e6fdf0484ea71bf5b8ef1167f14015.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+This reverts commit e1ab45b2dab51f94db9548666dfd7af626d2aa7e.
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-Revert "osxkeychain: erase matching passwords only"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+This reverts commit fcf5b74e59c1c0d18a8e8e939475007b3b5f83ad.
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-This reverts commit e3cef40db89f5a7c91f4e9d6c4959ca1e41f4647.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+This reverts commit d5b35bba86e6fdf0484ea71bf5b8ef1167f14015.
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-Revert "osxkeychain: erase all matching credentials"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+This reverts commit e3cef40db89f5a7c91f4e9d6c4959ca1e41f4647.
</span>
This reverts commit 9032bcad82f45a403e4a8de86e1fcb4bfd1ab282.
<span style='display:block; white-space:pre;background:#ffe0e0;'>-Revert "osxkeychain: replace deprecated SecKeychain API"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> This reverts commit 9abe31f5f161be4d69118bdfae00103cd6efa510.
---
contrib/credential/osxkeychain/Makefile | 3 +-
<span style='display:block; white-space:pre;background:#ffe0e0;'>- .../osxkeychain/git-credential-osxkeychain.c | 376 ++++--------------
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- 2 files changed, 69 insertions(+), 310 deletions(-)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ .../osxkeychain/git-credential-osxkeychain.c | 390 +++---------------
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 2 files changed, 69 insertions(+), 324 deletions(-)
</span>
diff --git contrib/credential/osxkeychain/Makefile contrib/credential/osxkeychain/Makefile
index 238f5f8c36..4b3a08a2ba 100644
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -36,10 +34,10 @@ index 238f5f8c36..4b3a08a2ba 100644
</span> git-credential-osxkeychain.o: git-credential-osxkeychain.c
$(CC) -c $(CFLAGS) $<
diff --git contrib/credential/osxkeychain/git-credential-osxkeychain.c contrib/credential/osxkeychain/git-credential-osxkeychain.c
<span style='display:block; white-space:pre;background:#ffe0e0;'>-index 6a40917b1e..5f2e5f16c8 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 6ce22a28ed..5f2e5f16c8 100644
</span> --- a/contrib/credential/osxkeychain/git-credential-osxkeychain.c
+++ b/contrib/credential/osxkeychain/git-credential-osxkeychain.c
<span style='display:block; white-space:pre;background:#ffe0e0;'>-@@ -3,51 +3,14 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -3,52 +3,14 @@
</span> #include <stdlib.h>
#include <Security/Security.h>
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -52,6 +50,7 @@ index 6a40917b1e..5f2e5f16c8 100644
</span> -static CFDataRef password;
-static CFDataRef password_expiry_utc;
-static CFDataRef oauth_refresh_token;
<span style='display:block; white-space:pre;background:#e0ffe0;'>+-static int state_seen;
</span> -
-static void clear_credential(void)
-{
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -99,7 +98,7 @@ index 6a40917b1e..5f2e5f16c8 100644
</span> static void die(const char *err, ...)
{
char msg[4096];
<span style='display:block; white-space:pre;background:#ffe0e0;'>-@@ -56,199 +19,70 @@ static void die(const char *err, ...)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -57,202 +19,70 @@ static void die(const char *err, ...)
</span> vsnprintf(msg, sizeof(msg), err, params);
fprintf(stderr, "%s\n", msg);
va_end(params);
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -222,7 +221,10 @@ index 6a40917b1e..5f2e5f16c8 100644
</span> - CFDictionaryRef item;
- CFDataRef data;
- OSStatus result;
<span style='display:block; white-space:pre;background:#ffe0e0;'>--
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ void *buf;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ UInt32 len;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ SecKeychainItemRef item;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> - attrs = CREATE_SEC_ATTRIBUTES(kSecMatchLimit, kSecMatchLimitOne,
- kSecReturnAttributes, kCFBooleanTrue,
- kSecReturnData, kCFBooleanTrue,
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -231,10 +233,7 @@ index 6a40917b1e..5f2e5f16c8 100644
</span> - if (result) {
- goto out;
- }
<span style='display:block; white-space:pre;background:#ffe0e0;'>-+ void *buf;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ UInt32 len;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ SecKeychainItemRef item;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span> - data = CFDictionaryGetValue(item, kSecValueData);
+ if (SecKeychainFindInternetPassword(KEYCHAIN_ARGS, &len, &buf, &item))
+ return;
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -248,6 +247,9 @@ index 6a40917b1e..5f2e5f16c8 100644
</span>
- CFRelease(item);
-
<span style='display:block; white-space:pre;background:#e0ffe0;'>+- write_item("capability[]", "state", strlen("state"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- write_item("state[]", "osxkeychain:seen=1", strlen("osxkeychain:seen=1"));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span> -out:
- CFRelease(attrs);
-
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -332,7 +334,7 @@ index 6a40917b1e..5f2e5f16c8 100644
</span>
/*
* Require at least a protocol and host for removal, which is what git
<span style='display:block; white-space:pre;background:#ffe0e0;'>-@@ -256,69 +90,25 @@ static OSStatus delete_internet_password(void)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -260,72 +90,25 @@ static OSStatus delete_internet_password(void)
</span> * Keychain manager.
*/
if (!protocol || !host)
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -368,6 +370,9 @@ index 6a40917b1e..5f2e5f16c8 100644
</span> - CFMutableDataRef data;
- CFDictionaryRef attrs;
- OSStatus result;
<span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if (state_seen)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return errSecSuccess;
</span> -
/* Only store complete credentials */
if (!protocol || !host || !username || !password)
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -413,7 +418,7 @@ index 6a40917b1e..5f2e5f16c8 100644
</span> }
static void read_credential(void)
<span style='display:block; white-space:pre;background:#ffe0e0;'>-@@ -341,60 +131,36 @@ static void read_credential(void)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -348,64 +131,36 @@ static void read_credential(void)
</span>
if (!strcmp(buf, "protocol")) {
if (!strcmp(v, "imap"))
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -483,11 +488,15 @@ index 6a40917b1e..5f2e5f16c8 100644
</span> - oauth_refresh_token = CFDataCreate(kCFAllocatorDefault,
- (UInt8 *)v,
- strlen(v));
<span style='display:block; white-space:pre;background:#e0ffe0;'>+- else if (!strcmp(buf, "state[]")) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if (!strcmp(v, "osxkeychain:seen=1"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- state_seen = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span> + password = xstrdup(v);
/*
* Ignore other lines; we don't know what they mean, but
* this future-proofs us when later versions of git do
<span style='display:block; white-space:pre;background:#ffe0e0;'>-@@ -407,7 +173,6 @@ static void read_credential(void)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -418,30 +173,21 @@ static void read_credential(void)
</span>
int main(int argc, const char **argv)
{
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -495,7 +504,12 @@ index 6a40917b1e..5f2e5f16c8 100644
</span> const char *usage =
"usage: git credential-osxkeychain <get|store|erase>";
<span style='display:block; white-space:pre;background:#ffe0e0;'>-@@ -417,17 +182,12 @@ int main(int argc, const char **argv)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (!argv[1])
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ die("%s", usage);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if (open(argv[0], O_RDONLY | O_EXLOCK) == -1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- die("failed to lock %s", argv[0]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span> read_credential();
if (!strcmp(argv[1], "get"))
</pre><pre style='margin:0'>
</pre>