Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:dirkmueller:Factory
syslogd
sysklogd-1.4.1-systemd.dif
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File sysklogd-1.4.1-systemd.dif of Package syslogd
--- Makefile | 4 +-- syslogd.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 67 insertions(+), 5 deletions(-) --- Makefile +++ Makefile 2017-04-06 09:32:55.360422009 +0000 @@ -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. @@ -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) # Define the following to impart start-up delay in klogd. This is # useful if klogd is started simultaneously or in close-proximity to syslogd. --- syslogd.c +++ syslogd.c 2017-04-06 09:29:43.524044965 +0000 @@ -505,6 +505,7 @@ static char sccsid[] __attribute__ ((un #if defined(__linux__) #include <paths.h> +#include <systemd/sd-daemon.h> #endif #ifndef UTMP_FILE @@ -990,8 +991,11 @@ int main(argc, argv) } 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; } @@ -1298,6 +1302,59 @@ static int create_unix_socket(const char 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)); @@ -2368,7 +2425,12 @@ void dienow(void) 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]);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor