fix some warnings, add log flushing for standalone services

This commit is contained in:
z3APA3A 2020-10-30 18:56:09 +03:00
parent a0da9c97e8
commit 245222f59c
4 changed files with 18 additions and 8 deletions

View File

@ -202,7 +202,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){
cheader.updated = conf.time;
lseek(counterd, 0, SEEK_SET);
write(counterd, &cheader, sizeof(struct counter_header));
(void)write(counterd, &cheader, sizeof(struct counter_header));
for(tl=tlin; tl; tl = tl->next){
if(tl->number){
lseek(counterd,
@ -211,7 +211,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){
crecord.traf64 = tl->traf64;
crecord.cleared = tl->cleared;
crecord.updated = tl->updated;
write(counterd, &crecord, sizeof(struct counter_record));
(void)write(counterd, &crecord, sizeof(struct counter_record));
}
if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){
tl->cleared = conf.time;

View File

@ -1161,7 +1161,7 @@ static int h_ace(int argc, char **argv){
sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record),
SEEK_SET);
memset(&crecord, 0, sizeof(struct counter_record));
read(conf.counterd, &crecord, sizeof(struct counter_record));
(void)read(conf.counterd, &crecord, sizeof(struct counter_record));
tl->traf64 = crecord.traf64;
tl->cleared = crecord.cleared;
tl->updated = crecord.updated;
@ -1379,15 +1379,18 @@ static int h_chroot(int argc, char **argv){
}
chrootp = mystrdup((char *)argv[1]);
}
if (gid && setregid(gid,gid)) {
if(gid && setregid(gid,gid)) {
fprintf(stderr, "Unable to set gid %d", (int)gid);
return(4);
}
if (uid && setreuid(uid,uid)) {
if(uid && setreuid(uid,uid)) {
fprintf(stderr, "Unable to set uid %d", (int)uid);
return(5);
}
chdir("/");
if(chdir("/")){
fprintf(stderr, "Unable to chdir to /");
return(5);
}
return 0;
}
#endif

View File

@ -836,9 +836,13 @@ static void stdlog(const char * buf, int len, struct LOGGER *logger) {
FILE *log = ((struct stdlogdata *)logger->data)->fp;
fprintf(log, "%s\n", buf);
#ifdef WITHMAIN
fflush(log);
#endif
}
static void stdlogrotate(struct LOGGER *logger){
#ifndef WITHMAIN
char tmpbuf[1024];
struct stdlogdata *lp = (struct stdlogdata *)logger->data;
if(lp->fp) lp->fp = freopen((char *)dologname (tmpbuf, sizeof(tmpbuf) -1, logger->selector, NULL, logger->rotate, conf.time), "a", lp->fp);
@ -886,9 +890,10 @@ static void stdlogrotate(struct LOGGER *logger){
else
strcat((char *)tmpbuf, (char *)conf.archiver[i]);
}
system((char *)tmpbuf+1);
(void)system((char *)tmpbuf+1);
}
}
#endif
}
static void stdlogflush(struct LOGGER *logger){
@ -913,8 +918,10 @@ static void logsyslog(const char * buf, int len, struct LOGGER *logger) {
}
static void syslogrotate(struct LOGGER *logger){
#ifndef WITHMAIN
closelog();
openlog(logger->selector+1, LOG_PID, LOG_DAEMON);
#endif
}
static void syslogclose(struct LOGGER *logger){

View File

@ -557,7 +557,7 @@ void * adminchild(struct clientparam* param) {
if(writable && !error){
fflush(writable);
#ifndef _WINCE
ftruncate(fileno(writable), ftell(writable));
(void)ftruncate(fileno(writable), ftell(writable));
#endif
}
printstr(&pp, error? "<h3><font color=\"red\">Config file is not writable</font></h3>Make sure you have \"writable\" command in configuration file":