summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko2009-03-04 01:33:22 +0000
committerDenis Vlasenko2009-03-04 01:33:22 +0000
commitbc7177187f6b4f32c2f9562358294dfc7b521f67 (patch)
tree3730020ba2f9caeb9d7815a975af51830b51ce11
parent8bc376bc12225a62c64269f9ce82d89860519ed7 (diff)
downloadbusybox-bc7177187f6b4f32c2f9562358294dfc7b521f67.zip
busybox-bc7177187f6b4f32c2f9562358294dfc7b521f67.tar.gz
syslogd: fix new log file mode 0600 -> 0666 (as usual, affected by umask)1_13_3
-rw-r--r--sysklogd/syslogd.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 38ea3d7..f624eb7 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -301,17 +301,23 @@ static void log_locally(time_t now, char *msg)
}
#endif
if (G.logFD >= 0) {
+ /* Reopen log file every second. This allows admin
+ * to delete the file and not worry about restarting us.
+ * This costs almost nothing since it happens
+ * _at most_ once a second.
+ */
if (!now)
now = time(NULL);
if (G.last_log_time != now) {
- G.last_log_time = now; /* reopen log file every second */
+ G.last_log_time = now;
close(G.logFD);
goto reopen;
}
} else {
reopen:
- G.logFD = device_open(G.logFilePath, O_WRONLY | O_CREAT
- | O_NOCTTY | O_APPEND | O_NONBLOCK);
+ G.logFD = open(G.logFilePath, O_WRONLY | O_CREAT
+ | O_NOCTTY | O_APPEND | O_NONBLOCK,
+ 0666);
if (G.logFD < 0) {
/* cannot open logfile? - print to /dev/console then */
int fd = device_open(DEV_CONSOLE, O_WRONLY | O_NOCTTY | O_NONBLOCK);