fix regression with previous commit regarding auth infos and ha1

This commit is contained in:
Simon Morlat 2015-09-18 22:35:10 +02:00
parent 669e23633d
commit e0d2b13123
4 changed files with 27 additions and 21 deletions

View file

@ -230,7 +230,7 @@ static bool_t realm_match(const char *realm1, const char *realm2){
return FALSE;
}
static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *username, const char *realm, const char *domain){
static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *username, const char *realm, const char *domain, bool_t ignore_realm){
MSList *elem;
const LinphoneAuthInfo *ret=NULL;
@ -250,9 +250,9 @@ static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *user
}
ret=pinfo;
}
} else if (domain && pinfo->domain && strcmp(domain,pinfo->domain)==0 && pinfo->ha1==NULL) {
} else if (domain && pinfo->domain && strcmp(domain,pinfo->domain)==0 && (pinfo->ha1==NULL || ignore_realm)) {
return pinfo;
} else if (!domain && pinfo->ha1==NULL) {
} else if (!domain && (pinfo->ha1==NULL || ignore_realm)) {
return pinfo;
}
}
@ -260,6 +260,24 @@ static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *user
return ret;
}
const LinphoneAuthInfo *_linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username, const char *domain, bool_t ignore_realm){
const LinphoneAuthInfo *ai=NULL;
if (realm){
ai=find_auth_info(lc,username,realm,NULL, FALSE);
if (ai==NULL && domain){
ai=find_auth_info(lc,username,realm,domain, FALSE);
}
}
if (ai == NULL && domain != NULL) {
ai=find_auth_info(lc,username,NULL,domain, ignore_realm);
}
if (ai==NULL){
ai=find_auth_info(lc,username,NULL,NULL, ignore_realm);
}
/*if (ai) ms_message("linphone_core_find_auth_info(): returning auth info username=%s, realm=%s", ai->username, ai->realm);*/
return ai;
}
/**
* Find authentication info matching realm, username, domain criteria.
* First of all, (realm,username) pair are searched. If multiple results (which should not happen because realm are supposed to be unique), then domain is added to the search.
@ -270,21 +288,7 @@ static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *user
* @return a #LinphoneAuthInfo
**/
const LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username, const char *domain){
const LinphoneAuthInfo *ai=NULL;
if (realm){
ai=find_auth_info(lc,username,realm,NULL);
if (ai==NULL && domain){
ai=find_auth_info(lc,username,realm,domain);
}
}
if (ai == NULL && domain != NULL) {
ai=find_auth_info(lc,username,NULL,domain);
}
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;
return _linphone_core_find_auth_info(lc, realm, username, domain, TRUE);
}
/*the auth info is expected to be in the core's list*/
@ -348,7 +352,7 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info)
SalOp *op=(SalOp*)elem->data;
LinphoneAuthInfo *ai;
const SalAuthInfo *req_sai=sal_op_get_auth_requested(op);
ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,req_sai->realm,req_sai->username,req_sai->domain);
ai=(LinphoneAuthInfo*)_linphone_core_find_auth_info(lc,req_sai->realm,req_sai->username,req_sai->domain, FALSE);
if (ai){
SalAuthInfo sai;
MSList* proxy;

View file

@ -968,7 +968,7 @@ static void auth_failure(SalOp *op, SalAuthInfo* info) {
LinphoneAuthInfo *ai=NULL;
if( info != NULL ){
ai = (LinphoneAuthInfo*)linphone_core_find_auth_info(lc,info->realm,info->username,info->domain);
ai = (LinphoneAuthInfo*)_linphone_core_find_auth_info(lc,info->realm,info->username,info->domain, TRUE);
if (ai){
ms_message("%s/%s/%s authentication fails.",info->realm,info->username,info->domain);
@ -1172,7 +1172,7 @@ static bool_t fill_auth_info_with_client_certificate(LinphoneCore *lc, SalAuthIn
}
static bool_t fill_auth_info(LinphoneCore *lc, SalAuthInfo* sai) {
LinphoneAuthInfo *ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,sai->realm,sai->username,sai->domain);
LinphoneAuthInfo *ai=(LinphoneAuthInfo*)_linphone_core_find_auth_info(lc,sai->realm,sai->username,sai->domain, FALSE);
if (ai) {
sai->userid=ms_strdup(ai->userid?ai->userid:ai->username);
sai->password=ai->passwd?ms_strdup(ai->passwd):NULL;

View file

@ -338,6 +338,7 @@ SalStreamDir get_video_dir_from_call_params(const LinphoneCallParams *params);
void linphone_auth_info_write_config(struct _LpConfig *config, LinphoneAuthInfo *obj, int pos);
void linphone_core_write_auth_info(LinphoneCore *lc, LinphoneAuthInfo *ai);
const LinphoneAuthInfo *_linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username, const char *domain, bool_t ignore_realm);
void linphone_core_update_proxy_register(LinphoneCore *lc);
void linphone_core_refresh_subscribes(LinphoneCore *lc);

View file

@ -3160,6 +3160,7 @@ static void call_rejected_because_wrong_credentials_with_params(const char* user
LinphoneAuthInfo* wrong_auth_info=linphone_auth_info_clone(good_auth_info);
bool_t result=FALSE;
linphone_auth_info_set_passwd(wrong_auth_info,"passecretdutout");
linphone_auth_info_set_ha1(wrong_auth_info, NULL);
linphone_core_clear_all_auth_info(marie->lc);
if (user_agent) {