vlc | branch: master | Thomas Guillem <[email protected]> | Thu Oct 31 15:32:08 2019 +0100| [7ea67ca1f03feec859a7bae0e72584e20c68554e] | committer: Thomas Guillem
keychain: store the authtype Needed for the test_modules_keystore success. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7ea67ca1f03feec859a7bae0e72584e20c68554e --- modules/keystore/keychain.m | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/modules/keystore/keychain.m b/modules/keystore/keychain.m index e788755b0c..6afd11a8df 100644 --- a/modules/keystore/keychain.m +++ b/modules/keystore/keychain.m @@ -230,6 +230,7 @@ static int SetAttributesForQuery(const char *const ppsz_values[KEY_MAX], NSMutab const char *psz_path = ppsz_values[KEY_PATH]; const char *psz_port = ppsz_values[KEY_PORT]; const char *psz_realm = ppsz_values[KEY_REALM]; + const char *psz_authtype = ppsz_values[KEY_AUTHTYPE]; if (psz_label) { [query setObject:[NSString stringWithUTF8String:psz_label] forKey:(__bridge id)kSecAttrLabel]; @@ -268,6 +269,23 @@ static int SetAttributesForQuery(const char *const ppsz_values[KEY_MAX], NSMutab if (psz_realm) { [query setObject:[NSString stringWithUTF8String:psz_realm] forKey:(__bridge id)kSecAttrSecurityDomain]; } + if (psz_authtype) { + if (strncasecmp(psz_protocol, "http", 4) == 0) { + const struct vlc2secattr tab[] = + { /* /!\ Alphabetical order /!\ */ + { "Basic", kSecAttrAuthenticationTypeHTTPBasic }, + { "Digest", kSecAttrAuthenticationTypeHTTPDigest }, + }; + const struct vlc2secattr *entry = + bsearch(psz_authtype, tab, ARRAY_SIZE(tab), sizeof(tab[0]), vlc2secattr_cmp); + if (entry) + [query setObject:(__bridge id)entry->secattr forKey:(__bridge id)kSecAttrAuthenticationType]; + } + else if (strcasecmp(psz_protocol, "smb") == 0) { + if (strcmp(psz_authtype, "2") == 0) + [query setObject:(__bridge id)kSecAttrAuthenticationTypeMSN forKey:(__bridge id)kSecAttrAuthenticationType]; + } + } return VLC_SUCCESS; } @@ -322,6 +340,29 @@ static int FillEntryValues(const NSDictionary *item, char *ppsz_values[KEY_MAX]) return VLC_ENOMEM; } + const char *auth_val = NULL; + if ([protocol isEqualToString:(__bridge NSString*)kSecAttrProtocolHTTP] + || [protocol isEqualToString:(__bridge NSString*)kSecAttrProtocolHTTPS]) + { + id authtype = [item objectForKey:(__bridge id)kSecAttrAuthenticationType]; + if (authtype == (__bridge id)kSecAttrAuthenticationTypeHTTPBasic) + auth_val = "Basic"; + else if (authtype == (__bridge id)kSecAttrAuthenticationTypeHTTPDigest) + auth_val = "Digest"; + } + else if ([protocol isEqualToString:(__bridge NSString*)kSecAttrProtocolSMB]) + { + id keytype = [item objectForKey:(__bridge id)kSecAttrAuthenticationType]; + if (keytype == (__bridge id)kSecAttrAuthenticationTypeMSN) + auth_val = "2"; + } + if (auth_val) + { + ppsz_values[KEY_AUTHTYPE] = strdup(auth_val); + if (!ppsz_values[KEY_AUTHTYPE]) + return VLC_ENOMEM; + } + return VLC_SUCCESS; } _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
