Fix #62: early log messages lost when running in systemd
This is a follow-up to d7576c7
which initially added support for running
in systemd based systems. Since the unit file sources the syslog.socket
we have /run/systemd/journal/syslog open already on descriptor 3. All
we need to do is verify that's the mode syslogd runs in.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
parent
c82c004de7
commit
7ec64e5f9c
@ -193,6 +193,7 @@ void untty(void);
|
|||||||
static void parsemsg(const char *from, char *msg);
|
static void parsemsg(const char *from, char *msg);
|
||||||
static int opensys(const char *file);
|
static int opensys(const char *file);
|
||||||
static void printsys(char *msg);
|
static void printsys(char *msg);
|
||||||
|
static void unix_cb(int sd, void *arg);
|
||||||
static void logmsg(struct buf_msg *buffer);
|
static void logmsg(struct buf_msg *buffer);
|
||||||
static void logrotate(struct filed *f);
|
static void logrotate(struct filed *f);
|
||||||
static void rotate_file(struct filed *f, struct stat *stp_or_null);
|
static void rotate_file(struct filed *f, struct stat *stp_or_null);
|
||||||
@ -521,12 +522,20 @@ int main(int argc, char *argv[])
|
|||||||
.pe_serv = "syslog",
|
.pe_serv = "syslog",
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Default to _PATH_LOG for the UNIX domain socket */
|
/* Figure out where to read system log messages from */
|
||||||
if (!pflag)
|
if (!pflag) {
|
||||||
addpeer(&(struct peer) {
|
/* Do we run under systemd-journald (Requires=syslog.socket)? */
|
||||||
.pe_name = _PATH_LOG,
|
if (fcntl(3, F_GETFD) != -1) {
|
||||||
.pe_mode = 0666,
|
if (socket_register(3, NULL, unix_cb, NULL) == -1)
|
||||||
});
|
err(1, "failed registering syslog.socket (3)");
|
||||||
|
} else {
|
||||||
|
/* Default to _PATH_LOG for the UNIX domain socket */
|
||||||
|
addpeer(&(struct peer) {
|
||||||
|
.pe_name = _PATH_LOG,
|
||||||
|
.pe_mode = 0666,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!Foreground && !Debug) {
|
if (!Foreground && !Debug) {
|
||||||
ppid = waitdaemon(30);
|
ppid = waitdaemon(30);
|
||||||
|
@ -6,7 +6,7 @@ Requires=syslog.socket
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
EnvironmentFile=-@SYSCONFDIR@/default/syslogd
|
EnvironmentFile=-@SYSCONFDIR@/default/syslogd
|
||||||
ExecStart=@SBINDIR@/syslogd -F -p /run/systemd/journal/syslog $SYSLOGD_OPTS
|
ExecStart=@SBINDIR@/syslogd -F $SYSLOGD_OPTS
|
||||||
StandardOutput=null
|
StandardOutput=null
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user