Sync from SUSE:SLFO:Main syslogd revision bc786bf41cca4f10d6402fdc425cfe00
This commit is contained in:
commit
eb97ddced7
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
## Default LFS
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
53
klog.service
Normal file
53
klog.service
Normal file
@ -0,0 +1,53 @@
|
||||
# /lib/systemd/system/klog.service
|
||||
#
|
||||
# This file is part of package systemd.
|
||||
#
|
||||
# Copyright (c) 2011 SuSE LINUX Products GmbH, Germany.
|
||||
# Author: Werner Fink
|
||||
# Please send feedback to http://www.suse.de/feedback
|
||||
#
|
||||
# Description:
|
||||
#
|
||||
# Create the well known /var/log/boot.msg
|
||||
# By using dmesg(1) the normal kernel and boot messages handled
|
||||
# by systemd will not disappear. The character device /dev/tty10
|
||||
# will be created by udevd and therefore should exists only if
|
||||
# virtual consoles are available.
|
||||
#
|
||||
|
||||
[Unit]
|
||||
Description=Early Kernel Boot Messages
|
||||
DefaultDependencies=no
|
||||
Requires=local-fs.target
|
||||
After=local-fs.target
|
||||
Before=shutdown.target
|
||||
RefuseManualStart=true
|
||||
ConditionPathIsDirectory=/var/log
|
||||
|
||||
[Service]
|
||||
# added automatically, for details please see
|
||||
# https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort
|
||||
ProtectSystem=full
|
||||
ProtectHome=true
|
||||
ProtectHostname=true
|
||||
ProtectKernelTunables=true
|
||||
ProtectKernelModules=true
|
||||
ProtectControlGroups=true
|
||||
RestrictRealtime=true
|
||||
# end of automatic additions
|
||||
Type=oneshot
|
||||
StandardError=tty
|
||||
StandardOutput=tty
|
||||
RemainAfterExit=yes
|
||||
Environment=CONSOLE_LOGLEVEL=
|
||||
Environment=KLOG_CONSOLE=10
|
||||
EnvironmentFile=-/etc/sysconfig/boot
|
||||
ExecStart=/bin/sh -c "test -s /var/log/boot.msg && /bin/mv -f /var/log/boot.msg /var/log/boot.omsg || :"
|
||||
ExecStart=/bin/sh -c "/bin/dmesg -r > /var/log/boot.msg"
|
||||
ExecStart=/bin/sh -c "test -s /dev/shm/initrd.msg -a -O /dev/shm/initrd.msg && /bin/cat /dev/shm/initrd.msg >> /var/log/boot.msg || :"
|
||||
ExecStart=/bin/sh -c "test -c /dev/tty$KLOG_CONSOLE && /usr/bin/setlogcons $KLOG_CONSOLE || :"
|
||||
ExecStart=/bin/sh -c "if test -n \"$CONSOLE_LOGLEVEL\" ; then /bin/dmesg -n $CONSOLE_LOGLEVEL || : ; fi"
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
||||
Alias=bootmsg.service
|
50
klogd.service
Normal file
50
klogd.service
Normal file
@ -0,0 +1,50 @@
|
||||
# /lib/systemd/system/klogd.service
|
||||
#
|
||||
# This file is part of package klogd.
|
||||
#
|
||||
# Copyright (c) 2011 SuSE LINUX Products GmbH, Germany.
|
||||
# Author: Werner Fink
|
||||
# Please send feedback to http://www.suse.de/feedback
|
||||
#
|
||||
# Description:
|
||||
#
|
||||
# Used to start klogd, the System Kernel Logging Service
|
||||
# if and only if the System Logger does not provide this
|
||||
# its self. If the System Logger can do Kernel Logging
|
||||
# Service this file should be masked by a symbolic link
|
||||
# from /etc/systemd/system/klogd.service to /dev/null.
|
||||
#
|
||||
# If klogd.service is started then BindsTo=syslog.service
|
||||
# within unit section to make it disappear if syslogd dies.
|
||||
#
|
||||
|
||||
[Unit]
|
||||
Description=System Kernel Logging Service
|
||||
Requisite=syslogd.service
|
||||
BindsTo=syslogd.service
|
||||
After=syslogd.service
|
||||
RefuseManualStart=true
|
||||
|
||||
[Service]
|
||||
# added automatically, for details please see
|
||||
# https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort
|
||||
ProtectSystem=full
|
||||
ProtectHome=true
|
||||
PrivateDevices=true
|
||||
ProtectHostname=true
|
||||
ProtectClock=true
|
||||
ProtectKernelTunables=true
|
||||
ProtectKernelModules=true
|
||||
ProtectControlGroups=true
|
||||
RestrictRealtime=true
|
||||
# end of automatic additions
|
||||
Type=simple
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
Environment=KERNEL_LOGLEVEL=1
|
||||
Environment=KLOGD_PARAMS=
|
||||
EnvironmentFile=-/etc/sysconfig/syslog
|
||||
ExecStart=/sbin/klogd -n -c $KERNEL_LOGLEVEL $KLOGD_PARAMS -x
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
30
logrotate.syslog
Normal file
30
logrotate.syslog
Normal file
@ -0,0 +1,30 @@
|
||||
#
|
||||
# Please note, that changing of log file permissions in this
|
||||
# file is not sufficient if syslog-ng is used as log daemon.
|
||||
#
|
||||
# It is required to specify the permissions in the syslog-ng
|
||||
# configuration file /etc/syslog-ng/syslog-ng.conf as well.
|
||||
#
|
||||
|
||||
# the firewall,acpid,NetworkManager log files
|
||||
# are used by syslog-ng and rsyslog only, the
|
||||
# other by all syslog daemons.
|
||||
# the mail log files are used by all syslog daemons
|
||||
# the news log files are used by all syslog daemons
|
||||
/var/log/warn /var/log/messages /var/log/allmessages /var/log/localmessages
|
||||
/var/log/firewall /var/log/acpid /var/log/NetworkManager
|
||||
/var/log/mail /var/log/mail.info /var/log/mail.warn /var/log/mail.err
|
||||
/var/log/news/news.crit /var/log/news/news.err /var/log/news/news.notice
|
||||
{
|
||||
compress
|
||||
dateext
|
||||
maxage 365
|
||||
rotate 99
|
||||
missingok
|
||||
notifempty
|
||||
size +4096k
|
||||
sharedscripts
|
||||
postrotate
|
||||
/usr/bin/systemctl reload syslog.service > /dev/null
|
||||
endscript
|
||||
}
|
15
sysconfig.boot
Normal file
15
sysconfig.boot
Normal file
@ -0,0 +1,15 @@
|
||||
## Path: System/Logging
|
||||
## Description: System logging
|
||||
## Type: list(1,2,3,4,5,6,7,8,9,10,11,12)
|
||||
## Default: 10
|
||||
#
|
||||
# Console for logging
|
||||
#
|
||||
KLOG_CONSOLE="10"
|
||||
|
||||
## Type: list(,0,emerg,1,alert,2,crit,3,err,4,warning,5,notice,6,info,7,debug)
|
||||
## Default:
|
||||
#
|
||||
# Loglevel for log console (numbers are equal to corresponding strings)
|
||||
#
|
||||
CONSOLE_LOGLEVEL=""
|
22
sysconfig.klogd
Normal file
22
sysconfig.klogd
Normal file
@ -0,0 +1,22 @@
|
||||
## Path: System/Logging
|
||||
## Description: System logging
|
||||
|
||||
## Type: list(0,1,2,3,4,5,6,7)
|
||||
## Default: 1
|
||||
## Config: ""
|
||||
## ServiceRestart: syslog
|
||||
#
|
||||
# Default loglevel for klogd
|
||||
#
|
||||
KERNEL_LOGLEVEL=1
|
||||
|
||||
## Type: string
|
||||
## Default: -x
|
||||
## Config: ""
|
||||
## ServiceRestart: syslog
|
||||
#
|
||||
# if not empty: parameters for klogd
|
||||
# for example KLOGD_PARAMS="-x" to avoid (duplicate) symbol resolution
|
||||
#
|
||||
KLOGD_PARAMS="-x"
|
||||
|
12
sysconfig.syslogd
Normal file
12
sysconfig.syslogd
Normal file
@ -0,0 +1,12 @@
|
||||
## Path: System/Logging
|
||||
## Description: System logging
|
||||
|
||||
## Type: string
|
||||
## Default: ""
|
||||
## Config: ""
|
||||
## ServiceRestart: syslog
|
||||
#
|
||||
# if not empty: parameters for syslogd
|
||||
# for example SYSLOGD_PARAMS="-r -s my.dom.ain"
|
||||
#
|
||||
SYSLOGD_PARAMS=""
|
37
sysklogd-1.4.1-CVE-2014-3634.patch
Normal file
37
sysklogd-1.4.1-CVE-2014-3634.patch
Normal file
@ -0,0 +1,37 @@
|
||||
---
|
||||
syslog.c | 6 ++++++
|
||||
syslogd.c | 7 +++++++
|
||||
2 files changed, 13 insertions(+)
|
||||
|
||||
--- syslog.c
|
||||
+++ syslog.c 2014-09-24 16:09:26.062235727 +0000
|
||||
@@ -75,6 +75,13 @@ static char sccsid[] = "@(#)syslog.c 5.2
|
||||
|
||||
#define _PATH_LOGNAME "/dev/log"
|
||||
|
||||
+#undef LOG_FAC
|
||||
+static inline int LOG_FAC(const int pri)
|
||||
+{
|
||||
+ unsigned int fac = pri >> 3;
|
||||
+ return (fac > 23) ? 23 : fac;
|
||||
+}
|
||||
+
|
||||
#include "fortify.h"
|
||||
|
||||
static int LogFile = -1; /* fd for log */
|
||||
--- syslogd.c
|
||||
+++ syslogd.c 2014-09-22 08:18:13.122235747 +0000
|
||||
@@ -614,6 +614,13 @@ static char sccsid[] __attribute__ ((un
|
||||
#define SYSTEMD_PATH_LOG "/run/systemd/journal/syslog"
|
||||
#endif
|
||||
|
||||
+#undef LOG_FAC
|
||||
+static inline int LOG_FAC(const int pri)
|
||||
+{
|
||||
+ unsigned int fac = pri >> 3;
|
||||
+ return (fac > 23) ? 23 : fac;
|
||||
+}
|
||||
+
|
||||
char *ConfFile = _PATH_LOGCONF;
|
||||
char *PidFile = _PATH_LOGPID;
|
||||
char ctty[] = _PATH_CONSOLE;
|
367
sysklogd-1.4.1-clearing.patch
Normal file
367
sysklogd-1.4.1-clearing.patch
Normal file
@ -0,0 +1,367 @@
|
||||
!
|
||||
! Be able to write errors on creating of pid file on
|
||||
! the current terminal (bug #394787)
|
||||
!
|
||||
---
|
||||
klogd.c | 78 +++++++++++++++++++++++++++++++++++---------------------------
|
||||
pidfile.c | 39 +++++++++++++++++++++++++++----
|
||||
syslogd.c | 60 +++++++++++++++++++++++++++++------------------
|
||||
3 files changed, 117 insertions(+), 60 deletions(-)
|
||||
|
||||
--- klogd.c
|
||||
+++ klogd.c 2022-10-17 11:12:11.438652739 +0000
|
||||
@@ -268,6 +268,8 @@
|
||||
#include <stdarg.h>
|
||||
#include <paths.h>
|
||||
#include <stdlib.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/wait.h>
|
||||
#include "klogd.h"
|
||||
#include "ksyms.h"
|
||||
#ifndef TESTING
|
||||
@@ -366,13 +368,12 @@ static void CloseLogSrc()
|
||||
/*
|
||||
* Signal handler to terminate the parent process.
|
||||
*/
|
||||
+static volatile sig_atomic_t leave;
|
||||
#ifndef TESTING
|
||||
void doexit(sig)
|
||||
-
|
||||
int sig;
|
||||
-
|
||||
{
|
||||
- exit (0);
|
||||
+ leave++;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1110,14 +1111,41 @@ int main(argc, argv)
|
||||
{
|
||||
if (!check_pid(PidFile))
|
||||
{
|
||||
- signal (SIGTERM, doexit);
|
||||
- if ( fork() == 0 )
|
||||
- {
|
||||
- auto int fl;
|
||||
- int num_fds = getdtablesize();
|
||||
+ pid_t pid;
|
||||
+ int n=0, num_fds, fl, status;
|
||||
|
||||
+ leave = 0;
|
||||
+ signal (SIGTERM, doexit);
|
||||
+ switch ((pid = fork())) {
|
||||
+ default:
|
||||
+ retry:
|
||||
+ /*
|
||||
+ * Parent process
|
||||
+ */
|
||||
+ switch (waitpid(pid, &status, WNOHANG|WUNTRACED)) {
|
||||
+ case -1:
|
||||
+ if (errno == EINTR)
|
||||
+ goto retry;
|
||||
+ break;
|
||||
+ case 0:
|
||||
+ if (leave)
|
||||
+ exit(0);
|
||||
+ usleep(10*1000);
|
||||
+ if (++n < 30000)
|
||||
+ goto retry;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+ case -1:
|
||||
+ /*
|
||||
+ * Not reached unless something major went wrong.
|
||||
+ */
|
||||
+ exit(1);
|
||||
+ case 0:
|
||||
signal (SIGTERM, SIG_DFL);
|
||||
-
|
||||
+
|
||||
+ num_fds = getdtablesize();
|
||||
+
|
||||
/* This is the child closing its file descriptors. */
|
||||
for (fl= 0; fl <= num_fds; ++fl)
|
||||
{
|
||||
@@ -1128,17 +1156,12 @@ int main(argc, argv)
|
||||
}
|
||||
|
||||
setsid();
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- /*
|
||||
- * Parent process
|
||||
- */
|
||||
- sleep(300);
|
||||
- /*
|
||||
- * Not reached unless something major went wrong.
|
||||
- */
|
||||
- exit(1);
|
||||
+
|
||||
+ /* tuck my process id away */
|
||||
+ if (!write_pid(PidFile))
|
||||
+ Terminate();
|
||||
+
|
||||
+ break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1147,19 +1170,6 @@ int main(argc, argv)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
-
|
||||
-
|
||||
- /* tuck my process id away */
|
||||
- if (!check_pid(PidFile))
|
||||
- {
|
||||
- if (!write_pid(PidFile))
|
||||
- Terminate();
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- fputs("klogd: Already running.\n", stderr);
|
||||
- Terminate();
|
||||
- }
|
||||
#endif
|
||||
|
||||
/* Signal setups. */
|
||||
@@ -1225,6 +1235,8 @@ int main(argc, argv)
|
||||
{
|
||||
if ( change_state )
|
||||
ChangeLogging();
|
||||
+ if (leave)
|
||||
+ exit(0);
|
||||
switch ( logsrc )
|
||||
{
|
||||
case kernel:
|
||||
--- pidfile.c
|
||||
+++ pidfile.c 2022-10-17 11:11:16.627630427 +0000
|
||||
@@ -23,6 +23,7 @@
|
||||
* Sat Aug 19 13:24:33 MET DST 1995: Martin Schulze
|
||||
* First version (v0.2) released
|
||||
*/
|
||||
+#define USE_FCNTL 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
@@ -31,6 +32,10 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
+#if defined(USE_FCNTL) && (USE_FCNTL != 0)
|
||||
+# include <unistd.h>
|
||||
+# include <fcntl.h>
|
||||
+#endif
|
||||
|
||||
/* read_pid
|
||||
*
|
||||
@@ -86,6 +91,9 @@ int write_pid (char *pidfile)
|
||||
FILE *f;
|
||||
int fd;
|
||||
int pid;
|
||||
+#if defined(USE_FCNTL) && (USE_FCNTL != 0)
|
||||
+ struct flock lck;
|
||||
+#endif
|
||||
|
||||
if ( ((fd = open(pidfile, O_RDWR|O_CREAT|O_TRUNC, 0644)) == -1)
|
||||
|| ((f = fdopen(fd, "r+")) == NULL) ) {
|
||||
@@ -93,23 +101,46 @@ int write_pid (char *pidfile)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+#if defined(USE_FCNTL) && (USE_FCNTL != 0)
|
||||
+ memset(&lck, 0, sizeof (struct flock));
|
||||
+ lck.l_type = F_WRLCK;
|
||||
+ lck.l_whence = SEEK_SET;
|
||||
+
|
||||
+ if (fcntl(fd, F_SETLK, &lck) == -1) {
|
||||
+ fclose(f);
|
||||
+ memset(&lck, 0, sizeof (struct flock));
|
||||
+ fcntl(fd, F_GETLK, &lck);
|
||||
+ fprintf(stderr, "Can't lock, lock is held by pid %d.\n", lck.l_pid);
|
||||
+ return 0;
|
||||
+ }
|
||||
+#else
|
||||
if (flock(fd, LOCK_EX|LOCK_NB) == -1) {
|
||||
fscanf(f, "%d", &pid);
|
||||
fclose(f);
|
||||
- printf("Can't lock, lock is held by pid %d.\n", pid);
|
||||
+ fprintf(stderr, "Can't lock, lock is held by pid %d.\n", pid);
|
||||
return 0;
|
||||
}
|
||||
+#endif
|
||||
|
||||
pid = getpid();
|
||||
if (!fprintf(f,"%d\n", pid)) {
|
||||
- printf("Can't write pid , %s.\n", strerror(errno));
|
||||
+ fprintf(stderr, "Can't write pid , %s.\n", strerror(errno));
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
fflush(f);
|
||||
|
||||
- if (flock(fd, LOCK_UN) == -1) {
|
||||
- printf("Can't unlock pidfile %s, %s.\n", pidfile, strerror(errno));
|
||||
+#if defined(USE_FCNTL) && (USE_FCNTL != 0)
|
||||
+ memset(&lck, 0, sizeof (struct flock));
|
||||
+ lck.l_type = F_UNLCK;
|
||||
+ lck.l_whence = SEEK_SET;
|
||||
+
|
||||
+ if (fcntl(fd, F_SETLK, &lck) == -1)
|
||||
+#else
|
||||
+ if (flock(fd, LOCK_UN) == -1)
|
||||
+#endif
|
||||
+ {
|
||||
+ fprintf(stderr,"Can't unlock pidfile %s, %s.\n", pidfile, strerror(errno));
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
--- syslogd.c
|
||||
+++ syslogd.c 2022-10-17 11:11:16.627630427 +0000
|
||||
@@ -22,7 +22,7 @@ char copyright2[] =
|
||||
#endif /* not lint */
|
||||
|
||||
#if !defined(lint) && !defined(NO_SCCS)
|
||||
-static char sccsid[] = "@(#)syslogd.c 5.27 (Berkeley) 10/10/88";
|
||||
+static char sccsid[] __attribute__ ((unused)) = "@(#)syslogd.c 5.27 (Berkeley) 10/10/88";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -900,7 +900,9 @@ int main(argc, argv)
|
||||
fd_set readfds;
|
||||
|
||||
#ifndef TESTING
|
||||
+#ifdef SYSLOG_UNIXAF
|
||||
int fd;
|
||||
+#endif
|
||||
#ifdef SYSLOG_INET
|
||||
#ifdef INET6
|
||||
struct sockaddr_storage frominet;
|
||||
@@ -915,7 +917,9 @@ int main(argc, argv)
|
||||
int ch;
|
||||
struct hostent *hent;
|
||||
|
||||
+#if defined(SYSLOG_UNIXAF) || defined(TESTING)
|
||||
char line[MAXLINE +1];
|
||||
+#endif
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
int maxfds;
|
||||
@@ -1033,11 +1037,20 @@ int main(argc, argv)
|
||||
exit(1);
|
||||
case 0:
|
||||
signal (SIGTERM, SIG_DFL);
|
||||
-
|
||||
+
|
||||
+ /* tuck my process id away */
|
||||
+ dprintf("Writing pidfile.\n");
|
||||
+ if (!write_pid(PidFile))
|
||||
+ {
|
||||
+ dprintf("Can't write pid.\n");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
num_fds = getdtablesize();
|
||||
for (i = 0; i < num_fds; i++)
|
||||
(void) close(i);
|
||||
untty();
|
||||
+ break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1047,36 +1060,37 @@ int main(argc, argv)
|
||||
}
|
||||
}
|
||||
else
|
||||
+ {
|
||||
#endif
|
||||
debugging_on = 1;
|
||||
#ifndef SYSV
|
||||
- else
|
||||
setlinebuf(stdout);
|
||||
#endif
|
||||
|
||||
#ifndef TESTING
|
||||
- /* tuck my process id away */
|
||||
- if ( !Debug )
|
||||
- {
|
||||
- dprintf("Writing pidfile.\n");
|
||||
- if (!check_pid(PidFile))
|
||||
+ /* tuck my process id away */
|
||||
+ if ( !Debug )
|
||||
{
|
||||
- if (!write_pid(PidFile))
|
||||
+ dprintf("Writing pidfile.\n");
|
||||
+ if (!check_pid(PidFile))
|
||||
+ {
|
||||
+ if (!write_pid(PidFile))
|
||||
+ {
|
||||
+ dprintf("Can't write pid.\n");
|
||||
+ if (getpid() != ppid)
|
||||
+ kill (ppid, SIGTERM);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
{
|
||||
- dprintf("Can't write pid.\n");
|
||||
+ dprintf("Pidfile (and pid) already exist.\n");
|
||||
if (getpid() != ppid)
|
||||
kill (ppid, SIGTERM);
|
||||
exit(1);
|
||||
}
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- dprintf("Pidfile (and pid) already exist.\n");
|
||||
- if (getpid() != ppid)
|
||||
- kill (ppid, SIGTERM);
|
||||
- exit(1);
|
||||
- }
|
||||
- } /* if ( !Debug ) */
|
||||
+ } /* if ( !Debug ) */
|
||||
+ }
|
||||
#endif
|
||||
|
||||
consfile.f_type = F_CONSOLE;
|
||||
@@ -1738,7 +1752,7 @@ void logmsg(pri, msg, from, flags)
|
||||
int flags;
|
||||
{
|
||||
register struct filed *f;
|
||||
- int fac, prilev, lognum;
|
||||
+ int fac, prilev;
|
||||
int msglen;
|
||||
char *timestamp;
|
||||
#ifdef __gnu_linux__
|
||||
@@ -1746,6 +1760,8 @@ void logmsg(pri, msg, from, flags)
|
||||
#else
|
||||
#ifndef SYSV
|
||||
sigset_t omask;
|
||||
+#else
|
||||
+ int lognum;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -2512,11 +2528,9 @@ void init()
|
||||
register int i, lognum;
|
||||
register FILE *cf;
|
||||
register struct filed *f;
|
||||
-#ifndef TESTING
|
||||
#ifndef SYSV
|
||||
register struct filed **nextp = (struct filed **) 0;
|
||||
#endif
|
||||
-#endif
|
||||
register char *p;
|
||||
register unsigned int Forwarding = 0;
|
||||
#ifdef CONT_LINE
|
||||
@@ -2601,7 +2615,7 @@ void init()
|
||||
#else
|
||||
*nextp = (struct filed *)calloc(1, sizeof(*f));
|
||||
cfline("*.ERR\t" _PATH_CONSOLE, *nextp);
|
||||
- (*nextp)->f_next = (struct filed *)calloc(1, sizeof(*f)) /* ASP */
|
||||
+ (*nextp)->f_next = (struct filed *)calloc(1, sizeof(*f)); /* ASP */
|
||||
cfline("*.PANIC\t*", (*nextp)->f_next);
|
||||
#endif
|
||||
Initialized = 1;
|
14
sysklogd-1.4.1-dgram.patch
Normal file
14
sysklogd-1.4.1-dgram.patch
Normal file
@ -0,0 +1,14 @@
|
||||
--- syslog.c
|
||||
+++ syslog.c 2001-05-23 18:48:13.000000000 +0000
|
||||
@@ -224,8 +224,9 @@ openlog(ident, logstat, logfac)
|
||||
strncpy(SyslogAddr.sa_data, _PATH_LOGNAME,
|
||||
sizeof(SyslogAddr.sa_data));
|
||||
if (LogStat & LOG_NDELAY) {
|
||||
- LogFile = socket(AF_UNIX, SOCK_DGRAM, 0);
|
||||
-/* fcntl(LogFile, F_SETFD, 1); */
|
||||
+ if ((LogFile = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0)
|
||||
+ return;
|
||||
+ fcntl(LogFile, F_SETFD, 1);
|
||||
}
|
||||
}
|
||||
if (LogFile != -1 && !connected &&
|
498
sysklogd-1.4.1-dns.patch
Normal file
498
sysklogd-1.4.1-dns.patch
Normal file
@ -0,0 +1,498 @@
|
||||
---
|
||||
Makefile | 4
|
||||
resolve.c | 249 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
syslogd.c | 139 +++++-----------------------------
|
||||
3 files changed, 275 insertions(+), 117 deletions(-)
|
||||
|
||||
--- Makefile
|
||||
+++ Makefile 2022-10-18 06:11:16.691008894 +0000
|
||||
@@ -79,8 +79,8 @@ test: syslog_tst ksym oops.ko tsyslogd
|
||||
|
||||
install: install_man install_exec
|
||||
|
||||
-syslogd: syslogd.o pidfile.o
|
||||
- ${CC} ${LDFLAGS} -o syslogd syslogd.o pidfile.o ${LIBS}
|
||||
+syslogd: syslogd.o pidfile.o resolve.o
|
||||
+ ${CC} ${LDFLAGS} -o syslogd syslogd.o pidfile.o resolve.o ${LIBS}
|
||||
|
||||
klogd: klogd.o syslog.o pidfile.o ksym.o ksym_mod.o
|
||||
${CC} ${LDFLAGS} -o klogd klogd.o syslog.o pidfile.o ksym.o \
|
||||
--- resolve.c
|
||||
+++ resolve.c 2022-10-18 06:11:16.691008894 +0000
|
||||
@@ -0,0 +1,249 @@
|
||||
+/*
|
||||
+ * Resolve a hostname
|
||||
+ *
|
||||
+ * Copyright (C) 2003, SuSE Linux AG
|
||||
+ * Written by okir@suse.de
|
||||
+ */
|
||||
+
|
||||
+#include <sys/poll.h>
|
||||
+#include <netdb.h>
|
||||
+#include <string.h>
|
||||
+#include <time.h>
|
||||
+#include <malloc.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <signal.h>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+#if defined(__GLIBC__)
|
||||
+#define dprintf mydprintf
|
||||
+#endif /* __GLIBC__ */
|
||||
+
|
||||
+/* Number of times we retry resolving a name */
|
||||
+#define RESOLVER_RETRIES 10
|
||||
+/* Timeout between retries to resolve a name */
|
||||
+#define RESOLVER_RETRY_TIME (3 * 60)
|
||||
+/* Time to wait for the sub-process comes up with an
|
||||
+ * answer, before we suspend the entry */
|
||||
+#define RESOLVER_WAIT_TIME 5
|
||||
+
|
||||
+struct res_name {
|
||||
+ struct res_name * next;
|
||||
+ char * name;
|
||||
+ unsigned int retries;
|
||||
+ time_t retry_time;
|
||||
+ time_t wait_time;
|
||||
+ pid_t process;
|
||||
+ int pipe;
|
||||
+ struct sockaddr_storage address;
|
||||
+};
|
||||
+
|
||||
+extern void dprintf(char *fmt, ...);
|
||||
+static int do_result(struct res_name *res);
|
||||
+static void do_query(int, int, const char *);
|
||||
+
|
||||
+static struct res_name *resolve;
|
||||
+
|
||||
+int
|
||||
+resolve_name(const char *name, int family, struct sockaddr_storage *addr)
|
||||
+{
|
||||
+ struct res_name *res;
|
||||
+ int fd[2];
|
||||
+ pid_t pid;
|
||||
+ time_t now;
|
||||
+
|
||||
+ time(&now);
|
||||
+ for (res = resolve; res; res = res->next) {
|
||||
+ if (!strcmp(res->name, name)) {
|
||||
+ /* If there's still a sub-process
|
||||
+ * attached, see if it came up with an
|
||||
+ * answer in the meantime */
|
||||
+ if (res->pipe >= 0)
|
||||
+ do_result(res);
|
||||
+ goto check_result;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ res = (struct res_name *) calloc(1, sizeof(*res));
|
||||
+ res->name = strdup(name);
|
||||
+ res->retries = RESOLVER_RETRIES;
|
||||
+ res->retry_time = now + RESOLVER_RETRY_TIME;
|
||||
+ res->pipe = -1;
|
||||
+ res->next = resolve;
|
||||
+ resolve = res;
|
||||
+
|
||||
+retry: res->retries -= 1;
|
||||
+
|
||||
+ dprintf("Trying to resolve \"%s\", attempt #%u\n",
|
||||
+ res->name, RESOLVER_RETRIES - res->retries);
|
||||
+
|
||||
+ if (res->pipe >= 0) {
|
||||
+ /* Make sure resolver subprocess is dead */
|
||||
+ kill(res->process, SIGKILL);
|
||||
+ close(res->pipe);
|
||||
+ res->pipe = -1;
|
||||
+ }
|
||||
+
|
||||
+ signal(SIGCHLD, SIG_IGN);
|
||||
+ if (pipe(fd) < 0) {
|
||||
+ /* log error? */
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if ((pid = fork()) < 0) {
|
||||
+ /* log error? */
|
||||
+ close(fd[0]);
|
||||
+ close(fd[1]);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (pid == 0) {
|
||||
+ close(fd[0]);
|
||||
+ do_query(fd[1], family, res->name);
|
||||
+ /* shouldn't return */
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ res->wait_time = now + RESOLVER_WAIT_TIME;
|
||||
+ res->process = pid;
|
||||
+ res->pipe = fd[0];
|
||||
+ close(fd[1]);
|
||||
+
|
||||
+ /* Try to collect result within the next couple
|
||||
+ * of seconds */
|
||||
+ do_result(res);
|
||||
+
|
||||
+check_result:
|
||||
+ if (res->pipe >= 0) {
|
||||
+ dprintf("%s: name resolution not complete, "
|
||||
+ "waiting for resolver sub-process\n",
|
||||
+ res->name);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (res->address.ss_family != AF_UNSPEC) {
|
||||
+ *addr = res->address;
|
||||
+ return 1;
|
||||
+ }
|
||||
+ if (res->retries == 0) {
|
||||
+ dprintf("%s: too many failed attempts to resolve hostname, "
|
||||
+ "given up.\n", res->name);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if (res->retry_time > now) {
|
||||
+ dprintf("%s: name resolution failed, "
|
||||
+ "will retry in %d seconds\n",
|
||||
+ res->name, res->retry_time - now);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ goto retry;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * This function clears the resolver's internal state
|
||||
+ * when syslogd received a SIGHUP
|
||||
+ */
|
||||
+void
|
||||
+init_resolver(void)
|
||||
+{
|
||||
+ struct res_name *res;
|
||||
+
|
||||
+ for (res = resolve; res; res = res->next) {
|
||||
+ res->address.ss_family = AF_UNSPEC;
|
||||
+ res->retries = RESOLVER_RETRIES;
|
||||
+ res->retry_time = 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * Collect result from sub-process
|
||||
+ */
|
||||
+int
|
||||
+do_result(struct res_name *res)
|
||||
+{
|
||||
+ struct sockaddr_storage addr;
|
||||
+ struct pollfd _poll;
|
||||
+ long wait;
|
||||
+ int n;
|
||||
+
|
||||
+ if (res->pipe < 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ /* See if we should wait for the subprocess to come
|
||||
+ * up with an answer (the initial call to do_result
|
||||
+ * after starting the sub-process will always wait for
|
||||
+ * a few seconds to avoid losing messages) */
|
||||
+ if ((wait = res->wait_time - time(NULL)) < 0)
|
||||
+ wait = 0;
|
||||
+
|
||||
+ /* See if we get the resolver's result within the
|
||||
+ * next "wait" seconds. If not, let it continue in the
|
||||
+ * background */
|
||||
+ _poll.fd = res->pipe;
|
||||
+ _poll.events = POLLIN;
|
||||
+ if (poll(&_poll, 1, wait * 1000) < 1)
|
||||
+ return 0;
|
||||
+
|
||||
+ n = read(res->pipe, &addr, sizeof(addr));
|
||||
+
|
||||
+ /* child process has done its duty. */
|
||||
+ kill(res->process, SIGKILL);
|
||||
+ close(res->pipe);
|
||||
+ res->process = 0;
|
||||
+ res->pipe = -1;
|
||||
+
|
||||
+ if (n != sizeof(addr))
|
||||
+ return -1;
|
||||
+
|
||||
+ res->address = addr;
|
||||
+ if (addr.ss_family != AF_UNSPEC)
|
||||
+ return 1;
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Sub-process performing lookup
|
||||
+ */
|
||||
+void
|
||||
+do_query(int fd, int family, const char *name)
|
||||
+{
|
||||
+ struct sockaddr_storage ss;
|
||||
+ struct addrinfo hints, *res;
|
||||
+ int r;
|
||||
+
|
||||
+ memset(&hints, 0, sizeof(hints));
|
||||
+ hints.ai_socktype = SOCK_DGRAM;
|
||||
+#ifdef notyet
|
||||
+ /* XXX - specify AI_whatever for automatic v4-v6 mapping */
|
||||
+#else
|
||||
+ hints.ai_family = (family == AF_INET)? family : AF_UNSPEC;
|
||||
+#endif
|
||||
+
|
||||
+ r = getaddrinfo(name, "syslog", &hints, &res);
|
||||
+ if (r != 0) {
|
||||
+ dprintf("failed to resolve \"%s\": %s\n",
|
||||
+ name, gai_strerror(r));
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ memset(&ss, 0, sizeof(ss));
|
||||
+
|
||||
+ /* Do v4mapped v6 address (supported by recent glibcs
|
||||
+ * only) */
|
||||
+ if (family == AF_INET6 && res->ai_family == AF_INET) {
|
||||
+ struct sockaddr_in6 *six = (struct sockaddr_in6 *) &ss;
|
||||
+ struct sockaddr_in *sin = (struct sockaddr_in *) res->ai_addr;
|
||||
+
|
||||
+ six->sin6_family = AF_INET6;
|
||||
+ six->sin6_port = sin->sin_port;
|
||||
+ six->sin6_addr.s6_addr16[5] = 0xffff;
|
||||
+ six->sin6_addr.s6_addr32[3] = sin->sin_addr.s_addr;
|
||||
+ } else if (res->ai_addrlen > sizeof(ss)) {
|
||||
+ dprintf("failed to resolve \"%s\": address too large\n",
|
||||
+ name);
|
||||
+ exit(1);
|
||||
+ } else {
|
||||
+ memcpy(&ss, res->ai_addr, res->ai_addrlen);
|
||||
+ }
|
||||
+ write(fd, &ss, sizeof(ss));
|
||||
+ exit(0);
|
||||
+}
|
||||
--- syslogd.c
|
||||
+++ syslogd.c 2022-10-18 06:17:39.648170295 +0000
|
||||
@@ -683,14 +683,7 @@ struct filed {
|
||||
struct {
|
||||
char f_hname[MAXHOSTNAMELEN+1];
|
||||
#ifdef INET6
|
||||
- union {
|
||||
- struct sockaddr sa;
|
||||
- struct sockaddr_in sin;
|
||||
- struct sockaddr_in6 sin6;
|
||||
- } f_sa;
|
||||
-#define f_addr f_sa.sa
|
||||
-#define f_addr4 f_sa.sin
|
||||
-#define f_addr6 f_sa.sin6
|
||||
+ struct sockaddr_storage f_addr;
|
||||
#else
|
||||
struct sockaddr_in f_addr;
|
||||
#endif
|
||||
@@ -846,19 +839,17 @@ int decode(char *name, struct code *code
|
||||
#if defined(__GLIBC__)
|
||||
#define dprintf mydprintf
|
||||
#endif /* __GLIBC__ */
|
||||
-static void dprintf(char *, ...);
|
||||
+void dprintf(char *, ...);
|
||||
static void allocate_log(void);
|
||||
-void sighup_handler();
|
||||
+void sighup_handler(int sig);
|
||||
|
||||
#ifdef SYSLOG_UNIXAF
|
||||
static int create_unix_socket(const char *path);
|
||||
#endif
|
||||
#ifdef SYSLOG_INET
|
||||
static int create_inet_socket();
|
||||
-#ifdef INET6
|
||||
-static void setup_inetaddr_all();
|
||||
-static const char *setup_inetaddr(struct filed *f);
|
||||
-#endif
|
||||
+extern int resolve_name(const char *, int, struct sockaddr_storage *);
|
||||
+extern void init_resolver(void);
|
||||
#endif
|
||||
|
||||
int main(argc, argv)
|
||||
@@ -1413,63 +1404,6 @@ static int create_inet_socket()
|
||||
return fd;
|
||||
}
|
||||
|
||||
-#ifdef INET6
|
||||
-
|
||||
-static void setup_inetaddr_all()
|
||||
-{
|
||||
- struct filed *f;
|
||||
-#ifdef SYSV
|
||||
- int lognum;
|
||||
-
|
||||
- for (lognum = 0; lognum <= nlogs; lognum++) {
|
||||
- f = &Files[lognum];
|
||||
-#else
|
||||
- for (f = Files; f; f = f->f_next) {
|
||||
-#endif
|
||||
- if (f->f_type == F_FORW_UNKN) {
|
||||
- if (setup_inetaddr(f)) {
|
||||
- f->f_prevcount = INET_RETRY_MAX;
|
||||
- f->f_time = time( (time_t *)0 );
|
||||
- } else {
|
||||
- f->f_type = F_FORW;
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-static const char *setup_inetaddr(struct filed *f)
|
||||
-{
|
||||
- struct addrinfo hints, *res;
|
||||
- int error;
|
||||
-
|
||||
- memset(&hints, 0, sizeof(hints));
|
||||
- hints.ai_family = family == AF_INET6 ? AF_UNSPEC : AF_INET;
|
||||
- hints.ai_socktype = SOCK_DGRAM;
|
||||
- error = getaddrinfo(f->f_un.f_forw.f_hname, "syslog", &hints, &res);
|
||||
- if (error) {
|
||||
- return gai_strerror(error);
|
||||
- }
|
||||
- if (res->ai_addrlen > sizeof(f->f_un.f_forw.f_sa)) {
|
||||
- freeaddrinfo(res);
|
||||
- return "addrlen too large";
|
||||
- }
|
||||
- if (family == AF_INET6 && res->ai_family == AF_INET) {
|
||||
- /* v4mapped addr */
|
||||
- f->f_un.f_forw.f_addr.sa_family = AF_INET6;
|
||||
- f->f_un.f_forw.f_addr6.sin6_port =
|
||||
- ((struct sockaddr_in *)res->ai_addr)->sin_port;
|
||||
- f->f_un.f_forw.f_addr6.sin6_addr.s6_addr16[5] = 0xffff;
|
||||
- memcpy(&f->f_un.f_forw.f_addr6.sin6_addr.s6_addr32[3],
|
||||
- &((struct sockaddr_in *)res->ai_addr)->sin_addr,
|
||||
- sizeof(struct in_addr));
|
||||
- } else {
|
||||
- memcpy(&f->f_un.f_forw.f_addr, res->ai_addr, res->ai_addrlen);
|
||||
- }
|
||||
- freeaddrinfo(res);
|
||||
-
|
||||
- return NULL;
|
||||
-}
|
||||
-#endif /* end of INET6 */
|
||||
#endif
|
||||
|
||||
char **
|
||||
@@ -1913,7 +1847,7 @@ void fprintlog(f, from, flags, msg)
|
||||
char line[MAXLINE + 1];
|
||||
time_t fwd_suspend;
|
||||
#ifdef INET6
|
||||
- const char *errmsg;
|
||||
+ int reserr;
|
||||
#else
|
||||
struct hostent *hp;
|
||||
#endif
|
||||
@@ -1982,38 +1916,21 @@ void fprintlog(f, from, flags, msg)
|
||||
*/
|
||||
case F_FORW_UNKN:
|
||||
dprintf(" %s\n", f->f_un.f_forw.f_hname);
|
||||
- fwd_suspend = time((time_t *) 0) - f->f_time;
|
||||
- if ( fwd_suspend >= INET_SUSPEND_TIME ) {
|
||||
- dprintf("Forwarding suspension to unknown over, retrying\n");
|
||||
-#ifdef INET6
|
||||
- if ((errmsg = setup_inetaddr(f))) {
|
||||
- dprintf("Failure: %s\n", errmsg);
|
||||
-#else
|
||||
- if ( (hp = gethostbyname(f->f_un.f_forw.f_hname)) == NULL ) {
|
||||
- dprintf("Failure: %s\n", sys_h_errlist[h_errno]);
|
||||
-#endif
|
||||
- dprintf("Retries: %d\n", f->f_prevcount);
|
||||
- if ( --f->f_prevcount < 0 ) {
|
||||
- dprintf("Giving up.\n");
|
||||
- f->f_type = F_UNUSED;
|
||||
- }
|
||||
- else
|
||||
- dprintf("Left retries: %d\n", f->f_prevcount);
|
||||
- }
|
||||
- else {
|
||||
- dprintf("%s found, resuming.\n", f->f_un.f_forw.f_hname);
|
||||
-#ifndef INET6 /* not */
|
||||
- memcpy((char *) &f->f_un.f_forw.f_addr.sin_addr, hp->h_addr, hp->h_length);
|
||||
-#endif
|
||||
- f->f_prevcount = 0;
|
||||
- f->f_type = F_FORW;
|
||||
- goto f_forw;
|
||||
- }
|
||||
+ reserr = resolve_name(f->f_un.f_forw.f_hname,
|
||||
+ family,
|
||||
+ &f->f_un.f_forw.f_addr);
|
||||
+ if (reserr > 0) {
|
||||
+ dprintf("Successfully resolved hostname \"%s\"\n", f->f_un.f_forw.f_hname);
|
||||
+ f->f_type = F_FORW;
|
||||
+ } else if (reserr < 0) {
|
||||
+ dprintf("Giving up on hostname \"%s\"\n", f->f_un.f_forw.f_hname);
|
||||
+ f->f_type = F_UNUSED;
|
||||
+ break;
|
||||
+ } else {
|
||||
+ /* Not yet - query in progress, or suspended */
|
||||
+ break;
|
||||
}
|
||||
- else
|
||||
- dprintf("Forwarding suspension not over, time " \
|
||||
- "left: %d\n", INET_SUSPEND_TIME - fwd_suspend);
|
||||
- break;
|
||||
+ /* fallthrough */
|
||||
|
||||
case F_FORW:
|
||||
/*
|
||||
@@ -2429,9 +2346,7 @@ void logerror(type)
|
||||
}
|
||||
|
||||
void die(sig)
|
||||
-
|
||||
int sig;
|
||||
-
|
||||
{
|
||||
register struct filed *f;
|
||||
char buf[100];
|
||||
@@ -2655,6 +2570,7 @@ void init()
|
||||
#endif
|
||||
|
||||
#ifdef SYSLOG_INET
|
||||
+ init_resolver();
|
||||
if (Forwarding || AcceptRemote) {
|
||||
if (finet < 0) {
|
||||
finet = create_inet_socket();
|
||||
@@ -2671,10 +2587,6 @@ void init()
|
||||
InetInuse = 0;
|
||||
}
|
||||
inetm = finet;
|
||||
-#ifdef INET6
|
||||
- if (finet >= 0)
|
||||
- setup_inetaddr_all();
|
||||
-#endif
|
||||
#endif
|
||||
|
||||
Initialized = 1;
|
||||
@@ -3040,8 +2952,7 @@ int decode(name, codetab)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
-static void dprintf(char *fmt, ...)
|
||||
-
|
||||
+void dprintf(char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@@ -3061,8 +2972,7 @@ static void dprintf(char *fmt, ...)
|
||||
* The following function is responsible for allocating/reallocating the
|
||||
* array which holds the structures which define the logging outputs.
|
||||
*/
|
||||
-static void allocate_log()
|
||||
-
|
||||
+static void allocate_log(void)
|
||||
{
|
||||
dprintf("Called allocate_log, nlogs = %d.\n", nlogs);
|
||||
|
||||
@@ -3109,8 +3019,7 @@ static void allocate_log()
|
||||
* doing this during a signal handler. Instead this function simply sets
|
||||
* a flag variable which will tell the main loop to go through a restart.
|
||||
*/
|
||||
-void sighup_handler()
|
||||
-
|
||||
+void sighup_handler(int sig)
|
||||
{
|
||||
restart = 1;
|
||||
signal(SIGHUP, sighup_handler);
|
16
sysklogd-1.4.1-dontsleep.patch
Normal file
16
sysklogd-1.4.1-dontsleep.patch
Normal file
@ -0,0 +1,16 @@
|
||||
--- klogd.c
|
||||
+++ klogd.c 2007-06-18 11:22:06.978362000 +0000
|
||||
@@ -436,9 +436,11 @@ static void Terminate()
|
||||
{
|
||||
CloseLogSrc();
|
||||
Syslog(LOG_INFO, "Kernel log daemon terminating.");
|
||||
- sleep(1);
|
||||
- if ( output_file != (FILE *) 0 )
|
||||
+ if ( output_file != (FILE *) 0 ) {
|
||||
+ fflush(output_file);
|
||||
+ fsync(fileno(output_file));
|
||||
fclose(output_file);
|
||||
+ }
|
||||
closelog();
|
||||
#ifndef TESTING
|
||||
(void) remove_pid(PidFile);
|
90
sysklogd-1.4.1-forw.patch
Normal file
90
sysklogd-1.4.1-forw.patch
Normal file
@ -0,0 +1,90 @@
|
||||
---
|
||||
sysklogd.8 | 6 ++++++
|
||||
syslogd.c | 26 +++++++++++++++++++++++++-
|
||||
2 files changed, 31 insertions(+), 1 deletion(-)
|
||||
|
||||
--- sysklogd.8
|
||||
+++ sysklogd.8 2022-10-13 08:04:12.411821359 +0000
|
||||
@@ -29,6 +29,7 @@ sysklogd \- Linux system logging utiliti
|
||||
.RB [ " \-s "
|
||||
.I domainlist
|
||||
]
|
||||
+.RB [ " \-t " ]
|
||||
.RB [ " \-v " ]
|
||||
.SH DESCRIPTION
|
||||
.B Sysklogd
|
||||
@@ -150,6 +151,11 @@ is specified and the host logging resolv
|
||||
no domain would be cut, you will have to specify two domains like:
|
||||
.BR "\-s north.de:infodrom.north.de" .
|
||||
.TP
|
||||
+.B "\-t"
|
||||
+Tag forwarded messages with the sending hosts name as seen by the forwarder.
|
||||
+Useful for relaying syslog from DMZs through the firwall to an internal
|
||||
+loghost.
|
||||
+.TP
|
||||
.B "\-v"
|
||||
Print version and exit.
|
||||
.SH SIGNALS
|
||||
--- syslogd.c
|
||||
+++ syslogd.c 2022-10-13 08:08:49.502856189 +0000
|
||||
@@ -417,6 +417,13 @@ static char sccsid[] = "@(#)syslogd.c 5.
|
||||
* file is defined in the used libc and should not be hardcoded
|
||||
* into the syslogd binary referring the system it was compiled on.
|
||||
*
|
||||
+ * Mon Oct 18 19:23:00 CEST 1999: Andreas Siegert <afx@suse.de>
|
||||
+ * Added -t flag that triggers tagging of forwarded messages with
|
||||
+ * the sending hosts name as seen by the forwarder.
|
||||
+ * Useful for relaying syslog from DMZs through the firwall to an
|
||||
+ * internal loghost.
|
||||
+ * Format is "<""hostname"
|
||||
+ *
|
||||
* Sun Sep 17 21:26:16 CEST 2000: Martin Schulze <joey@infodrom.ffis.de>
|
||||
* Don't close open sockets upon reload. Thanks to Bill
|
||||
* Nottingham.
|
||||
@@ -787,6 +794,7 @@ int MarkInterval = 20 * 60; /* interval
|
||||
int MarkSeq = 0; /* mark sequence number */
|
||||
int NoFork = 0; /* don't fork - don't run in daemon mode */
|
||||
int AcceptRemote = 0; /* receive messages that come via UDP */
|
||||
+int TagForward = 0; /* afx: tag remote messages with the hostname they came from */
|
||||
char **StripDomains = NULL; /* these domains may be stripped before writing logs */
|
||||
char **LocalHosts = NULL; /* these hosts are logged with their hostname */
|
||||
int NoHops = 1; /* Can we bounce syslog messages through an
|
||||
@@ -888,7 +896,7 @@ int main(argc, argv)
|
||||
funix[i] = -1;
|
||||
}
|
||||
|
||||
- while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:v")) != EOF)
|
||||
+ while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:tv")) != EOF)
|
||||
switch((char)ch) {
|
||||
case 'a':
|
||||
if (nfunix < MAXFUNIX)
|
||||
@@ -933,6 +941,10 @@ int main(argc, argv)
|
||||
}
|
||||
StripDomains = crunch_list(optarg);
|
||||
break;
|
||||
+/* afx add -t for hostname tagging */
|
||||
+ case 't':
|
||||
+ TagForward = 1;
|
||||
+ break;
|
||||
case 'v':
|
||||
printf("syslogd %s.%s\n", VERSION, PATCHLEVEL);
|
||||
exit (0);
|
||||
@@ -1872,6 +1884,18 @@ void fprintlog(f, from, flags, msg)
|
||||
f->f_time = now;
|
||||
(void) snprintf(line, sizeof(line), "<%d>%s", f->f_prevpri, \
|
||||
(char *) iov[4].iov_base);
|
||||
+/* afx: add <sourcehost */
|
||||
+ if ((TagForward == 1) &&
|
||||
+ strncmp(f->f_prevhost,LocalHostName,MAXHOSTNAMELEN+1)) {
|
||||
+ (void) snprintf(line, sizeof(line), "<%d><%s: %s\n",
|
||||
+ f->f_prevpri, f->f_prevhost,
|
||||
+ (char *) iov[4].iov_base);
|
||||
+ } else {
|
||||
+ (void) snprintf(line, sizeof(line), "<%d>%s\n",
|
||||
+ f->f_prevpri,
|
||||
+ (char *) iov[4].iov_base);
|
||||
+ }
|
||||
+/* end afx */
|
||||
l = strlen(line);
|
||||
if (l > MAXLINE)
|
||||
l = MAXLINE;
|
262
sysklogd-1.4.1-klogd24.dif
Normal file
262
sysklogd-1.4.1-klogd24.dif
Normal file
@ -0,0 +1,262 @@
|
||||
---
|
||||
klogd.c | 4 ++--
|
||||
ksym.c | 55 +++++++++++++++++++++++++++++++++++++++----------------
|
||||
ksym_mod.c | 11 +++++------
|
||||
ksyms.h | 11 +++++++----
|
||||
4 files changed, 53 insertions(+), 28 deletions(-)
|
||||
|
||||
--- klogd.c
|
||||
+++ klogd.c 2022-10-13 08:49:17.755515718 +0000
|
||||
@@ -874,7 +874,7 @@ static void LogLine(char *ptr, int len)
|
||||
{
|
||||
auto int sym_space;
|
||||
|
||||
- unsigned long value;
|
||||
+ uintptr_t value;
|
||||
auto struct symbol sym;
|
||||
auto char *symbol;
|
||||
|
||||
@@ -899,7 +899,7 @@ static void LogLine(char *ptr, int len)
|
||||
break;
|
||||
}
|
||||
|
||||
- delta = sprintf( sym_start, "%s+0x%x/0x%02x]",
|
||||
+ delta = sprintf( sym_start, "%s+%zl/%zu]",
|
||||
symbol, sym.offset, sym.size );
|
||||
|
||||
space = sym_space + delta;
|
||||
--- ksym.c
|
||||
+++ ksym.c 2022-10-13 09:00:17.403732468 +0000
|
||||
@@ -164,7 +164,7 @@ extern int debugging;
|
||||
|
||||
/* Function prototypes. */
|
||||
static char * FindSymbolFile(void);
|
||||
-static int AddSymbol(unsigned long, char*);
|
||||
+static int AddSymbol(uintptr_t, char*);
|
||||
static void FreeSymbols(void);
|
||||
static int CheckVersion(char *);
|
||||
static int CheckMapVersion(char *);
|
||||
@@ -198,7 +198,7 @@ extern int InitKsyms(mapfile)
|
||||
|
||||
auto int version = 0;
|
||||
|
||||
- auto unsigned long int address;
|
||||
+ auto uintptr_t address;
|
||||
|
||||
auto FILE *sym_file;
|
||||
|
||||
@@ -250,16 +250,24 @@ extern int InitKsyms(mapfile)
|
||||
*/
|
||||
while ( !feof(sym_file) )
|
||||
{
|
||||
- if ( fscanf(sym_file, "%lx %c %511s\n", &address, &type, sym)
|
||||
- != 3 )
|
||||
+#if __WORDSIZE == 64
|
||||
+ if ( fscanf(sym_file, "%lx %c %511s\n", &address, &type, sym) != 3 )
|
||||
+#else
|
||||
+ if ( fscanf(sym_file, "%x %c %511s\n", &address, &type, sym) != 3 )
|
||||
+#endif
|
||||
{
|
||||
Syslog(LOG_ERR, "Error in symbol table input (#1).");
|
||||
fclose(sym_file);
|
||||
return(0);
|
||||
}
|
||||
if ( VERBOSE_DEBUGGING && debugging )
|
||||
+#if __WORDSIZE == 64
|
||||
fprintf(stderr, "Address: %lx, Type: %c, Symbol: %s\n",
|
||||
address, type, sym);
|
||||
+#else
|
||||
+ fprintf(stderr, "Address: %x, Type: %c, Symbol: %s\n",
|
||||
+ address, type, sym);
|
||||
+#endif
|
||||
|
||||
if ( AddSymbol(address, sym) == 0 )
|
||||
{
|
||||
@@ -534,7 +542,7 @@ static int CheckMapVersion(fname)
|
||||
{
|
||||
int version;
|
||||
FILE *sym_file;
|
||||
- auto unsigned long int address;
|
||||
+ auto uintptr_t address;
|
||||
auto char type,
|
||||
sym[512];
|
||||
|
||||
@@ -549,16 +557,24 @@ static int CheckMapVersion(fname)
|
||||
version = 0;
|
||||
while ( !feof(sym_file) && (version == 0) )
|
||||
{
|
||||
- if ( fscanf(sym_file, "%lx %c %511s\n", &address, \
|
||||
- &type, sym) != 3 )
|
||||
+#if __WORDSIZE == 64
|
||||
+ if ( fscanf(sym_file, "%lx %c %511s\n", &address, &type, sym) != 3 )
|
||||
+#else
|
||||
+ if ( fscanf(sym_file, "%x %c %511s\n", &address, &type, sym) != 3 )
|
||||
+#endif
|
||||
{
|
||||
Syslog(LOG_ERR, "Error in symbol table input (#2).");
|
||||
fclose(sym_file);
|
||||
return(0);
|
||||
}
|
||||
if ( VERBOSE_DEBUGGING && debugging )
|
||||
+#if __WORDSIZE == 64
|
||||
fprintf(stderr, "Address: %lx, Type: %c, " \
|
||||
"Symbol: %s\n", address, type, sym);
|
||||
+#else
|
||||
+ fprintf(stderr, "Address: %x, Type: %c, " \
|
||||
+ "Symbol: %s\n", address, type, sym);
|
||||
+#endif
|
||||
|
||||
version = CheckVersion(sym);
|
||||
}
|
||||
@@ -596,7 +612,7 @@ static int CheckMapVersion(fname)
|
||||
* Purpose: This function is responsible for adding a symbol name
|
||||
* and its address to the symbol table.
|
||||
*
|
||||
- * Arguments: (unsigned long) address, (char *) symbol
|
||||
+ * Arguments: (uintptr_t) address, (char *) symbol
|
||||
*
|
||||
* Return: int
|
||||
*
|
||||
@@ -606,7 +622,7 @@ static int CheckMapVersion(fname)
|
||||
|
||||
static int AddSymbol(address, symbol)
|
||||
|
||||
- unsigned long address;
|
||||
+ uintptr_t address;
|
||||
|
||||
char *symbol;
|
||||
|
||||
@@ -652,7 +668,7 @@ static int AddSymbol(address, symbol)
|
||||
|
||||
char * LookupSymbol(value, sym)
|
||||
|
||||
- unsigned long value;
|
||||
+ uintptr_t value;
|
||||
|
||||
struct symbol *sym;
|
||||
|
||||
@@ -774,7 +790,7 @@ extern char * ExpandKadds(line, el)
|
||||
*symbol;
|
||||
|
||||
char num[15];
|
||||
- auto unsigned long int value;
|
||||
+ auto uintptr_t value;
|
||||
|
||||
auto struct symbol sym;
|
||||
|
||||
@@ -858,7 +874,7 @@ extern char * ExpandKadds(line, el)
|
||||
value = strtol(kp2, (char **) 0, 16);
|
||||
if ( (symbol = LookupSymbol(value, &sym)) ) {
|
||||
if (sym.size)
|
||||
- elp += sprintf(elp, " (%s+%d/%d)", symbol, sym.offset, sym.size);
|
||||
+ elp += sprintf(elp, " (%s+%zl/%zu)", symbol, sym.offset, sym.size);
|
||||
else
|
||||
elp += sprintf(elp, " (%s)", symbol);
|
||||
}
|
||||
@@ -867,7 +883,7 @@ extern char * ExpandKadds(line, el)
|
||||
value = strtol(kp3, (char **) 0, 16);
|
||||
if ( (symbol = LookupSymbol(value, &sym)) ) {
|
||||
if (sym.size)
|
||||
- elp += sprintf(elp, " (%s+%d/%d)", symbol, sym.offset, sym.size);
|
||||
+ elp += sprintf(elp, " (%s+%zl/%zu)", symbol, sym.offset, sym.size);
|
||||
else
|
||||
elp += sprintf(elp, " (%s)", symbol);
|
||||
}
|
||||
@@ -878,7 +894,7 @@ extern char * ExpandKadds(line, el)
|
||||
value = strtol(kp2, (char **) 0, 16);
|
||||
if ( (symbol = LookupSymbol(value, &sym)) ) {
|
||||
if (sym.size)
|
||||
- elp += sprintf(elp, " (%s+%d/%d)", symbol, sym.offset, sym.size);
|
||||
+ elp += sprintf(elp, " (%s+%zl/%zu)", symbol, sym.offset, sym.size);
|
||||
else
|
||||
elp += sprintf(elp, " (%s)", symbol);
|
||||
}
|
||||
@@ -914,17 +930,24 @@ extern char * ExpandKadds(line, el)
|
||||
strcat(elp, symbol);
|
||||
elp += strlen(symbol);
|
||||
if ( debugging )
|
||||
- fprintf(stderr, "Symbol: %s = %lx = %s, %x/%d\n", \
|
||||
+#if __WORDSIZE == 64
|
||||
+ fprintf(stderr, "Symbol: %s = %lx = %s, %zx/%zu\n", \
|
||||
sl+1, value, \
|
||||
(sym.size==0) ? symbol+1 : symbol, \
|
||||
sym.offset, sym.size);
|
||||
+#else
|
||||
+ fprintf(stderr, "Symbol: %s = %x = %s, %zx/%zu\n", \
|
||||
+ sl+1, value, \
|
||||
+ (sym.size==0) ? symbol+1 : symbol, \
|
||||
+ sym.offset, sym.size);
|
||||
+#endif
|
||||
|
||||
value = 2;
|
||||
if ( sym.size != 0 )
|
||||
{
|
||||
--value;
|
||||
++kp;
|
||||
- elp += sprintf(elp, "+0x%x/0x%02x", sym.offset, sym.size);
|
||||
+ elp += sprintf(elp, "+%zx/%zu", sym.offset, sym.size);
|
||||
}
|
||||
strncat(elp, kp, value);
|
||||
elp += value;
|
||||
--- ksym_mod.c
|
||||
+++ ksym_mod.c 2022-10-13 10:53:51.690149032 +0000
|
||||
@@ -116,12 +116,11 @@
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include "module.h"
|
||||
-#if !defined(__GLIBC__)
|
||||
-#include <linux/time.h>
|
||||
-#endif /* __GLIBC__ */
|
||||
#include <stdarg.h>
|
||||
#include <paths.h>
|
||||
-#include <linux/version.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <limits.h>
|
||||
+/* #include <linux/version.h> */
|
||||
|
||||
#include "klogd.h"
|
||||
#include "ksyms.h"
|
||||
@@ -465,7 +464,7 @@ static int AddSymbol(line)
|
||||
* Purpose: Find the symbol which is related to the given address from
|
||||
* a kernel module.
|
||||
*
|
||||
- * Arguments: (long int) value, (struct symbol *) sym
|
||||
+ * Arguments: (uintptr_t) value, (struct symbol *) sym
|
||||
*
|
||||
* value:-> The address to be located.
|
||||
*
|
||||
@@ -481,7 +480,7 @@ static int AddSymbol(line)
|
||||
|
||||
extern char * LookupModuleSymbol(value, sym)
|
||||
|
||||
- unsigned long value;
|
||||
+ uintptr_t value;
|
||||
|
||||
struct symbol *sym;
|
||||
|
||||
--- ksyms.h
|
||||
+++ ksyms.h 2022-10-13 08:44:58.028153542 +0000
|
||||
@@ -20,16 +20,19 @@
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
+#include <sys/types.h>
|
||||
+#include <stdint.h>
|
||||
+
|
||||
/* Variables, structures and type definitions static to this module. */
|
||||
|
||||
struct symbol
|
||||
{
|
||||
char *name;
|
||||
- int size;
|
||||
- int offset;
|
||||
+ size_t size;
|
||||
+ __off64_t offset;
|
||||
};
|
||||
|
||||
|
||||
/* Function prototypes. */
|
||||
-extern char * LookupSymbol(unsigned long, struct symbol *);
|
||||
-extern char * LookupModuleSymbol(unsigned long int, struct symbol *);
|
||||
+extern char * LookupSymbol(uintptr_t, struct symbol *);
|
||||
+extern char * LookupModuleSymbol(uintptr_t, struct symbol *);
|
94
sysklogd-1.4.1-ksyslogsize.diff
Normal file
94
sysklogd-1.4.1-ksyslogsize.diff
Normal file
@ -0,0 +1,94 @@
|
||||
---
|
||||
klogd.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++-----
|
||||
1 file changed, 47 insertions(+), 5 deletions(-)
|
||||
|
||||
--- klogd.c
|
||||
+++ klogd.c 2022-10-14 13:17:38.386601331 +0000
|
||||
@@ -309,8 +309,10 @@ static int use_syscall = 0,
|
||||
no_fork = 0; /* don't fork - don't run in daemon mode */
|
||||
|
||||
static char *symfile = (char *) 0,
|
||||
- log_buffer[LOG_BUFFER_SIZE];
|
||||
+ *log_buffer = (char *) 0;
|
||||
|
||||
+static int log_buf_size = 0;
|
||||
+
|
||||
static FILE *output_file = (FILE *) 0;
|
||||
|
||||
static enum LOGSRC {none, proc, kernel} logsrc;
|
||||
@@ -932,8 +934,8 @@ static void LogKernelLine(void)
|
||||
* which will contain old messages. Then read the kernel log
|
||||
* messages into this fresh buffer.
|
||||
*/
|
||||
- memset(log_buffer, '\0', sizeof(log_buffer));
|
||||
- if ( (rdcnt = ksyslog(2, log_buffer, sizeof(log_buffer)-1)) < 0 )
|
||||
+ memset(log_buffer, '\0', log_buf_size);
|
||||
+ if ( (rdcnt = ksyslog(2, log_buffer, log_buf_size-1)) < 0 )
|
||||
{
|
||||
if ( errno == EINTR )
|
||||
return;
|
||||
@@ -957,8 +959,8 @@ static void LogProcLine(void)
|
||||
* which will contain old messages. Then read the kernel messages
|
||||
* from the message pseudo-file into this fresh buffer.
|
||||
*/
|
||||
- memset(log_buffer, '\0', sizeof(log_buffer));
|
||||
- if ( (rdcnt = read(kmsg, log_buffer, sizeof(log_buffer)-1)) < 0 )
|
||||
+ memset(log_buffer, '\0', log_buf_size);
|
||||
+ if ( (rdcnt = read(kmsg, log_buffer, log_buf_size-1)) < 0 )
|
||||
{
|
||||
if ( errno == EINTR )
|
||||
return;
|
||||
@@ -971,6 +973,44 @@ static void LogProcLine(void)
|
||||
return;
|
||||
}
|
||||
|
||||
+static void SetBufSize(void)
|
||||
+
|
||||
+{
|
||||
+ auto int n, sz;
|
||||
+
|
||||
+ n = ksyslog(10, NULL, 0); /* read ringbuffer size */
|
||||
+ if (n > 0) {
|
||||
+ log_buf_size = n;
|
||||
+ log_buffer = (char *) malloc(log_buf_size);
|
||||
+ if (!log_buffer) {
|
||||
+ perror("ksyslog");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!log_buf_size) {
|
||||
+ sz = LOG_BUFFER_SIZE;
|
||||
+ while (1) {
|
||||
+ log_buffer = (char *) malloc(sz+8);
|
||||
+ if (!log_buffer) {
|
||||
+ perror("ksyslog");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ n = ksyslog(3, log_buffer, sz+8);
|
||||
+ if (n < sz+8 || sz >= (1<<22))
|
||||
+ break;
|
||||
+ free(log_buffer);
|
||||
+ sz <<= 1;
|
||||
+ }
|
||||
+ log_buf_size = sz;
|
||||
+ }
|
||||
+
|
||||
+ if (n < 0) {
|
||||
+ perror("ksyslog");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
@@ -1049,6 +1089,8 @@ int main(argc, argv)
|
||||
console_log_level = *log_level - '0';
|
||||
}
|
||||
|
||||
+ /* get/probe for the kernel ring buffer size */
|
||||
+ SetBufSize();
|
||||
|
||||
#ifndef TESTING
|
||||
/*
|
15
sysklogd-1.4.1-large.patch
Normal file
15
sysklogd-1.4.1-large.patch
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
Makefile | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- Makefile
|
||||
+++ Makefile 2022-10-13 10:55:16.540631345 +0000
|
||||
@@ -51,7 +51,7 @@ MANDIR = $(prefix)/usr/share/man
|
||||
|
||||
# The following define determines whether the package adheres to the
|
||||
# file system standard.
|
||||
-FSSTND = -DFSSTND
|
||||
+FSSTND = -DFSSTND -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
|
||||
|
||||
# The following define establishes ownership for the man pages.
|
||||
# Avery tells me that there is a difference between Debian and
|
42
sysklogd-1.4.1-nofortify.patch
Normal file
42
sysklogd-1.4.1-nofortify.patch
Normal file
@ -0,0 +1,42 @@
|
||||
--- fortify.h
|
||||
+++ fortify.h 2008-05-30 10:18:14.874490898 +0000
|
||||
@@ -0,0 +1,17 @@
|
||||
+#if defined(__USE_FORTIFY_LEVEL)
|
||||
+# undef syslog
|
||||
+# undef vsyslog
|
||||
+# undef openlog
|
||||
+# undef closelog
|
||||
+# undef setlogmask
|
||||
+extern void priv_syslog(int, const char *, ...);
|
||||
+extern void priv_vsyslog(int, const char *, va_list);
|
||||
+extern void priv_openlog(const char *, int, int);
|
||||
+extern void priv_closelog(void);
|
||||
+extern int priv_setlogmask(int);
|
||||
+# define syslog priv_syslog
|
||||
+# define vsyslog priv_vsyslog
|
||||
+# define openlog priv_openlog
|
||||
+# define closelog priv_closelog
|
||||
+# define setlogmask priv_setlogmask
|
||||
+#endif
|
||||
--- klogd.c
|
||||
+++ klogd.c 2008-05-30 10:19:59.501151202 +0000
|
||||
@@ -296,6 +296,8 @@ static char *PidFile = "/etc/klogd.pid";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+#include "fortify.h"
|
||||
+
|
||||
static int kmsg,
|
||||
change_state = 0,
|
||||
terminate = 0,
|
||||
--- syslog.c
|
||||
+++ syslog.c 2008-05-30 10:20:24.799728870 +0000
|
||||
@@ -75,6 +75,8 @@ static char sccsid[] = "@(#)syslog.c 5.2
|
||||
|
||||
#define _PATH_LOGNAME "/dev/log"
|
||||
|
||||
+#include "fortify.h"
|
||||
+
|
||||
static int LogFile = -1; /* fd for log */
|
||||
static int connected; /* have done connect */
|
||||
static int LogStat = 0; /* status bits, set by openlog() */
|
197
sysklogd-1.4.1-reload.dif
Normal file
197
sysklogd-1.4.1-reload.dif
Normal file
@ -0,0 +1,197 @@
|
||||
---
|
||||
syslogd.c | 68 ++++++++++++++++++++++++++++++++++++++------------------------
|
||||
1 file changed, 42 insertions(+), 26 deletions(-)
|
||||
|
||||
--- syslogd.c
|
||||
+++ syslogd.c 2022-10-19 09:49:43.134694341 +0000
|
||||
@@ -544,6 +544,10 @@ static char sccsid[] __attribute__ ((un
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <signal.h>
|
||||
+#ifndef _GNU_SOURCE
|
||||
+typedef void (*sighandler_t)(int);
|
||||
+#endif
|
||||
+static sighandler_t resignal(int signum, sighandler_t handler);
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
@@ -618,7 +622,7 @@ char **parts;
|
||||
int inetm = 0;
|
||||
static int debugging_on = 0;
|
||||
static int nlogs = -1;
|
||||
-static int restart = 0;
|
||||
+static volatile sig_atomic_t restart;
|
||||
|
||||
#define MAXFUNIX 20
|
||||
|
||||
@@ -1134,13 +1138,13 @@ int main(argc, argv)
|
||||
|
||||
leave = 0;
|
||||
|
||||
- (void) signal(SIGTERM, die);
|
||||
+ (void) resignal(SIGTERM, die); /* Make recvfrom() be able to receive EINTR */
|
||||
(void) signal(SIGINT, Debug ? die : SIG_IGN);
|
||||
(void) signal(SIGQUIT, Debug ? die : SIG_IGN);
|
||||
- (void) signal(SIGCHLD, reapchild);
|
||||
- (void) signal(SIGALRM, domark);
|
||||
- (void) signal(SIGUSR1, Debug ? debug_switch : SIG_IGN);
|
||||
+ (void) resignal(SIGCHLD, reapchild);
|
||||
+ (void) resignal(SIGUSR1, Debug ? debug_switch : SIG_IGN);
|
||||
(void) signal(SIGXFSZ, SIG_IGN);
|
||||
+ (void) resignal(SIGALRM, domark); /* Make recvfrom() be able to receive EINTR */
|
||||
(void) alarm(TIMERINTVL);
|
||||
|
||||
/* Create a partial message table for all file descriptors. */
|
||||
@@ -1161,6 +1165,7 @@ int main(argc, argv)
|
||||
|
||||
dprintf("Starting.\n");
|
||||
init();
|
||||
+ (void) resignal(SIGHUP, sighup_handler);
|
||||
#ifndef TESTING
|
||||
if ( Debug )
|
||||
{
|
||||
@@ -1232,9 +1237,14 @@ int main(argc, argv)
|
||||
(fd_set *) NULL, (struct timeval *) NULL);
|
||||
if ( restart )
|
||||
{
|
||||
+ sigset_t blockhup;
|
||||
+ sigemptyset(&blockhup);
|
||||
+ sigaddset (&blockhup, SIGHUP);
|
||||
+ (void) sigprocmask(SIG_BLOCK, &blockhup, NULL);
|
||||
restart = 0;
|
||||
dprintf("\nReceived SIGHUP, reloading syslogd.\n");
|
||||
init();
|
||||
+ (void) sigprocmask (SIG_UNBLOCK, &blockhup, NULL);
|
||||
continue;
|
||||
}
|
||||
if (nfds == 0) {
|
||||
@@ -1756,7 +1766,8 @@ void logmsg(pri, msg, from, flags)
|
||||
int msglen;
|
||||
char *timestamp;
|
||||
#ifdef __gnu_linux__
|
||||
- sigset_t mask;
|
||||
+ sigset_t mask, omask;
|
||||
+ int lognum;
|
||||
#else
|
||||
#ifndef SYSV
|
||||
sigset_t omask;
|
||||
@@ -1771,7 +1782,7 @@ void logmsg(pri, msg, from, flags)
|
||||
sigemptyset(&mask);
|
||||
sigaddset(&mask, SIGHUP);
|
||||
sigaddset(&mask, SIGALRM);
|
||||
- sigprocmask(SIG_BLOCK, &mask, NULL);
|
||||
+ sigprocmask(SIG_BLOCK, &mask, &omask);
|
||||
#else
|
||||
#ifndef SYSV
|
||||
omask = sigblock(sigmask(SIGHUP)|sigmask(SIGALRM));
|
||||
@@ -1815,7 +1826,7 @@ void logmsg(pri, msg, from, flags)
|
||||
f->f_file = -1;
|
||||
}
|
||||
#ifdef __gnu_linux__
|
||||
- sigprocmask(SIG_UNBLOCK, &mask, NULL);
|
||||
+ sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||
#else
|
||||
#ifndef SYSV
|
||||
(void) sigsetmask(omask);
|
||||
@@ -1884,7 +1895,7 @@ void logmsg(pri, msg, from, flags)
|
||||
}
|
||||
}
|
||||
#ifdef __gnu_linux__
|
||||
- sigprocmask(SIG_UNBLOCK, &mask, NULL);
|
||||
+ sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||
#else
|
||||
#ifndef SYSV
|
||||
(void) sigsetmask(omask);
|
||||
@@ -2213,10 +2224,6 @@ void wallmsg(f, iov)
|
||||
if (fork() == 0) {
|
||||
(void) signal(SIGTERM, SIG_DFL);
|
||||
(void) alarm(0);
|
||||
-#ifndef SYSV
|
||||
- (void) signal(SIGTTOU, SIG_IGN);
|
||||
- (void) sigsetmask(0);
|
||||
-#endif
|
||||
(void) snprintf(greetings, sizeof(greetings),
|
||||
"\r\n\7Message from syslogd@%s at %.24s ...\r\n",
|
||||
(char *) iov[2].iov_base, ctime(&now));
|
||||
@@ -2281,19 +2288,32 @@ void wallmsg(f, iov)
|
||||
reenter = 0;
|
||||
}
|
||||
|
||||
+static sighandler_t resignal(int signum, sighandler_t handler)
|
||||
+{
|
||||
+ struct sigaction nact, oact;
|
||||
+ sigset_t sigset;
|
||||
+
|
||||
+ nact.sa_handler = handler;
|
||||
+ sigemptyset (&nact.sa_mask);
|
||||
+
|
||||
+ do {
|
||||
+ if (sigaction(signum, &nact, &oact) == 0)
|
||||
+ break;
|
||||
+ } while (errno == EINTR);
|
||||
+
|
||||
+ sigemptyset(&sigset);
|
||||
+ sigaddset(&sigset, signum);
|
||||
+
|
||||
+ sigprocmask(SIG_UNBLOCK, &sigset, NULL);
|
||||
+
|
||||
+ return oact.sa_handler;
|
||||
+}
|
||||
+
|
||||
void reapchild()
|
||||
{
|
||||
int saved_errno = errno;
|
||||
-#if defined(SYSV) && !defined(linux)
|
||||
- (void) signal(SIGCHLD, reapchild); /* reset signal handler -ASP */
|
||||
- wait ((int *)0);
|
||||
-#else
|
||||
while (waitpid(-1, (int*)0, WNOHANG|WUNTRACED) > 0)
|
||||
;
|
||||
-#endif
|
||||
-#ifdef linux
|
||||
- (void) signal(SIGCHLD, reapchild); /* reset signal handler -ASP */
|
||||
-#endif
|
||||
errno = saved_errno;
|
||||
}
|
||||
|
||||
@@ -2403,6 +2423,7 @@ void domark()
|
||||
#ifdef SYSV
|
||||
for (lognum = 0; lognum <= nlogs; lognum++) {
|
||||
f = &Files[lognum];
|
||||
+ }
|
||||
#else
|
||||
for (f = Files; f; f = f->f_next) {
|
||||
#endif
|
||||
@@ -2414,8 +2435,6 @@ void domark()
|
||||
BACKOFF(f);
|
||||
}
|
||||
}
|
||||
- }
|
||||
- (void) signal(SIGALRM, domark);
|
||||
(void) alarm(TIMERINTVL);
|
||||
}
|
||||
|
||||
@@ -2424,7 +2443,6 @@ void debug_switch()
|
||||
{
|
||||
dprintf("Switching debugging_on to %s\n", (debugging_on == 0) ? "true" : "false");
|
||||
debugging_on = (debugging_on == 0) ? 1 : 0;
|
||||
- signal(SIGUSR1, debug_switch);
|
||||
}
|
||||
|
||||
|
||||
@@ -2774,7 +2792,6 @@ void init()
|
||||
logmsg(LOG_SYSLOG|LOG_INFO, "syslogd " VERSION "." PATCHLEVEL \
|
||||
": restart." , LocalHostName, ADDDATE);
|
||||
#endif
|
||||
- (void) signal(SIGHUP, sighup_handler);
|
||||
dprintf("syslogd: restarted.\n");
|
||||
}
|
||||
#if FALSE
|
||||
@@ -3175,7 +3192,6 @@ static void allocate_log(void)
|
||||
void sighup_handler(int sig)
|
||||
{
|
||||
restart = 1;
|
||||
- signal(SIGHUP, sighup_handler);
|
||||
return;
|
||||
}
|
||||
|
27
sysklogd-1.4.1-reopen.patch
Normal file
27
sysklogd-1.4.1-reopen.patch
Normal file
@ -0,0 +1,27 @@
|
||||
#
|
||||
# Description: reconnects to log socket if a write fails with
|
||||
# ECONNREFUSED or ENOTCONN -- similar to reopen
|
||||
# in syslog routines provided by glibc.
|
||||
# Happens if the log socket (provided by syslog
|
||||
# daemon) has been reopened. Can be triggered by
|
||||
# "rcsyslog reload" while syslog-ng is used.
|
||||
# See also Bugzilla Bug #27971.
|
||||
#
|
||||
# Author: mt@suse.de
|
||||
#
|
||||
---
|
||||
syslog.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
--- syslog.c
|
||||
+++ syslog.c 2022-10-14 13:04:57.692223266 +0000
|
||||
@@ -177,7 +177,8 @@ vsyslog(pri, fmt, ap)
|
||||
&& (errno == ECONNRESET || errno == ENOTCONN || errno == ECONNREFUSED)) {
|
||||
closelog();
|
||||
openlog(LogTag, LogStat | LOG_NDELAY, LogFacility);
|
||||
- result = write(LogFile, tbuf, cnt + 1);
|
||||
+ if (connected)
|
||||
+ result = write(LogFile, tbuf, cnt + 1);
|
||||
}
|
||||
|
||||
if (result >= 0 || !(LogStat&LOG_CONS))
|
178
sysklogd-1.4.1-showpri.patch
Normal file
178
sysklogd-1.4.1-showpri.patch
Normal file
@ -0,0 +1,178 @@
|
||||
---
|
||||
sysklogd.8 | 23 +++++++++++++++++++++++
|
||||
syslogd.c | 54 ++++++++++++++++++++++++++++++++++++++----------------
|
||||
2 files changed, 61 insertions(+), 16 deletions(-)
|
||||
|
||||
--- sysklogd.8
|
||||
+++ sysklogd.8 2022-10-14 13:33:28.961599858 +0000
|
||||
@@ -31,6 +31,7 @@ sysklogd \- Linux system logging utiliti
|
||||
]
|
||||
.RB [ " \-t " ]
|
||||
.RB [ " \-v " ]
|
||||
+.RB [ " \-S " ]
|
||||
.SH DESCRIPTION
|
||||
.B Sysklogd
|
||||
provides two system utilities which provide support for
|
||||
@@ -158,6 +159,28 @@ loghost.
|
||||
.TP
|
||||
.B "\-v"
|
||||
Print version and exit.
|
||||
+.TP
|
||||
+.B "\-S"
|
||||
+Insert a special code before the hostname in each message to indicate the
|
||||
+message's priority and facility. Having the priority and facility encoded in
|
||||
+each message allows a log analyzer program to monitor a single file
|
||||
+containing all logged messages. The analyzer program can parse the
|
||||
+priority/facility code for each logged message to determine if it is
|
||||
+of interest.
|
||||
+
|
||||
+The priority/facility code takes the form of a priority number
|
||||
+followed by a letter that indicates the facility. The priority number
|
||||
+can range from 0 to 7. The facility letter can range from 'A' to 'Y',
|
||||
+where 'A' corresponds to facility number zero (LOG_KERN), 'B'
|
||||
+corresponds to facility 1 (LOG_USER), etc.
|
||||
+See /usr/include/sys/syslog.h for a list of priority and LOG_xxx codes.
|
||||
+
|
||||
+Example:
|
||||
+
|
||||
+ Jun 27 19:22:20 5Q:silence test[1966]: testing
|
||||
+
|
||||
+The above message contains a priority/facility code of '5Q', which breaks
|
||||
+down to a priority of 5 (LOG_NOTICE) and a facility of 16 (LOG_LOCAL0).
|
||||
.SH SIGNALS
|
||||
.B Syslogd
|
||||
reacts to a set of signals. You may easily send a signal to
|
||||
--- syslogd.c
|
||||
+++ syslogd.c 2022-10-14 13:27:33.395957312 +0000
|
||||
@@ -649,6 +649,9 @@ int funix[MAXFUNIX] = { -1, };
|
||||
#define SYNC_FILE 0x002 /* do fsync on file after printing */
|
||||
#define ADDDATE 0x004 /* add a date to the message */
|
||||
#define MARK 0x008 /* this message is a mark */
|
||||
+#define SHOWPRI 0x010 /* Will craft priFac before hostname */
|
||||
+
|
||||
+int showpri = 0; /* Are we showing priority in message ? Default: no */
|
||||
|
||||
/*
|
||||
* This table contains plain text for h_errno errors used by the
|
||||
@@ -828,7 +831,7 @@ void printchopped(const char *hname, cha
|
||||
void printline(const char *hname, char *msg);
|
||||
void printsys(char *msg);
|
||||
void logmsg(int pri, char *msg, const char *from, int flags);
|
||||
-void fprintlog(register struct filed *f, char *from, int flags, char *msg);
|
||||
+void fprintlog(register struct filed *f, char *from, int flags, char *msg, ...);
|
||||
void endtty();
|
||||
void wallmsg(register struct filed *f, struct iovec *iov);
|
||||
void reapchild();
|
||||
@@ -920,7 +923,7 @@ int main(argc, argv)
|
||||
funix[i] = -1;
|
||||
}
|
||||
|
||||
- while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:tv")) != EOF)
|
||||
+ while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:tvS")) != EOF)
|
||||
switch((char)ch) {
|
||||
case 'a':
|
||||
if (nfunix < MAXFUNIX)
|
||||
@@ -972,6 +975,9 @@ int main(argc, argv)
|
||||
case 'v':
|
||||
printf("syslogd %s.%s\n", VERSION, PATCHLEVEL);
|
||||
exit (0);
|
||||
+ case 'S':
|
||||
+ showpri++;
|
||||
+ break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
@@ -1287,7 +1293,7 @@ int main(argc, argv)
|
||||
|
||||
int usage()
|
||||
{
|
||||
- fprintf(stderr, "usage: syslogd [-drvh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
|
||||
+ fprintf(stderr, "usage: syslogd [-drvSh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
|
||||
" [-s domainlist] [-f conffile]\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -1755,7 +1761,7 @@ void logmsg(pri, msg, from, flags)
|
||||
|
||||
if (f->f_file >= 0) {
|
||||
untty();
|
||||
- fprintlog(f, (char *)from, flags, msg);
|
||||
+ fprintlog(f, (char *)from, flags|SHOWPRI, msg, prilev, fac);
|
||||
(void) close(f->f_file);
|
||||
f->f_file = -1;
|
||||
}
|
||||
@@ -1805,13 +1811,13 @@ void logmsg(pri, msg, from, flags)
|
||||
* in the future.
|
||||
*/
|
||||
if (now > REPEATTIME(f)) {
|
||||
- fprintlog(f, (char *)from, flags, (char *)NULL);
|
||||
+ fprintlog(f, (char *)from, flags|SHOWPRI, (char *)NULL, prilev, fac);
|
||||
BACKOFF(f);
|
||||
}
|
||||
} else {
|
||||
/* new line, save it */
|
||||
if (f->f_prevcount)
|
||||
- fprintlog(f, (char *)from, 0, (char *)NULL);
|
||||
+ fprintlog(f, (char *)from, 0|SHOWPRI, (char *)NULL, prilev, fac);
|
||||
f->f_prevpri = pri;
|
||||
f->f_repeatcount = 0;
|
||||
(void) strncpy(f->f_lasttime, timestamp, 15);
|
||||
@@ -1820,11 +1826,11 @@ void logmsg(pri, msg, from, flags)
|
||||
if (msglen < MAXSVLINE) {
|
||||
f->f_prevlen = msglen;
|
||||
(void) strcpy(f->f_prevline, msg);
|
||||
- fprintlog(f, (char *)from, flags, (char *)NULL);
|
||||
+ fprintlog(f, (char *)from, flags|SHOWPRI, (char *)NULL, prilev, fac);
|
||||
} else {
|
||||
f->f_prevline[0] = 0;
|
||||
f->f_prevlen = 0;
|
||||
- fprintlog(f, (char *)from, flags, msg);
|
||||
+ fprintlog(f, (char *)from, flags|SHOWPRI, msg, prilev, fac);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1840,11 +1846,7 @@ void logmsg(pri, msg, from, flags)
|
||||
} /* balance parentheses for emacs */
|
||||
#endif
|
||||
|
||||
-void fprintlog(f, from, flags, msg)
|
||||
- register struct filed *f;
|
||||
- char *from;
|
||||
- int flags;
|
||||
- char *msg;
|
||||
+void fprintlog(register struct filed *f, char *from, int flags,char *msg, ...)
|
||||
{
|
||||
struct iovec iov[6];
|
||||
register struct iovec *v = iov;
|
||||
@@ -1865,9 +1867,29 @@ void fprintlog(f, from, flags, msg)
|
||||
v->iov_base = f->f_lasttime;
|
||||
v->iov_len = 15;
|
||||
v++;
|
||||
- v->iov_base = " ";
|
||||
- v->iov_len = 1;
|
||||
- v++;
|
||||
+
|
||||
+ if(showpri && (flags & SHOWPRI) ) {
|
||||
+ va_list ap;
|
||||
+ int prilev;
|
||||
+ int fac;
|
||||
+ char prilev_char[5];
|
||||
+ const char fac_string[LOG_NFACILITIES+1]="ABCDEFGHIJKLMNOPQRSTUVWXY";
|
||||
+
|
||||
+ va_start(ap,msg);
|
||||
+ prilev=va_arg(ap,int);
|
||||
+ fac=va_arg(ap,int);
|
||||
+ va_end(ap);
|
||||
+ sprintf(prilev_char, " %1d%c:", prilev, fac_string[fac]);
|
||||
+ v->iov_base = prilev_char;
|
||||
+ v->iov_len = 4;
|
||||
+ v++;
|
||||
+ }
|
||||
+ else {
|
||||
+ v->iov_base = " ";
|
||||
+ v->iov_len = 1;
|
||||
+ v++;
|
||||
+ }
|
||||
+
|
||||
v->iov_base = f->f_prevhost;
|
||||
v->iov_len = strlen(v->iov_base);
|
||||
v++;
|
239
sysklogd-1.4.1-signal.dif
Normal file
239
sysklogd-1.4.1-signal.dif
Normal file
@ -0,0 +1,239 @@
|
||||
---
|
||||
syslogd.c | 107 +++++++++++++++++++++++++++++++++++++++++++++-----------------
|
||||
1 file changed, 78 insertions(+), 29 deletions(-)
|
||||
|
||||
--- syslogd.c
|
||||
+++ syslogd.c 2022-10-18 06:25:00.236304111 +0000
|
||||
@@ -826,6 +826,9 @@ extern int errno;
|
||||
int main(int argc, char **argv);
|
||||
char **crunch_list(char *list);
|
||||
int usage(void);
|
||||
+#ifdef SYSV
|
||||
+static pid_t sid;
|
||||
+#endif
|
||||
void untty(void);
|
||||
void printchopped(const char *hname, char *msg, int len, int fd);
|
||||
void printline(const char *hname, char *msg);
|
||||
@@ -839,7 +842,9 @@ const char *cvthname(struct sockaddr *f)
|
||||
void domark();
|
||||
void debug_switch();
|
||||
void logerror(const char *type);
|
||||
+static volatile sig_atomic_t leave;
|
||||
void die(int sig);
|
||||
+void dienow(void);
|
||||
#ifndef TESTING
|
||||
void doexit(int sig);
|
||||
#endif
|
||||
@@ -991,12 +996,32 @@ int main(argc, argv)
|
||||
dprintf("Checking pidfile.\n");
|
||||
if (!check_pid(PidFile))
|
||||
{
|
||||
+ pid_t pid;
|
||||
+ int n = 0, status;
|
||||
+
|
||||
signal (SIGTERM, doexit);
|
||||
- if (fork()) {
|
||||
+
|
||||
+ switch ((pid = fork())) {
|
||||
+ default:
|
||||
+ retry:
|
||||
/*
|
||||
* Parent process
|
||||
*/
|
||||
- sleep(300);
|
||||
+ switch (waitpid(pid, &status, WNOHANG|WUNTRACED)) {
|
||||
+ case -1:
|
||||
+ if (errno == EINTR)
|
||||
+ goto retry;
|
||||
+ break;
|
||||
+ case 0:
|
||||
+ if (leave)
|
||||
+ exit(0);
|
||||
+ usleep(10*1000);
|
||||
+ if (++n < 30000)
|
||||
+ goto retry;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+ case -1:
|
||||
/*
|
||||
* Not reached unless something major went wrong. 5
|
||||
* minutes should be a fair amount of time to wait.
|
||||
@@ -1006,12 +1031,14 @@ int main(argc, argv)
|
||||
* logs. -Joey
|
||||
*/
|
||||
exit(1);
|
||||
+ case 0:
|
||||
+ signal (SIGTERM, SIG_DFL);
|
||||
+
|
||||
+ num_fds = getdtablesize();
|
||||
+ for (i = 0; i < num_fds; i++)
|
||||
+ (void) close(i);
|
||||
+ untty();
|
||||
}
|
||||
- signal (SIGTERM, SIG_DFL);
|
||||
- num_fds = getdtablesize();
|
||||
- for (i= 0; i < num_fds; i++)
|
||||
- (void) close(i);
|
||||
- untty();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1091,6 +1118,8 @@ int main(argc, argv)
|
||||
if (isupper(*p))
|
||||
*p = tolower(*p);
|
||||
|
||||
+ leave = 0;
|
||||
+
|
||||
(void) signal(SIGTERM, die);
|
||||
(void) signal(SIGINT, Debug ? die : SIG_IGN);
|
||||
(void) signal(SIGQUIT, Debug ? die : SIG_IGN);
|
||||
@@ -1111,7 +1140,7 @@ int main(argc, argv)
|
||||
if (getpid() != ppid)
|
||||
kill (ppid, SIGTERM);
|
||||
#endif
|
||||
- die(0);
|
||||
+ dienow();
|
||||
}
|
||||
for(i= 0; i < num_fds; ++i)
|
||||
parts[i] = (char *) 0;
|
||||
@@ -1134,9 +1163,14 @@ int main(argc, argv)
|
||||
/* Main loop begins here. */
|
||||
for (;;) {
|
||||
int nfds;
|
||||
+
|
||||
+ if (leave)
|
||||
+ dienow();
|
||||
+
|
||||
errno = 0;
|
||||
FD_ZERO(&readfds);
|
||||
maxfds = 0;
|
||||
+
|
||||
#ifdef SYSLOG_UNIXAF
|
||||
#ifndef TESTING
|
||||
/*
|
||||
@@ -1322,7 +1356,7 @@ static int create_unix_socket(const char
|
||||
dprintf("cannot create %s (%d).\n", path, errno);
|
||||
close(fd);
|
||||
#ifndef SYSV
|
||||
- die(0);
|
||||
+ dienow();
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
@@ -1480,8 +1514,8 @@ crunch_list(list)
|
||||
void untty()
|
||||
#ifdef SYSV
|
||||
{
|
||||
- if ( !Debug ) {
|
||||
- setsid();
|
||||
+ if ( !Debug && !sid ) {
|
||||
+ sid = setsid();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1677,8 +1711,7 @@ void printsys(msg)
|
||||
/*
|
||||
* Decode a priority into textual information like auth.emerg.
|
||||
*/
|
||||
-char *textpri(pri)
|
||||
- int pri;
|
||||
+char *textpri(int pri)
|
||||
{
|
||||
static char res[20];
|
||||
CODE *c_pri, *c_fac;
|
||||
@@ -2239,9 +2272,7 @@ void reapchild()
|
||||
(void) signal(SIGCHLD, reapchild); /* reset signal handler -ASP */
|
||||
wait ((int *)0);
|
||||
#else
|
||||
- union wait status;
|
||||
-
|
||||
- while (wait3(&status, WNOHANG, (struct rusage *) NULL) > 0)
|
||||
+ while (waitpid(-1, (int*)0, WNOHANG|WUNTRACED) > 0)
|
||||
;
|
||||
#endif
|
||||
#ifdef linux
|
||||
@@ -2400,11 +2431,21 @@ void logerror(type)
|
||||
return;
|
||||
}
|
||||
|
||||
-void die(sig)
|
||||
- int sig;
|
||||
+void die(int sig)
|
||||
{
|
||||
- register struct filed *f;
|
||||
char buf[100];
|
||||
+ leave++;
|
||||
+
|
||||
+ dprintf("syslogd: exiting on signal %d\n", sig);
|
||||
+ (void) snprintf(buf, sizeof(buf), "exiting on signal %d", sig);
|
||||
+ errno = 0;
|
||||
+ logmsg(LOG_SYSLOG|LOG_INFO, buf, LocalHostName, ADDDATE);
|
||||
+ signal(sig, SIG_IGN);
|
||||
+}
|
||||
+
|
||||
+void dienow(void)
|
||||
+{
|
||||
+ register struct filed *f;
|
||||
int lognum;
|
||||
int i;
|
||||
int was_initialized = Initialized;
|
||||
@@ -2420,24 +2461,31 @@ void die(sig)
|
||||
}
|
||||
|
||||
Initialized = was_initialized;
|
||||
- if (sig) {
|
||||
- dprintf("syslogd: exiting on signal %d\n", sig);
|
||||
- (void) snprintf(buf, sizeof(buf), "exiting on signal %d", sig);
|
||||
- errno = 0;
|
||||
- logmsg(LOG_SYSLOG|LOG_INFO, buf, LocalHostName, ADDDATE);
|
||||
- }
|
||||
|
||||
/* Close the UNIX sockets. */
|
||||
- for (i = 0; i < nfunix; i++)
|
||||
+ for (i = 0; i < nfunix; i++)
|
||||
if (funix[i] != -1)
|
||||
close(funix[i]);
|
||||
+
|
||||
/* Close the inet socket. */
|
||||
if (InetInuse) close(inetm);
|
||||
|
||||
/* Clean-up files. */
|
||||
- for (i = 0; i < nfunix; i++)
|
||||
+ for (i = 0; i < nfunix; i++)
|
||||
if (funixn[i] && funix[i] != -1)
|
||||
(void)unlink(funixn[i]);
|
||||
+
|
||||
+ for (lognum = 0; lognum <= nlogs; lognum++) {
|
||||
+ f = &Files[lognum];
|
||||
+ if (f->f_file < 0)
|
||||
+ continue;
|
||||
+ if (f->f_type & F_FILE) {
|
||||
+ (void) fdatasync(f->f_file);
|
||||
+ (void) close(f->f_file);
|
||||
+ f->f_file = -1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
#ifndef TESTING
|
||||
(void) remove_pid(PidFile);
|
||||
#endif
|
||||
@@ -2451,7 +2499,7 @@ void die(sig)
|
||||
void doexit(sig)
|
||||
int sig;
|
||||
{
|
||||
- exit (0);
|
||||
+ leave++;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2516,7 +2564,8 @@ void init()
|
||||
case F_TTY:
|
||||
case F_CONSOLE:
|
||||
case F_USOCK:
|
||||
- (void) close(f->f_file);
|
||||
+ if (f->f_file >= 0)
|
||||
+ (void) close(f->f_file);
|
||||
break;
|
||||
}
|
||||
}
|
95
sysklogd-1.4.1-sparc.patch
Normal file
95
sysklogd-1.4.1-sparc.patch
Normal file
@ -0,0 +1,95 @@
|
||||
--- ksym.c
|
||||
+++ ksym.c 2001-05-23 18:50:36.000000000 +0000
|
||||
@@ -130,6 +130,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <sys/utsname.h>
|
||||
+#include <ctype.h>
|
||||
#include "klogd.h"
|
||||
#include "ksyms.h"
|
||||
#include "module.h"
|
||||
@@ -809,6 +810,84 @@ extern char * ExpandKadds(line, el)
|
||||
if ( (num_syms == 0) ||
|
||||
(kp = strstr(line, "[<")) == (char *) 0 )
|
||||
{
|
||||
+#ifdef __sparc__
|
||||
+ if (num_syms) {
|
||||
+ /*
|
||||
+ * On SPARC, register dumps do not have the [< >] characters in it.
|
||||
+ */
|
||||
+ static struct sparc_tests {
|
||||
+ char *str;
|
||||
+ int len;
|
||||
+ } tests[] = { { "PC: ", 4 },
|
||||
+ { " o7: ", 5 },
|
||||
+ { " ret_pc: ", 9 },
|
||||
+ { " i7: ", 5 },
|
||||
+ { "Caller[", 7 }
|
||||
+ };
|
||||
+ int i, j, ndigits;
|
||||
+ char *kp2;
|
||||
+ for (i = 0; i < 5; i++) {
|
||||
+ kp = strstr(line, tests[i].str);
|
||||
+ if (!kp) continue;
|
||||
+ kp2 = kp + tests[i].len;
|
||||
+ if (!isxdigit(*kp2)) continue;
|
||||
+ for (ndigits = 1; isxdigit(kp2[ndigits]); ndigits++);
|
||||
+ if (ndigits != 8 && ndigits != 16) continue;
|
||||
+ /* On sparc64, all kernel addresses are in first 4GB */
|
||||
+ if (ndigits == 16) {
|
||||
+ if (strncmp (kp2, "00000000", 8)) continue;
|
||||
+ kp2 += 8;
|
||||
+ }
|
||||
+ if (!i) {
|
||||
+ char *kp3;
|
||||
+ if (ndigits == 16 && kp > line && kp[-1L] != 'T') continue;
|
||||
+ kp3 = kp2 + 8;
|
||||
+ if (ndigits == 16) {
|
||||
+ if (strncmp (kp3, " TNPC: 00000000", 15) || !isxdigit(kp3[15]))
|
||||
+ continue;
|
||||
+ kp3 += 15;
|
||||
+ } else {
|
||||
+ if (strncmp (kp3, " NPC: ", 6) || !isxdigit(kp3[6]))
|
||||
+ continue;
|
||||
+ kp3 += 6;
|
||||
+ }
|
||||
+ for (j = 0; isxdigit(kp3[j]); j++);
|
||||
+ if (j != 8) continue;
|
||||
+ strncpy(elp, line, kp2 + 8 - line);
|
||||
+ elp += kp2 + 8 - line;
|
||||
+ value = strtol(kp2, (char **) 0, 16);
|
||||
+ if ( (symbol = LookupSymbol(value, &sym)) ) {
|
||||
+ if (sym.size)
|
||||
+ elp += sprintf(elp, " (%s+%d/%d)", symbol, sym.offset, sym.size);
|
||||
+ else
|
||||
+ elp += sprintf(elp, " (%s)", symbol);
|
||||
+ }
|
||||
+ strncpy(elp, kp2 + 8, kp3 - kp2);
|
||||
+ elp += kp3 - kp2;
|
||||
+ value = strtol(kp3, (char **) 0, 16);
|
||||
+ if ( (symbol = LookupSymbol(value, &sym)) ) {
|
||||
+ if (sym.size)
|
||||
+ elp += sprintf(elp, " (%s+%d/%d)", symbol, sym.offset, sym.size);
|
||||
+ else
|
||||
+ elp += sprintf(elp, " (%s)", symbol);
|
||||
+ }
|
||||
+ strcpy(elp, kp3 + 8);
|
||||
+ } else {
|
||||
+ strncpy(elp, line, kp2 + 8 - line);
|
||||
+ elp += kp2 + 8 - line;
|
||||
+ value = strtol(kp2, (char **) 0, 16);
|
||||
+ if ( (symbol = LookupSymbol(value, &sym)) ) {
|
||||
+ if (sym.size)
|
||||
+ elp += sprintf(elp, " (%s+%d/%d)", symbol, sym.offset, sym.size);
|
||||
+ else
|
||||
+ elp += sprintf(elp, " (%s)", symbol);
|
||||
+ }
|
||||
+ strcpy(elp, kp2 + 8);
|
||||
+ }
|
||||
+ return el;
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
strcpy(el, line);
|
||||
return(el);
|
||||
}
|
64
sysklogd-1.4.1-sysmap-prior-to-2.5.patch
Normal file
64
sysklogd-1.4.1-sysmap-prior-to-2.5.patch
Normal file
@ -0,0 +1,64 @@
|
||||
From: Jeff Mahoney <jeffm@suse.com>
|
||||
Subject: klogd: Silence System.map and symbol lookup warnings with modern kernels
|
||||
References: bnc#505421
|
||||
|
||||
klogd complains about not being able to parse the version of System.map and
|
||||
about not being able to load the kernel module symbol table.
|
||||
|
||||
Since kernels starting with 2.5 accurately report their own symbol table in
|
||||
Oopses, this is no longer necessary. The warnings are a harmless annoyance,
|
||||
but an annoyance nonetheless.
|
||||
|
||||
This patch detects if the running kernel is newer newer than 2.5.0 and
|
||||
disables the symbol lookup on startup, thus avoiding the warnings.
|
||||
|
||||
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
|
||||
---
|
||||
klogd.c | 22 ++++++++++++++++++++++
|
||||
1 file changed, 22 insertions(+)
|
||||
|
||||
--- klogd.c
|
||||
+++ klogd.c 2009-08-12 12:19:17.333901686 +0000
|
||||
@@ -285,6 +285,8 @@ _syscall3(int,ksyslog,int, type, char *,
|
||||
#define ksyslog klogctl
|
||||
#endif
|
||||
|
||||
+#include <sys/utsname.h>
|
||||
+
|
||||
#define LOG_BUFFER_SIZE 4096
|
||||
#define LOG_LINE_LENGTH 1000
|
||||
|
||||
@@ -1014,6 +1016,23 @@ static void SetBufSize(void)
|
||||
}
|
||||
}
|
||||
|
||||
+#ifndef KERNEL_VERSION
|
||||
+#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
|
||||
+#endif
|
||||
+
|
||||
+static int
|
||||
+need_lookup(void)
|
||||
+{
|
||||
+ struct utsname utsname;
|
||||
+ int major, minor, patch;
|
||||
+ if (uname(&utsname) < 0) {
|
||||
+ Syslog(LOG_ERR, "Cannot get kernel version information.");
|
||||
+ return 0;
|
||||
+ }
|
||||
+ sscanf(utsname.release, "%d.%d.%d", &major, &minor, &patch);
|
||||
+
|
||||
+ return (KERNEL_VERSION(major, minor, patch) < KERNEL_VERSION(2,5,0));
|
||||
+}
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
@@ -1199,6 +1218,9 @@ int main(argc, argv)
|
||||
else
|
||||
openlog("kernel", 0, LOG_KERN);
|
||||
|
||||
+ /* We don't need lookups on kernels > 2.4 */
|
||||
+ if (symbol_lookup)
|
||||
+ symbol_lookup = need_lookup();
|
||||
|
||||
/* Handle one-shot logging. */
|
||||
if ( one_shot )
|
173
sysklogd-1.4.1-systemd-multi.dif
Normal file
173
sysklogd-1.4.1-systemd-multi.dif
Normal file
@ -0,0 +1,173 @@
|
||||
---
|
||||
syslogd.c | 121 +++++++++++++++++++++++++++++++++++---------------------------
|
||||
1 file changed, 70 insertions(+), 51 deletions(-)
|
||||
|
||||
--- syslogd.c
|
||||
+++ syslogd.c 2022-10-17 09:33:43.942759127 +0000
|
||||
@@ -626,6 +626,9 @@ static volatile sig_atomic_t restart;
|
||||
int nfunix = 1;
|
||||
char *funixn[MAXFUNIX] = { _PATH_LOG };
|
||||
int funix[MAXFUNIX] = { -1, };
|
||||
+#if defined(__linux__)
|
||||
+int sd_fds = 0;
|
||||
+#endif
|
||||
|
||||
#ifdef UT_NAMESIZE
|
||||
# define UNAMESZ UT_NAMESIZE /* length of a login name */
|
||||
@@ -1047,12 +1050,44 @@ int main(argc, argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
+ i = 0;
|
||||
num_fds = getdtablesize();
|
||||
#if defined(__linux__)
|
||||
- if (sd_listen_fds(0) <= 0)
|
||||
-#endif
|
||||
- for (i = 0; i < num_fds; i++)
|
||||
+ /* if (sd_booted()) */ {
|
||||
+ const char *e;
|
||||
+ char buf[24] = { '\0' };
|
||||
+ char *p = NULL;
|
||||
+ unsigned long l;
|
||||
+
|
||||
+ /* fork & systemd socket activation:
|
||||
+ * fetch listen pid and update to ours,
|
||||
+ * when it is set to pid of our parent.
|
||||
+ */
|
||||
+ if ( (e = getenv("LISTEN_PID"))) {
|
||||
+ errno = 0;
|
||||
+ l = strtoul(e, &p, 10);
|
||||
+ if (errno == 0 && l > 0 && (!p || !*p)) {
|
||||
+ if (getppid() == (pid_t)l) {
|
||||
+ snprintf(buf, sizeof(buf), "%d",
|
||||
+ getpid());
|
||||
+ setenv("LISTEN_PID", buf, 1);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * init sd_fds and close all fds, except
|
||||
+ * of the fds provided by systemd.
|
||||
+ */
|
||||
+ sd_fds = sd_listen_fds(0);
|
||||
+ for( ; i < SD_LISTEN_FDS_START; i++)
|
||||
(void) close(i);
|
||||
+ if (sd_fds > 0)
|
||||
+ i = SD_LISTEN_FDS_START + sd_fds;
|
||||
+ }
|
||||
+#endif
|
||||
+ for ( ; i < num_fds; i++)
|
||||
+ (void) close(i);
|
||||
untty();
|
||||
break;
|
||||
}
|
||||
@@ -1094,6 +1129,11 @@ int main(argc, argv)
|
||||
exit(1);
|
||||
}
|
||||
} /* if ( !Debug ) */
|
||||
+#if defined(__linux__)
|
||||
+ /* if (sd_booted()) */ {
|
||||
+ sd_fds = sd_listen_fds(0);
|
||||
+ }
|
||||
+#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1367,54 +1407,30 @@ static int create_unix_socket(const char
|
||||
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");
|
||||
+ /*
|
||||
+ * Check whether an FD was passed in from systemd.
|
||||
+ * If so and it matches this socket, so use it.
|
||||
+ */
|
||||
+ if (sd_fds < 0) {
|
||||
+ logerror("Failed to acquire systemd socket");
|
||||
#ifndef SYSV
|
||||
- dienow();
|
||||
+ dienow();
|
||||
#else
|
||||
- return -1;
|
||||
+ 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
|
||||
+ if (sd_fds > 0) {
|
||||
+ for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + sd_fds; fd++) {
|
||||
+ if( sd_is_socket_unix(fd, SOCK_DGRAM, -1, path, 0) == 1) {
|
||||
+ /* ok, it matches -- just use as is */
|
||||
+ return fd;
|
||||
}
|
||||
-
|
||||
- return fd;
|
||||
+ /*
|
||||
+ * otherwise it either didn't matched *this* socket and
|
||||
+ * we just continue to check the next one or there were
|
||||
+ * an error and we will recreate it bellow.
|
||||
+ */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -2537,14 +2553,17 @@ void dienow(void)
|
||||
if (InetInuse) close(inetm);
|
||||
|
||||
/* Clean-up files. */
|
||||
- i = 0;
|
||||
+ for (i = 0; i < nfunix; i++) {
|
||||
+ if (funixn[i] && funix[i] != -1) {
|
||||
#if defined(__linux__)
|
||||
- if (sd_listen_fds(0) > 0)
|
||||
- i = 1;
|
||||
+ if (sd_fds > 0 &&
|
||||
+ funix[i] >= SD_LISTEN_FDS_START &&
|
||||
+ funix[i] < SD_LISTEN_FDS_START + sd_fds)
|
||||
+ continue;
|
||||
#endif
|
||||
- for (; i < nfunix; i++)
|
||||
- if (funixn[i] && funix[i] != -1)
|
||||
(void)unlink(funixn[i]);
|
||||
+ }
|
||||
+ }
|
||||
|
||||
for (lognum = 0; lognum <= nlogs; lognum++) {
|
||||
f = &Files[lognum];
|
29
sysklogd-1.4.1-systemd-sock-name.patch
Normal file
29
sysklogd-1.4.1-systemd-sock-name.patch
Normal file
@ -0,0 +1,29 @@
|
||||
--- syslogd.c
|
||||
+++ syslogd.c 2012/02/20 19:41:22
|
||||
@@ -610,6 +610,10 @@ static char sccsid[] __attribute__ ((un
|
||||
#define _PATH_LOG "/dev/log"
|
||||
#endif
|
||||
|
||||
+#ifndef SYSTEMD_PATH_LOG
|
||||
+#define SYSTEMD_PATH_LOG "/run/systemd/journal/syslog"
|
||||
+#endif
|
||||
+
|
||||
char *ConfFile = _PATH_LOGCONF;
|
||||
char *PidFile = _PATH_LOGPID;
|
||||
char ctty[] = _PATH_CONSOLE;
|
||||
@@ -936,6 +940,15 @@ int main(argc, argv)
|
||||
funix[i] = -1;
|
||||
}
|
||||
|
||||
+ /* systemd >= 38 wants we use /run/systemd/journal/syslog,
|
||||
+ * instead of /dev/log, but allow to override it using -p */
|
||||
+ if(sd_booted()) {
|
||||
+ struct stat st;
|
||||
+ if(stat(SYSTEMD_PATH_LOG, &st) != -1 && S_ISSOCK(st.st_mode)) {
|
||||
+ funixn[0] = SYSTEMD_PATH_LOG;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:tvS")) != EOF)
|
||||
switch((char)ch) {
|
||||
case 'a':
|
123
sysklogd-1.4.1-systemd.dif
Normal file
123
sysklogd-1.4.1-systemd.dif
Normal file
@ -0,0 +1,123 @@
|
||||
---
|
||||
Makefile | 4 +--
|
||||
syslogd.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
|
||||
2 files changed, 67 insertions(+), 5 deletions(-)
|
||||
|
||||
--- Makefile
|
||||
+++ Makefile 2022-10-17 09:00:32.945828594 +0000
|
||||
@@ -20,7 +20,7 @@
|
||||
CC= gcc
|
||||
#SKFLAGS= -g -DSYSV -Wall
|
||||
#LDFLAGS= -g
|
||||
-SKFLAGS= $(RPM_OPT_FLAGS) -DINET6 -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce
|
||||
+SKFLAGS= $(RPM_OPT_FLAGS) -DINET6 -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce -I.
|
||||
# -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
|
||||
# -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
|
||||
# $(shell getconf LFS_SKFLAGS)
|
||||
@@ -43,7 +43,7 @@ MANDIR = $(prefix)/usr/share/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 2022-10-17 08:59:33.354879789 +0000
|
||||
@@ -558,6 +558,7 @@ static char sccsid[] __attribute__ ((un
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <paths.h>
|
||||
+#include <systemd/sd-daemon.h>
|
||||
#endif
|
||||
|
||||
#ifndef UTMP_FILE
|
||||
@@ -1047,8 +1048,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;
|
||||
}
|
||||
@@ -1362,6 +1366,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));
|
||||
@@ -2480,7 +2537,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]);
|
||||
|
160
sysklogd-1.4.1-unix_sockets.patch
Normal file
160
sysklogd-1.4.1-unix_sockets.patch
Normal file
@ -0,0 +1,160 @@
|
||||
---
|
||||
syslog.conf.5 | 10 +++++++
|
||||
syslogd.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
|
||||
2 files changed, 82 insertions(+), 4 deletions(-)
|
||||
|
||||
--- syslog.conf.5
|
||||
+++ syslog.conf.5 2022-10-14 13:18:21.953821655 +0000
|
||||
@@ -173,6 +173,16 @@ command before
|
||||
.BR syslogd (8)
|
||||
is started.
|
||||
|
||||
+.SS Unix Socket (UDP)
|
||||
+This version of
|
||||
+.BR syslogd (8)
|
||||
+has support for logging output to named sockets (UDP UNIX domain sockets).
|
||||
+A named socket can be used as a destination for log messages by prepending
|
||||
+a double at-sign symbol (``@@'') to the pathname of the socket file. This
|
||||
+feature is useful for applications that need to process all logged messages.
|
||||
+All they need to do is open the named socket for reading and then process
|
||||
+the messages as they are received.
|
||||
+
|
||||
.SS Terminal and Console
|
||||
If the file you specified is a tty, special tty-handling is done, same
|
||||
with
|
||||
--- syslogd.c
|
||||
+++ syslogd.c 2022-10-14 13:25:41.625956092 +0000
|
||||
@@ -688,6 +688,10 @@ struct filed {
|
||||
struct sockaddr_in f_addr;
|
||||
#endif
|
||||
} f_forw; /* forwarding address */
|
||||
+ struct {
|
||||
+ struct sockaddr_un su_addr; /* destination address */
|
||||
+ int su_addrlen; /* address len */
|
||||
+ } f_usock; /* UNIX domain socket address */
|
||||
char f_fname[MAXFNAME];
|
||||
} f_un;
|
||||
char f_prevline[MAXSVLINE]; /* last message logged */
|
||||
@@ -699,6 +703,8 @@ struct filed {
|
||||
int f_repeatcount; /* number of "repeated" msgs */
|
||||
int f_flags; /* store some additional flags */
|
||||
};
|
||||
+#define fus_su f_un.f_usock.su_addr
|
||||
+#define fus_sal f_un.f_usock.su_addrlen
|
||||
|
||||
/*
|
||||
* Intervals at which we flush out "message repeated" messages,
|
||||
@@ -729,10 +735,11 @@ int repeatinterval[] = { 30, 60 }; /* #
|
||||
#define F_FORW_SUSP 7 /* suspended host forwarding */
|
||||
#define F_FORW_UNKN 8 /* unknown host forwarding */
|
||||
#define F_PIPE 9 /* named pipe */
|
||||
+#define F_USOCK 10 /* UNIX domain UDP socket */
|
||||
char *TypeNames[] = {
|
||||
"UNUSED", "FILE", "TTY", "CONSOLE",
|
||||
"FORW", "USERS", "WALL", "FORW(SUSPENDED)",
|
||||
- "FORW(UNKNOWN)", "PIPE"
|
||||
+ "FORW(UNKNOWN)", "PIPE", "USOCK"
|
||||
};
|
||||
|
||||
struct filed *Files = (struct filed *) 0;
|
||||
@@ -2050,6 +2057,32 @@ void fprintlog(f, from, flags, msg)
|
||||
(void) fsync(f->f_file);
|
||||
break;
|
||||
|
||||
+ case F_USOCK:
|
||||
+ f->f_time = now;
|
||||
+ dprintf(" %s\n", f->fus_su.sun_path[0] ? f->fus_su.sun_path : "<undefined>");
|
||||
+ if (f->f_file != -1) {
|
||||
+ int l;
|
||||
+ char line[MAXLINE +1];
|
||||
+
|
||||
+ int chunk_len,dstbuf_size = 0;
|
||||
+ for (l = 0;l < 5;l++) {
|
||||
+ if( (chunk_len = iov[l].iov_len) > (sizeof(line) - dstbuf_size))
|
||||
+ chunk_len = sizeof(line) - dstbuf_size;
|
||||
+ if(chunk_len > 0) {
|
||||
+ memcpy(&line[dstbuf_size],iov[l].iov_base,chunk_len);
|
||||
+ dstbuf_size += chunk_len;
|
||||
+ }
|
||||
+ }
|
||||
+ if ((l = dstbuf_size) > MAXLINE) l = MAXLINE;
|
||||
+ line[l] = 0;
|
||||
+ if (sendto(f->f_file, line, l, MSG_DONTWAIT,
|
||||
+ (struct sockaddr*) &f->fus_su, f->fus_sal) != l) {
|
||||
+ dprintf("sendto error - \"%s\"\n",strerror(errno));
|
||||
+ /* sendto error must be ignored */
|
||||
+ }
|
||||
+ }
|
||||
+ break;
|
||||
+
|
||||
case F_USERS:
|
||||
case F_WALL:
|
||||
f->f_time = now;
|
||||
@@ -2462,6 +2495,7 @@ void init()
|
||||
case F_PIPE:
|
||||
case F_TTY:
|
||||
case F_CONSOLE:
|
||||
+ case F_USOCK:
|
||||
(void) close(f->f_file);
|
||||
break;
|
||||
}
|
||||
@@ -2614,7 +2648,11 @@ void init()
|
||||
case F_PIPE:
|
||||
case F_TTY:
|
||||
case F_CONSOLE:
|
||||
- printf("%s", f->f_un.f_fname);
|
||||
+ case F_USOCK:
|
||||
+ if(f->f_type == F_USOCK)
|
||||
+ printf("%s", f->fus_su.sun_path[0] ? f->fus_su.sun_path : "<undefined>");
|
||||
+ else
|
||||
+ printf("%s", f->f_un.f_fname);
|
||||
if (f->f_file == -1)
|
||||
printf(" (unused)");
|
||||
break;
|
||||
@@ -2832,14 +2870,44 @@ void cfline(line, f)
|
||||
switch (*p)
|
||||
{
|
||||
case '@':
|
||||
+ if(*(++p) == '@') {
|
||||
+ /* We need to set up for output to a named socket...
|
||||
+ */
|
||||
+ memset((char *)&f->fus_su, 0, sizeof(f->fus_su));
|
||||
+ (void)strncpy(f->fus_su.sun_path, ++p,
|
||||
+ sizeof(f->fus_su.sun_path)-1);
|
||||
+ f->fus_su.sun_path[sizeof(f->fus_su.sun_path)-1] = 0;
|
||||
+ dprintf ("unix socket filename: %s\n",
|
||||
+ f->fus_su.sun_path);
|
||||
+ f->fus_su.sun_family = AF_UNIX;
|
||||
+ if( (f->f_file = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0) {
|
||||
+ dprintf("Can't create unix socket\n");
|
||||
+ logerror("Can't create unix socket");
|
||||
+ break;
|
||||
+ }
|
||||
+ f->fus_sal = strlen(f->fus_su.sun_path) +
|
||||
+ sizeof(f->fus_su.sun_family);
|
||||
+ f->f_type = F_USOCK;
|
||||
+
|
||||
+ /* Make sure that pathname exists...
|
||||
+ */
|
||||
+ if (bind(f->f_file, (struct sockaddr *)&f->fus_su, f->fus_sal) < 0 ||
|
||||
+ (chmod(f->fus_su.sun_path, 0666) < 0)) {
|
||||
+ dprintf("Can't bind unix socket to name\n");
|
||||
+ logerror("Can't bind unix unix socket to name");
|
||||
+ break;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
#ifdef SYSLOG_INET
|
||||
+#ifndef INET6
|
||||
if (!LogPort) {
|
||||
f->f_type = F_UNUSED;
|
||||
logerror("Forward rule without networking enabled");
|
||||
break;
|
||||
}
|
||||
-
|
||||
- (void) strcpy(f->f_un.f_forw.f_hname, ++p);
|
||||
+#endif
|
||||
+ (void) strcpy(f->f_un.f_forw.f_hname, p);
|
||||
dprintf("forwarding host: %s\n", p); /*ASP*/
|
||||
#ifdef INET6
|
||||
f->f_type = F_FORW_UNKN;
|
584
sysklogd-1.4.1.dif
Normal file
584
sysklogd-1.4.1.dif
Normal file
@ -0,0 +1,584 @@
|
||||
---
|
||||
Makefile | 24 ++++++++++++----------
|
||||
klogd.c | 57 ++++++++++++++++++++++++++++++++++++++++------------
|
||||
pidfile.c | 10 ++++-----
|
||||
resolve.c | 21 ++++++++++++++++---
|
||||
sample-s390.conf | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
sample.conf | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
syslog.c | 7 +++++-
|
||||
syslogd.c | 51 ++++++++++++++++++++++++++++------------------
|
||||
8 files changed, 238 insertions(+), 52 deletions(-)
|
||||
|
||||
--- Makefile
|
||||
+++ Makefile 2022-10-19 09:50:35.677760471 +0000
|
||||
@@ -17,20 +17,23 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
+# For newer Kernel we have 16k buffer size
|
||||
+LOG_BUFFER_SIZE = -DLOG_BUFFER_SIZE=16384
|
||||
+
|
||||
CC= gcc
|
||||
#SKFLAGS= -g -DSYSV -Wall
|
||||
#LDFLAGS= -g
|
||||
-SKFLAGS= $(RPM_OPT_FLAGS) -DINET6 -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce -I.
|
||||
+SKFLAGS= $(RPM_OPT_FLAGS) -D_GNU_SOURCE -DINET6 -DSYSV -Wall $(LOG_BUFFER_SIZE) -fPIE -I.
|
||||
# -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
|
||||
# -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
|
||||
# $(shell getconf LFS_SKFLAGS)
|
||||
-LDFLAGS= -s
|
||||
+LDFLAGS= -pie
|
||||
|
||||
# Look where your install program is.
|
||||
INSTALL = /usr/bin/install
|
||||
|
||||
# Destination paths, set prefix=/opt if required
|
||||
-BINDIR = $(prefix)/usr/sbin
|
||||
+BINDIR = $(prefix)/sbin
|
||||
MANDIR = $(prefix)/usr/share/man
|
||||
|
||||
# There is one report that under an all ELF system there may be a need to
|
||||
@@ -47,7 +50,7 @@ LIBS += $(shell pkg-config libsystemd --
|
||||
|
||||
# Define the following to impart start-up delay in klogd. This is
|
||||
# useful if klogd is started simultaneously or in close-proximity to syslogd.
|
||||
-# KLOGD_START_DELAY = -DKLOGD_DELAY=5
|
||||
+KLOGD_START_DELAY = -DKLOGD_DELAY=5
|
||||
|
||||
# The following define determines whether the package adheres to the
|
||||
# file system standard.
|
||||
@@ -127,14 +130,15 @@ clobber: clean
|
||||
rm -f syslogd klogd ksym syslog_tst oops_test TAGS tsyslogd tklogd
|
||||
|
||||
install_exec: syslogd klogd
|
||||
- ${INSTALL} -m 500 -s syslogd ${BINDIR}/syslogd
|
||||
- ${INSTALL} -m 500 -s klogd ${BINDIR}/klogd
|
||||
+ ${INSTALL} -m 500 -s syslogd ${DESTDIR}${BINDIR}/syslogd
|
||||
+ ${INSTALL} -m 500 -s klogd ${DESTDIR}${BINDIR}/klogd
|
||||
+ ${INSTALL} -m 644 sample.conf ${DESTDIR}/etc/syslog.conf
|
||||
|
||||
install_man:
|
||||
- ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} sysklogd.8 ${MANDIR}/man8/sysklogd.8
|
||||
- ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} syslogd.8 ${MANDIR}/man8/syslogd.8
|
||||
- ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} syslog.conf.5 ${MANDIR}/man5/syslog.conf.5
|
||||
- ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} klogd.8 ${MANDIR}/man8/klogd.8
|
||||
+ ${INSTALL} -m ${MAN_PERMS} sysklogd.8 ${DESTDIR}${MANDIR}/man8/sysklogd.8
|
||||
+ ${INSTALL} -m ${MAN_PERMS} syslogd.8 ${DESTDIR}${MANDIR}/man8/syslogd.8
|
||||
+ ${INSTALL} -m ${MAN_PERMS} syslog.conf.5 ${DESTDIR}${MANDIR}/man5/syslog.conf.5
|
||||
+ ${INSTALL} -m ${MAN_PERMS} klogd.8 ${DESTDIR}${MANDIR}/man8/klogd.8
|
||||
|
||||
obj-m += oops.o
|
||||
|
||||
--- klogd.c
|
||||
+++ klogd.c 2022-10-19 09:50:35.677760471 +0000
|
||||
@@ -289,15 +289,21 @@ _syscall3(int,ksyslog,int, type, char *,
|
||||
|
||||
#include <sys/utsname.h>
|
||||
|
||||
-#define LOG_BUFFER_SIZE 4096
|
||||
+#ifndef _PATH_KLOG
|
||||
+# define _PATH_KLOG "/proc/kmsg"
|
||||
+#endif
|
||||
+
|
||||
+#ifndef LOG_BUFFER_SIZE
|
||||
+# define LOG_BUFFER_SIZE 4096
|
||||
+#endif
|
||||
#define LOG_LINE_LENGTH 1000
|
||||
|
||||
#ifndef TESTING
|
||||
-#if defined(FSSTND)
|
||||
+# if defined(FSSTND)
|
||||
static char *PidFile = _PATH_VARRUN "klogd.pid";
|
||||
-#else
|
||||
+# else
|
||||
static char *PidFile = "/etc/klogd.pid";
|
||||
-#endif
|
||||
+# endif
|
||||
#endif
|
||||
|
||||
#include "fortify.h"
|
||||
@@ -311,6 +317,8 @@ static int kmsg,
|
||||
|
||||
static int use_syscall = 0,
|
||||
one_shot = 0,
|
||||
+ ring_buf = 0,
|
||||
+ ring_buf_clear = 0,
|
||||
symbol_lookup = 1,
|
||||
no_fork = 0; /* don't fork - don't run in daemon mode */
|
||||
|
||||
@@ -891,8 +899,7 @@ static void LogLine(char *ptr, int len)
|
||||
value = strtoul(sym_start+1, (char **) 0, 16);
|
||||
*(line-1) = '>'; /* put back delim */
|
||||
|
||||
- symbol = LookupSymbol(value, &sym);
|
||||
- if ( !symbol_lookup || symbol == (char *) 0 )
|
||||
+ if ( !symbol_lookup || (symbol = LookupSymbol(value, &sym)) == (char *) 0 )
|
||||
{
|
||||
parse_state = PARSING_TEXT;
|
||||
break;
|
||||
@@ -933,7 +940,7 @@ static void LogLine(char *ptr, int len)
|
||||
static void LogKernelLine(void)
|
||||
|
||||
{
|
||||
- auto int rdcnt;
|
||||
+ auto int rdcnt, lvl;
|
||||
|
||||
/*
|
||||
* Zero-fill the log buffer. This should cure a multitude of
|
||||
@@ -942,6 +949,11 @@ static void LogKernelLine(void)
|
||||
* messages into this fresh buffer.
|
||||
*/
|
||||
memset(log_buffer, '\0', log_buf_size);
|
||||
+ lvl = 2;
|
||||
+ if (one_shot) {
|
||||
+ if (ring_buf) lvl = 3;
|
||||
+ if (ring_buf_clear) lvl = 4;
|
||||
+ }
|
||||
if ( (rdcnt = ksyslog(2, log_buffer, log_buf_size-1)) < 0 )
|
||||
{
|
||||
if ( errno == EINTR )
|
||||
@@ -1051,10 +1063,15 @@ int main(argc, argv)
|
||||
|
||||
#ifndef TESTING
|
||||
pid_t ppid = getpid();
|
||||
- chdir ("/");
|
||||
+ if (chdir ("/") < 0) {
|
||||
+ fprintf(stderr,
|
||||
+ "klogd: Can not change to root directory: %s\n",
|
||||
+ strerror(errno));
|
||||
+ exit(1);
|
||||
+ }
|
||||
#endif
|
||||
/* Parse the command-line. */
|
||||
- while ((ch = getopt(argc, argv, "c:df:iIk:nopsvx2")) != EOF)
|
||||
+ while ((ch = getopt(argc, argv, "c:df:iIk:nopsvx2rR")) != EOF)
|
||||
switch((char)ch)
|
||||
{
|
||||
case '2': /* Print lines with symbols twice. */
|
||||
@@ -1085,6 +1102,14 @@ int main(argc, argv)
|
||||
case 'o': /* One-shot mode. */
|
||||
one_shot = 1;
|
||||
break;
|
||||
+ case 'r': /* One-shot mode. */
|
||||
+ one_shot = 1;
|
||||
+ ring_buf = 1;
|
||||
+ break;
|
||||
+ case 'R': /* One-shot mode. */
|
||||
+ one_shot = 1;
|
||||
+ ring_buf_clear = 1;
|
||||
+ break;
|
||||
case 'p':
|
||||
SetParanoiaLevel(1); /* Load symbols on oops. */
|
||||
break;
|
||||
@@ -1229,8 +1254,11 @@ int main(argc, argv)
|
||||
if ( one_shot )
|
||||
{
|
||||
if (symbol_lookup) {
|
||||
- InitKsyms(symfile);
|
||||
- InitMsyms();
|
||||
+ /* Both functions return 1 at success and 0 otherwise */
|
||||
+ symbol_lookup = InitKsyms(symfile);
|
||||
+ symbol_lookup |= InitMsyms();
|
||||
+ if (!symbol_lookup)
|
||||
+ Syslog(LOG_WARNING, "Cannot build symbol table - disabling symbol lookups");
|
||||
}
|
||||
if ( (logsrc = GetKernelLogSrc()) == kernel )
|
||||
LogKernelLine();
|
||||
@@ -1245,8 +1273,11 @@ int main(argc, argv)
|
||||
#endif
|
||||
logsrc = GetKernelLogSrc();
|
||||
if (symbol_lookup) {
|
||||
- InitKsyms(symfile);
|
||||
- InitMsyms();
|
||||
+ /* Both functions return 1 at success and 0 otherwise */
|
||||
+ symbol_lookup = InitKsyms(symfile);
|
||||
+ symbol_lookup |= InitMsyms();
|
||||
+ if (!symbol_lookup)
|
||||
+ Syslog(LOG_WARNING, "Cannot build symbol table - disabling symbol lookups");
|
||||
}
|
||||
|
||||
#ifndef TESTING
|
||||
--- pidfile.c
|
||||
+++ pidfile.c 2022-10-19 09:50:35.677760471 +0000
|
||||
@@ -46,11 +46,11 @@
|
||||
int read_pid (char *pidfile)
|
||||
{
|
||||
FILE *f;
|
||||
- int pid;
|
||||
+ int pid = 0;
|
||||
|
||||
if (!(f=fopen(pidfile,"r")))
|
||||
return 0;
|
||||
- fscanf(f,"%d", &pid);
|
||||
+ (void)fscanf(f,"%d", &pid);
|
||||
fclose(f);
|
||||
return pid;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ int write_pid (char *pidfile)
|
||||
{
|
||||
FILE *f;
|
||||
int fd;
|
||||
- int pid;
|
||||
+ int pid = 0;
|
||||
#if defined(USE_FCNTL) && (USE_FCNTL != 0)
|
||||
struct flock lck;
|
||||
#endif
|
||||
@@ -115,14 +115,14 @@ int write_pid (char *pidfile)
|
||||
}
|
||||
#else
|
||||
if (flock(fd, LOCK_EX|LOCK_NB) == -1) {
|
||||
- fscanf(f, "%d", &pid);
|
||||
+ (void)fscanf(f, "%d", &pid);
|
||||
fclose(f);
|
||||
fprintf(stderr, "Can't lock, lock is held by pid %d.\n", pid);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
- pid = getpid();
|
||||
+ pid = (int)getpid();
|
||||
if (!fprintf(f,"%d\n", pid)) {
|
||||
fprintf(stderr, "Can't write pid , %s.\n", strerror(errno));
|
||||
close(fd);
|
||||
--- resolve.c
|
||||
+++ resolve.c 2022-10-19 09:50:35.677760471 +0000
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
+#include <errno.h>
|
||||
|
||||
#if defined(__GLIBC__)
|
||||
#define dprintf mydprintf
|
||||
@@ -208,7 +209,7 @@ do_query(int fd, int family, const char
|
||||
{
|
||||
struct sockaddr_storage ss;
|
||||
struct addrinfo hints, *res;
|
||||
- int r;
|
||||
+ int r, c;
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
@@ -244,6 +245,20 @@ do_query(int fd, int family, const char
|
||||
} else {
|
||||
memcpy(&ss, res->ai_addr, res->ai_addrlen);
|
||||
}
|
||||
- write(fd, &ss, sizeof(ss));
|
||||
- exit(0);
|
||||
+
|
||||
+ c = 100;
|
||||
+ do {
|
||||
+ if ((r = write(fd, &ss, sizeof(ss))) < 0) {
|
||||
+ if ((errno != EAGAIN) && (errno != EINTR)) {
|
||||
+ dprintf("failed to write: %s\n", strerror(errno));
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ usleep(50000);
|
||||
+ }
|
||||
+ } while ((r < 0) && (c-- > 0));
|
||||
+
|
||||
+ if (r >= 0)
|
||||
+ exit(0);
|
||||
+ dprintf("failed to write: %s\n", strerror(errno));
|
||||
+ exit(1);
|
||||
}
|
||||
--- sample-s390.conf
|
||||
+++ sample-s390.conf 2022-10-19 09:50:35.677760471 +0000
|
||||
@@ -0,0 +1,60 @@
|
||||
+# /etc/syslog.conf - Configuration file for syslogd(8)
|
||||
+#
|
||||
+# For info about the format of this file, see "man syslog.conf".
|
||||
+#
|
||||
+
|
||||
+#
|
||||
+#
|
||||
+# print most on /dev/console and on the xconsole pipe
|
||||
+#
|
||||
+kern.*;*.warning;news.emerg;mail.alert;authpriv.none /dev/console
|
||||
+kern.*;*.warning;news.err;mail.err;authpriv.none |/dev/xconsole
|
||||
+*.emerg *
|
||||
+
|
||||
+# enable this, if you want that root is informed
|
||||
+# immediately, e.g. of logins
|
||||
+#*.alert root
|
||||
+
|
||||
+
|
||||
+#
|
||||
+# all email-messages in one file
|
||||
+#
|
||||
+mail.* -/var/log/mail
|
||||
+mail.info -/var/log/mail.info
|
||||
+mail.warning -/var/log/mail.warn
|
||||
+mail.err /var/log/mail.err
|
||||
+
|
||||
+#
|
||||
+# all news-messages
|
||||
+#
|
||||
+# these files are rotated and examined by "news.daily"
|
||||
+news.crit -/var/log/news/news.crit
|
||||
+news.err -/var/log/news/news.err
|
||||
+news.notice -/var/log/news/news.notice
|
||||
+# enable this, if you want to keep all news messages
|
||||
+# in one file
|
||||
+#news.* -/var/log/news.all
|
||||
+
|
||||
+#
|
||||
+# Warnings in one file
|
||||
+#
|
||||
+*.=warning;*.=err -/var/log/warn
|
||||
+*.crit /var/log/warn
|
||||
+
|
||||
+#
|
||||
+# save the rest in one file
|
||||
+#
|
||||
+*.*;mail.none;news.none -/var/log/messages
|
||||
+
|
||||
+#
|
||||
+# enable this, if you want to keep all messages
|
||||
+# in one file
|
||||
+#*.* -/var/log/allmessages
|
||||
+
|
||||
+#
|
||||
+# Some foreign boot scripts require local7
|
||||
+#
|
||||
+local0,local1.* -/var/log/localmessages
|
||||
+local2,local3.* -/var/log/localmessages
|
||||
+local4,local5.* -/var/log/localmessages
|
||||
+local6,local7.* -/var/log/localmessages
|
||||
--- sample.conf
|
||||
+++ sample.conf 2022-10-19 09:50:35.677760471 +0000
|
||||
@@ -0,0 +1,60 @@
|
||||
+# /etc/syslog.conf - Configuration file for syslogd(8)
|
||||
+#
|
||||
+# For info about the format of this file, see "man syslog.conf".
|
||||
+#
|
||||
+
|
||||
+#
|
||||
+#
|
||||
+# print most on tty10 and on the xconsole pipe
|
||||
+#
|
||||
+kern.warning;*.err;authpriv.none /dev/tty10
|
||||
+kern.warning;*.err;authpriv.none |/dev/xconsole
|
||||
+*.emerg *
|
||||
+
|
||||
+# enable this, if you want that root is informed
|
||||
+# immediately, e.g. of logins
|
||||
+#*.alert root
|
||||
+
|
||||
+
|
||||
+#
|
||||
+# all email-messages in one file
|
||||
+#
|
||||
+mail.* -/var/log/mail
|
||||
+mail.info -/var/log/mail.info
|
||||
+mail.warning -/var/log/mail.warn
|
||||
+mail.err /var/log/mail.err
|
||||
+
|
||||
+#
|
||||
+# all news-messages
|
||||
+#
|
||||
+# these files are rotated and examined by "news.daily"
|
||||
+news.crit -/var/log/news/news.crit
|
||||
+news.err -/var/log/news/news.err
|
||||
+news.notice -/var/log/news/news.notice
|
||||
+# enable this, if you want to keep all news messages
|
||||
+# in one file
|
||||
+#news.* -/var/log/news.all
|
||||
+
|
||||
+#
|
||||
+# Warnings in one file
|
||||
+#
|
||||
+*.=warning;*.=err -/var/log/warn
|
||||
+*.crit /var/log/warn
|
||||
+
|
||||
+#
|
||||
+# save the rest in one file
|
||||
+#
|
||||
+*.*;mail.none;news.none -/var/log/messages
|
||||
+
|
||||
+#
|
||||
+# enable this, if you want to keep all messages
|
||||
+# in one file
|
||||
+#*.* -/var/log/allmessages
|
||||
+
|
||||
+#
|
||||
+# Some foreign boot scripts require local7
|
||||
+#
|
||||
+local0,local1.* -/var/log/localmessages
|
||||
+local2,local3.* -/var/log/localmessages
|
||||
+local4,local5.* -/var/log/localmessages
|
||||
+local6,local7.* -/var/log/localmessages
|
||||
--- syslog.c
|
||||
+++ syslog.c 2022-10-19 09:50:35.677760471 +0000
|
||||
@@ -73,7 +73,12 @@ static char sccsid[] = "@(#)syslog.c 5.2
|
||||
#include <paths.h>
|
||||
#include <stdio.h>
|
||||
|
||||
-#define _PATH_LOGNAME "/dev/log"
|
||||
+#ifdef _PATH_LOG
|
||||
+# define _PATH_LOGNAME _PATH_LOG
|
||||
+#endif
|
||||
+#ifndef _PATH_LOGNAME
|
||||
+# define _PATH_LOGNAME "/dev/log"
|
||||
+#endif
|
||||
|
||||
#undef LOG_FAC
|
||||
static inline int LOG_FAC(const int pri)
|
||||
--- syslogd.c
|
||||
+++ syslogd.c 2022-10-19 09:55:06.300950261 +0000
|
||||
@@ -519,6 +519,7 @@ static char sccsid[] __attribute__ ((un
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <utmp.h>
|
||||
+#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <setjmp.h>
|
||||
@@ -651,7 +652,11 @@ int sd_fds = 0;
|
||||
# define UNAMESZ 8 /* length of a login name */
|
||||
#endif
|
||||
#define MAXUNAMES 20 /* maximum number of user names */
|
||||
-#define MAXFNAME 200 /* max file pathname length */
|
||||
+#ifdef _POSIX_PATH_MAX
|
||||
+# define MAXFNAME _POSIX_PATH_MAX
|
||||
+#else
|
||||
+# define MAXFNAME 200 /* max file pathname length */
|
||||
+#endif
|
||||
|
||||
#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */
|
||||
#define TABLE_NOPRI 0 /* Value to indicate no priority in f_pmask */
|
||||
@@ -733,8 +738,8 @@ struct filed {
|
||||
* in seconds after previous message is logged. After each flush,
|
||||
* we move to the next interval until we reach the largest.
|
||||
*/
|
||||
-int repeatinterval[] = { 30, 60 }; /* # of secs before flush */
|
||||
-#define MAXREPEAT ((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1)
|
||||
+time_t repeatinterval[] = { 30, 60 }; /* # of secs before flush */
|
||||
+#define MAXREPEAT ((int)((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1))
|
||||
#define REPEATTIME(f) ((f)->f_time + repeatinterval[(f)->f_repeatcount])
|
||||
#define BACKOFF(f) { if (++(f)->f_repeatcount > MAXREPEAT) \
|
||||
(f)->f_repeatcount = MAXREPEAT; \
|
||||
@@ -849,7 +854,7 @@ int usage(void);
|
||||
static pid_t sid;
|
||||
#endif
|
||||
void untty(void);
|
||||
-void printchopped(const char *hname, char *msg, int len, int fd);
|
||||
+void printchopped(const char *hname, char *msg, size_t len, int fd);
|
||||
void printline(const char *hname, char *msg);
|
||||
void printsys(char *msg);
|
||||
void logmsg(int pri, char *msg, const char *from, int flags);
|
||||
@@ -944,7 +949,12 @@ int main(argc, argv)
|
||||
int maxfds;
|
||||
|
||||
#ifndef TESTING
|
||||
- chdir ("/");
|
||||
+ if (chdir("/") < 0) {
|
||||
+ fprintf(stderr,
|
||||
+ "syslogd: Can not change to root directory: %s\n",
|
||||
+ strerror(errno));
|
||||
+ exit(1);
|
||||
+ }
|
||||
#endif
|
||||
for (i = 1; i < MAXFUNIX; i++) {
|
||||
funixn[i] = "";
|
||||
@@ -1400,7 +1410,7 @@ int main(argc, argv)
|
||||
parts[fileno(stdin)] = (char *) 0;
|
||||
i = read(fileno(stdin), line, MAXLINE);
|
||||
if (i > 0) {
|
||||
- printchopped(LocalHostName, line, i+1, fileno(stdin));
|
||||
+ printchopped(LocalHostName, line, (size_t)(i+1), fileno(stdin));
|
||||
} else if (i < 0) {
|
||||
if (errno != EINTR) {
|
||||
logerror("stdin");
|
||||
@@ -1474,8 +1484,9 @@ static int create_unix_socket(const char
|
||||
close(fd);
|
||||
#ifndef SYSV
|
||||
dienow();
|
||||
-#endif
|
||||
+#else
|
||||
return -1;
|
||||
+#endif
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
@@ -1660,7 +1671,7 @@ void untty()
|
||||
void printchopped(hname, msg, len, fd)
|
||||
const char *hname;
|
||||
char *msg;
|
||||
- int len;
|
||||
+ size_t len;
|
||||
int fd;
|
||||
{
|
||||
auto int ptlngth;
|
||||
@@ -1771,6 +1782,8 @@ void printline(hname, msg)
|
||||
while ((c = *p++) && q < &line[sizeof(line) - 4]) {
|
||||
if (c == '\n' || c == 127)
|
||||
*q++ = ' ';
|
||||
+ else if (c == '\t')
|
||||
+ *q++ = c;
|
||||
else if (c < 040) {
|
||||
*q++ = '^';
|
||||
*q++ = c ^ 0100;
|
||||
@@ -1954,7 +1967,7 @@ void logmsg(pri, msg, from, flags)
|
||||
!strcmp(from, f->f_prevhost)) {
|
||||
(void) strncpy(f->f_lasttime, timestamp, 15);
|
||||
f->f_prevcount++;
|
||||
- dprintf("msg repeated %d times, %ld sec of %d.\n",
|
||||
+ dprintf("msg repeated %d times, %ld sec of %ld.\n",
|
||||
f->f_prevcount, now - f->f_time,
|
||||
repeatinterval[f->f_repeatcount]);
|
||||
/*
|
||||
@@ -2293,15 +2306,7 @@ void wallmsg(f, iov)
|
||||
register struct filed *f;
|
||||
struct iovec *iov;
|
||||
{
|
||||
- char p[sizeof (_PATH_DEV) + UNAMESZ];
|
||||
- register int i;
|
||||
- int ttyf, len;
|
||||
static int reenter = 0;
|
||||
- struct utmp ut;
|
||||
- struct utmp *uptr;
|
||||
- char greetings[200];
|
||||
-
|
||||
- (void) &len;
|
||||
|
||||
if (reenter++)
|
||||
return;
|
||||
@@ -2309,12 +2314,18 @@ void wallmsg(f, iov)
|
||||
/* open the user login file */
|
||||
setutent();
|
||||
|
||||
-
|
||||
/*
|
||||
* Might as well fork instead of using nonblocking I/O
|
||||
* and doing notty().
|
||||
*/
|
||||
if (fork() == 0) {
|
||||
+ char p[sizeof (_PATH_DEV) + UNAMESZ];
|
||||
+ register int i;
|
||||
+ int ttyf, len;
|
||||
+ struct utmp ut;
|
||||
+ struct utmp *uptr;
|
||||
+ char greetings[200];
|
||||
+
|
||||
(void) signal(SIGTERM, SIG_DFL);
|
||||
(void) alarm(0);
|
||||
(void) snprintf(greetings, sizeof(greetings),
|
||||
@@ -2358,7 +2369,7 @@ void wallmsg(f, iov)
|
||||
iov[1].iov_len = 0;
|
||||
}
|
||||
if (setjmp(ttybuf) == 0) {
|
||||
- (void) signal(SIGALRM, endtty);
|
||||
+ (void) resignal(SIGALRM, endtty);
|
||||
(void) alarm(15);
|
||||
/* open the terminal */
|
||||
ttyf = open(p, O_WRONLY|O_NOCTTY);
|
||||
@@ -2521,7 +2532,7 @@ void domark()
|
||||
for (f = Files; f; f = f->f_next) {
|
||||
#endif
|
||||
if (f->f_prevcount && now >= REPEATTIME(f)) {
|
||||
- dprintf("flush %s: repeated %d times, %d sec.\n",
|
||||
+ dprintf("flush %s: repeated %d times, %ld sec.\n",
|
||||
TypeNames[f->f_type], f->f_prevcount,
|
||||
repeatinterval[f->f_repeatcount]);
|
||||
fprintlog(f, LocalHostName, 0, (char *)NULL);
|
BIN
sysklogd-1.5.1.tar.gz
(Stored with Git LFS)
Normal file
BIN
sysklogd-1.5.1.tar.gz
(Stored with Git LFS)
Normal file
Binary file not shown.
501
sysklogd-ipv6.diff
Normal file
501
sysklogd-ipv6.diff
Normal file
@ -0,0 +1,501 @@
|
||||
---
|
||||
CHANGES | 3
|
||||
Makefile | 2
|
||||
syslogd.c | 228 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
|
||||
3 files changed, 210 insertions(+), 23 deletions(-)
|
||||
|
||||
--- CHANGES
|
||||
+++ CHANGES 2022-10-13 08:13:35.285747318 +0000
|
||||
@@ -72,6 +72,9 @@ Version 1.5
|
||||
. Matthew Fischer <futhark@vzavenue.net>
|
||||
- Remove special treatment of the percent sign in klogd
|
||||
|
||||
+Version 1.4.1-usagi (2001/03/21)
|
||||
+ - syslogd IPv6 support
|
||||
+ (based on patch from Hiroyuki YAMAMORI <h-yamamo@db3.so-net.ne.jp>)
|
||||
|
||||
Version 1.4.1
|
||||
|
||||
--- Makefile
|
||||
+++ Makefile 2022-10-13 08:30:44.607385067 +0000
|
||||
@@ -20,7 +20,7 @@
|
||||
CC= gcc
|
||||
#SKFLAGS= -g -DSYSV -Wall
|
||||
#LDFLAGS= -g
|
||||
-SKFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce
|
||||
+SKFLAGS= $(RPM_OPT_FLAGS) -DINET6 -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce
|
||||
# -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
|
||||
# -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
|
||||
# $(shell getconf LFS_SKFLAGS)
|
||||
--- syslogd.c
|
||||
+++ syslogd.c 2022-10-13 08:30:05.088090073 +0000
|
||||
@@ -654,6 +654,7 @@ int funix[MAXFUNIX] = { -1, };
|
||||
* This table contains plain text for h_errno errors used by the
|
||||
* net subsystem.
|
||||
*/
|
||||
+#ifndef INET6 /* not */
|
||||
const char *sys_h_errlist[] = {
|
||||
"No problem", /* NETDB_SUCCESS */
|
||||
"Authoritative answer: host not found", /* HOST_NOT_FOUND */
|
||||
@@ -662,6 +663,7 @@ const char *sys_h_errlist[] = {
|
||||
"Valid name, no data record of requested type", /* NO_DATA */
|
||||
"no address, look for MX record" /* NO_ADDRESS */
|
||||
};
|
||||
+#endif
|
||||
|
||||
/*
|
||||
* This structure represents the files that will have log
|
||||
@@ -680,7 +682,18 @@ struct filed {
|
||||
char f_uname[MAXUNAMES][UNAMESZ+1];
|
||||
struct {
|
||||
char f_hname[MAXHOSTNAMELEN+1];
|
||||
+#ifdef INET6
|
||||
+ union {
|
||||
+ struct sockaddr sa;
|
||||
+ struct sockaddr_in sin;
|
||||
+ struct sockaddr_in6 sin6;
|
||||
+ } f_sa;
|
||||
+#define f_addr f_sa.sa
|
||||
+#define f_addr4 f_sa.sin
|
||||
+#define f_addr6 f_sa.sin6
|
||||
+#else
|
||||
struct sockaddr_in f_addr;
|
||||
+#endif
|
||||
} f_forw; /* forwarding address */
|
||||
char f_fname[MAXFNAME];
|
||||
} f_un;
|
||||
@@ -788,7 +801,11 @@ char *LocalDomain; /* our local domain
|
||||
char *emptystring = "";
|
||||
int InetInuse = 0; /* non-zero if INET sockets are being used */
|
||||
int finet = -1; /* Internet datagram socket */
|
||||
+#ifdef INET6
|
||||
+sa_family_t family; /* socket address family */
|
||||
+#else
|
||||
int LogPort; /* port number for INET connections */
|
||||
+#endif
|
||||
int Initialized = 0; /* set when we have initialized ourselves */
|
||||
int MarkInterval = 20 * 60; /* interval between marks in seconds */
|
||||
int MarkSeq = 0; /* mark sequence number */
|
||||
@@ -815,10 +832,10 @@ void fprintlog(register struct filed *f,
|
||||
void endtty();
|
||||
void wallmsg(register struct filed *f, struct iovec *iov);
|
||||
void reapchild();
|
||||
-const char *cvthname(struct sockaddr_in *f);
|
||||
+const char *cvthname(struct sockaddr *f);
|
||||
void domark();
|
||||
void debug_switch();
|
||||
-void logerror(char *type);
|
||||
+void logerror(const char *type);
|
||||
void die(int sig);
|
||||
#ifndef TESTING
|
||||
void doexit(int sig);
|
||||
@@ -838,6 +855,10 @@ static int create_unix_socket(const char
|
||||
#endif
|
||||
#ifdef SYSLOG_INET
|
||||
static int create_inet_socket();
|
||||
+#ifdef INET6
|
||||
+static void setup_inetaddr_all();
|
||||
+static const char *setup_inetaddr(struct filed *f);
|
||||
+#endif
|
||||
#endif
|
||||
|
||||
int main(argc, argv)
|
||||
@@ -875,7 +896,12 @@ int main(argc, argv)
|
||||
#ifndef TESTING
|
||||
int fd;
|
||||
#ifdef SYSLOG_INET
|
||||
+#ifdef INET6
|
||||
+ struct sockaddr_storage frominet;
|
||||
+ char hbuf[INET6_ADDRSTRLEN];
|
||||
+#else
|
||||
struct sockaddr_in frominet;
|
||||
+#endif
|
||||
char *from;
|
||||
#endif
|
||||
pid_t ppid = getpid();
|
||||
@@ -1204,10 +1230,21 @@ int main(argc, argv)
|
||||
memset(line, 0, sizeof(line));
|
||||
msglen = recvfrom(finet, line, MAXLINE - 2, 0, \
|
||||
(struct sockaddr *) &frominet, &len);
|
||||
+#ifdef INET6
|
||||
+ if (getnameinfo((struct sockaddr *)&frominet, len,
|
||||
+ hbuf, sizeof(hbuf), NULL, 0,
|
||||
+ NI_NUMERICHOST)) {
|
||||
+ strcpy(hbuf, "???");
|
||||
+ }
|
||||
+ dprintf("Message from inetd socket: #%d, host: %s\n",
|
||||
+ inetm, hbuf);
|
||||
+#else
|
||||
+
|
||||
dprintf("Message from inetd socket: #%d, host: %s\n",
|
||||
inetm, inet_ntoa(frominet.sin_addr));
|
||||
+#endif
|
||||
if (msglen > 0) {
|
||||
- from = (char *)cvthname(&frominet);
|
||||
+ from = (char *)cvthname((struct sockaddr*)&frominet);
|
||||
/*
|
||||
* Here we could check if the host is permitted
|
||||
* to send us syslog messages. We just have to
|
||||
@@ -1293,18 +1330,51 @@ static int create_unix_socket(const char
|
||||
static int create_inet_socket()
|
||||
{
|
||||
int fd, on = 1;
|
||||
+#ifdef INET6
|
||||
+ struct addrinfo hints, *res;
|
||||
+ int error;
|
||||
+#else
|
||||
struct sockaddr_in sin;
|
||||
+#endif
|
||||
int sockflags;
|
||||
|
||||
+#ifdef INET6
|
||||
+ fd = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
+ if (fd >= 0) {
|
||||
+ family = AF_INET6;
|
||||
+ } else {
|
||||
+ family = AF_INET;
|
||||
+ dprintf("cannot create INET6 socket.\n");
|
||||
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
+ }
|
||||
+#else
|
||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
+#endif
|
||||
if (fd < 0) {
|
||||
logerror("syslog: Unknown protocol, suspending inet service.");
|
||||
return fd;
|
||||
}
|
||||
|
||||
+#ifdef NO_BIND_AT_FORWARD_ONLY
|
||||
+ if (AcceptRemote == 0)
|
||||
+ return fd;
|
||||
+#endif
|
||||
+#ifdef INET6
|
||||
+ memset(&hints, 0, sizeof(hints));
|
||||
+ hints.ai_flags = AI_PASSIVE;
|
||||
+ hints.ai_family = family;
|
||||
+ hints.ai_socktype = SOCK_DGRAM;
|
||||
+ error = getaddrinfo(NULL, "syslog", &hints, &res);
|
||||
+ if (error) {
|
||||
+ logerror(gai_strerror(error));
|
||||
+ close(fd);
|
||||
+ return -1;
|
||||
+ }
|
||||
+#else
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = LogPort;
|
||||
+#endif
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, \
|
||||
(char *) &on, sizeof(on)) < 0 ) {
|
||||
logerror("setsockopt(REUSEADDR), suspending inet");
|
||||
@@ -1329,13 +1399,77 @@ static int create_inet_socket()
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
+#ifdef INET6
|
||||
+ error = bind(fd, res->ai_addr, res->ai_addrlen);
|
||||
+ freeaddrinfo(res);
|
||||
+ if (error < 0) {
|
||||
+#else
|
||||
if (bind(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
|
||||
+#endif
|
||||
logerror("bind, suspending inet");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
+
|
||||
+#ifdef INET6
|
||||
+
|
||||
+static void setup_inetaddr_all()
|
||||
+{
|
||||
+ struct filed *f;
|
||||
+#ifdef SYSV
|
||||
+ int lognum;
|
||||
+
|
||||
+ for (lognum = 0; lognum <= nlogs; lognum++) {
|
||||
+ f = &Files[lognum];
|
||||
+#else
|
||||
+ for (f = Files; f; f = f->f_next) {
|
||||
+#endif
|
||||
+ if (f->f_type == F_FORW_UNKN) {
|
||||
+ if (setup_inetaddr(f)) {
|
||||
+ f->f_prevcount = INET_RETRY_MAX;
|
||||
+ f->f_time = time( (time_t *)0 );
|
||||
+ } else {
|
||||
+ f->f_type = F_FORW;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static const char *setup_inetaddr(struct filed *f)
|
||||
+{
|
||||
+ struct addrinfo hints, *res;
|
||||
+ int error;
|
||||
+
|
||||
+ memset(&hints, 0, sizeof(hints));
|
||||
+ hints.ai_family = family == AF_INET6 ? AF_UNSPEC : AF_INET;
|
||||
+ hints.ai_socktype = SOCK_DGRAM;
|
||||
+ error = getaddrinfo(f->f_un.f_forw.f_hname, "syslog", &hints, &res);
|
||||
+ if (error) {
|
||||
+ return gai_strerror(error);
|
||||
+ }
|
||||
+ if (res->ai_addrlen > sizeof(f->f_un.f_forw.f_sa)) {
|
||||
+ freeaddrinfo(res);
|
||||
+ return "addrlen too large";
|
||||
+ }
|
||||
+ if (family == AF_INET6 && res->ai_family == AF_INET) {
|
||||
+ /* v4mapped addr */
|
||||
+ f->f_un.f_forw.f_addr.sa_family = AF_INET6;
|
||||
+ f->f_un.f_forw.f_addr6.sin6_port =
|
||||
+ ((struct sockaddr_in *)res->ai_addr)->sin_port;
|
||||
+ f->f_un.f_forw.f_addr6.sin6_addr.s6_addr16[5] = 0xffff;
|
||||
+ memcpy(&f->f_un.f_forw.f_addr6.sin6_addr.s6_addr32[3],
|
||||
+ &((struct sockaddr_in *)res->ai_addr)->sin_addr,
|
||||
+ sizeof(struct in_addr));
|
||||
+ } else {
|
||||
+ memcpy(&f->f_un.f_forw.f_addr, res->ai_addr, res->ai_addrlen);
|
||||
+ }
|
||||
+ freeaddrinfo(res);
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+#endif /* end of INET6 */
|
||||
#endif
|
||||
|
||||
char **
|
||||
@@ -1778,8 +1912,12 @@ void fprintlog(f, from, flags, msg)
|
||||
register int l;
|
||||
char line[MAXLINE + 1];
|
||||
time_t fwd_suspend;
|
||||
+#ifdef INET6
|
||||
+ const char *errmsg;
|
||||
+#else
|
||||
struct hostent *hp;
|
||||
#endif
|
||||
+#endif
|
||||
|
||||
dprintf("Called fprintlog, ");
|
||||
|
||||
@@ -1833,22 +1971,27 @@ void fprintlog(f, from, flags, msg)
|
||||
fwd_suspend);
|
||||
}
|
||||
break;
|
||||
-
|
||||
+
|
||||
/*
|
||||
* The trick is to wait some time, then retry to get the
|
||||
* address. If that fails retry x times and then give up.
|
||||
*
|
||||
* You'll run into this problem mostly if the name server you
|
||||
* need for resolving the address is on the same machine, but
|
||||
- * is started after syslogd.
|
||||
+ * is started after syslogd.
|
||||
*/
|
||||
case F_FORW_UNKN:
|
||||
dprintf(" %s\n", f->f_un.f_forw.f_hname);
|
||||
fwd_suspend = time((time_t *) 0) - f->f_time;
|
||||
if ( fwd_suspend >= INET_SUSPEND_TIME ) {
|
||||
dprintf("Forwarding suspension to unknown over, retrying\n");
|
||||
+#ifdef INET6
|
||||
+ if ((errmsg = setup_inetaddr(f))) {
|
||||
+ dprintf("Failure: %s\n", errmsg);
|
||||
+#else
|
||||
if ( (hp = gethostbyname(f->f_un.f_forw.f_hname)) == NULL ) {
|
||||
dprintf("Failure: %s\n", sys_h_errlist[h_errno]);
|
||||
+#endif
|
||||
dprintf("Retries: %d\n", f->f_prevcount);
|
||||
if ( --f->f_prevcount < 0 ) {
|
||||
dprintf("Giving up.\n");
|
||||
@@ -1859,7 +2002,9 @@ void fprintlog(f, from, flags, msg)
|
||||
}
|
||||
else {
|
||||
dprintf("%s found, resuming.\n", f->f_un.f_forw.f_hname);
|
||||
+#ifndef INET6 /* not */
|
||||
memcpy((char *) &f->f_un.f_forw.f_addr.sin_addr, hp->h_addr, hp->h_length);
|
||||
+#endif
|
||||
f->f_prevcount = 0;
|
||||
f->f_type = F_FORW;
|
||||
goto f_forw;
|
||||
@@ -1901,7 +2046,11 @@ void fprintlog(f, from, flags, msg)
|
||||
l = MAXLINE;
|
||||
if (sendto(finet, line, l, 0, \
|
||||
(struct sockaddr *) &f->f_un.f_forw.f_addr,
|
||||
- sizeof(f->f_un.f_forw.f_addr)) != l) {
|
||||
+#ifdef INET6
|
||||
+ family == AF_INET6 ?
|
||||
+ sizeof(struct sockaddr_in6) :
|
||||
+#endif
|
||||
+ sizeof(f->f_un.f_forw.f_addr)) != l) {
|
||||
int e = errno;
|
||||
dprintf("INET sendto error: %d = %s.\n",
|
||||
e, strerror(e));
|
||||
@@ -2132,28 +2281,53 @@ void reapchild()
|
||||
/*
|
||||
* Return a printable representation of a host address.
|
||||
*/
|
||||
-const char *cvthname(f)
|
||||
- struct sockaddr_in *f;
|
||||
+const char *cvthname(struct sockaddr *f)
|
||||
{
|
||||
+#ifdef INET6
|
||||
+ static char hname[NI_MAXHOST];
|
||||
+ int error;
|
||||
+#else
|
||||
struct hostent *hp;
|
||||
+ char *hname;
|
||||
+#endif
|
||||
register char *p;
|
||||
int count;
|
||||
|
||||
- if (f->sin_family != AF_INET) {
|
||||
+#ifdef INET6
|
||||
+ if (((struct sockaddr *)f)->sa_family == AF_INET6 &&
|
||||
+ IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)f)->sin6_addr)) {
|
||||
+ ((struct sockaddr *)f)->sa_family = AF_INET;
|
||||
+ ((struct sockaddr_in *)f)->sin_addr.s_addr =
|
||||
+ ((struct sockaddr_in6 *)f)->sin6_addr.s6_addr32[3];
|
||||
+ }
|
||||
+ error = getnameinfo((struct sockaddr *)f,
|
||||
+ ((struct sockaddr *)f)->sa_family == AF_INET6 ?
|
||||
+ sizeof(struct sockaddr_in6)
|
||||
+ : sizeof(struct sockaddr_in),
|
||||
+ hname, sizeof(hname), NULL, 0, 0);
|
||||
+ if (error) {
|
||||
+ dprintf("Malformed from address %s\n", gai_strerror(error));
|
||||
+ return ("???");
|
||||
+ }
|
||||
+#else
|
||||
+ if (((struct sockaddr_in *)f)->sin_family != AF_INET) {
|
||||
dprintf("Malformed from address.\n");
|
||||
return ("???");
|
||||
}
|
||||
- hp = gethostbyaddr((char *) &f->sin_addr, sizeof(struct in_addr), \
|
||||
- f->sin_family);
|
||||
+ hp = gethostbyaddr((char *) &(((struct sockaddr_in *)&f)->sin_addr),
|
||||
+ sizeof(struct in_addr),
|
||||
+ ((struct sockaddr_in *)f)->sin_family);
|
||||
if (hp == 0) {
|
||||
dprintf("Host name for your address (%s) unknown.\n",
|
||||
- inet_ntoa(f->sin_addr));
|
||||
- return (inet_ntoa(f->sin_addr));
|
||||
+ inet_ntoa(((struct sockaddr_in *)f)->sin_addr));
|
||||
+ return (inet_ntoa(((struct sockaddr_in *)f)->sin_addr));
|
||||
}
|
||||
+ hname = hp->h_name;
|
||||
+#endif
|
||||
/*
|
||||
* Convert to lower case, just like LocalDomain above
|
||||
*/
|
||||
- for (p = (char *)hp->h_name; *p ; p++)
|
||||
+ for (p = hname; *p ; p++)
|
||||
if (isupper(*p))
|
||||
*p = tolower(*p);
|
||||
|
||||
@@ -2161,17 +2335,17 @@ const char *cvthname(f)
|
||||
* Notice that the string still contains the fqdn, but your
|
||||
* hostname and domain are separated by a '\0'.
|
||||
*/
|
||||
- if ((p = strchr(hp->h_name, '.'))) {
|
||||
+ if ((p = strchr(hname, '.'))) {
|
||||
if (strcmp(p + 1, LocalDomain) == 0) {
|
||||
*p = '\0';
|
||||
- return (hp->h_name);
|
||||
+ return (hname);
|
||||
} else {
|
||||
if (StripDomains) {
|
||||
count=0;
|
||||
while (StripDomains[count]) {
|
||||
if (strcmp(p + 1, StripDomains[count]) == 0) {
|
||||
*p = '\0';
|
||||
- return (hp->h_name);
|
||||
+ return (hname);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
@@ -2179,9 +2353,9 @@ const char *cvthname(f)
|
||||
if (LocalHosts) {
|
||||
count=0;
|
||||
while (LocalHosts[count]) {
|
||||
- if (!strcmp(hp->h_name, LocalHosts[count])) {
|
||||
+ if (!strcmp(hname, LocalHosts[count])) {
|
||||
*p = '\0';
|
||||
- return (hp->h_name);
|
||||
+ return (hname);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
@@ -2189,7 +2363,7 @@ const char *cvthname(f)
|
||||
}
|
||||
}
|
||||
|
||||
- return (hp->h_name);
|
||||
+ return (hname);
|
||||
}
|
||||
|
||||
void domark()
|
||||
@@ -2239,7 +2413,7 @@ void debug_switch()
|
||||
* Print syslogd errors some place.
|
||||
*/
|
||||
void logerror(type)
|
||||
- char *type;
|
||||
+ const char *type;
|
||||
{
|
||||
char buf[100];
|
||||
|
||||
@@ -2333,6 +2507,7 @@ void init()
|
||||
#else
|
||||
char cline[BUFSIZ];
|
||||
#endif
|
||||
+#ifndef INET6 /* not */
|
||||
struct servent *sp;
|
||||
|
||||
sp = getservbyname("syslog", "udp");
|
||||
@@ -2347,6 +2522,7 @@ void init()
|
||||
LogPort = 0;
|
||||
} else
|
||||
LogPort = sp->s_port;
|
||||
+#endif
|
||||
|
||||
/*
|
||||
* Close all open log files and free log descriptor array.
|
||||
@@ -2495,6 +2671,10 @@ void init()
|
||||
InetInuse = 0;
|
||||
}
|
||||
inetm = finet;
|
||||
+#ifdef INET6
|
||||
+ if (finet >= 0)
|
||||
+ setup_inetaddr_all();
|
||||
+#endif
|
||||
#endif
|
||||
|
||||
Initialized = 1;
|
||||
@@ -2582,7 +2762,7 @@ void cfline(line, f)
|
||||
int singlpri = 0;
|
||||
int ignorepri = 0;
|
||||
int syncfile;
|
||||
-#ifdef SYSLOG_INET
|
||||
+#if defined(SYSLOG_INET) && !defined(INET6)
|
||||
struct hostent *hp;
|
||||
#endif
|
||||
char buf[MAXLINE];
|
||||
@@ -2747,6 +2927,9 @@ void cfline(line, f)
|
||||
|
||||
(void) strcpy(f->f_un.f_forw.f_hname, ++p);
|
||||
dprintf("forwarding host: %s\n", p); /*ASP*/
|
||||
+#ifdef INET6
|
||||
+ f->f_type = F_FORW_UNKN;
|
||||
+#else
|
||||
if ( (hp = gethostbyname(p)) == NULL ) {
|
||||
f->f_type = F_FORW_UNKN;
|
||||
f->f_prevcount = INET_RETRY_MAX;
|
||||
@@ -2761,6 +2944,7 @@ void cfline(line, f)
|
||||
f->f_un.f_forw.f_addr.sin_port = LogPort;
|
||||
if ( f->f_type == F_FORW )
|
||||
memcpy((char *) &f->f_un.f_forw.f_addr.sin_addr, hp->h_addr, hp->h_length);
|
||||
+#endif
|
||||
/*
|
||||
* Otherwise the host might be unknown due to an
|
||||
* inaccessible nameserver (perhaps on the same
|
58
syslog.8
Normal file
58
syslog.8
Normal file
@ -0,0 +1,58 @@
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii syslog.8
|
||||
.\"
|
||||
.TH SYSLOG 8 "May 2008" "syslog" "System Logging"
|
||||
.SH NAME
|
||||
syslog - the system logging service
|
||||
.SH DESCRIPTION
|
||||
There are different syslog daemon implementations
|
||||
supported as the system's syslog service, currently:
|
||||
.BR syslogd ,
|
||||
.BR rsyslogd ,
|
||||
.BR syslog-ng .
|
||||
|
||||
It depends on the software selection during the installation
|
||||
which daemon is installed as default.
|
||||
|
||||
Each syslog-daemon provides an own service file, that is:
|
||||
.BR syslogd.service ,
|
||||
.BR rsyslogd.service ,
|
||||
.BR syslog-ng.service .
|
||||
|
||||
Only one syslog-daemon can be installed, it activates itself as the syslog
|
||||
service by creating the
|
||||
.BR syslog.service
|
||||
alias, a common name to start/stop, query status and reload the daemon while
|
||||
log rotation.
|
||||
|
||||
The
|
||||
.BR /etc/sysconfig/syslog
|
||||
file contains several variables allowing to specify additional
|
||||
settings, such as start parameters for the daemon or additional
|
||||
chroot log sockets.
|
||||
The \fIyast2 sysconfig\fR module provides a comfortable way to
|
||||
change these settings.
|
||||
|
||||
Starting with openSUSE-12.3, the
|
||||
.BR SYSLOG_DAEMON
|
||||
variable, which was used to select the daemon before, has been
|
||||
removed. Also the
|
||||
.BR SYSLOG_REQUIRES_NETWORK
|
||||
has been removed and each daemon declares in its service file
|
||||
whether the network will be started before syslog or not.
|
||||
|
||||
.SH BUGS
|
||||
Please report bugs at <http://bugs.opensuse.org>
|
||||
.SH AUTHOR
|
||||
.nf
|
||||
Juergen Weigert <jw@suse.com>
|
||||
Dr. Werner Fink <werner@suse.com>
|
||||
Marius Tomaschewski <mt@suse.com>
|
||||
.SH "SEE ALSO"
|
||||
.BR sysklogd (8)
|
||||
.BR syslogd (8)
|
||||
.BR syslog.conf (5)
|
||||
.BR syslog-ng (8)
|
||||
.BR syslog-ng.conf (5)
|
||||
.BR rsyslogd (8)
|
||||
.BR rsyslog.conf (5)
|
3
syslogd-rpmlintrc
Normal file
3
syslogd-rpmlintrc
Normal file
@ -0,0 +1,3 @@
|
||||
addFilter(".*W:.*macro-in-comment.*%{version}.*")
|
||||
addFilter(".*W:.*binary-or-shlib-calls-gethostbyname.*/usr/sbin/syslogd.*")
|
||||
|
49
syslogd-service-prepare
Normal file
49
syslogd-service-prepare
Normal file
@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) 2011 SuSE LINUX Products GmbH, Germany.
|
||||
#
|
||||
# Description:
|
||||
#
|
||||
# This script is executed by syslogd.service to prepare
|
||||
# the syslogd daemon start.
|
||||
# Currently it writes an evirtoment file which contains
|
||||
# a variable with the additional log socket parameters
|
||||
# passed to syslogd.
|
||||
#
|
||||
# Author: Werner Fink, Marius Tomaschewski
|
||||
# Please send feedback to http://www.suse.de/feedback
|
||||
#
|
||||
test -s "/etc/sysconfig/syslog" && \
|
||||
. "/etc/sysconfig/syslog"
|
||||
|
||||
run_dir="/var/run/syslogd"
|
||||
env_file="/var/run/syslogd/additional-log-sockets.env"
|
||||
|
||||
umask 0022
|
||||
/bin/mkdir -p -m 0755 "${run_dir}"
|
||||
|
||||
#
|
||||
# Prepare include with sockets in chroot's
|
||||
# passed as start parameter to the syslogd.
|
||||
#
|
||||
echo -n 'ADDITIONAL_SOCKET="' > "${env_file}"
|
||||
for variable in ${!SYSLOGD_ADDITIONAL_SOCKET*}; do
|
||||
eval value=\$$variable
|
||||
test -z "$value" && continue
|
||||
test ! -d "${value%/*}" && continue
|
||||
echo -n "-a $value "
|
||||
done >> "${env_file}"
|
||||
echo '"' >> "${env_file}"
|
||||
|
||||
#
|
||||
# make sure xconsole exists and is a pipe
|
||||
#
|
||||
if test -e /dev/xconsole -a ! -p /dev/xconsole ; then
|
||||
/bin/rm -f /dev/xconsole
|
||||
fi
|
||||
if test ! -e /dev/xconsole ; then
|
||||
/bin/mknod -m 0600 /dev/xconsole p
|
||||
/bin/chown root:tty /dev/xconsole
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
1365
syslogd.changes
Normal file
1365
syslogd.changes
Normal file
File diff suppressed because it is too large
Load Diff
54
syslogd.service
Normal file
54
syslogd.service
Normal file
@ -0,0 +1,54 @@
|
||||
#
|
||||
# This file is part of package syslogd.
|
||||
#
|
||||
# Copyright (c) 2011 SuSE LINUX Products GmbH, Germany.
|
||||
# Author: Werner Fink, Marius Tomaschewski
|
||||
# Please send feedback to http://www.suse.de/feedback
|
||||
#
|
||||
# Description:
|
||||
#
|
||||
# Used to start syslogd as the System Logging Service daemon.
|
||||
# The SYSLOG_DAEMON variable in /etc/sysconfig/syslog is not
|
||||
# used any longer, instead use
|
||||
# systemctl enable syslogd.service
|
||||
# which also installs an alias to syslog.service.
|
||||
#
|
||||
|
||||
[Unit]
|
||||
Description=System Logging Service
|
||||
Conflicts=syslog-ng.service rsyslog.service
|
||||
Requires=var-run.mount
|
||||
Requires=syslog.socket
|
||||
Requires=network.target
|
||||
Requires=klogd.service
|
||||
Before=klogd.service
|
||||
|
||||
[Service]
|
||||
# added automatically, for details please see
|
||||
# https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort
|
||||
ProtectSystem=full
|
||||
ProtectHome=true
|
||||
PrivateDevices=true
|
||||
ProtectHostname=true
|
||||
ProtectClock=true
|
||||
ProtectKernelTunables=true
|
||||
ProtectKernelModules=true
|
||||
ProtectKernelLogs=true
|
||||
ProtectControlGroups=true
|
||||
RestrictRealtime=true
|
||||
# end of automatic additions
|
||||
Type=notify
|
||||
Sockets=syslog.socket
|
||||
StandardOutput=null
|
||||
Environment=ADDITIONAL_SOCKET=
|
||||
ExecStartPre=/usr/sbin/syslogd-service-prepare
|
||||
EnvironmentFile=-/var/run/syslogd/additional-log-sockets.env
|
||||
ExecStart=/usr/sbin/syslogd -n $ADDITIONAL_SOCKET
|
||||
ExecReload=/bin/systemctl kill --signal=TSTP klogd.service
|
||||
ExecReload=/sbin/killproc -p /var/run/syslogd.pid -HUP /usr/sbin/syslogd
|
||||
ExecReload=/bin/systemctl kill --signal=CONT klogd.service
|
||||
ExecReload=/bin/systemctl kill --signal=USR2 klogd.service
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Alias=syslog.service
|
408
syslogd.spec
Normal file
408
syslogd.spec
Normal file
@ -0,0 +1,408 @@
|
||||
#
|
||||
# spec file for package syslogd
|
||||
#
|
||||
# Copyright (c) 2022 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
# upon. The license for this file, and modifications and additions to the
|
||||
# file, is the same license as for the pristine package itself (unless the
|
||||
# license for the pristine package is not an Open Source License, in which
|
||||
# case the license is the MIT License). An "Open Source License" is a
|
||||
# license that conforms to the Open Source Definition (Version 1.9)
|
||||
# published by the Open Source Initiative.
|
||||
|
||||
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
|
||||
#Compat macro for new _fillupdir macro introduced in Nov 2017
|
||||
%if ! %{defined _fillupdir}
|
||||
%define _fillupdir /var/adm/fillup-templates
|
||||
%endif
|
||||
|
||||
%if ! %{defined _rundir}
|
||||
%define _rundir %{_localstatedir}/run
|
||||
%endif
|
||||
Name: syslogd
|
||||
Version: 1.5.1
|
||||
Release: 0
|
||||
Summary: The Syslog daemon
|
||||
License: GPL-2.0-or-later
|
||||
Group: System/Daemons
|
||||
URL: https://www.infodrom.org/projects/sysklogd/
|
||||
Source: https://www.infodrom.org/projects/sysklogd/download/sysklogd-%{version}.tar.gz
|
||||
#Source4: https://www.infodrom.org/projects/sysklogd/download/sysklogd-%{version}.tar.gz.asc
|
||||
Source1: logrotate.syslog
|
||||
Source2: sysconfig.syslogd
|
||||
Source3: sysconfig.klogd
|
||||
Source5: syslog.8
|
||||
Source6: klog.service
|
||||
Source7: klogd.service
|
||||
Source8: syslogd.service
|
||||
Source9: syslogd-service-prepare
|
||||
Source11: syslogd-rpmlintrc
|
||||
Source12: sysconfig.boot
|
||||
Patch0: sysklogd-1.4.1.dif
|
||||
Patch1: sysklogd-1.4.1-dgram.patch
|
||||
Patch2: sysklogd-1.4.1-sparc.patch
|
||||
Patch3: sysklogd-1.4.1-forw.patch
|
||||
Patch5: sysklogd-ipv6.diff
|
||||
Patch6: sysklogd-1.4.1-klogd24.dif
|
||||
Patch7: sysklogd-1.4.1-large.patch
|
||||
Patch8: sysklogd-1.4.1-dns.patch
|
||||
Patch9: sysklogd-1.4.1-reopen.patch
|
||||
Patch12: sysklogd-1.4.1-ksyslogsize.diff
|
||||
Patch13: sysklogd-1.4.1-unix_sockets.patch
|
||||
Patch14: sysklogd-1.4.1-showpri.patch
|
||||
Patch18: sysklogd-1.4.1-dontsleep.patch
|
||||
Patch19: sysklogd-1.4.1-signal.dif
|
||||
Patch20: sysklogd-1.4.1-clearing.patch
|
||||
Patch21: sysklogd-1.4.1-nofortify.patch
|
||||
Patch22: sysklogd-1.4.1-sysmap-prior-to-2.5.patch
|
||||
Patch23: sysklogd-1.4.1-reload.dif
|
||||
Patch24: sysklogd-1.4.1-systemd.dif
|
||||
Patch25: sysklogd-1.4.1-systemd-multi.dif
|
||||
Patch26: sysklogd-1.4.1-systemd-sock-name.patch
|
||||
# PATCH-FIX-SUSE bsc#897262, CVE-2014-3634 rsyslog/syslogd: remote syslog PRI vulnerability
|
||||
Patch28: sysklogd-1.4.1-CVE-2014-3634.patch
|
||||
BuildRequires: pkgconfig
|
||||
BuildRequires: group(news)
|
||||
BuildRequires: pkgconfig(libsystemd)
|
||||
BuildRequires: pkgconfig(systemd)
|
||||
BuildRequires: user(news)
|
||||
Requires: klogd
|
||||
Requires(post): %fillup_prereq
|
||||
Requires(post): permissions
|
||||
# Note: this package is for >= 12.3 only
|
||||
# and does not provide LSB init scripts!
|
||||
Requires(pre): syslog-service >= 2.0
|
||||
Requires(pre): user(news)
|
||||
Requires(pre): group(news)
|
||||
Conflicts: syslog
|
||||
Provides: sysklogd
|
||||
Provides: syslog
|
||||
Provides: sysvinit(syslog)
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
%{?systemd_requires}
|
||||
|
||||
%description
|
||||
The syslogd daemon is the general system logging daemon, which is
|
||||
responsible for handling requests for syslog services.
|
||||
|
||||
This version of syslogd is similar to the standard Berkeley product,
|
||||
but with a number of compatible extensions.
|
||||
|
||||
%package -n klogd
|
||||
Summary: The kernel log daemon
|
||||
Group: System/Daemons
|
||||
Requires(post): %fillup_prereq
|
||||
|
||||
%description -n klogd
|
||||
The klogd daemon 'listens' to kernel log messages, prioritizes them,
|
||||
and routes them to either output files or to syslog daemon.
|
||||
|
||||
This version of klogd will optionally translate kernel addresses to
|
||||
their symbolic equivalents if provided with a system map.
|
||||
|
||||
%package -n syslog-service
|
||||
Version: 2.0
|
||||
Release: 0
|
||||
Summary: Syslog service files & scripts
|
||||
Group: System/Daemons
|
||||
Requires: logrotate
|
||||
Requires: syslog
|
||||
Requires: sysvinit(network)
|
||||
Requires(post): %fillup_prereq
|
||||
BuildArch: noarch
|
||||
|
||||
%description -n syslog-service
|
||||
The package syslog-service provides the service boot
|
||||
scripts for SysV and the service unit files for systemd.
|
||||
|
||||
%prep
|
||||
%setup -q -n sysklogd-1.5.1
|
||||
%patch1 -b .dgram
|
||||
%patch2 -b .sparc
|
||||
%patch3 -b .forw
|
||||
%patch5 -b .ipv6
|
||||
%patch6 -b .klogd24
|
||||
%patch7 -b .large
|
||||
%patch8 -b .dns
|
||||
%patch9 -b .reopen
|
||||
%patch12 -b .klsize
|
||||
%patch13 -b .usock
|
||||
%patch14 -b .shprio
|
||||
%patch18 -b .sleep
|
||||
%patch19 -b .signal
|
||||
%patch20 -b .clear
|
||||
%patch21 -b .nofortify
|
||||
%patch22 -b .sysmap
|
||||
%patch23 -b .reload
|
||||
%patch24 -b .sd
|
||||
%patch25 -b .sd2
|
||||
%patch26 -b .sd3
|
||||
%patch28 -b .cve20143634
|
||||
%patch0 -b .p0
|
||||
|
||||
%build
|
||||
%ifarch s390 s390x
|
||||
mv sample-s390.conf sample.conf
|
||||
%endif
|
||||
# honor the increased LOG_BUF_LEN in kernel/printk.c
|
||||
make %{?_smp_mflags} BINDIR=%{_sbindir} LOG_BUFFER_SIZE=-DLOG_BUFFER_SIZE=131072
|
||||
|
||||
%install
|
||||
mkdir -p %{buildroot}/etc
|
||||
mkdir -p %{buildroot}/sbin
|
||||
mkdir -p %{buildroot}/%{_sbindir}
|
||||
mkdir -p %{buildroot}/%{_mandir}/man{5,8}
|
||||
mkdir -p %{buildroot}%{_fillupdir}
|
||||
mkdir -p %{buildroot}%{_unitdir}
|
||||
mkdir -p -m 0755 %{buildroot}/%{_rundir}/syslogd
|
||||
make install MANDIR=%{_mandir} BINDIR=%{_sbindir} DESTDIR=%{buildroot}
|
||||
%if 0%{?suse_version} > 1500
|
||||
mkdir -p %{buildroot}%{_distconfdir}/logrotate.d
|
||||
install -m 644 %{SOURCE1} %{buildroot}%{_distconfdir}/logrotate.d/syslog
|
||||
%else
|
||||
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
|
||||
install -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/syslog
|
||||
%endif
|
||||
install -m 644 %{SOURCE2} %{buildroot}%{_fillupdir}
|
||||
install -m 644 %{SOURCE3} %{buildroot}%{_fillupdir}
|
||||
install -m 644 %{SOURCE5} %{buildroot}/%{_mandir}/man8/syslog.8
|
||||
install -m 644 %{SOURCE6} %{buildroot}%{_unitdir}/
|
||||
install -m 644 %{SOURCE7} %{buildroot}%{_unitdir}/
|
||||
install -m 644 %{SOURCE8} %{buildroot}%{_unitdir}/
|
||||
install -m 755 %{SOURCE9} %{buildroot}/%{_sbindir}/
|
||||
ln -s service %{buildroot}/%{_sbindir}/rcsyslogd
|
||||
install -m 644 %{SOURCE12} %{buildroot}%{_fillupdir}
|
||||
%if 0%{?suse_version} < 1550
|
||||
for sbin in klogd syslogd ; do
|
||||
ln -sf %{_sbindir}/${sbin} %{buildroot}/sbin/${sbin}
|
||||
done
|
||||
%endif
|
||||
%ifarch s390 s390x
|
||||
sed -i 's/^KERNEL_LOGLEVEL=1/KERNEL_LOGLEVEL=7/' \
|
||||
%{buildroot}%{_fillupdir}/sysconfig.klogd
|
||||
%endif
|
||||
|
||||
%if %{defined verify_permissions}
|
||||
%verifyscript
|
||||
%verify_permissions -e %{_sysconfdir}/syslog.conf
|
||||
%endif
|
||||
|
||||
%pre
|
||||
%service_add_pre syslogd.service
|
||||
|
||||
%post
|
||||
%set_permissions %{_sysconfdir}/syslog.conf
|
||||
#
|
||||
# add syslog variables provided by syslogd if needed
|
||||
#
|
||||
%{remove_and_set -n syslog SYSLOG_DAEMON}
|
||||
%{remove_and_set -n syslog SYSLOG_REQUIRES_NETWORK}
|
||||
%{fillup_only -ns syslog syslogd}
|
||||
#
|
||||
# create dirs, touch log default files
|
||||
#
|
||||
mkdir -p var/log
|
||||
touch var/log/messages; chmod 640 var/log/messages
|
||||
touch var/log/mail; chmod 640 var/log/mail
|
||||
touch var/log/mail.info; chmod 640 var/log/mail.info
|
||||
touch var/log/mail.warn; chmod 640 var/log/mail.warn
|
||||
touch var/log/mail.err; chmod 640 var/log/mail.err
|
||||
test -f var/log/news && mv var/log/news var/log/news.bak
|
||||
mkdir -p -m 0750 var/log/news
|
||||
chown news:news var/log/news
|
||||
touch var/log/news/news.crit; chmod 640 var/log/news/news.crit
|
||||
chown news:news var/log/news/news.crit
|
||||
touch var/log/news/news.err; chmod 640 var/log/news/news.err
|
||||
chown news:news var/log/news/news.err
|
||||
touch var/log/news/news.notice; chmod 640 var/log/news/news.notice
|
||||
chown news:news var/log/news/news.notice
|
||||
#
|
||||
# Enable the syslogd as service
|
||||
#
|
||||
# This macro enables based on a systemctl preset config file only
|
||||
%service_add_post syslogd.service
|
||||
# But we want to enable a syslog-daemon regardless of the preset;
|
||||
# force the creation of a syslog.service alias link (bnc#790805).
|
||||
# We do not check the obsolete SYSLOG_DAEMON variable as we want
|
||||
# to switch when installing it and there is a provider conflict.
|
||||
%{_bindir}/systemctl -f enable syslogd.service >/dev/null 2>&1 || :
|
||||
|
||||
%preun
|
||||
%service_del_preun syslog.socket
|
||||
%service_del_preun syslogd.service
|
||||
|
||||
%postun
|
||||
%service_del_postun syslogd.service
|
||||
|
||||
%preun -n syslog-service
|
||||
%service_del_preun klog.service
|
||||
|
||||
%post -n syslog-service -p /bin/bash
|
||||
%{remove_and_set -n syslog SYSLOG_DAEMON}
|
||||
%{remove_and_set -n syslog SYSLOG_REQUIRES_NETWORK}
|
||||
%{remove_and_set -n boot KLOGCONSOLE_PARAMS}
|
||||
%{fillup_only -n boot}
|
||||
#BEGIN KLOGCONSOLE_PARAMS migration
|
||||
# KLOGCONSOLE_PARAMS was supported in /etc/sysconfig/boot up to Leap 15 and SLE 15.
|
||||
# Based on genopts-1.3 options parser.
|
||||
if test "$KLOGCONSOLE_PARAMS" != "no" ; then
|
||||
KLOG_CONSOLE=
|
||||
CONSOLE_LOGLEVEL=
|
||||
function optarg_parse {
|
||||
until [ $# -eq 0 ] ; do
|
||||
case "$1" in
|
||||
-* )
|
||||
OPTTMP="${1:1}"
|
||||
until [[ -z "$OPTTMP" ]] ; do
|
||||
case "${OPTTMP:0:1}" in
|
||||
r )
|
||||
KLOG_CONSOLE="${OPTTMP:1}"
|
||||
if [[ -z "$KLOG_CONSOLE" ]] ; then
|
||||
shift
|
||||
KLOG_CONSOLE="$1"
|
||||
else
|
||||
break
|
||||
fi
|
||||
;;
|
||||
l )
|
||||
CONSOLE_LOGLEVEL="${OPTTMP:1}"
|
||||
if [[ -z "$CONSOLE_LOGLEVEL" ]] ; then
|
||||
shift
|
||||
CONSOLE_LOGLEVEL="$1"
|
||||
else
|
||||
break
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
OPTTMP="${OPTTMP:1}"
|
||||
done
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
optarg_parse $KLOGCONSOLE_PARAMS
|
||||
case "$CONSOLE_LOGLEVEL" in
|
||||
0) CONSOLE_LOGLEVEL=emerg ;;
|
||||
1) CONSOLE_LOGLEVEL=alert ;;
|
||||
2) CONSOLE_LOGLEVEL=crit ;;
|
||||
3) CONSOLE_LOGLEVEL=err ;;
|
||||
4) CONSOLE_LOGLEVEL=warning ;;
|
||||
5) CONSOLE_LOGLEVEL=notice ;;
|
||||
6) CONSOLE_LOGLEVEL=info ;;
|
||||
7) CONSOLE_LOGLEVEL=debug ;;
|
||||
esac
|
||||
unset OPTTMP
|
||||
cat >%{_sysconfdir}/sysconfig/boot.update <<EOF
|
||||
## Path: System/Logging
|
||||
## Description: System logging
|
||||
|
||||
## Type: list(1,2,3,4,5,6,7,8,9,10,11,12)
|
||||
## Default: 10
|
||||
#
|
||||
# Console for logging
|
||||
#
|
||||
KLOG_CONSOLE="$KLOG_CONSOLE"
|
||||
|
||||
## Type: list(,0,emerg,1,alert,2,crit,3,err,4,warning,5,notice,6,info,7,debug)
|
||||
## Default:
|
||||
#
|
||||
# Loglevel for log console
|
||||
#
|
||||
CONSOLE_LOGLEVEL="$CONSOLE_LOGLEVEL"
|
||||
EOF
|
||||
fillup -m %{_sysconfdir}/sysconfig/boot.update %{_sysconfdir}/sysconfig/boot %{_sysconfdir}/sysconfig/boot
|
||||
rm %{_sysconfdir}/sysconfig/boot.update
|
||||
fi
|
||||
#END KLOGCONSOLE_PARAMS migration
|
||||
|
||||
# when exists, remove the broken link pointing to the
|
||||
# common syslog.service file, we've provided before...
|
||||
rm -f %{_sysconfdir}/systemd/system/multi-user.target.wants/syslog.service
|
||||
%service_add_post klog.service
|
||||
%{_bindir}/systemctl -f enable klog.service >/dev/null 2>&1 || :
|
||||
|
||||
%pre -n syslog-service
|
||||
%service_add_pre klog.service
|
||||
%if 0%{?suse_version} > 1500
|
||||
# Prepare for migration to /usr/etc; save any old .rpmsave
|
||||
for i in logrotate.d/syslog ; do
|
||||
test -f %{_sysconfdir}/${i}.rpmsave && mv -v %{_sysconfdir}/${i}.rpmsave %{_sysconfdir}/${i}.rpmsave.old ||:
|
||||
done
|
||||
%endif
|
||||
|
||||
%if 0%{?suse_version} > 1500
|
||||
%posttrans -n syslog-service
|
||||
# Migration to /usr/etc, restore just created .rpmsave
|
||||
for i in logrotate.d/syslog ; do
|
||||
test -f %{_sysconfdir}/${i}.rpmsave && mv -v %{_sysconfdir}/${i}.rpmsave %{_sysconfdir}/${i} ||:
|
||||
done
|
||||
%endif
|
||||
|
||||
%postun -n syslog-service
|
||||
%service_del_postun klog.service
|
||||
|
||||
%pre -n klogd
|
||||
%service_add_pre klogd.service
|
||||
|
||||
%post -n klogd
|
||||
#
|
||||
# add syslog variables provided by klogd if needed
|
||||
#
|
||||
%{remove_and_set -n syslog SYSLOG_DAEMON}
|
||||
%{remove_and_set -n syslog SYSLOG_REQUIRES_NETWORK}
|
||||
%{fillup_only -ns syslog klogd}
|
||||
#
|
||||
# Enable the syslogd as service
|
||||
#
|
||||
%service_add_post klogd.service
|
||||
|
||||
%preun -n klogd
|
||||
%service_del_preun klogd.service
|
||||
|
||||
%postun -n klogd
|
||||
%service_del_postun klogd.service
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%{_fillupdir}/sysconfig.syslogd
|
||||
%config %verify(not mode) %attr(0600,root,root) %{_sysconfdir}/syslog.conf
|
||||
%{_mandir}/man5/syslog.conf.5%{ext_man}
|
||||
%{_mandir}/man8/syslogd.8%{ext_man}
|
||||
%{_mandir}/man8/sysklogd.8%{ext_man}
|
||||
%{_unitdir}/syslogd.service
|
||||
%{_sbindir}/syslogd-service-prepare
|
||||
%attr(0755,root,root) %dir %ghost %{_rundir}/syslogd
|
||||
%{_sbindir}/syslogd
|
||||
%{_sbindir}/rcsyslogd
|
||||
%if 0%{?suse_version} < 1550
|
||||
/sbin/syslogd
|
||||
%endif
|
||||
|
||||
%files -n klogd
|
||||
%defattr(-,root,root)
|
||||
%{_fillupdir}/sysconfig.klogd
|
||||
%{_unitdir}/klogd.service
|
||||
%{_mandir}/man8/klogd.8%{ext_man}
|
||||
%{_sbindir}/klogd
|
||||
%if 0%{?suse_version} < 1550
|
||||
/sbin/klogd
|
||||
%endif
|
||||
|
||||
%files -n syslog-service
|
||||
%defattr(-,root,root)
|
||||
%{_fillupdir}/sysconfig.boot
|
||||
%if 0%{?suse_version} > 1500
|
||||
%{_distconfdir}/logrotate.d/syslog
|
||||
%else
|
||||
%config(noreplace) %{_sysconfdir}/logrotate.d/syslog
|
||||
%endif
|
||||
%{_unitdir}/klog.service
|
||||
%{_mandir}/man8/syslog.8%{ext_man}
|
||||
|
||||
%changelog
|
Loading…
Reference in New Issue
Block a user