1
0
mirror of https://github.com/docker/docker-credential-helpers.git synced 2026-06-28 07:11:36 +05:30

Compare commits

...

6 Commits

Author SHA1 Message Date
Vincent Demeester 1057cf7f86 Merge pull request #43 from jeanlaurent/windows-makefile
Add .exe to windows Makefile target
2017-03-03 18:03:14 +01:00
Jean-Laurent de Morlhon 40d06d0090 Add .exe to windows Makefile target
Signed-off-by: Jean-Laurent de Morlhon <jeanlaurent@morlhon.net>
2017-03-03 17:58:06 +01:00
Vincent Demeester de50f50ab0 Merge pull request #41 from jeanlaurent/codesign
Add a makefile target to codesign output binary on macOS
2017-03-03 17:56:55 +01:00
Vincent Demeester 3c3e1d3af1 Merge pull request #42 from ebriney/fix-keychain-list
Reconstruct the full url when doing `keychain_list`
2017-03-03 17:56:15 +01:00
Emmanuel Briney 19ec1c3164 reconstruct the full url when doing keychain_list
Signed-off-by: Emmanuel Briney <emmanuel.briney@docker.com>
2017-03-03 17:16:00 +01:00
Jean-Laurent de Morlhon 2a3f7a4468 Add a makefile target to codesign output binary on macOS
Signed-off-by: Jean-Laurent de Morlhon <jeanlaurent@morlhon.net>
2017-03-03 16:20:29 +01:00
2 changed files with 59 additions and 24 deletions
+7 -2
View File
@@ -9,7 +9,12 @@ deps:
osxkeychain: osxkeychain:
mkdir -p bin mkdir -p bin
go build -o bin/docker-credential-osxkeychain osxkeychain/cmd/main_darwin.go go build -ldflags -s -o bin/docker-credential-osxkeychain osxkeychain/cmd/main_darwin.go
codesign: osxkeychain
$(eval SIGNINGHASH = $(shell security find-identity -v -p codesigning | grep "Developer ID Application: Docker Inc" | cut -d ' ' -f 4))
xcrun -log codesign -s $(SIGNINGHASH) --force --verbose bin/docker-credential-osxkeychain
xcrun codesign --verify --deep --strict --verbose=2 --display bin/docker-credential-osxkeychain
secretservice: secretservice:
mkdir -p bin mkdir -p bin
@@ -17,7 +22,7 @@ secretservice:
wincred: wincred:
mkdir -p bin mkdir -p bin
go build -o bin/docker-credential-wincred wincred/cmd/main_windows.go go build -o bin/docker-credential-wincred.exe wincred/cmd/main_windows.go
test: test:
# tests all packages except vendor # tests all packages except vendor
+50 -20
View File
@@ -1,5 +1,6 @@
#include "osxkeychain_darwin.h" #include "osxkeychain_darwin.h"
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#include <Foundation/NSValue.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -129,30 +130,23 @@ char *keychain_list(char *** paths, char *** accts, unsigned int *list_l) {
if (status) { if (status) {
return get_error(status); return get_error(status);
} }
int numKeys = CFArrayGetCount(result); CFIndex numKeys = CFArrayGetCount(result);
*paths = (char **) malloc((int)sizeof(char *)*numKeys); *paths = (char **) malloc((int)sizeof(char *)*numKeys);
*accts = (char **) malloc((int)sizeof(char *)*numKeys); *accts = (char **) malloc((int)sizeof(char *)*numKeys);
//result is of type CFArray //result is of type CFArray
for(int i=0; i<numKeys; i++) { for(CFIndex i=0; i<numKeys; i++) {
CFDictionaryRef currKey = CFArrayGetValueAtIndex(result,i); CFDictionaryRef currKey = CFArrayGetValueAtIndex(result,i);
if (CFDictionaryContainsKey(currKey, CFSTR("path"))) {
//Even if a key is stored without an account, Apple defaults it to null so these arrays will be of the same length CFStringRef protocolTmp = CFDictionaryGetValue(currKey, CFSTR("ptcl"));
CFStringRef pathTmp = CFDictionaryGetValue(currKey, CFSTR("path")); if (protocolTmp != NULL) {
CFStringRef acctTmp = CFDictionaryGetValue(currKey, CFSTR("acct")); CFStringRef protocolStr = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@"), protocolTmp);
if (acctTmp == NULL) { if (CFStringCompare(protocolStr, CFSTR("htps"), 0) == kCFCompareEqualTo) {
acctTmp = CFSTR("account not defined"); protocolTmp = CFSTR("https://");
} }
char * path = (char *) malloc(CFStringGetLength(pathTmp)+1); else {
path = CFStringToCharArr(pathTmp); protocolTmp = CFSTR("http://");
path[strlen(path)] = '\0'; }
char * acct = (char *) malloc(CFStringGetLength(acctTmp)+1); CFRelease(protocolStr);
acct = CFStringToCharArr(acctTmp);
acct[strlen(acct)] = '\0';
//We now have all we need, username and servername. Now export this to .go
(*paths)[i] = (char *) malloc(sizeof(char)*(strlen(path)+1));
memcpy((*paths)[i], path, sizeof(char)*(strlen(path)+1));
(*accts)[i] = (char *) malloc(sizeof(char)*(strlen(acct)+1));
memcpy((*accts)[i], acct, sizeof(char)*(strlen(acct)+1));
} }
else { else {
char * path = "0"; char * path = "0";
@@ -161,9 +155,45 @@ char *keychain_list(char *** paths, char *** accts, unsigned int *list_l) {
memcpy((*paths)[i], path, sizeof(char)*(strlen(path))); memcpy((*paths)[i], path, sizeof(char)*(strlen(path)));
(*accts)[i] = (char *) malloc(sizeof(char)*(strlen(acct))); (*accts)[i] = (char *) malloc(sizeof(char)*(strlen(acct)));
memcpy((*accts)[i], acct, sizeof(char)*(strlen(acct))); memcpy((*accts)[i], acct, sizeof(char)*(strlen(acct)));
continue;
} }
CFMutableStringRef str = CFStringCreateMutableCopy(NULL, 0, protocolTmp);
CFStringRef serverTmp = CFDictionaryGetValue(currKey, CFSTR("srvr"));
if (serverTmp != NULL) {
CFStringAppend(str, serverTmp);
} }
*list_l = numKeys;
CFStringRef pathTmp = CFDictionaryGetValue(currKey, CFSTR("path"));
if (pathTmp != NULL) {
CFStringAppend(str, pathTmp);
}
const NSNumber * portTmp = CFDictionaryGetValue(currKey, CFSTR("port"));
if (portTmp != NULL && portTmp.integerValue != 0) {
CFStringRef portStr = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@"), portTmp);
CFStringAppend(str, CFSTR(":"));
CFStringAppend(str, portStr);
CFRelease(portStr);
}
CFStringRef acctTmp = CFDictionaryGetValue(currKey, CFSTR("acct"));
if (acctTmp == NULL) {
acctTmp = CFSTR("account not defined");
}
char * path = CFStringToCharArr(str);
char * acct = CFStringToCharArr(acctTmp);
//We now have all we need, username and servername. Now export this to .go
(*paths)[i] = (char *) malloc(sizeof(char)*(strlen(path)+1));
memcpy((*paths)[i], path, sizeof(char)*(strlen(path)+1));
(*accts)[i] = (char *) malloc(sizeof(char)*(strlen(acct)+1));
memcpy((*accts)[i], acct, sizeof(char)*(strlen(acct)+1));
CFRelease(str);
}
*list_l = (int)numKeys;
return NULL; return NULL;
} }