} 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);
}
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)) {
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)) {
}
}
}
- fcntl(fileno(out), F_SETFD, FD_CLOEXEC);
if((ch = stdmkchild(argv + optind + 1, NULL, NULL)) < 0) {
flog(LOG_ERR, "accesslog: could not fork child: %s", strerror(errno));
exit(1);
if(pfd[1].revents & POLLHUP)
break;
}
+ fclose(out);
if(pidfile != NULL)
unlink(pidfile);
return(0);