mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 18:45:40 +08:00
Fixed race conditions with users on configuration reload
This commit is contained in:
parent
fcbb000b0e
commit
4709f7a7b9
57
src/3proxy.c
57
src/3proxy.c
@ -84,6 +84,13 @@ FILE * confopen(){
|
|||||||
return fopen(curconf, "r");
|
return fopen(curconf, "r");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void freepwl(struct passwords *pwl){
|
||||||
|
for(; pwl; pwl = (struct passwords *)itfree(pwl, pwl->next)){
|
||||||
|
if(pwl->user)myfree(pwl->user);
|
||||||
|
if(pwl->password)myfree(pwl->password);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void freeconf(struct extparam *confp){
|
void freeconf(struct extparam *confp){
|
||||||
struct bandlim * bl;
|
struct bandlim * bl;
|
||||||
@ -108,20 +115,8 @@ void freeconf(struct extparam *confp){
|
|||||||
confp->trafcounter = NULL;
|
confp->trafcounter = NULL;
|
||||||
counterd = confp->counterd;
|
counterd = confp->counterd;
|
||||||
confp->counterd = -1;
|
confp->counterd = -1;
|
||||||
pthread_mutex_unlock(&tc_mutex);
|
|
||||||
if(tc)dumpcounters(tc,counterd);
|
|
||||||
for(; tc; tc = (struct trafcount *) itfree(tc, tc->next)){
|
|
||||||
if(tc->comment)myfree(tc->comment);
|
|
||||||
freeacl(tc->ace);
|
|
||||||
}
|
|
||||||
confp->countertype = NONE;
|
confp->countertype = NONE;
|
||||||
|
pthread_mutex_unlock(&tc_mutex);
|
||||||
|
|
||||||
|
|
||||||
logtarget = confp->logtarget;
|
|
||||||
confp->logtarget = NULL;
|
|
||||||
logformat = confp->logformat;
|
|
||||||
confp->logformat = NULL;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&bandlim_mutex);
|
pthread_mutex_lock(&bandlim_mutex);
|
||||||
bl = confp->bandlimiter;
|
bl = confp->bandlimiter;
|
||||||
@ -131,18 +126,27 @@ void freeconf(struct extparam *confp){
|
|||||||
confp->bandlimfunc = NULL;
|
confp->bandlimfunc = NULL;
|
||||||
pthread_mutex_unlock(&bandlim_mutex);
|
pthread_mutex_unlock(&bandlim_mutex);
|
||||||
|
|
||||||
|
pthread_mutex_lock(&pwl_mutex);
|
||||||
|
pw = confp->pwl;
|
||||||
|
confp->pwl = NULL;
|
||||||
|
pthread_mutex_unlock(&pwl_mutex);
|
||||||
|
|
||||||
|
|
||||||
|
logtarget = confp->logtarget;
|
||||||
|
confp->logtarget = NULL;
|
||||||
|
logformat = confp->logformat;
|
||||||
|
confp->logformat = NULL;
|
||||||
logname = confp->logname;
|
logname = confp->logname;
|
||||||
confp->logname = NULL;
|
confp->logname = NULL;
|
||||||
|
confp->rotate = 0;
|
||||||
|
confp->logtype = NONE;
|
||||||
|
|
||||||
archiverc = confp->archiverc;
|
archiverc = confp->archiverc;
|
||||||
confp->archiverc = 0;
|
confp->archiverc = 0;
|
||||||
archiver = confp->archiver;
|
archiver = confp->archiver;
|
||||||
confp->archiver = NULL;
|
confp->archiver = NULL;
|
||||||
fm = confp->fmon;
|
fm = confp->fmon;
|
||||||
confp->fmon = NULL;
|
confp->fmon = NULL;
|
||||||
pw = confp->pwl;
|
|
||||||
confp->pwl = NULL;
|
|
||||||
confp->rotate = 0;
|
|
||||||
confp->logtype = NONE;
|
|
||||||
confp->authfunc = ipauth;
|
confp->authfunc = ipauth;
|
||||||
confp->bandlimfunc = NULL;
|
confp->bandlimfunc = NULL;
|
||||||
memset(&confp->intsa, 0, sizeof(confp->intsa));
|
memset(&confp->intsa, 0, sizeof(confp->intsa));
|
||||||
@ -163,6 +167,12 @@ void freeconf(struct extparam *confp){
|
|||||||
|
|
||||||
usleep(SLEEPTIME);
|
usleep(SLEEPTIME);
|
||||||
|
|
||||||
|
if(tc)dumpcounters(tc,counterd);
|
||||||
|
for(; tc; tc = (struct trafcount *) itfree(tc, tc->next)){
|
||||||
|
if(tc->comment)myfree(tc->comment);
|
||||||
|
freeacl(tc->ace);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
freeacl(acl);
|
freeacl(acl);
|
||||||
freepwl(pw);
|
freepwl(pw);
|
||||||
@ -219,8 +229,6 @@ int SetStatus( DWORD dwState, DWORD dwExitCode, DWORD dwProgress )
|
|||||||
|
|
||||||
void __stdcall CommandHandler( DWORD dwCommand )
|
void __stdcall CommandHandler( DWORD dwCommand )
|
||||||
{
|
{
|
||||||
FILE *fp;
|
|
||||||
int error;
|
|
||||||
switch( dwCommand )
|
switch( dwCommand )
|
||||||
{
|
{
|
||||||
case SERVICE_CONTROL_STOP:
|
case SERVICE_CONTROL_STOP:
|
||||||
@ -1047,14 +1055,13 @@ static int h_users(int argc, unsigned char **argv){
|
|||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
memset(pwl, 0, sizeof(struct passwords));
|
memset(pwl, 0, sizeof(struct passwords));
|
||||||
pwl->next = conf.pwl;
|
|
||||||
conf.pwl = pwl;
|
|
||||||
arg = (unsigned char *)strchr((char *)argv[j], ':');
|
arg = (unsigned char *)strchr((char *)argv[j], ':');
|
||||||
if(!arg||!arg[1]||!arg[2]||arg[3]!=':') {
|
if(!arg||!arg[1]||!arg[2]||arg[3]!=':') {
|
||||||
pwl->user = (unsigned char *)mystrdup((char *)argv[j]);
|
pwl->user = (unsigned char *)mystrdup((char *)argv[j]);
|
||||||
pwl->pwtype = SYS;
|
pwl->pwtype = SYS;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
*arg = 0;
|
*arg = 0;
|
||||||
pwl->user = (unsigned char *)mystrdup((char *)argv[j]);
|
pwl->user = (unsigned char *)mystrdup((char *)argv[j]);
|
||||||
if((arg[1] == 'C' && arg[2] == 'L' && (pwl->pwtype = CL)) ||
|
if((arg[1] == 'C' && arg[2] == 'L' && (pwl->pwtype = CL)) ||
|
||||||
@ -1067,6 +1074,12 @@ static int h_users(int argc, unsigned char **argv){
|
|||||||
pwl->password = (unsigned char *) mystrdup((char *)arg + 1);
|
pwl->password = (unsigned char *) mystrdup((char *)arg + 1);
|
||||||
pwl->pwtype = UN;
|
pwl->pwtype = UN;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
pthread_mutex_lock(&pwl_mutex);
|
||||||
|
pwl->next = conf.pwl;
|
||||||
|
conf.pwl = pwl;
|
||||||
|
pthread_mutex_unlock(&pwl_mutex);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -914,13 +914,6 @@ void * itfree(void *data, void * retval){
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void freepwl(struct passwords *pwl){
|
|
||||||
for(; pwl; pwl = (struct passwords *)itfree(pwl, pwl->next)){
|
|
||||||
if(pwl->user)myfree(pwl->user);
|
|
||||||
if(pwl->password)myfree(pwl->password);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void freeauth(struct auth * authfuncs){
|
void freeauth(struct auth * authfuncs){
|
||||||
for(; authfuncs; authfuncs = (struct auth *)itfree(authfuncs, authfuncs->next));
|
for(; authfuncs; authfuncs = (struct auth *)itfree(authfuncs, authfuncs->next));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user