mirror of
https://github.com/docker/docker-credential-helpers.git
synced 2026-06-13 16:01:28 +05:30
Fix type conversion for labels added to search queries on macOS
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
This commit is contained in:
@@ -135,16 +135,20 @@ char * CFStringToCharArr(CFStringRef aString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *keychain_list(char *credsLabel, char *** paths, char *** accts, unsigned int *list_l) {
|
char *keychain_list(char *credsLabel, char *** paths, char *** accts, unsigned int *list_l) {
|
||||||
|
CFStringRef credsLabelCF = CFStringCreateWithCString(NULL, credsLabel, kCFStringEncodingUTF8);
|
||||||
CFMutableDictionaryRef query = CFDictionaryCreateMutable (NULL, 1, NULL, NULL);
|
CFMutableDictionaryRef query = CFDictionaryCreateMutable (NULL, 1, NULL, NULL);
|
||||||
CFDictionaryAddValue(query, kSecClass, kSecClassInternetPassword);
|
CFDictionaryAddValue(query, kSecClass, kSecClassInternetPassword);
|
||||||
CFDictionaryAddValue(query, kSecReturnAttributes, kCFBooleanTrue);
|
CFDictionaryAddValue(query, kSecReturnAttributes, kCFBooleanTrue);
|
||||||
CFDictionaryAddValue(query, kSecMatchLimit, kSecMatchLimitAll);
|
CFDictionaryAddValue(query, kSecMatchLimit, kSecMatchLimitAll);
|
||||||
CFDictionaryAddValue(query, kSecAttrLabel, CFSTR(credsLabel));
|
CFDictionaryAddValue(query, kSecAttrLabel, credsLabelCF);
|
||||||
//Use this query dictionary
|
//Use this query dictionary
|
||||||
CFTypeRef result= NULL;
|
CFTypeRef result= NULL;
|
||||||
OSStatus status = SecItemCopyMatching(
|
OSStatus status = SecItemCopyMatching(
|
||||||
query,
|
query,
|
||||||
&result);
|
&result);
|
||||||
|
|
||||||
|
CFRelease(credsLabelCF);
|
||||||
|
|
||||||
//Ran a search and store the results in result
|
//Ran a search and store the results in result
|
||||||
if (status) {
|
if (status) {
|
||||||
return get_error(status);
|
return get_error(status);
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ import (
|
|||||||
|
|
||||||
func TestOSXKeychainHelper(t *testing.T) {
|
func TestOSXKeychainHelper(t *testing.T) {
|
||||||
creds := &credentials.Credentials{
|
creds := &credentials.Credentials{
|
||||||
Label: credentials.CredsLabel,
|
Label: credentials.CredsLabel,
|
||||||
ServerURL: "https://foobar.docker.io:2376/v1",
|
ServerURL: "https://foobar.docker.io:2376/v1",
|
||||||
Username: "foobar",
|
Username: "foobar",
|
||||||
Secret: "foobarbaz",
|
Secret: "foobarbaz",
|
||||||
}
|
}
|
||||||
creds1 := &credentials.Credentials{
|
creds1 := &credentials.Credentials{
|
||||||
Label: credentials.CredsLabel,
|
Label: credentials.CredsLabel,
|
||||||
ServerURL: "https://foobar.docker.io:2376/v2",
|
ServerURL: "https://foobar.docker.io:2376/v2",
|
||||||
Username: "foobarbaz",
|
Username: "foobarbaz",
|
||||||
Secret: "foobar",
|
Secret: "foobar",
|
||||||
|
|||||||
Reference in New Issue
Block a user