X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Faccesslog.c;h=88b61b3a889067922295b56703c97811f76077a7;hb=10f3ffeba5689f21f405caf2f93a3953ae5f1c80;hp=5aa25743964af97bb4d462af00ed405f05115ce3;hpb=e51483a1b5ecc3b5e486f1d951d044d5bd34bce7;p=ashd.git diff --git a/src/accesslog.c b/src/accesslog.c index 5aa2574..88b61b3 100644 --- a/src/accesslog.c +++ b/src/accesslog.c @@ -46,8 +46,10 @@ static char *format; static struct timeval now; static volatile int reopen = 0; -static void qputs(char *s, FILE *o) +static void qputs(char *sp, FILE *o) { + unsigned char *s = (unsigned char *)sp; + for(; *s; s++) { if(*s == '\"') { fputs("\\\"", o); @@ -58,7 +60,7 @@ static void qputs(char *s, FILE *o) } else if(*s == '\t') { fputs("\\t", o); } else if((*s < 32) || (*s >= 128)) { - fprintf(o, "\\x%02x", *s); + fprintf(o, "\\x%02x", (int)*s); } else { fputc(*s, o); } @@ -255,6 +257,7 @@ static void reopenlog(void) flog(LOG_WARNING, "accesslog: could not reopen log file `%s' on SIGHUP: %s", outname, strerror(errno)); return; } + fcntl(fileno(new), F_SETFD, FD_CLOEXEC); if(locklog) { if(lockfile(new)) { if((errno == EAGAIN) || (errno == EACCES)) { @@ -326,11 +329,13 @@ int main(int argc, char **argv) outname = argv[optind]; if(outname == NULL) { out = stdout; + locklog = 0; } else { if((out = fopen(argv[optind], "a")) == NULL) { flog(LOG_ERR, "accesslog: could not open %s for logging: %s", argv[optind], strerror(errno)); exit(1); } + fcntl(fileno(out), F_SETFD, FD_CLOEXEC); } if(locklog) { if(lockfile(out)) { @@ -392,6 +397,7 @@ int main(int argc, char **argv) if(pfd[1].revents & POLLHUP) break; } + fclose(out); if(pidfile != NULL) unlink(pidfile); return(0);