This commit is contained in:
parent
27f938a3ac
commit
819b050974
236
sysklogd-1.4.1-signal.dif
Normal file
236
sysklogd-1.4.1-signal.dif
Normal file
@ -0,0 +1,236 @@
|
||||
--- syslogd.c
|
||||
+++ syslogd.c 2008-03-26 17:45:54.247851855 +0100
|
||||
@@ -770,6 +770,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);
|
||||
@@ -783,7 +786,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
|
||||
@@ -932,12 +937,32 @@ int main(argc, argv)
|
||||
dprintf("Checking pidfile.\n");
|
||||
if (!check_pid(PidFile))
|
||||
{
|
||||
- if (fork()) {
|
||||
+ pid_t pid;
|
||||
+ int n = 0, status;
|
||||
+
|
||||
+ signal (SIGTERM, doexit);
|
||||
+
|
||||
+ switch ((pid = fork())) {
|
||||
+ default:
|
||||
+ retry:
|
||||
/*
|
||||
* Parent process
|
||||
*/
|
||||
- signal (SIGTERM, doexit);
|
||||
- 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.
|
||||
@@ -947,11 +972,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();
|
||||
}
|
||||
- num_fds = getdtablesize();
|
||||
- for (i= 0; i < num_fds; i++)
|
||||
- (void) close(i);
|
||||
- untty();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1028,6 +1056,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);
|
||||
@@ -1044,7 +1074,7 @@ int main(argc, argv)
|
||||
(char **) 0 )
|
||||
{
|
||||
logerror("Cannot allocate memory for message parts table.");
|
||||
- die(0);
|
||||
+ dienow();
|
||||
}
|
||||
for(i= 0; i < num_fds; ++i)
|
||||
parts[i] = (char *) 0;
|
||||
@@ -1067,9 +1097,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
|
||||
/*
|
||||
@@ -1256,7 +1291,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;
|
||||
}
|
||||
@@ -1406,8 +1441,8 @@ crunch_list(list)
|
||||
void untty()
|
||||
#ifdef SYSV
|
||||
{
|
||||
- if ( !Debug ) {
|
||||
- setsid();
|
||||
+ if ( !Debug && !sid ) {
|
||||
+ sid = setsid();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1597,8 +1632,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;
|
||||
@@ -2128,9 +2162,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
|
||||
@@ -2289,13 +2321,21 @@ void logerror(type)
|
||||
return;
|
||||
}
|
||||
|
||||
-void die(sig)
|
||||
+void die(int sig)
|
||||
+{
|
||||
+ 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);
|
||||
+}
|
||||
|
||||
- int sig;
|
||||
-
|
||||
+void dienow(void)
|
||||
{
|
||||
register struct filed *f;
|
||||
- char buf[100];
|
||||
int lognum;
|
||||
int i;
|
||||
int was_initialized = Initialized;
|
||||
@@ -2311,24 +2351,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
|
||||
@@ -2342,7 +2389,7 @@ void die(sig)
|
||||
void doexit(sig)
|
||||
int sig;
|
||||
{
|
||||
- exit (0);
|
||||
+ leave++;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2403,7 +2450,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;
|
||||
}
|
||||
}
|
@ -1,22 +1,25 @@
|
||||
--- .pkgextract
|
||||
+++ .pkgextract 2006-02-08 17:29:50.000000000 +0100
|
||||
@@ -0,0 +1,16 @@
|
||||
+patch -p0 --suffix=.dgram -s < ../sysklogd-1.4.1-dgram.patch
|
||||
+patch -p0 --suffix=.sparc -s < ../sysklogd-1.4.1-sparc.patch
|
||||
+patch -p0 --suffix=.forw -s < ../sysklogd-1.4.1-forw.patch
|
||||
+patch -p0 --suffix=.fileleak -s < ../sysklogd-1.4.1-fileleak.patch
|
||||
+patch -p0 --suffix=.ipv6 -s < ../sysklogd-ipv6.diff
|
||||
+patch -p0 --suffix=.klogd24 -s < ../sysklogd-1.4.1-klogd24.dif
|
||||
+patch -p0 --suffix=.large -s < ../sysklogd-1.4.1-large.patch
|
||||
+patch -p1 --suffix=.dns -s < ../sysklogd-1.4.1-dns.patch
|
||||
+patch -p0 --suffix=.reopen -s < ../sysklogd-1.4.1-reopen.patch
|
||||
+patch -p0 --suffix=.sobsd -s < ../sysklogd-1.4.1-no_SO_BSDCOMPAT.diff
|
||||
+patch -p1 --suffix=.owlcr -s < ../sysklogd-1.4.1-owl-crunch_list.diff
|
||||
+patch -p1 --suffix=.klsize -s < ../sysklogd-1.4.1-ksyslogsize.diff
|
||||
+patch -p0 --suffix=.usock -s < ../sysklogd-1.4.1-unix_sockets.patch
|
||||
+patch -p0 --suffix=.shprio -s < ../sysklogd-1.4.1-showpri.patch
|
||||
+patch -p1 --suffix=.presperc -s < ../sysklogd-1.4.1-preserve_percents.patch
|
||||
+patch -p1 --suffix=.utf8 -s < ../sysklogd-1.4.1-utf8.patch
|
||||
@@ -0,0 +1,19 @@
|
||||
+patch -p0 -b --suffix=.dgram -s < ../sysklogd-1.4.1-dgram.patch
|
||||
+patch -p0 -b --suffix=.sparc -s < ../sysklogd-1.4.1-sparc.patch
|
||||
+patch -p0 -b --suffix=.forw -s < ../sysklogd-1.4.1-forw.patch
|
||||
+patch -p0 -b --suffix=.fileleak -s < ../sysklogd-1.4.1-fileleak.patch
|
||||
+patch -p0 -b --suffix=.ipv6 -s < ../sysklogd-ipv6.diff
|
||||
+patch -p0 -b --suffix=.klogd24 -s < ../sysklogd-1.4.1-klogd24.dif
|
||||
+patch -p0 -b --suffix=.large -s < ../sysklogd-1.4.1-large.patch
|
||||
+patch -p1 -b --suffix=.dns -s < ../sysklogd-1.4.1-dns.patch
|
||||
+patch -p0 -b --suffix=.reopen -s < ../sysklogd-1.4.1-reopen.patch
|
||||
+patch -p0 -b --suffix=.sobsd -s < ../sysklogd-1.4.1-no_SO_BSDCOMPAT.diff
|
||||
+patch -p1 -b --suffix=.owlcr -s < ../sysklogd-1.4.1-owl-crunch_list.diff
|
||||
+patch -p1 -b --suffix=.klsize -s < ../sysklogd-1.4.1-ksyslogsize.diff
|
||||
+patch -p0 -b --suffix=.usock -s < ../sysklogd-1.4.1-unix_sockets.patch
|
||||
+patch -p0 -b --suffix=.shprio -s < ../sysklogd-1.4.1-showpri.patch
|
||||
+patch -p1 -b --suffix=.presperc -s < ../sysklogd-1.4.1-preserve_percents.patch
|
||||
+patch -p1 -b --suffix=.utf8 -s < ../sysklogd-1.4.1-utf8.patch
|
||||
+patch -p1 -b --suffix=.ksym -s < ../sysklogd-1.4.1-ksym.patch
|
||||
+patch -p1 -b --suffix=.sleep -s < ../sysklogd-1.4.1-dontsleep.patch
|
||||
+patch -p0 -b --suffix=.signal -s < ../sysklogd-1.4.1-signal.dif
|
||||
--- Makefile
|
||||
+++ Makefile 2006-02-08 17:29:50.000000000 +0100
|
||||
@@ -1,14 +1,17 @@
|
||||
@ -31,7 +34,7 @@
|
||||
#LDFLAGS= -g
|
||||
-CFLAGS= $(RPM_OPT_FLAGS) -DINET6 -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce
|
||||
-LDFLAGS= -s
|
||||
+CFLAGS= $(RPM_OPT_FLAGS) -D_GNU_SOURCE -DINET6 -DSYSV -Wall -pipe $(LOG_BUFFER_SIZE) -funroll-loops -fpie
|
||||
+CFLAGS= $(RPM_OPT_FLAGS) -D_GNU_SOURCE -DINET6 -DSYSV -Wall -pipe $(LOG_BUFFER_SIZE) -fPIE
|
||||
+LDFLAGS= -pie
|
||||
|
||||
# Look where your install program is.
|
||||
@ -535,7 +538,7 @@
|
||||
@@ -1257,8 +1269,9 @@
|
||||
close(fd);
|
||||
#ifndef SYSV
|
||||
die(0);
|
||||
dienow();
|
||||
-#endif
|
||||
+#else
|
||||
return -1;
|
||||
|
@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Mar 26 17:53:11 CET 2008 - werner@suse.de
|
||||
|
||||
- Do not exit within signal handlers
|
||||
- Avoid race condition between fork() and signal handling
|
||||
- Use setsid() only once
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jan 24 11:40:04 CET 2008 - werner@suse.de
|
||||
|
||||
|
19
syslogd.spec
19
syslogd.spec
@ -10,6 +10,7 @@
|
||||
|
||||
# norootforbuild
|
||||
|
||||
|
||||
Name: syslogd
|
||||
%define omc_prefix /usr/share/omc
|
||||
%define omc_svcdir %{omc_prefix}/svcinfo.d
|
||||
@ -19,7 +20,7 @@ PreReq: coreutils %fillup_prereq klogd sed
|
||||
Provides: syslog
|
||||
AutoReqProv: on
|
||||
Version: 1.4.1
|
||||
Release: 648
|
||||
Release: 661
|
||||
Summary: The Syslog daemon
|
||||
Source: sysklogd-1.4.1.tar.bz2
|
||||
Source1: logrotate.syslog
|
||||
@ -46,6 +47,7 @@ Patch15: sysklogd-1.4.1-preserve_percents.patch
|
||||
Patch16: sysklogd-1.4.1-utf8.patch
|
||||
Patch17: sysklogd-1.4.1-ksym.patch
|
||||
Patch18: sysklogd-1.4.1-dontsleep.patch
|
||||
Patch19: sysklogd-1.4.1-signal.dif
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
|
||||
%description
|
||||
@ -108,6 +110,7 @@ Authors:
|
||||
%patch16 -p1 -b .utf8
|
||||
%patch17 -p1 -b .ksym
|
||||
%patch18 -p1 -b .sleep
|
||||
%patch19 -p0 -b .signal
|
||||
%patch0 -p0
|
||||
|
||||
%build
|
||||
@ -222,6 +225,10 @@ fi
|
||||
%{omc_svcdir}/syslog.xml
|
||||
|
||||
%changelog
|
||||
* Wed Mar 26 2008 werner@suse.de
|
||||
- Do not exit within signal handlers
|
||||
- Avoid race condition between fork() and signal handling
|
||||
- Use setsid() only once
|
||||
* Thu Jan 24 2008 werner@suse.de
|
||||
- Add missing prerequirements (bug #355801)
|
||||
* Thu Aug 09 2007 olh@suse.de
|
||||
@ -415,7 +422,7 @@ fi
|
||||
- Fix the bug fix
|
||||
* Thu Feb 14 2002 werner@suse.de
|
||||
- Fix bug #12747: move to fillup_and_insserv and sysconfig scheme
|
||||
* Wed Sep 19 2001 ro@suse.de
|
||||
* Thu Sep 20 2001 ro@suse.de
|
||||
- fixed typo in rc_script SYSLOGD_PARAM -> SYSLOGD_PARAMS (#10950)
|
||||
* Thu Aug 30 2001 werner@suse.de
|
||||
- Fix bug #9096
|
||||
@ -442,7 +449,7 @@ fi
|
||||
- fixed startscript
|
||||
* Mon Nov 13 2000 ro@suse.de
|
||||
- fixed to compile on 2.4 kernel header
|
||||
* Tue Oct 17 2000 bk@suse.de
|
||||
* Wed Oct 18 2000 bk@suse.de
|
||||
- add sample-s390.conf for s390.
|
||||
* Thu Sep 14 2000 werner@suse.de
|
||||
- Fix format handling within Syslog()
|
||||
@ -481,9 +488,9 @@ fi
|
||||
- ran old prepare_spec on spec file to switch to new prepare_spec.
|
||||
* Fri Sep 10 1999 ro@suse.de
|
||||
- fixed nodos patch
|
||||
* Mon Sep 06 1999 werner@suse.de
|
||||
* Tue Sep 07 1999 werner@suse.de
|
||||
- Avoid possible crash if no kernel symbols are available.
|
||||
* Fri Sep 03 1999 werner@suse.de
|
||||
* Sat Sep 04 1999 werner@suse.de
|
||||
- Update to new version 1.3.32
|
||||
- Add sparc patch
|
||||
- Add security patch (DOS)
|
||||
@ -509,7 +516,7 @@ fi
|
||||
- /var/log/news should be owned by news.news
|
||||
* Thu Jan 07 1999 bs@suse.de
|
||||
- fixed comment in syslog.conf
|
||||
* Mon Dec 14 1998 ro@suse.de
|
||||
* Tue Dec 15 1998 ro@suse.de
|
||||
- removed noreplace from syslogd.conf: necessary change for news-logs
|
||||
* Fri Dec 11 1998 ro@suse.de
|
||||
- split up news logs
|
||||
|
Loading…
Reference in New Issue
Block a user