X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Faccesslog.c;h=0c292c818f7b5c0c13c1e2270c26ed8a93fba124;hb=5f0c1cd631b9abcca90afe15cf129babba86f7f1;hp=5b0c7081152bb0abda657efc0db3eb7cf7a73cc6;hpb=ca170d77b595e63bbbaba28ace23cc88e855c41a;p=ashd.git diff --git a/src/accesslog.c b/src/accesslog.c index 5b0c708..0c292c8 100644 --- a/src/accesslog.c +++ b/src/accesslog.c @@ -58,7 +58,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)(unsigned char)*s); } else { fputc(*s, o); } @@ -255,6 +255,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)) { @@ -273,6 +274,7 @@ static void reopenlog(void) static void usage(FILE *out) { fprintf(out, "usage: accesslog [-hFaL] [-f FORMAT] [-p PIDFILE] OUTFILE CHILD [ARGS...]\n"); + fprintf(out, " accesslog -P LOGFILE\n"); } int main(int argc, char **argv) @@ -325,11 +327,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)) {