|
@@ -285,6 +285,7 @@ static int h_external(int argc, unsigned char ** argv){
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static int h_log(int argc, unsigned char ** argv){
|
|
static int h_log(int argc, unsigned char ** argv){
|
|
|
|
|
+ unsigned char tmpbuf[8192];
|
|
|
conf.logfunc = logstdout;
|
|
conf.logfunc = logstdout;
|
|
|
if(conf.logtarget){
|
|
if(conf.logtarget){
|
|
|
myfree(conf.logtarget);
|
|
myfree(conf.logtarget);
|
|
@@ -317,14 +318,12 @@ static int h_log(int argc, unsigned char ** argv){
|
|
|
conf.logname = (unsigned char *)mystrdup((char *)argv[1]);
|
|
conf.logname = (unsigned char *)mystrdup((char *)argv[1]);
|
|
|
fp = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.logtime), "a");
|
|
fp = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.logtime), "a");
|
|
|
if(!fp){
|
|
if(!fp){
|
|
|
- perror("fopen()");
|
|
|
|
|
|
|
+ perror((char *)tmpbuf);
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- pthread_mutex_lock(&log_mutex);
|
|
|
|
|
if(conf.stdlog)fclose(conf.stdlog);
|
|
if(conf.stdlog)fclose(conf.stdlog);
|
|
|
conf.stdlog = fp;
|
|
conf.stdlog = fp;
|
|
|
- pthread_mutex_unlock(&log_mutex);
|
|
|
|
|
#ifdef _WINCE
|
|
#ifdef _WINCE
|
|
|
freopen(tmpbuf, "w", stdout);
|
|
freopen(tmpbuf, "w", stdout);
|
|
|
freopen(tmpbuf, "w", stderr);
|
|
freopen(tmpbuf, "w", stderr);
|
|
@@ -340,6 +339,17 @@ static int h_stacksize(int argc, unsigned char **argv){
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+static int h_force(int argc, unsigned char **argv){
|
|
|
|
|
+ conf.noforce = 0;
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static int h_noforce(int argc, unsigned char **argv){
|
|
|
|
|
+ conf.noforce = 1;
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static int h_service(int argc, unsigned char **argv){
|
|
static int h_service(int argc, unsigned char **argv){
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
@@ -395,17 +405,22 @@ static int h_counter(int argc, unsigned char **argv){
|
|
|
fprintf(stderr, "Not a counter file %s, line %d\n", argv[1], linenum);
|
|
fprintf(stderr, "Not a counter file %s, line %d\n", argv[1], linenum);
|
|
|
return 2;
|
|
return 2;
|
|
|
}
|
|
}
|
|
|
-#ifdef _MSC_VER
|
|
|
|
|
#ifdef _TIME64_T_DEFINED
|
|
#ifdef _TIME64_T_DEFINED
|
|
|
-#ifndef _MAX__TIME64_T
|
|
|
|
|
-#define _MAX__TIME64_T 0x793406fffi64
|
|
|
|
|
|
|
+#ifdef _MAX__TIME64_T
|
|
|
|
|
+#define MAX_COUNTER_TIME (_MAX__TIME64_T)
|
|
|
|
|
+#elif defined (MAX__TIME64_T)
|
|
|
|
|
+#define MAX_COUNTER_TIME (MAX__TIME64_T)
|
|
|
|
|
+#else
|
|
|
|
|
+#define MAX_COUNTER_TIME (0x793406fff)
|
|
|
#endif
|
|
#endif
|
|
|
|
|
+#else
|
|
|
|
|
+#define MAX_COUNTER_TIME ((sizeof(time_t)>4)?(time_t)0x793406fff:(time_t)0x7fffffff)
|
|
|
#endif
|
|
#endif
|
|
|
- if(ch1.updated >= _MAX__TIME64_T){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if(ch1.updated < 0 || ch1.updated >= MAX_COUNTER_TIME){
|
|
|
fprintf(stderr, "Invalid or corrupted counter file %s. Use countersutil utility to convert from older version\n", argv[1]);
|
|
fprintf(stderr, "Invalid or corrupted counter file %s. Use countersutil utility to convert from older version\n", argv[1]);
|
|
|
return 3;
|
|
return 3;
|
|
|
}
|
|
}
|
|
|
-#endif
|
|
|
|
|
cheader.updated = ch1.updated;
|
|
cheader.updated = ch1.updated;
|
|
|
}
|
|
}
|
|
|
if(argc >=4) {
|
|
if(argc >=4) {
|
|
@@ -548,8 +563,8 @@ static int h_nserver(int argc, unsigned char **argv){
|
|
|
if(numservers < MAXNSERVERS) {
|
|
if(numservers < MAXNSERVERS) {
|
|
|
if((str = strchr((char *)argv[1], '/')))
|
|
if((str = strchr((char *)argv[1], '/')))
|
|
|
*str = 0;
|
|
*str = 0;
|
|
|
- if(!getip46(46, argv[1], (struct sockaddr *)&nservers[numservers].addr)) return 1;
|
|
|
|
|
*SAPORT(&nservers[numservers].addr) = htons(53);
|
|
*SAPORT(&nservers[numservers].addr) = htons(53);
|
|
|
|
|
+ if(parsehost(46, argv[1], (struct sockaddr *)&nservers[numservers].addr)) return 1;
|
|
|
if(str) {
|
|
if(str) {
|
|
|
nservers[numservers].usetcp = strstr(str + 1, "tcp")? 1:0;
|
|
nservers[numservers].usetcp = strstr(str + 1, "tcp")? 1:0;
|
|
|
*str = '/';
|
|
*str = '/';
|
|
@@ -566,7 +581,7 @@ static int h_authnserver(int argc, unsigned char **argv){
|
|
|
|
|
|
|
|
if((str = strchr((char *)argv[1], '/')))
|
|
if((str = strchr((char *)argv[1], '/')))
|
|
|
*str = 0;
|
|
*str = 0;
|
|
|
- if(!getip46(46, argv[1], (struct sockaddr *)&authnserver.addr)) return 1;
|
|
|
|
|
|
|
+ if(parsehost(46, argv[1], (struct sockaddr *)&authnserver.addr)) return 1;
|
|
|
*SAPORT(&authnserver.addr) = htons(53);
|
|
*SAPORT(&authnserver.addr) = htons(53);
|
|
|
if(str) {
|
|
if(str) {
|
|
|
authnserver.usetcp = strstr(str + 1, "tcp")? 1:0;
|
|
authnserver.usetcp = strstr(str + 1, "tcp")? 1:0;
|
|
@@ -1199,12 +1214,10 @@ static int h_ace(int argc, unsigned char **argv){
|
|
|
tl->traf64 = crecord.traf64;
|
|
tl->traf64 = crecord.traf64;
|
|
|
tl->cleared = crecord.cleared;
|
|
tl->cleared = crecord.cleared;
|
|
|
tl->updated = crecord.updated;
|
|
tl->updated = crecord.updated;
|
|
|
-#ifdef _MAX__TIME64_T
|
|
|
|
|
- if(tl->cleared >= _MAX__TIME64_T || tl->updated >= _MAX__TIME64_T){
|
|
|
|
|
- fprintf(stderr, "Invalid or corrupted counter file. Use countersutil utility to convert from older version\n");
|
|
|
|
|
|
|
+ if(tl->cleared < 0 || tl->cleared >= MAX_COUNTER_TIME || tl->updated < 0 || tl->updated >= MAX_COUNTER_TIME){
|
|
|
|
|
+ fprintf(stderr, "Invalid, incompatible or corrupted counter file.\n");
|
|
|
return(6);
|
|
return(6);
|
|
|
}
|
|
}
|
|
|
-#endif
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
pthread_mutex_lock(&tc_mutex);
|
|
pthread_mutex_lock(&tc_mutex);
|
|
@@ -1293,7 +1306,7 @@ static int h_plugin(int argc, unsigned char **argv){
|
|
|
static int h_setuid(int argc, unsigned char **argv){
|
|
static int h_setuid(int argc, unsigned char **argv){
|
|
|
int res;
|
|
int res;
|
|
|
res = atoi((char *)argv[1]);
|
|
res = atoi((char *)argv[1]);
|
|
|
- if(!res || setuid(res)) {
|
|
|
|
|
|
|
+ if(!res || setreuid(res,res)) {
|
|
|
fprintf(stderr, "Unable to set uid %d", res);
|
|
fprintf(stderr, "Unable to set uid %d", res);
|
|
|
return(1);
|
|
return(1);
|
|
|
}
|
|
}
|
|
@@ -1304,7 +1317,7 @@ static int h_setgid(int argc, unsigned char **argv){
|
|
|
int res;
|
|
int res;
|
|
|
|
|
|
|
|
res = atoi((char *)argv[1]);
|
|
res = atoi((char *)argv[1]);
|
|
|
- if(!res || setgid(res)) {
|
|
|
|
|
|
|
+ if(!res || setregid(res,res)) {
|
|
|
fprintf(stderr, "Unable to set gid %d", res);
|
|
fprintf(stderr, "Unable to set gid %d", res);
|
|
|
return(1);
|
|
return(1);
|
|
|
}
|
|
}
|
|
@@ -1399,6 +1412,8 @@ struct commands commandhandlers[]={
|
|
|
{commandhandlers+56, "delimchar",h_delimchar, 2, 2},
|
|
{commandhandlers+56, "delimchar",h_delimchar, 2, 2},
|
|
|
{commandhandlers+57, "authnserver", h_authnserver, 2, 2},
|
|
{commandhandlers+57, "authnserver", h_authnserver, 2, 2},
|
|
|
{commandhandlers+58, "stacksize", h_stacksize, 2, 2},
|
|
{commandhandlers+58, "stacksize", h_stacksize, 2, 2},
|
|
|
|
|
+ {commandhandlers+59, "force", h_force, 1, 1},
|
|
|
|
|
+ {commandhandlers+60, "noforce", h_noforce, 1, 1},
|
|
|
{specificcommands, "", h_noop, 1, 0}
|
|
{specificcommands, "", h_noop, 1, 0}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -1686,6 +1701,7 @@ int reload (void){
|
|
|
fp = confopen();
|
|
fp = confopen();
|
|
|
if(fp){
|
|
if(fp){
|
|
|
error = readconfig(fp);
|
|
error = readconfig(fp);
|
|
|
|
|
+ conf.version++;
|
|
|
if(error) {
|
|
if(error) {
|
|
|
freeconf(&conf);
|
|
freeconf(&conf);
|
|
|
}
|
|
}
|