git.iko.soy/typeable/nixpkgs
on master help sign in
fix the impurity error. However, this introduces another error. Apparently

there is some difference between "install" on my FC3 machine and "install" in coreutils in Nix: building install_man install -o root -g root -m 644 sysklogd.8 /nix/store/x03w5xpzcya04b4ax47lic2ahnf479nz-sysklogd-1.4.1/usr/share/man/man8/sysklogd.8 install: cannot change ownership of `/nix/store/x03w5xpzcya04b4ax47lic2ahnf479nz-sysklogd-1.4.1/usr/share/man/man8/sysklogd.8': Operation not permitted make: *** [install_man] Error 1 svn path=/nixpkgs/trunk/; revision=5035

commit920ff11c96adb56b389be31ff0042e136c4f61c2 authorArmijn Hemel <armijn@gpl-violations.org> dateTue 14 Mar 2006, 15:30 (21 years ago) parent304f3fb
2 files changed+902−1
pkgs/os-specific/linux/sysklogd/default.nix+1−1 pkgs/os-specific/linux/sysklogd/sysklogd-1.4.1-cvs-20050525-local.diff+901
pkgs/os-specific/linux/sysklogd/default.nix+1−1
@@ -7,5 +7,5 @@ stdenv.mkDerivation {
77 url = http://nix.cs.uu.nl/dist/tarballs/sysklogd-1.4.1.tar.gz;
88 md5 = "d214aa40beabf7bdb0c9b3c64432c774";
99 };
10− patches = [./sysklogd-1.4.1-cvs-20050525.diff ./sysklogd-1.4.1-asm.patch];
10+ patches = [./sysklogd-1.4.1-cvs-20050525-local.diff ./sysklogd-1.4.1-asm.patch];
1111}
pkgs/os-specific/linux/sysklogd/sysklogd-1.4.1-cvs-20050525-local.diffnew file+901
@@ -0,0 +1,901 @@
1+diff -ruN sysklogd-1.4.1/CHANGES sysklogd-1.4.1.new/CHANGES
2+--- sysklogd-1.4.1/CHANGES 2001-03-11 20:35:51.000000000 +0100
3++++ sysklogd-1.4.1.new/CHANGES 2006-03-14 16:22:13.000000000 +0100
4+@@ -1,3 +1,42 @@
5++Version 1.4.2
6++
7++ . Dmitry V. Levin <ldv@altlinux.org>
8++ - Close file descriptor in FindSymbolFile() in ksym.c in order not to
9++ leak file descriptors.
10++ . Solar Designer <solar@openwall.com>
11++ - improve crunch_list()
12++ - Prevent potential buffer overflow in reading messages from the
13++ kernel log ringbuffer.
14++ - Ensure that "len" is not placed in a register, and that the
15++ endtty() signal handler is not installed too early which could
16++ cause a segmentation fault or worse.
17++ . Steve Grubb <linux_4ever@yahoo.com>
18++ - fix memory calculation in crunch_list()
19++ . Martin Schulze <joey@infodrom.org>
20++ - klogd will reconnect to the logger (mostly syslogd) after it went
21++ away
22++ - On heavily loaded system syslog will not spit out error messages
23++ anymore when recvfrom() results in EAGAIN
24++ - Makefile improvements
25++ - Local copy of module.h
26++ - Improved sysklogd.8
27++ - Always log with syslogd's timezone and locale
28++ - Remove trailing newline when forwarding messages
29++ . Jon Burgess <Jon_Burgess@eur.3com.com>
30++ - Moved the installation of the signal handler up a little bit so it
31++ guaranteed to be available when the child is forked, hence, fixing a
32++ race condition. This used to create problems with UML and fast
33++ machines.
34++ . Greg Trounson <gregt@maths.otago.ac.nz>
35++ - Improved README.linux
36++ . Ulf H�rnhammar <Ulf.Harnhammar.9485@student.uu.se>
37++ - Bondary check for fscanf() in InitKsyms() and CheckMapVersion()
38++ . Colin Phipps <cph@cph.demon.co.uk>
39++ - Don't block on the network socket in case of package los
40++ . Dirk Mueller <mueller@kde.org>
41++ - Don't crash when filesize limit is reached (e.g. without LFS)
42++
43++
44+ Version 1.4.1
45+
46+ . klogd will set the console log level only if `-c' is given on the
47+@@ -30,3 +69,9 @@
48+ . Olaf Kirch <okir@caldera.de>
49+ - Remove Unix Domain Sockets and switch to Datagram Unix Sockets
50+ . Several bugfixes and improvements, please refer to the .c files
51++
52++
53++Local variables:
54++mode: indented-text
55++fill-column: 72
56++End:
57+diff -ruN sysklogd-1.4.1/klogd.8 sysklogd-1.4.1.new/klogd.8
58+--- sysklogd-1.4.1/klogd.8 2001-03-11 20:35:51.000000000 +0100
59++++ sysklogd-1.4.1.new/klogd.8 2006-03-14 16:22:13.000000000 +0100
60+@@ -3,8 +3,9 @@
61+ .\" Sun Jul 30 01:35:55 MET: Martin Schulze: Updates
62+ .\" Sun Nov 19 23:22:21 MET: Martin Schulze: Updates
63+ .\" Mon Aug 19 09:42:08 CDT 1996: Dr. G.W. Wettstein: Updates
64++.\" Fri Mar 11 17:11:46 CET 2005: Martin Schulze: sysctl updates
65+ .\"
66+-.TH KLOGD 8 "21 August, 1999" "Version 1.4" "Linux System Administration"
67++.TH KLOGD 8 "11 March 2005" "Version 1.4" "Linux System Administration"
68+ .SH NAME
69+ klogd \- Kernel Log Daemon
70+ .LP
71+@@ -38,6 +39,12 @@
72+ .TP
73+ .BI "\-c " n
74+ Sets the default log level of console messages to \fIn\fR.
75++This should nowardays be configured with the
76++.BR sysctl (8)
77++program, e.g. via
78++.BI "sysctl kernel.printk=" n
79++or via
80++.IR /etc/sysctl.conf .
81+ .TP
82+ .B "\-d"
83+ Enable debugging mode. This will generate \fBLOTS\fR of output to
84+@@ -321,7 +328,7 @@
85+ .B klogd
86+ to reload the module symbol information whenever a protection fault
87+ is detected. Caution should be used before invoking the program in
88+-\'paranoid\' mode. The stability of the kernel and the operating
89++\&'paranoid\&' mode. The stability of the kernel and the operating
90+ environment is always under question when a protection fault occurs.
91+ Since the klogd daemon must execute system calls in order to read the
92+ module symbol information there is the possibility that the system may
93+diff -ruN sysklogd-1.4.1/klogd.c sysklogd-1.4.1.new/klogd.c
94+--- sysklogd-1.4.1/klogd.c 2001-03-11 20:40:10.000000000 +0100
95++++ sysklogd-1.4.1.new/klogd.c 2006-03-14 16:22:13.000000000 +0100
96+@@ -243,6 +243,9 @@
97+ * people have submitted patches: Troels Walsted Hansen
98+ * <troels@thule.no>, Wolfgang Oertl <Wolfgang.Oertl@uibk.ac.at>
99+ * and Thomas Roessler.
100++ * Thu Apr 29 15:24:07 2004: Solar Designer <solar@openwall.com>
101++ * Prevent potential buffer overflow in reading messages from the
102++ * kernel log rinbuffer.
103+ */
104+
105+
106+@@ -938,7 +941,7 @@
107+ * messages into this fresh buffer.
108+ */
109+ memset(log_buffer, '\0', sizeof(log_buffer));
110+- if ( (rdcnt = ksyslog(2, log_buffer, sizeof(log_buffer))) < 0 )
111++ if ( (rdcnt = ksyslog(2, log_buffer, sizeof(log_buffer)-1)) < 0 )
112+ {
113+ if ( errno == EINTR )
114+ return;
115+diff -ruN sysklogd-1.4.1/ksym.c sysklogd-1.4.1.new/ksym.c
116+--- sysklogd-1.4.1/ksym.c 2000-09-12 23:53:31.000000000 +0200
117++++ sysklogd-1.4.1.new/ksym.c 2006-03-14 16:22:13.000000000 +0100
118+@@ -105,6 +105,15 @@
119+ *
120+ * Tue Sep 12 23:48:12 CEST 2000: Martin Schulze <joey@infodrom.ffis.de>
121+ * Close symbol file in InitKsyms() when an error occurred.
122++ *
123++ * Thu Apr 29 18:07:16 CEST 2004: Dmitry Levin <ldv@altlinux.org>
124++ * Close file descriptor in FindSymbolFile() in order not to leak
125++ * file descriptors.
126++ *
127++ * Fri Jul 16 08:32:49 CEST 2004: Ulf H�rnhammar <Ulf.Harnhammar.9485@student.uu.se>
128++ * Added boundary check for fscanf() in InitKsyms() and
129++ * CheckMapVersion() to prevent an unintended crash when reading
130++ * an incorrect System.map.
131+ */
132+
133+
134+@@ -236,7 +245,7 @@
135+ */
136+ while ( !feof(sym_file) )
137+ {
138+- if ( fscanf(sym_file, "%lx %c %s\n", &address, &type, sym)
139++ if ( fscanf(sym_file, "%lx %c %511s\n", &address, &type, sym)
140+ != 3 )
141+ {
142+ Syslog(LOG_ERR, "Error in symbol table input (#1).");
143+@@ -344,6 +353,7 @@
144+ if ( (sym_file = fopen(symfile, "r")) != (FILE *) 0 ) {
145+ if (CheckMapVersion(symfile) == 1)
146+ file = symfile;
147++ fclose (sym_file);
148+ }
149+ if (sym_file == (FILE *) 0 || file == (char *) 0) {
150+ sprintf (symfile, "%s", *mf);
151+@@ -352,6 +362,7 @@
152+ if ( (sym_file = fopen(symfile, "r")) != (FILE *) 0 ) {
153+ if (CheckMapVersion(symfile) == 1)
154+ file = symfile;
155++ fclose (sym_file);
156+ }
157+ }
158+
159+@@ -533,7 +544,7 @@
160+ version = 0;
161+ while ( !feof(sym_file) && (version == 0) )
162+ {
163+- if ( fscanf(sym_file, "%lx %c %s\n", &address, \
164++ if ( fscanf(sym_file, "%lx %c %511s\n", &address, \
165+ &type, sym) != 3 )
166+ {
167+ Syslog(LOG_ERR, "Error in symbol table input (#2).");
168+@@ -899,3 +910,11 @@
169+ return;
170+ }
171+ #endif
172++
173++/*
174++ * Local variables:
175++ * c-indent-level: 8
176++ * c-basic-offset: 8
177++ * tab-width: 8
178++ * End:
179++ */
180+diff -ruN sysklogd-1.4.1/ksym_mod.c sysklogd-1.4.1.new/ksym_mod.c
181+--- sysklogd-1.4.1/ksym_mod.c 2000-09-12 23:15:28.000000000 +0200
182++++ sysklogd-1.4.1.new/ksym_mod.c 2006-03-14 16:22:13.000000000 +0100
183+@@ -78,6 +78,11 @@
184+ *
185+ * Tue Sep 12 23:11:13 CEST 2000: Martin Schulze <joey@infodrom.ffis.de>
186+ * Changed llseek() to lseek64() in order to skip a libc warning.
187++ *
188++ * Wed Mar 31 17:35:01 CEST 2004: Martin Schulze <joey@infodrom.org>
189++ * Removed references to <linux/module.h> since it doesn't work
190++ * anymore with its recent content from Linux 2.4/2.6, created
191++ * module.h locally instead.
192+ */
193+
194+
195+@@ -89,11 +94,12 @@
196+ #include <errno.h>
197+ #include <sys/fcntl.h>
198+ #include <sys/stat.h>
199++#include "module.h"
200+ #if !defined(__GLIBC__)
201+ #include <linux/time.h>
202+-#include <linux/module.h>
203++#include <linux/linkage.h>
204+ #else /* __GLIBC__ */
205+-#include <linux/module.h>
206++#include <linux/linkage.h>
207+ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
208+ extern int get_kernel_syms __P ((struct kernel_sym *__table));
209+ #endif /* __GLIBC__ */
210+@@ -107,7 +113,7 @@
211+
212+ #if !defined(__GLIBC__)
213+ /*
214+- * The following bit uses some kernel/library magic to product what
215++ * The following bit uses some kernel/library magic to produce what
216+ * looks like a function call to user level code. This function is
217+ * actually a system call in disguise. The purpose of the getsyms
218+ * call is to return a current copy of the in-kernel symbol table.
219+diff -ruN sysklogd-1.4.1/Makefile sysklogd-1.4.1.new/Makefile
220+--- sysklogd-1.4.1/Makefile 1998-10-12 22:25:15.000000000 +0200
221++++ sysklogd-1.4.1.new/Makefile 2006-03-14 16:22:41.000000000 +0100
222+@@ -4,12 +4,15 @@
223+ #CFLAGS= -g -DSYSV -Wall
224+ #LDFLAGS= -g
225+ CFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce
226++# -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
227+ LDFLAGS= -s
228+
229+ # Look where your install program is.
230+-INSTALL = /usr/bin/install
231+-BINDIR = /usr/sbin
232+-MANDIR = /usr/man
233++INSTALL = install
234++
235++# Destination paths, set prefix=/opt if required
236++BINDIR = $(prefix)/usr/sbin
237++MANDIR = $(prefix)/usr/share/man
238+
239+ # There is one report that under an all ELF system there may be a need to
240+ # explicilty link with libresolv.a. If linking syslogd fails you may wish
241+@@ -34,8 +37,9 @@
242+ # The following define establishes ownership for the man pages.
243+ # Avery tells me that there is a difference between Debian and
244+ # Slackware. Rather than choose sides I am leaving it up to the user.
245+-MAN_OWNER = root
246+-# MAN_OWNER = man
247++MAN_USER = root
248++MAN_GROUP = root
249++MAN_PERMS = 644
250+
251+ # The following define establishes the name of the pid file for the
252+ # syslogd daemon. The library include file (paths.h) defines the
253+@@ -116,7 +120,7 @@
254+ ${INSTALL} -m 500 -s klogd ${BINDIR}/klogd
255+
256+ install_man:
257+- ${INSTALL} -o ${MAN_OWNER} -g ${MAN_OWNER} -m 644 sysklogd.8 ${MANDIR}/man8/sysklogd.8
258+- ${INSTALL} -o ${MAN_OWNER} -g ${MAN_OWNER} -m 644 syslogd.8 ${MANDIR}/man8/syslogd.8
259+- ${INSTALL} -o ${MAN_OWNER} -g ${MAN_OWNER} -m 644 syslog.conf.5 ${MANDIR}/man5/syslog.conf.5
260+- ${INSTALL} -o ${MAN_OWNER} -g ${MAN_OWNER} -m 644 klogd.8 ${MANDIR}/man8/klogd.8
261++ ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} sysklogd.8 ${MANDIR}/man8/sysklogd.8
262++ ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} syslogd.8 ${MANDIR}/man8/syslogd.8
263++ ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} syslog.conf.5 ${MANDIR}/man5/syslog.conf.5
264++ ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} klogd.8 ${MANDIR}/man8/klogd.8
265+diff -ruN sysklogd-1.4.1/module.h sysklogd-1.4.1.new/module.h
266+--- sysklogd-1.4.1/module.h 1970-01-01 01:00:00.000000000 +0100
267++++ sysklogd-1.4.1.new/module.h 2006-03-14 16:22:13.000000000 +0100
268+@@ -0,0 +1,90 @@
269++/*
270++ module.h - Miscellaneous module definitions
271++ Copyright (c) 1996 Richard Henderson <rth@tamu.edu>
272++ Copyright (c) 2004 Martin Schulze <joey@infodrom.org>
273++
274++ This file is part of the sysklogd package.
275++
276++ This program is free software; you can redistribute it and/or modify
277++ it under the terms of the GNU General Public License as published by
278++ the Free Software Foundation; either version 2 of the License, or
279++ (at your option) any later version.
280++
281++ This program is distributed in the hope that it will be useful,
282++ but WITHOUT ANY WARRANTY; without even the implied warranty of
283++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
284++ GNU General Public License for more details.
285++
286++ You should have received a copy of the GNU General Public License
287++ along with this program; if not, write to the Free Software
288++ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
289++*/
290++
291++/* ChangeLog:
292++ *
293++ * Wed Mar 31 17:35:01 CEST 2004: Martin Schulze <joey@infodrom.org>
294++ * Created local copy of module.h based on the content of Linux
295++ * 2.2 since <linux/module.h> doesn't work anymore with its
296++ * recent content from Linux 2.4/2.6.
297++ */
298++
299++#include <asm/atomic.h>
300++
301++#define MODULE_NAME_LEN 60
302++
303++struct kernel_sym
304++{
305++ unsigned long value;
306++ char name[MODULE_NAME_LEN];
307++};
308++
309++
310++struct list_head {
311++ struct list_head *next, *prev;
312++};
313++
314++
315++struct module_info
316++{
317++ unsigned long addr;
318++ unsigned long size;
319++ unsigned long flags;
320++ long usecount;
321++};
322++
323++
324++struct module
325++{
326++ unsigned long size_of_struct; /* == sizeof(module) */
327++ struct module *next;
328++ const char *name;
329++ unsigned long size;
330++
331++ union
332++ {
333++ int usecount;
334++ long pad;
335++ } uc; /* Needs to keep its size - so says rth */
336++
337++ unsigned long flags; /* AUTOCLEAN et al */
338++
339++ unsigned nsyms;
340++ unsigned ndeps;
341++
342++ struct module_symbol *syms;
343++ struct module_ref *deps;
344++ struct module_ref *refs;
345++ int (*init)(void);
346++ void (*cleanup)(void);
347++ const struct exception_table_entry *ex_table_start;
348++ const struct exception_table_entry *ex_table_end;
349++#ifdef __alpha__
350++ unsigned long gp;
351++#endif
352++ /* Members past this point are extensions to the basic
353++ module support and are optional. Use mod_opt_member()
354++ to examine them. */
355++ const struct module_persist *persist_start;
356++ const struct module_persist *persist_end;
357++ int (*can_unload)(void);
358++};
359+diff -ruN sysklogd-1.4.1/pidfile.c sysklogd-1.4.1.new/pidfile.c
360+--- sysklogd-1.4.1/pidfile.c 1998-02-10 23:37:12.000000000 +0100
361++++ sysklogd-1.4.1.new/pidfile.c 2006-03-14 16:22:13.000000000 +0100
362+@@ -87,7 +87,7 @@
363+ int fd;
364+ int pid;
365+
366+- if ( ((fd = open(pidfile, O_RDWR|O_CREAT, 0644)) == -1)
367++ if ( ((fd = open(pidfile, O_RDWR|O_CREAT|O_TRUNC, 0644)) == -1)
368+ || ((f = fdopen(fd, "r+")) == NULL) ) {
369+ fprintf(stderr, "Can't open or create %s.\n", pidfile);
370+ return 0;
371+diff -ruN sysklogd-1.4.1/README.1st sysklogd-1.4.1.new/README.1st
372+--- sysklogd-1.4.1/README.1st 1997-06-02 19:21:39.000000000 +0200
373++++ sysklogd-1.4.1.new/README.1st 2006-03-14 16:22:13.000000000 +0100
374+@@ -1,5 +1,5 @@
375+-Very important information before using version 1.3
376+----------------------------------------------------
377++Important information
378++---------------------
379+
380+ The included version of syslogd behaves in a slightly different manner
381+ to the one in former releases. Please review the following important
382+@@ -63,3 +63,10 @@
383+ these scripts should remove all old .pid files found in /var/run.
384+ This will insure that klogd and syslogd start properly even if prior
385+ executions have been terminated harshly.
386++
387++* Large file support, i.e. support to write to log files that are
388++ larger than 2 GB is not part of syslogd, but a matter of the Glibc
389++ emitting different system calls to the kernel interface. To support
390++ large files you'll have to compile syslogd with the compiler defines
391++ -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE so that glibc adjusts the
392++ system calls.
393+diff -ruN sysklogd-1.4.1/README.linux sysklogd-1.4.1.new/README.linux
394+--- sysklogd-1.4.1/README.linux 1999-01-19 01:09:12.000000000 +0100
395++++ sysklogd-1.4.1.new/README.linux 2006-03-14 16:22:13.000000000 +0100
396+@@ -40,12 +40,17 @@
397+ a useful addition to the software gene pool.
398+
399+ There is a mailing list covering this package and syslog in general.
400+-The lists address is sysklogd@Infodrom.North.DE . To subscribe send a
401+-mail to Majordomo@Infodrom.North.DE with a line "subscribe sysklogd"
402++The lists address is infodrom-sysklogd@lists.infodrom.org . To subscribe send a
403++mail to majordomo@lists.infodrom.org with a line "subscribe infodrom-sysklogd"
404+ in the message body.
405+
406+-New versions of this package will be available at Joey's ftp server.
407+-ftp://ftp.infodrom.north.de/pub/people/joey/sysklogd/
408++A second mailing list exists as infodrom-sysklogd-cvs@lists.infodrom.org. Only
409++CVS messages and diffs are distributed there. Whenever new code is added to
410++sysklogd, CVS generates a mail from these changes which will be sent to
411++this list. Discussions will take place on the first list.
412++
413++The latest version of this software can be found at:
414++http://www.infodrom.org/projects/sysklogd/download.php3
415+
416+ Best regards,
417+
418+@@ -67,6 +72,6 @@
419+
420+ Martin Schulze
421+ Infodrom Oldenburg
422+-joey@linux.de
423++joey@infodrom.org
424+
425+-And a host of bug reporters whose contributions cannot be underestimated.
426++And a number of bug reporters whose contributions cannot be underestimated.
427+diff -ruN sysklogd-1.4.1/sysklogd.8 sysklogd-1.4.1.new/sysklogd.8
428+--- sysklogd-1.4.1/sysklogd.8 2001-03-11 20:35:51.000000000 +0100
429++++ sysklogd-1.4.1.new/sysklogd.8 2006-03-14 16:22:13.000000000 +0100
430+@@ -84,7 +84,7 @@
431+ .B MAXFUNIX
432+ within the syslogd.c source file. An example for a chroot() daemon is
433+ described by the people from OpenBSD at
434+-http://www.psionic.com/papers/dns.html.
435++<http://www.guides.sk/psionic/dns/>.
436+ .TP
437+ .B "\-d"
438+ Turns on debug mode. Using this the daemon will not proceed a
439+@@ -117,7 +117,8 @@
440+ between two \fI-- MARK --\fR lines is 20 minutes. This can be changed
441+ with this option. Setting the
442+ .I interval
443+-to zero turns it off entirely.
444++to zero turns it off entirely. Depending on other log messages
445++generated these lines may not be written consecutively.
446+ .TP
447+ .B "\-n"
448+ Avoid auto-backgrounding. This is needed especially if the
449+@@ -364,8 +365,10 @@
450+
451+ To avoid this in further times no messages that were received from a
452+ remote host are sent out to another (or the same) remote host
453+-anymore. If there are scenarios where this doesn't make sense, please
454+-drop me (Joey) a line.
455++anymore. If you experience are setup in which this doesn't make
456++sense, please use the
457++.B \-h
458++commandline switch.
459+
460+ If the remote host is located in the same domain as the host,
461+ .B syslogd
462+diff -ruN sysklogd-1.4.1/syslog.c sysklogd-1.4.1.new/syslog.c
463+--- sysklogd-1.4.1/syslog.c 2001-03-11 20:35:51.000000000 +0100
464++++ sysklogd-1.4.1.new/syslog.c 2006-03-14 16:22:13.000000000 +0100
465+@@ -47,6 +47,9 @@
466+ * Sun Mar 11 20:23:44 CET 2001: Martin Schulze <joey@infodrom.ffis.de>
467+ * Use SOCK_DGRAM for loggin, renables it to work.
468+ *
469++ * Wed Aug 27 17:48:16 CEST 2003: Martin Schulze <joey@Infodrom.org>
470++ * Improved patch by Michael Pomraning <mjp@securepipe.com> to
471++ * reconnect klogd to the logger after it went away.
472+ */
473+
474+ #include <sys/types.h>
475+@@ -98,6 +101,7 @@
476+ register char *p;
477+ time_t now;
478+ int fd, saved_errno;
479++ int result;
480+ char tbuf[2048], fmt_cpy[1024], *stdp = (char *) 0;
481+
482+ saved_errno = errno;
483+@@ -167,7 +171,16 @@
484+ }
485+
486+ /* output the message to the local logger */
487+- if (write(LogFile, tbuf, cnt + 1) >= 0 || !(LogStat&LOG_CONS))
488++ result = write(LogFile, tbuf, cnt + 1);
489++
490++ if (result == -1
491++ && (errno == ECONNRESET || errno == ENOTCONN || errno == ECONNREFUSED)) {
492++ closelog();
493++ openlog(LogTag, LogStat | LOG_NDELAY, LogFacility);
494++ result = write(LogFile, tbuf, cnt + 1);
495++ }
496++
497++ if (result >= 0 || !(LogStat&LOG_CONS))
498+ return;
499+
500+ /*
501+diff -ruN sysklogd-1.4.1/syslog.conf.5 sysklogd-1.4.1.new/syslog.conf.5
502+--- sysklogd-1.4.1/syslog.conf.5 1999-08-21 12:49:14.000000000 +0200
503++++ sysklogd-1.4.1.new/syslog.conf.5 2006-03-14 16:22:13.000000000 +0100
504+@@ -64,7 +64,7 @@
505+ The
506+ .I facility
507+ is one of the following keywords:
508+-.BR auth ", " authpriv ", " cron ", " daemon ", " kern ", " lpr ", "
509++.BR auth ", " authpriv ", " cron ", " daemon ", " ftp ", " kern ", " lpr ", "
510+ .BR mail ", " mark ", " news ", " security " (same as " auth "), "
511+ .BR syslog ", " user ", " uucp " and " local0 " through " local7 .
512+ The keyword
513+@@ -121,12 +121,21 @@
514+
515+ This
516+ .BR syslogd (8)
517+-has a syntax extension to the original BSD source, that makes its use
518++has a syntax extension to the original BSD source, which makes its use
519+ more intuitively. You may precede every priority with an equation sign
520+-(``='') to specify only this single priority and not any of the
521+-above. You may also (both is valid, too) precede the priority with an
522+-exclamation mark (``!'') to ignore all that priorities, either exact
523+-this one or this and any higher priority. If you use both extensions
524++(``='') to specify that
525++.B syslogd
526++should only refer to this single priority and not this priority and
527++all higher priorities.
528++
529++You may also precide the priority with an exclamation mark (``!'') if
530++you want
531++.B syslogd
532++to ignore this priority and all higher priorities.
533++You may even use both, the exclamation mark and the equation sign if
534++you want
535++.B syslogd
536++to ignore only this single priority. If you use both extensions
537+ than the exclamation mark must occur before the equation sign, just
538+ use it intuitively.
539+
540+@@ -300,7 +309,7 @@
541+ .B syslogd
542+ log all messages that come with either the
543+ .BR info " or the " notice
544+-facility into the file
545++priority into the file
546+ .IR /var/log/messages ,
547+ except for all messages that use the
548+ .B mail
549+diff -ruN sysklogd-1.4.1/syslogd.c sysklogd-1.4.1.new/syslogd.c
550+--- sysklogd-1.4.1/syslogd.c 2001-03-11 20:40:10.000000000 +0100
551++++ sysklogd-1.4.1.new/syslogd.c 2006-03-14 16:22:13.000000000 +0100
552+@@ -441,6 +441,39 @@
553+ * Don't return a closed fd if `-a' is called with a wrong path.
554+ * Thanks to Bill Nottingham <notting@redhat.com> for providing
555+ * a patch.
556++ * Thu Apr 13 05:08:10 CEST 2001: Jon Burgess <Jon_Burgess@eur.3com.com>
557++ * Moved the installation of the signal handler up a little bit
558++ * so it guaranteed to be available when the child is forked,
559++ * hence, fixing a race condition. This used to create problems
560++ * with UML and fast machines.
561++ *
562++ * Sat Apr 17 18:03:05 CEST 2004: Steve Grubb <linux_4ever@yahoo.com>
563++ * Correct memory allocation for for commandline arguments in
564++ * crunch_list().
565++ *
566++ * Thu Apr 29 12:38:39 CEST 2004: Solar Designer <solar@openwall.com>
567++ * Applied Openwall paranoia patches to improve crunch_list().
568++ *
569++ * Tue May 4 16:47:30 CEST 2004: Solar Designer <solar@openwall.com>
570++ * Ensure that "len" is not placed in a register, and that the
571++ * endtty() signal handler is not installed too early which could
572++ * cause a segmentation fault or worse.
573++ *
574++ * Tue May 4 16:52:01 CEST 2004: Solar Designer <solar@openwall.com>
575++ * Adjust the size of a variable to prevent a buffer overflow
576++ * should _PATH_DEV ever contain something different than "/dev/".
577++ *
578++ * Tue Nov 2 20:28:23 CET 2004: Colin Phipps <cph@cph.demon.co.uk>
579++ * Don't block on the network socket, in case a packet gets lost
580++ * between select and recv.
581++ *
582++ * Sun Nov 7 12:28:47 CET 2004: Martin Schulze <joey@infodrom.org>
583++ * Discard any timestamp information found in received syslog
584++ * messages. This will affect local messages sent from a
585++ * different timezone.
586++ *
587++ * Sun Nov 7 13:47:00 CET 2004: Martin Schulze <joey@infodrom.org>
588++ * Remove trailing newline when forwarding messages.
589+ */
590+
591+
592+@@ -890,11 +923,11 @@
593+ dprintf("Checking pidfile.\n");
594+ if (!check_pid(PidFile))
595+ {
596++ signal (SIGTERM, doexit);
597+ if (fork()) {
598+ /*
599+ * Parent process
600+ */
601+- signal (SIGTERM, doexit);
602+ sleep(300);
603+ /*
604+ * Not reached unless something major went wrong. 5
605+@@ -992,6 +1025,7 @@
606+ (void) signal(SIGCHLD, reapchild);
607+ (void) signal(SIGALRM, domark);
608+ (void) signal(SIGUSR1, Debug ? debug_switch : SIG_IGN);
609++ (void) signal(SIGXFSZ, SIG_IGN);
610+ (void) alarm(TIMERINTVL);
611+
612+ /* Create a partial message table for all file descriptors. */
613+@@ -1141,13 +1175,13 @@
614+ */
615+ printchopped(from, line, \
616+ i + 2, finet);
617+- } else if (i < 0 && errno != EINTR) {
618++ } else if (i < 0 && errno != EINTR && errno != EAGAIN) {
619+ dprintf("INET socket error: %d = %s.\n", \
620+ errno, strerror(errno));
621+ logerror("recvfrom inet");
622+ /* should be harmless now that we set
623+ * BSDCOMPAT on the socket */
624+- sleep(10);
625++ sleep(1);
626+ }
627+ }
628+ #endif
629+@@ -1216,6 +1250,7 @@
630+ {
631+ int fd, on = 1;
632+ struct sockaddr_in sin;
633++ int sockflags;
634+
635+ fd = socket(AF_INET, SOCK_DGRAM, 0);
636+ if (fd < 0) {
637+@@ -1241,6 +1276,24 @@
638+ close(fd);
639+ return -1;
640+ }
641++ /* We must not block on the network socket, in case a packet
642++ * gets lost between select and recv, otherise the process
643++ * will stall until the timeout, and other processes trying to
644++ * log will also stall.
645++ */
646++ if ((sockflags = fcntl(fd, F_GETFL)) != -1) {
647++ sockflags |= O_NONBLOCK;
648++ /*
649++ * SETFL could fail too, so get it caught by the subsequent
650++ * error check.
651++ */
652++ sockflags = fcntl(fd, F_SETFL, sockflags);
653++ }
654++ if (sockflags == -1) {
655++ logerror("fcntl(O_NONBLOCK), suspending inet");
656++ close(fd);
657++ return -1;
658++ }
659+ if (bind(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
660+ logerror("bind, suspending inet");
661+ close(fd);
662+@@ -1254,30 +1307,26 @@
663+ crunch_list(list)
664+ char *list;
665+ {
666+- int count, i;
667++ int i, m, n;
668+ char *p, *q;
669+ char **result = NULL;
670+
671+ p = list;
672+
673+ /* strip off trailing delimiters */
674+- while (p[strlen(p)-1] == LIST_DELIMITER) {
675+- count--;
676++ while (*p && p[strlen(p)-1] == LIST_DELIMITER)
677+ p[strlen(p)-1] = '\0';
678+- }
679+ /* cut off leading delimiters */
680+- while (p[0] == LIST_DELIMITER) {
681+- count--;
682++ while (p[0] == LIST_DELIMITER)
683+ p++;
684+- }
685+
686+- /* count delimiters to calculate elements */
687+- for (count=i=0; p[i]; i++)
688+- if (p[i] == LIST_DELIMITER) count++;
689++ /* count delimiters to calculate the number of elements */
690++ for (n = i = 0; p[i]; i++)
691++ if (p[i] == LIST_DELIMITER) n++;
692+
693+- if ((result = (char **)malloc(sizeof(char *) * count+2)) == NULL) {
694++ if ((result = (char **)malloc(sizeof(char *) * (n + 2))) == NULL) {
695+ printf ("Sorry, can't get enough memory, exiting.\n");
696+- exit(0);
697++ exit(1);
698+ }
699+
700+ /*
701+@@ -1285,30 +1334,28 @@
702+ * characters are different from any delimiters,
703+ * so we don't have to care about this.
704+ */
705+- count = 0;
706+- while ((q=strchr(p, LIST_DELIMITER))) {
707+- result[count] = (char *) malloc((q - p + 1) * sizeof(char));
708+- if (result[count] == NULL) {
709++ m = 0;
710++ while ((q = strchr(p, LIST_DELIMITER)) && m < n) {
711++ result[m] = (char *) malloc((q - p + 1) * sizeof(char));
712++ if (result[m] == NULL) {
713+ printf ("Sorry, can't get enough memory, exiting.\n");
714+- exit(0);
715++ exit(1);
716+ }
717+- strncpy(result[count], p, q - p);
718+- result[count][q - p] = '\0';
719++ memcpy(result[m], p, q - p);
720++ result[m][q - p] = '\0';
721+ p = q; p++;
722+- count++;
723++ m++;
724+ }
725+- if ((result[count] = \
726+- (char *)malloc(sizeof(char) * strlen(p) + 1)) == NULL) {
727++ if ((result[m] = strdup(p)) == NULL) {
728+ printf ("Sorry, can't get enough memory, exiting.\n");
729+- exit(0);
730++ exit(1);
731+ }
732+- strcpy(result[count],p);
733+- result[++count] = NULL;
734++ result[++m] = NULL;
735+
736+ #if 0
737+- count=0;
738+- while (result[count])
739+- dprintf ("#%d: %s\n", count, StripDomains[count++]);
740++ m = 0;
741++ while (result[m])
742++ dprintf ("#%d: %s\n", m, result[m++]);
743+ #endif
744+ return result;
745+ }
746+@@ -1539,30 +1586,48 @@
747+ int fac, prilev, lognum;
748+ int msglen;
749+ char *timestamp;
750++#ifdef __gnu_linux__
751++ sigset_t mask;
752++#else
753++#ifndef SYSV
754++ sigset_t omask;
755++#endif
756++#endif
757+
758+ dprintf("logmsg: %s, flags %x, from %s, msg %s\n", textpri(pri), flags, from, msg);
759+
760++#ifdef __gnu_linux__
761++ sigemptyset(&mask);
762++ sigaddset(&mask, SIGHUP);
763++ sigaddset(&mask, SIGALRM);
764++ sigprocmask(SIG_BLOCK, &mask, NULL);
765++#else
766+ #ifndef SYSV
767+ omask = sigblock(sigmask(SIGHUP)|sigmask(SIGALRM));
768+ #endif
769++#endif
770+
771+ /*
772+ * Check to see if msg looks non-standard.
773++ *
774++ * A message looks like
775++ * Nov 17 11:42:33 CRON[
776++ * 01234567890123456
777++ * ^ ^ ^ ^ ^
778++ *
779++ * Remote messages are not accompanied by a timestamp.
780++ * Local messages are accompanied by a timestamp (program's timezone)
781+ */
782+ msglen = strlen(msg);
783+- if (msglen < 16 || msg[3] != ' ' || msg[6] != ' ' ||
784+- msg[9] != ':' || msg[12] != ':' || msg[15] != ' ')
785+- flags |= ADDDATE;
786+-
787+- (void) time(&now);
788+- if (flags & ADDDATE)
789+- timestamp = ctime(&now) + 4;
790+- else {
791+- timestamp = msg;
792++ if (!(msglen < 16 || msg[3] != ' ' || msg[6] != ' ' ||
793++ msg[9] != ':' || msg[12] != ':' || msg[15] != ' ')) {
794+ msg += 16;
795+ msglen -= 16;
796+ }
797+
798++ (void) time(&now);
799++ timestamp = ctime(&now) + 4;
800++
801+ /* extract facility and priority level */
802+ if (flags & MARK)
803+ fac = LOG_NFACILITIES;
804+@@ -1581,9 +1646,13 @@
805+ (void) close(f->f_file);
806+ f->f_file = -1;
807+ }
808++#ifdef __gnu_linux__
809++ sigprocmask(SIG_UNBLOCK, &mask, NULL);
810++#else
811+ #ifndef SYSV
812+ (void) sigsetmask(omask);
813+ #endif
814++#endif
815+ return;
816+ }
817+ #ifdef SYSV
818+@@ -1646,9 +1715,13 @@
819+ }
820+ }
821+ }
822++#ifdef __gnu_linux__
823++ sigprocmask(SIG_UNBLOCK, &mask, NULL);
824++#else
825+ #ifndef SYSV
826+ (void) sigsetmask(omask);
827+ #endif
828++#endif
829+ }
830+ #if FALSE
831+ } /* balance parentheses for emacs */
832+@@ -1771,7 +1844,7 @@
833+ dprintf("Not sending message to remote.\n");
834+ else {
835+ f->f_time = now;
836+- (void) snprintf(line, sizeof(line), "<%d>%s\n", f->f_prevpri, \
837++ (void) snprintf(line, sizeof(line), "<%d>%s", f->f_prevpri, \
838+ (char *) iov[4].iov_base);
839+ l = strlen(line);
840+ if (l > MAXLINE)
841+@@ -1815,7 +1888,7 @@
842+ v->iov_len = 1;
843+ }
844+ again:
845+- /* f->f_file == -1 is an indicator that the we couldn't
846++ /* f->f_file == -1 is an indicator that we couldn't
847+ open the file at startup. */
848+ if (f->f_file == -1)
849+ break;
850+@@ -1852,7 +1925,7 @@
851+ errno = e;
852+ logerror(f->f_un.f_fname);
853+ }
854+- } else if (f->f_flags & SYNC_FILE)
855++ } else if (f->f_type == F_FILE && (f->f_flags & SYNC_FILE))
856+ (void) fsync(f->f_file);
857+ break;
858+
859+@@ -1891,7 +1964,7 @@
860+ register struct filed *f;
861+ struct iovec *iov;
862+ {
863+- char p[6 + UNAMESZ];
864++ char p[sizeof (_PATH_DEV) + UNAMESZ];
865+ register int i;
866+ int ttyf, len;
867+ static int reenter = 0;
868+@@ -1899,6 +1972,8 @@
869+ struct utmp *uptr;
870+ char greetings[200];
871+
872++ (void) &len;
873++
874+ if (reenter++)
875+ return;
876+
877+@@ -1913,7 +1988,6 @@
878+ if (fork() == 0) {
879+ (void) signal(SIGTERM, SIG_DFL);
880+ (void) alarm(0);
881+- (void) signal(SIGALRM, endtty);
882+ #ifndef SYSV
883+ (void) signal(SIGTTOU, SIG_IGN);
884+ (void) sigsetmask(0);
885+@@ -1929,7 +2003,7 @@
886+ /* is this slot used? */
887+ if (ut.ut_name[0] == '\0')
888+ continue;
889+- if (ut.ut_type == LOGIN_PROCESS)
890++ if (ut.ut_type != USER_PROCESS)
891+ continue;
892+ if (!(strcmp (ut.ut_name,"LOGIN"))) /* paranoia */
893+ continue;
894+@@ -1959,6 +2033,7 @@
895+ iov[1].iov_len = 0;
896+ }
897+ if (setjmp(ttybuf) == 0) {
898++ (void) signal(SIGALRM, endtty);
899+ (void) alarm(15);
900+ /* open the terminal */
901+ ttyf = open(p, O_WRONLY|O_NOCTTY);