Commit 9059151d authored by venaas's avatar venaas Committed by venaas
Browse files

improved findserver a bit

git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@411 e88ac4ed-0b26-0410-9574-a7f39faa03bf
parent 0ab8340b
...@@ -1704,22 +1704,20 @@ struct clsrvconf *choosesrvconf(struct list *srvconfs) { ...@@ -1704,22 +1704,20 @@ struct clsrvconf *choosesrvconf(struct list *srvconfs) {
struct server *findserver(struct realm **realm, struct tlv *username, uint8_t acc) { struct server *findserver(struct realm **realm, struct tlv *username, uint8_t acc) {
struct clsrvconf *srvconf; struct clsrvconf *srvconf;
struct realm *subrealm; struct realm *subrealm;
struct server *server = NULL;
char *id = (char *)tlv2str(username); char *id = (char *)tlv2str(username);
if (!id) if (!id)
return NULL; return NULL;
/* returns with lock on realm */ /* returns with lock on realm */
*realm = id2realm(realms, id); *realm = id2realm(realms, id);
if (!*realm) { if (!*realm)
free(id); goto exit;
return NULL;
}
debug(DBG_DBG, "found matching realm: %s", (*realm)->name); debug(DBG_DBG, "found matching realm: %s", (*realm)->name);
srvconf = choosesrvconf(acc ? (*realm)->accsrvconfs : (*realm)->srvconfs); srvconf = choosesrvconf(acc ? (*realm)->accsrvconfs : (*realm)->srvconfs);
if (!srvconf) { if (!srvconf)
free(id); goto exit;
return NULL; server = srvconf->servers;
}
if (!acc && !(*realm)->parent && !srvconf->servers) { if (!acc && !(*realm)->parent && !srvconf->servers) {
subrealm = adddynamicrealmserver(*realm, srvconf, id); subrealm = adddynamicrealmserver(*realm, srvconf, id);
if (subrealm) { if (subrealm) {
...@@ -1727,10 +1725,12 @@ struct server *findserver(struct realm **realm, struct tlv *username, uint8_t ac ...@@ -1727,10 +1725,12 @@ struct server *findserver(struct realm **realm, struct tlv *username, uint8_t ac
pthread_mutex_unlock(&(*realm)->mutex); pthread_mutex_unlock(&(*realm)->mutex);
freerealm(*realm); freerealm(*realm);
*realm = subrealm; *realm = subrealm;
server = ((struct clsrvconf *)subrealm->srvconfs->first->data)->servers;
} }
} }
exit:
free(id); free(id);
return srvconf->servers; return server;
} }
......
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