[vlc-devel] [PATCH 6/6] keychain: store the authtype
Thomas Guillem
thomas at gllm.fr
Thu Oct 31 15:38:12 CET 2019
Needed for the test_modules_keystore success.
---
modules/keystore/keychain.m | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/modules/keystore/keychain.m b/modules/keystore/keychain.m
index 2051082669d..dcc4a319e40 100644
--- a/modules/keystore/keychain.m
+++ b/modules/keystore/keychain.m
@@ -229,6 +229,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];
@@ -267,6 +268,26 @@ 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) {
+ /* libsmb2 not used, using libdsm for smbv1 */
+ [query setObject:(__bridge id)kSecAttrKeyTypeRC4 forKey:(__bridge id)kSecAttrKeyType];
+ }
+
+ }
+ }
return VLC_SUCCESS;
}
@@ -319,6 +340,22 @@ static int FillEntryValues(const NSDictionary *item, char *ppsz_values[KEY_MAX])
if (realm)
SET_NSSTR(KEY_REALM, realm);
+ if (protocol == (__bridge id)kSecAttrProtocolHTTP
+ || protocol == (__bridge id)kSecAttrProtocolHTTPS)
+ {
+ id authtype = [item objectForKey:(__bridge id)kSecAttrAuthenticationType];
+ if (authtype == (__bridge id)kSecAttrAuthenticationTypeHTTPBasic)
+ SET_STR(KEY_AUTHTYPE, "Basic");
+ else if (authtype == (__bridge id)kSecAttrAuthenticationTypeHTTPDigest)
+ SET_STR(KEY_AUTHTYPE, "Digest");
+ }
+ else if (protocol == (__bridge id)kSecAttrProtocolSMB)
+ {
+ id keytype = [item objectForKey:(__bridge id)kSecAttrKeyType];
+ if (keytype != (__bridge id)kSecAttrKeyTypeRC4)
+ SET_STR(KEY_AUTHTYPE, "2");
+ }
+
return VLC_SUCCESS;
}
--
2.20.1
More information about the vlc-devel
mailing list