Commit 263364ac authored by Sylvain Berfini's avatar Sylvain Berfini

Fix find auth info algorithm

parent 2db728a6
...@@ -256,25 +256,27 @@ static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *user ...@@ -256,25 +256,27 @@ static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *user
MSList *elem; MSList *elem;
const LinphoneAuthInfo *ret=NULL; const LinphoneAuthInfo *ret=NULL;
for (elem=lc->auth_info;elem!=NULL;elem=elem->next){ for (elem=lc->auth_info;elem!=NULL;elem=elem->next) {
LinphoneAuthInfo *pinfo=(LinphoneAuthInfo*)elem->data; LinphoneAuthInfo *pinfo = (LinphoneAuthInfo*)elem->data;
if (username && pinfo->username && strcmp(username,pinfo->username)==0){ if (username && pinfo->username && strcmp(username,pinfo->username)==0) {
if (realm && domain){ if (realm && domain){
if (pinfo->realm && strcmp(realm,pinfo->realm)==0 if (pinfo->realm && strcmp(realm,pinfo->realm)==0
&& pinfo->domain && strcmp(domain,pinfo->domain)==0){ && pinfo->domain && strcmp(domain,pinfo->domain)==0) {
return pinfo; return pinfo;
} }
} else if (realm){ } else if (realm) {
if (pinfo->realm && realm_match(realm,pinfo->realm)){ if (pinfo->realm && realm_match(realm,pinfo->realm)) {
if (ret!=NULL){ if (ret!=NULL) {
ms_warning("Non unique realm found for %s",username); ms_warning("Non unique realm found for %s",username);
return NULL; return NULL;
} }
ret=pinfo; ret=pinfo;
} }
} else if (domain && pinfo->domain && strcmp(domain,pinfo->domain)==0){ } else if (domain && pinfo->domain && strcmp(domain,pinfo->domain)==0) {
return pinfo; return pinfo;
} else return pinfo; } else if (!domain) {
return pinfo;
}
} }
} }
return ret; return ret;
...@@ -291,14 +293,13 @@ static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *user ...@@ -291,14 +293,13 @@ static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *user
**/ **/
const LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username, const char *domain){ const LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username, const char *domain){
const LinphoneAuthInfo *ai=NULL; const LinphoneAuthInfo *ai=NULL;
if (domain){ if (realm){
ai=find_auth_info(lc,username,realm,domain);
if (ai==NULL){
ai=find_auth_info(lc,username,NULL,domain);
}
}
if (ai==NULL && realm) {
ai=find_auth_info(lc,username,realm,NULL); ai=find_auth_info(lc,username,realm,NULL);
if (ai==NULL && domain){
ai=find_auth_info(lc,username,realm,domain);
}
} else if (domain != NULL) {
ai=find_auth_info(lc,username,NULL,domain);
} }
if (ai==NULL){ if (ai==NULL){
ai=find_auth_info(lc,username,NULL,NULL); ai=find_auth_info(lc,username,NULL,NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment