2017-04-06 11:40:20 +02:00
|
|
|
---
|
|
|
|
Makefile | 4 +--
|
|
|
|
syslogd.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
|
|
|
|
2 files changed, 67 insertions(+), 5 deletions(-)
|
|
|
|
|
2010-11-26 17:39:35 +01:00
|
|
|
--- Makefile
|
2017-04-06 11:40:20 +02:00
|
|
|
+++ Makefile 2017-04-06 09:32:55.360422009 +0000
|
2010-11-26 17:39:35 +01:00
|
|
|
@@ -3,7 +3,7 @@
|
|
|
|
CC= gcc
|
|
|
|
#CFLAGS= -g -DSYSV -Wall
|
|
|
|
#LDFLAGS= -g
|
|
|
|
-CFLAGS= $(RPM_OPT_FLAGS) -DINET6 -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce
|
|
|
|
+CFLAGS= $(RPM_OPT_FLAGS) -DINET6 -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce -I.
|
|
|
|
LDFLAGS= -s
|
|
|
|
|
|
|
|
# Look where your install program is.
|
2017-04-06 11:40:20 +02:00
|
|
|
@@ -21,7 +21,7 @@ MANDIR = /usr/man
|
|
|
|
# specific to the ALPHA. If you are attempting to build this package under
|
|
|
|
# an ALPHA and linking fails with unresolved references please try
|
|
|
|
# uncommenting the following define.
|
|
|
|
-# LIBS = ${LIBS} -linux
|
|
|
|
+LIBS += $(shell pkg-config libsystemd --libs)
|
2010-11-26 17:39:35 +01:00
|
|
|
|
2017-04-06 11:40:20 +02:00
|
|
|
# Define the following to impart start-up delay in klogd. This is
|
|
|
|
# useful if klogd is started simultaneously or in close-proximity to syslogd.
|
2010-11-26 17:39:35 +01:00
|
|
|
--- syslogd.c
|
2017-04-06 11:40:20 +02:00
|
|
|
+++ syslogd.c 2017-04-06 09:29:43.524044965 +0000
|
|
|
|
@@ -505,6 +505,7 @@ static char sccsid[] __attribute__ ((un
|
2010-11-26 17:39:35 +01:00
|
|
|
|
|
|
|
#if defined(__linux__)
|
|
|
|
#include <paths.h>
|
2017-04-06 11:40:20 +02:00
|
|
|
+#include <systemd/sd-daemon.h>
|
2010-11-26 17:39:35 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef UTMP_FILE
|
2017-04-06 11:40:20 +02:00
|
|
|
@@ -990,8 +991,11 @@ int main(argc, argv)
|
2010-11-26 17:39:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
num_fds = getdtablesize();
|
|
|
|
- for (i = 0; i < num_fds; i++)
|
|
|
|
- (void) close(i);
|
|
|
|
+#if defined(__linux__)
|
|
|
|
+ if (sd_listen_fds(0) <= 0)
|
|
|
|
+#endif
|
|
|
|
+ for (i = 0; i < num_fds; i++)
|
|
|
|
+ (void) close(i);
|
|
|
|
untty();
|
|
|
|
break;
|
|
|
|
}
|
2017-04-06 11:40:20 +02:00
|
|
|
@@ -1298,6 +1302,59 @@ static int create_unix_socket(const char
|
2010-11-26 17:39:35 +01:00
|
|
|
if (path[0] == '\0')
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
+#if defined(__linux__)
|
|
|
|
+ if (strcmp(path, _PATH_LOG) == 0) {
|
|
|
|
+ int r;
|
|
|
|
+
|
|
|
|
+ /* Check whether an FD was passed in from systemd. If
|
|
|
|
+ * so, it's the /dev/log socket, so use it. */
|
|
|
|
+
|
|
|
|
+ r = sd_listen_fds(0);
|
|
|
|
+ if (r < 0) {
|
|
|
|
+ logerror("Failed to acquire systemd socket");
|
|
|
|
+#ifndef SYSV
|
|
|
|
+ dienow();
|
|
|
|
+#else
|
|
|
|
+ return -1;
|
|
|
|
+#endif
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (r > 1) {
|
|
|
|
+ logerror("Wrong number of systemd sockets passed");
|
|
|
|
+#ifndef SYSV
|
|
|
|
+ dienow();
|
|
|
|
+#else
|
|
|
|
+ return -1;
|
|
|
|
+#endif
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (r == 1) {
|
|
|
|
+ fd = SD_LISTEN_FDS_START;
|
|
|
|
+ r = sd_is_socket_unix(fd, SOCK_DGRAM, -1, _PATH_LOG, 0);
|
|
|
|
+ if (r < 0) {
|
|
|
|
+ logerror("Failed to verify systemd socket type");
|
|
|
|
+#ifndef SYSV
|
|
|
|
+ dienow();
|
|
|
|
+#else
|
|
|
|
+ return -1;
|
|
|
|
+#endif
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!r) {
|
|
|
|
+ logerror("Passed systemd socket of wrong type");
|
|
|
|
+#ifndef SYSV
|
|
|
|
+ dienow();
|
|
|
|
+#else
|
|
|
|
+ return -1;
|
|
|
|
+#endif
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return fd;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
(void) unlink(path);
|
|
|
|
|
|
|
|
memset(&sunx, 0, sizeof(sunx));
|
2017-04-06 11:40:20 +02:00
|
|
|
@@ -2368,7 +2425,12 @@ void dienow(void)
|
2010-11-26 17:39:35 +01:00
|
|
|
if (InetInuse) close(inetm);
|
|
|
|
|
|
|
|
/* Clean-up files. */
|
|
|
|
- for (i = 0; i < nfunix; i++)
|
|
|
|
+ i = 0;
|
|
|
|
+#if defined(__linux__)
|
|
|
|
+ if (sd_listen_fds(0) > 0)
|
|
|
|
+ i = 1;
|
|
|
|
+#endif
|
|
|
|
+ for (; i < nfunix; i++)
|
|
|
|
if (funixn[i] && funix[i] != -1)
|
|
|
|
(void)unlink(funixn[i]);
|
|
|
|
|