Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:dirkmueller:branches:openSUSE:Factory:Rings:1-MinimalX
syslogd
sysklogd-1.4.1.dif
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File sysklogd-1.4.1.dif of Package syslogd
--- 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);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor