From 8f3ff2dbd95873709c0a6024aca0805273c7465c Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 18 Feb 2015 17:59:57 +0100 Subject: [PATCH] fix bug about authentication When ha1 password storage is enabled (the default), the lookup of LinphoneAuthInfo must be done with realm, otherwise the password will not work. --- coreapi/authentication.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/coreapi/authentication.c b/coreapi/authentication.c index de7248316..0306803f8 100644 --- a/coreapi/authentication.c +++ b/coreapi/authentication.c @@ -200,7 +200,7 @@ static char * remove_quotes(char * input){ return input; } -static int realm_match(const char *realm1, const char *realm2){ +static bool_t realm_match(const char *realm1, const char *realm2){ if (realm1==NULL && realm2==NULL) return TRUE; if (realm1!=NULL && realm2!=NULL){ if (strcmp(realm1,realm2)==0) return TRUE; @@ -226,7 +226,7 @@ static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *user LinphoneAuthInfo *pinfo = (LinphoneAuthInfo*)elem->data; if (username && pinfo->username && strcmp(username,pinfo->username)==0) { if (realm && domain){ - if (pinfo->realm && strcmp(realm,pinfo->realm)==0 + if (pinfo->realm && realm_match(realm,pinfo->realm) && pinfo->domain && strcmp(domain,pinfo->domain)==0) { return pinfo; } @@ -238,9 +238,9 @@ static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *user } ret=pinfo; } - } else if (domain && pinfo->domain && strcmp(domain,pinfo->domain)==0) { + } else if (domain && pinfo->domain && strcmp(domain,pinfo->domain)==0 && pinfo->ha1==NULL) { return pinfo; - } else if (!domain) { + } else if (!domain && pinfo->ha1==NULL) { return pinfo; } } @@ -271,6 +271,7 @@ const LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const cha if (ai==NULL){ ai=find_auth_info(lc,username,NULL,NULL); } + /*if (ai) ms_message("linphone_core_find_auth_info(): returning auth info username=%s, realm=%s", ai->username, ai->realm);*/ return ai; }