"limit" support in authcache to bind sessions to ip

This commit is contained in:
z3APA3A committed 2019-08-21 15:20:43 +03:00
1 parent 336b411ea2
commit e7e7d2fddf
5 files changed
+33 -8

No files matched your search

+17 -7
View File
@@ -721,15 +721,24 @@ int cacheauth(struct clientparam * param){
continue;
}
if(((!(conf.authcachetype&2)) || (param->username && ac->username && !strcmp(ac->username, (char *)param->username))) &&
((!(conf.authcachetype&1)) || (*SAFAMILY(&ac->sa) == *SAFAMILY(&param->sincr) && !memcmp(SAADDR(&ac->sa), SAADDR(&param->sincr), SAADDRLEN(&ac->sa)))) &&
if((!(conf.authcachetype&2) || (param->username && ac->username && !strcmp(ac->username, (char *)param->username))) &&
(!(conf.authcachetype&4) || (ac->password && param->password && !strcmp(ac->password, (char *)param->password)))) {
if(param->username){
myfree(param->username);
if(!(conf.authcachetype&1)
|| ((*SAFAMILY(&ac->sa) == *SAFAMILY(&param->sincr)
&& !memcmp(SAADDR(&ac->sa), SAADDR(&param->sincr), SAADDRLEN(&ac->sa))))){
if(param->username){
myfree(param->username);
}
param->username = (unsigned char *)mystrdup(ac->username);
pthread_mutex_unlock(&hash_mutex);
return 0;
}
else if ((conf.authcachetype&1) && (conf.authcachetype&8)) {
pthread_mutex_unlock(&hash_mutex);
return 10;
}
param->username = (unsigned char *)mystrdup(ac->username);
pthread_mutex_unlock(&hash_mutex);
return 0;
}
last = ac;
ac = ac->next;
@@ -790,6 +799,7 @@ int doauth(struct clientparam * param){
break;
}
if(res > ret) ret = res;
if(ret > 9) return ret;
}
if(!res){
return alwaysauth(param);