1 Submitted By: Robert Connolly <robert at linuxfromscratch dot org> (ashes)
3 Initial Package Version: 1.4.1
4 Upstream Status: Not submitted
5 Origin: http://www.infodrom.org/projects/sysklogd/cvs.php3
6 Description: This patch is a cvs snapshot update as of 20050123.
7 Minus the debain and CVS directories. See the CHANGES.
9 diff -Naur sysklogd-1.4.1/CHANGES sysklogd-20050123/CHANGES
10 --- sysklogd-1.4.1/CHANGES 2001-03-11 14:35:51.000000000 -0500
11 +++ sysklogd-20050123/CHANGES 2005-01-15 14:14:21.000000000 -0500
15 + . Dmitry V. Levin <ldv@altlinux.org>
16 + - Close file descriptor in FindSymbolFile() in ksym.c in order not to
17 + leak file descriptors.
18 + . Solar Designer <solar@openwall.com>
19 + - improve crunch_list()
20 + - Prevent potential buffer overflow in reading messages from the
21 + kernel log ringbuffer.
22 + - Ensure that "len" is not placed in a register, and that the
23 + endtty() signal handler is not installed too early which could
24 + cause a segmentation fault or worse.
25 + . Steve Grubb <linux_4ever@yahoo.com>
26 + - fix memory calculation in crunch_list()
27 + . Martin Schulze <joey@infodrom.org>
28 + - klogd will reconnect to the logger (mostly syslogd) after it went
30 + - On heavily loaded system syslog will not spit out error messages
31 + anymore when recvfrom() results in EAGAIN
32 + - Makefile improvements
33 + - Local copy of module.h
34 + - Improved sysklogd.8
35 + - Always log with syslogd's timezone and locale
36 + - Remove trailing newline when forwarding messages
37 + . Jon Burgess <Jon_Burgess@eur.3com.com>
38 + - Moved the installation of the signal handler up a little bit so it
39 + guaranteed to be available when the child is forked, hence, fixing a
40 + race condition. This used to create problems with UML and fast
42 + . Greg Trounson <gregt@maths.otago.ac.nz>
43 + - Improved README.linux
44 + . Ulf Härnhammar <Ulf.Harnhammar.9485@student.uu.se>
45 + - Bondary check for fscanf() in InitKsyms() and CheckMapVersion()
46 + . Colin Phipps <cph@cph.demon.co.uk>
47 + - Don't block on the network socket in case of package los
48 + . Dirk Mueller <mueller@kde.org>
49 + - Don't crash when filesize limit is reached (e.g. without LFS)
54 . klogd will set the console log level only if `-c' is given on the
56 . Olaf Kirch <okir@caldera.de>
57 - Remove Unix Domain Sockets and switch to Datagram Unix Sockets
58 . Several bugfixes and improvements, please refer to the .c files
65 diff -Naur sysklogd-1.4.1/klogd.8 sysklogd-20050123/klogd.8
66 --- sysklogd-1.4.1/klogd.8 2001-03-11 14:35:51.000000000 -0500
67 +++ sysklogd-20050123/klogd.8 2001-03-11 18:00:51.000000000 -0500
70 to reload the module symbol information whenever a protection fault
71 is detected. Caution should be used before invoking the program in
72 -\'paranoid\' mode. The stability of the kernel and the operating
73 +\&'paranoid\&' mode. The stability of the kernel and the operating
74 environment is always under question when a protection fault occurs.
75 Since the klogd daemon must execute system calls in order to read the
76 module symbol information there is the possibility that the system may
77 diff -Naur sysklogd-1.4.1/klogd.c sysklogd-20050123/klogd.c
78 --- sysklogd-1.4.1/klogd.c 2001-03-11 14:40:10.000000000 -0500
79 +++ sysklogd-20050123/klogd.c 2004-04-29 09:29:03.000000000 -0400
81 * people have submitted patches: Troels Walsted Hansen
82 * <troels@thule.no>, Wolfgang Oertl <Wolfgang.Oertl@uibk.ac.at>
83 * and Thomas Roessler.
84 + * Thu Apr 29 15:24:07 2004: Solar Designer <solar@openwall.com>
85 + * Prevent potential buffer overflow in reading messages from the
86 + * kernel log rinbuffer.
91 * messages into this fresh buffer.
93 memset(log_buffer, '\0', sizeof(log_buffer));
94 - if ( (rdcnt = ksyslog(2, log_buffer, sizeof(log_buffer))) < 0 )
95 + if ( (rdcnt = ksyslog(2, log_buffer, sizeof(log_buffer)-1)) < 0 )
99 diff -Naur sysklogd-1.4.1/ksym.c sysklogd-20050123/ksym.c
100 --- sysklogd-1.4.1/ksym.c 2000-09-12 17:53:31.000000000 -0400
101 +++ sysklogd-20050123/ksym.c 2004-07-16 02:48:27.000000000 -0400
104 * Tue Sep 12 23:48:12 CEST 2000: Martin Schulze <joey@infodrom.ffis.de>
105 * Close symbol file in InitKsyms() when an error occurred.
107 + * Thu Apr 29 18:07:16 CEST 2004: Dmitry Levin <ldv@altlinux.org>
108 + * Close file descriptor in FindSymbolFile() in order not to leak
109 + * file descriptors.
111 + * Fri Jul 16 08:32:49 CEST 2004: Ulf Härnhammar <Ulf.Harnhammar.9485@student.uu.se>
112 + * Added boundary check for fscanf() in InitKsyms() and
113 + * CheckMapVersion() to prevent an unintended crash when reading
114 + * an incorrect System.map.
120 while ( !feof(sym_file) )
122 - if ( fscanf(sym_file, "%lx %c %s\n", &address, &type, sym)
123 + if ( fscanf(sym_file, "%lx %c %511s\n", &address, &type, sym)
126 Syslog(LOG_ERR, "Error in symbol table input (#1).");
128 if ( (sym_file = fopen(symfile, "r")) != (FILE *) 0 ) {
129 if (CheckMapVersion(symfile) == 1)
133 if (sym_file == (FILE *) 0 || file == (char *) 0) {
134 sprintf (symfile, "%s", *mf);
136 if ( (sym_file = fopen(symfile, "r")) != (FILE *) 0 ) {
137 if (CheckMapVersion(symfile) == 1)
145 while ( !feof(sym_file) && (version == 0) )
147 - if ( fscanf(sym_file, "%lx %c %s\n", &address, \
148 + if ( fscanf(sym_file, "%lx %c %511s\n", &address, \
151 Syslog(LOG_ERR, "Error in symbol table input (#2).");
159 + * c-indent-level: 8
160 + * c-basic-offset: 8
164 diff -Naur sysklogd-1.4.1/ksym_mod.c sysklogd-20050123/ksym_mod.c
165 --- sysklogd-1.4.1/ksym_mod.c 2000-09-12 17:15:28.000000000 -0400
166 +++ sysklogd-20050123/ksym_mod.c 2004-03-31 10:47:08.000000000 -0500
169 * Tue Sep 12 23:11:13 CEST 2000: Martin Schulze <joey@infodrom.ffis.de>
170 * Changed llseek() to lseek64() in order to skip a libc warning.
172 + * Wed Mar 31 17:35:01 CEST 2004: Martin Schulze <joey@infodrom.org>
173 + * Removed references to <linux/module.h> since it doesn't work
174 + * anymore with its recent content from Linux 2.4/2.6, created
175 + * module.h locally instead.
181 #include <sys/fcntl.h>
182 #include <sys/stat.h>
184 #if !defined(__GLIBC__)
185 #include <linux/time.h>
186 -#include <linux/module.h>
187 +#include <linux/linkage.h>
188 #else /* __GLIBC__ */
189 -#include <linux/module.h>
190 +#include <linux/linkage.h>
191 extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
192 extern int get_kernel_syms __P ((struct kernel_sym *__table));
193 #endif /* __GLIBC__ */
196 #if !defined(__GLIBC__)
198 - * The following bit uses some kernel/library magic to product what
199 + * The following bit uses some kernel/library magic to produce what
200 * looks like a function call to user level code. This function is
201 * actually a system call in disguise. The purpose of the getsyms
202 * call is to return a current copy of the in-kernel symbol table.
203 diff -Naur sysklogd-1.4.1/Makefile sysklogd-20050123/Makefile
204 --- sysklogd-1.4.1/Makefile 1998-10-12 16:25:15.000000000 -0400
205 +++ sysklogd-20050123/Makefile 2004-04-29 07:04:03.000000000 -0400
207 #CFLAGS= -g -DSYSV -Wall
209 CFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce
210 +# -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
213 # Look where your install program is.
214 INSTALL = /usr/bin/install
218 +# Destination paths, set prefix=/opt if required
219 +BINDIR = $(prefix)/usr/sbin
220 +MANDIR = $(prefix)/usr/share/man
222 # There is one report that under an all ELF system there may be a need to
223 # explicilty link with libresolv.a. If linking syslogd fails you may wish
225 # The following define establishes ownership for the man pages.
226 # Avery tells me that there is a difference between Debian and
227 # Slackware. Rather than choose sides I am leaving it up to the user.
234 # The following define establishes the name of the pid file for the
235 # syslogd daemon. The library include file (paths.h) defines the
237 ${INSTALL} -m 500 -s klogd ${BINDIR}/klogd
240 - ${INSTALL} -o ${MAN_OWNER} -g ${MAN_OWNER} -m 644 sysklogd.8 ${MANDIR}/man8/sysklogd.8
241 - ${INSTALL} -o ${MAN_OWNER} -g ${MAN_OWNER} -m 644 syslogd.8 ${MANDIR}/man8/syslogd.8
242 - ${INSTALL} -o ${MAN_OWNER} -g ${MAN_OWNER} -m 644 syslog.conf.5 ${MANDIR}/man5/syslog.conf.5
243 - ${INSTALL} -o ${MAN_OWNER} -g ${MAN_OWNER} -m 644 klogd.8 ${MANDIR}/man8/klogd.8
244 + ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} sysklogd.8 ${MANDIR}/man8/sysklogd.8
245 + ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} syslogd.8 ${MANDIR}/man8/syslogd.8
246 + ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} syslog.conf.5 ${MANDIR}/man5/syslog.conf.5
247 + ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} klogd.8 ${MANDIR}/man8/klogd.8
248 diff -Naur sysklogd-1.4.1/module.h sysklogd-20050123/module.h
249 --- sysklogd-1.4.1/module.h 1969-12-31 19:00:00.000000000 -0500
250 +++ sysklogd-20050123/module.h 2004-07-27 07:36:10.000000000 -0400
253 + module.h - Miscellaneous module definitions
254 + Copyright (c) 1996 Richard Henderson <rth@tamu.edu>
255 + Copyright (c) 2004 Martin Schulze <joey@infodrom.org>
257 + This file is part of the sysklogd package.
259 + This program is free software; you can redistribute it and/or modify
260 + it under the terms of the GNU General Public License as published by
261 + the Free Software Foundation; either version 2 of the License, or
262 + (at your option) any later version.
264 + This program is distributed in the hope that it will be useful,
265 + but WITHOUT ANY WARRANTY; without even the implied warranty of
266 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
267 + GNU General Public License for more details.
269 + You should have received a copy of the GNU General Public License
270 + along with this program; if not, write to the Free Software
271 + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
276 + * Wed Mar 31 17:35:01 CEST 2004: Martin Schulze <joey@infodrom.org>
277 + * Created local copy of module.h based on the content of Linux
278 + * 2.2 since <linux/module.h> doesn't work anymore with its
279 + * recent content from Linux 2.4/2.6.
282 +#include <asm/atomic.h>
284 +#define MODULE_NAME_LEN 60
288 + unsigned long value;
289 + char name[MODULE_NAME_LEN];
294 + struct list_head *next, *prev;
300 + unsigned long addr;
301 + unsigned long size;
302 + unsigned long flags;
309 + unsigned long size_of_struct; /* == sizeof(module) */
310 + struct module *next;
312 + unsigned long size;
318 + } uc; /* Needs to keep its size - so says rth */
320 + unsigned long flags; /* AUTOCLEAN et al */
325 + struct module_symbol *syms;
326 + struct module_ref *deps;
327 + struct module_ref *refs;
329 + void (*cleanup)(void);
330 + const struct exception_table_entry *ex_table_start;
331 + const struct exception_table_entry *ex_table_end;
335 + /* Members past this point are extensions to the basic
336 + module support and are optional. Use mod_opt_member()
337 + to examine them. */
338 + const struct module_persist *persist_start;
339 + const struct module_persist *persist_end;
340 + int (*can_unload)(void);
342 diff -Naur sysklogd-1.4.1/pidfile.c sysklogd-20050123/pidfile.c
343 --- sysklogd-1.4.1/pidfile.c 1998-02-10 17:37:12.000000000 -0500
344 +++ sysklogd-20050123/pidfile.c 2003-09-27 22:38:18.000000000 -0400
349 - if ( ((fd = open(pidfile, O_RDWR|O_CREAT, 0644)) == -1)
350 + if ( ((fd = open(pidfile, O_RDWR|O_CREAT|O_TRUNC, 0644)) == -1)
351 || ((f = fdopen(fd, "r+")) == NULL) ) {
352 fprintf(stderr, "Can't open or create %s.\n", pidfile);
354 diff -Naur sysklogd-1.4.1/README.1st sysklogd-20050123/README.1st
355 --- sysklogd-1.4.1/README.1st 1997-06-02 13:21:39.000000000 -0400
356 +++ sysklogd-20050123/README.1st 2003-09-04 09:22:23.000000000 -0400
358 -Very important information before using version 1.3
359 ----------------------------------------------------
360 +Important information
361 +---------------------
363 The included version of syslogd behaves in a slightly different manner
364 to the one in former releases. Please review the following important
366 these scripts should remove all old .pid files found in /var/run.
367 This will insure that klogd and syslogd start properly even if prior
368 executions have been terminated harshly.
370 +* Large file support, i.e. support to write to log files that are
371 + larger than 2 GB is not part of syslogd, but a matter of the Glibc
372 + emitting different system calls to the kernel interface. To support
373 + large files you'll have to compile syslogd with the compiler defines
374 + -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE so that glibc adjusts the
376 diff -Naur sysklogd-1.4.1/README.linux sysklogd-20050123/README.linux
377 --- sysklogd-1.4.1/README.linux 1999-01-18 19:09:12.000000000 -0500
378 +++ sysklogd-20050123/README.linux 2004-07-09 13:22:29.000000000 -0400
380 a useful addition to the software gene pool.
382 There is a mailing list covering this package and syslog in general.
383 -The lists address is sysklogd@Infodrom.North.DE . To subscribe send a
384 -mail to Majordomo@Infodrom.North.DE with a line "subscribe sysklogd"
385 +The lists address is infodrom-sysklogd@lists.infodrom.org . To subscribe send a
386 +mail to majordomo@lists.infodrom.org with a line "subscribe infodrom-sysklogd"
389 -New versions of this package will be available at Joey's ftp server.
390 -ftp://ftp.infodrom.north.de/pub/people/joey/sysklogd/
391 +A second mailing list exists as infodrom-sysklogd-cvs@lists.infodrom.org. Only
392 +CVS messages and diffs are distributed there. Whenever new code is added to
393 +sysklogd, CVS generates a mail from these changes which will be sent to
394 +this list. Discussions will take place on the first list.
396 +The latest version of this software can be found at:
397 +http://www.infodrom.org/projects/sysklogd/download.php3
408 -And a host of bug reporters whose contributions cannot be underestimated.
409 +And a number of bug reporters whose contributions cannot be underestimated.
410 diff -Naur sysklogd-1.4.1/sysklogd.8 sysklogd-20050123/sysklogd.8
411 --- sysklogd-1.4.1/sysklogd.8 2001-03-11 14:35:51.000000000 -0500
412 +++ sysklogd-20050123/sysklogd.8 2004-07-09 13:33:32.000000000 -0400
415 within the syslogd.c source file. An example for a chroot() daemon is
416 described by the people from OpenBSD at
417 -http://www.psionic.com/papers/dns.html.
418 +<http://www.guides.sk/psionic/dns/>.
421 Turns on debug mode. Using this the daemon will not proceed a
423 between two \fI-- MARK --\fR lines is 20 minutes. This can be changed
424 with this option. Setting the
426 -to zero turns it off entirely.
427 +to zero turns it off entirely. Depending on other log messages
428 +generated these lines may not be written consecutively.
431 Avoid auto-backgrounding. This is needed especially if the
434 To avoid this in further times no messages that were received from a
435 remote host are sent out to another (or the same) remote host
436 -anymore. If there are scenarios where this doesn't make sense, please
437 -drop me (Joey) a line.
438 +anymore. If you experience are setup in which this doesn't make
439 +sense, please use the
443 If the remote host is located in the same domain as the host,
445 diff -Naur sysklogd-1.4.1/syslog.c sysklogd-20050123/syslog.c
446 --- sysklogd-1.4.1/syslog.c 2001-03-11 14:35:51.000000000 -0500
447 +++ sysklogd-20050123/syslog.c 2003-08-27 11:56:01.000000000 -0400
449 * Sun Mar 11 20:23:44 CET 2001: Martin Schulze <joey@infodrom.ffis.de>
450 * Use SOCK_DGRAM for loggin, renables it to work.
452 + * Wed Aug 27 17:48:16 CEST 2003: Martin Schulze <joey@Infodrom.org>
453 + * Improved patch by Michael Pomraning <mjp@securepipe.com> to
454 + * reconnect klogd to the logger after it went away.
457 #include <sys/types.h>
463 char tbuf[2048], fmt_cpy[1024], *stdp = (char *) 0;
469 /* output the message to the local logger */
470 - if (write(LogFile, tbuf, cnt + 1) >= 0 || !(LogStat&LOG_CONS))
471 + result = write(LogFile, tbuf, cnt + 1);
474 + && (errno == ECONNRESET || errno == ENOTCONN || errno == ECONNREFUSED)) {
476 + openlog(LogTag, LogStat | LOG_NDELAY, LogFacility);
477 + result = write(LogFile, tbuf, cnt + 1);
480 + if (result >= 0 || !(LogStat&LOG_CONS))
484 diff -Naur sysklogd-1.4.1/syslog.conf.5 sysklogd-20050123/syslog.conf.5
485 --- sysklogd-1.4.1/syslog.conf.5 1999-08-21 06:49:14.000000000 -0400
486 +++ sysklogd-20050123/syslog.conf.5 2003-05-22 15:31:20.000000000 -0400
490 is one of the following keywords:
491 -.BR auth ", " authpriv ", " cron ", " daemon ", " kern ", " lpr ", "
492 +.BR auth ", " authpriv ", " cron ", " daemon ", " ftp ", " kern ", " lpr ", "
493 .BR mail ", " mark ", " news ", " security " (same as " auth "), "
494 .BR syslog ", " user ", " uucp " and " local0 " through " local7 .
496 @@ -121,12 +121,21 @@
500 -has a syntax extension to the original BSD source, that makes its use
501 +has a syntax extension to the original BSD source, which makes its use
502 more intuitively. You may precede every priority with an equation sign
503 -(``='') to specify only this single priority and not any of the
504 -above. You may also (both is valid, too) precede the priority with an
505 -exclamation mark (``!'') to ignore all that priorities, either exact
506 -this one or this and any higher priority. If you use both extensions
507 +(``='') to specify that
509 +should only refer to this single priority and not this priority and
510 +all higher priorities.
512 +You may also precide the priority with an exclamation mark (``!'') if
515 +to ignore this priority and all higher priorities.
516 +You may even use both, the exclamation mark and the equation sign if
519 +to ignore only this single priority. If you use both extensions
520 than the exclamation mark must occur before the equation sign, just
525 log all messages that come with either the
526 .BR info " or the " notice
527 -facility into the file
528 +priority into the file
529 .IR /var/log/messages ,
530 except for all messages that use the
532 diff -Naur sysklogd-1.4.1/syslogd.c sysklogd-20050123/syslogd.c
533 --- sysklogd-1.4.1/syslogd.c 2001-03-11 14:40:10.000000000 -0500
534 +++ sysklogd-20050123/syslogd.c 2005-01-15 14:13:08.000000000 -0500
536 * Don't return a closed fd if `-a' is called with a wrong path.
537 * Thanks to Bill Nottingham <notting@redhat.com> for providing
539 + * Thu Apr 13 05:08:10 CEST 2001: Jon Burgess <Jon_Burgess@eur.3com.com>
540 + * Moved the installation of the signal handler up a little bit
541 + * so it guaranteed to be available when the child is forked,
542 + * hence, fixing a race condition. This used to create problems
543 + * with UML and fast machines.
545 + * Sat Apr 17 18:03:05 CEST 2004: Steve Grubb <linux_4ever@yahoo.com>
546 + * Correct memory allocation for for commandline arguments in
549 + * Thu Apr 29 12:38:39 CEST 2004: Solar Designer <solar@openwall.com>
550 + * Applied Openwall paranoia patches to improve crunch_list().
552 + * Tue May 4 16:47:30 CEST 2004: Solar Designer <solar@openwall.com>
553 + * Ensure that "len" is not placed in a register, and that the
554 + * endtty() signal handler is not installed too early which could
555 + * cause a segmentation fault or worse.
557 + * Tue May 4 16:52:01 CEST 2004: Solar Designer <solar@openwall.com>
558 + * Adjust the size of a variable to prevent a buffer overflow
559 + * should _PATH_DEV ever contain something different than "/dev/".
561 + * Tue Nov 2 20:28:23 CET 2004: Colin Phipps <cph@cph.demon.co.uk>
562 + * Don't block on the network socket, in case a packet gets lost
563 + * between select and recv.
565 + * Sun Nov 7 12:28:47 CET 2004: Martin Schulze <joey@infodrom.org>
566 + * Discard any timestamp information found in received syslog
567 + * messages. This will affect local messages sent from a
568 + * different timezone.
570 + * Sun Nov 7 13:47:00 CET 2004: Martin Schulze <joey@infodrom.org>
571 + * Remove trailing newline when forwarding messages.
575 @@ -890,11 +923,11 @@
576 dprintf("Checking pidfile.\n");
577 if (!check_pid(PidFile))
579 + signal (SIGTERM, doexit);
584 - signal (SIGTERM, doexit);
587 * Not reached unless something major went wrong. 5
589 (void) signal(SIGCHLD, reapchild);
590 (void) signal(SIGALRM, domark);
591 (void) signal(SIGUSR1, Debug ? debug_switch : SIG_IGN);
592 + (void) signal(SIGXFSZ, SIG_IGN);
593 (void) alarm(TIMERINTVL);
595 /* Create a partial message table for all file descriptors. */
596 @@ -1141,13 +1175,13 @@
598 printchopped(from, line, \
600 - } else if (i < 0 && errno != EINTR) {
601 + } else if (i < 0 && errno != EINTR && errno != EAGAIN) {
602 dprintf("INET socket error: %d = %s.\n", \
603 errno, strerror(errno));
604 logerror("recvfrom inet");
605 /* should be harmless now that we set
606 * BSDCOMPAT on the socket */
612 @@ -1216,6 +1250,7 @@
615 struct sockaddr_in sin;
618 fd = socket(AF_INET, SOCK_DGRAM, 0);
620 @@ -1241,6 +1276,24 @@
624 + /* We must not block on the network socket, in case a packet
625 + * gets lost between select and recv, otherise the process
626 + * will stall until the timeout, and other processes trying to
627 + * log will also stall.
629 + if ((sockflags = fcntl(fd, F_GETFL)) != -1) {
630 + sockflags |= O_NONBLOCK;
632 + * SETFL could fail too, so get it caught by the subsequent
635 + sockflags = fcntl(fd, F_SETFL, sockflags);
637 + if (sockflags == -1) {
638 + logerror("fcntl(O_NONBLOCK), suspending inet");
642 if (bind(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
643 logerror("bind, suspending inet");
645 @@ -1254,30 +1307,26 @@
652 char **result = NULL;
656 /* strip off trailing delimiters */
657 - while (p[strlen(p)-1] == LIST_DELIMITER) {
659 + while (*p && p[strlen(p)-1] == LIST_DELIMITER)
660 p[strlen(p)-1] = '\0';
662 /* cut off leading delimiters */
663 - while (p[0] == LIST_DELIMITER) {
665 + while (p[0] == LIST_DELIMITER)
669 - /* count delimiters to calculate elements */
670 - for (count=i=0; p[i]; i++)
671 - if (p[i] == LIST_DELIMITER) count++;
672 + /* count delimiters to calculate the number of elements */
673 + for (n = i = 0; p[i]; i++)
674 + if (p[i] == LIST_DELIMITER) n++;
676 - if ((result = (char **)malloc(sizeof(char *) * count+2)) == NULL) {
677 + if ((result = (char **)malloc(sizeof(char *) * (n + 2))) == NULL) {
678 printf ("Sorry, can't get enough memory, exiting.\n");
684 @@ -1285,30 +1334,28 @@
685 * characters are different from any delimiters,
686 * so we don't have to care about this.
689 - while ((q=strchr(p, LIST_DELIMITER))) {
690 - result[count] = (char *) malloc((q - p + 1) * sizeof(char));
691 - if (result[count] == NULL) {
693 + while ((q = strchr(p, LIST_DELIMITER)) && m < n) {
694 + result[m] = (char *) malloc((q - p + 1) * sizeof(char));
695 + if (result[m] == NULL) {
696 printf ("Sorry, can't get enough memory, exiting.\n");
700 - strncpy(result[count], p, q - p);
701 - result[count][q - p] = '\0';
702 + memcpy(result[m], p, q - p);
703 + result[m][q - p] = '\0';
708 - if ((result[count] = \
709 - (char *)malloc(sizeof(char) * strlen(p) + 1)) == NULL) {
710 + if ((result[m] = strdup(p)) == NULL) {
711 printf ("Sorry, can't get enough memory, exiting.\n");
715 - strcpy(result[count],p);
716 - result[++count] = NULL;
717 + result[++m] = NULL;
721 - while (result[count])
722 - dprintf ("#%d: %s\n", count, StripDomains[count++]);
725 + dprintf ("#%d: %s\n", m, result[m++]);
729 @@ -1548,21 +1595,25 @@
732 * Check to see if msg looks non-standard.
734 + * A message looks like
735 + * Nov 17 11:42:33 CRON[
736 + * 01234567890123456
739 + * Remote messages are not accompanied by a timestamp.
740 + * Local messages are accompanied by a timestamp (program's timezone)
742 msglen = strlen(msg);
743 - if (msglen < 16 || msg[3] != ' ' || msg[6] != ' ' ||
744 - msg[9] != ':' || msg[12] != ':' || msg[15] != ' ')
748 - if (flags & ADDDATE)
749 - timestamp = ctime(&now) + 4;
752 + if (!(msglen < 16 || msg[3] != ' ' || msg[6] != ' ' ||
753 + msg[9] != ':' || msg[12] != ':' || msg[15] != ' ')) {
759 + timestamp = ctime(&now) + 4;
761 /* extract facility and priority level */
763 fac = LOG_NFACILITIES;
764 @@ -1771,7 +1822,7 @@
765 dprintf("Not sending message to remote.\n");
768 - (void) snprintf(line, sizeof(line), "<%d>%s\n", f->f_prevpri, \
769 + (void) snprintf(line, sizeof(line), "<%d>%s", f->f_prevpri, \
770 (char *) iov[4].iov_base);
773 @@ -1815,7 +1866,7 @@
777 - /* f->f_file == -1 is an indicator that the we couldn't
778 + /* f->f_file == -1 is an indicator that we couldn't
779 open the file at startup. */
782 @@ -1852,7 +1903,7 @@
784 logerror(f->f_un.f_fname);
786 - } else if (f->f_flags & SYNC_FILE)
787 + } else if (f->f_type == F_FILE && (f->f_flags & SYNC_FILE))
788 (void) fsync(f->f_file);
791 @@ -1891,7 +1942,7 @@
792 register struct filed *f;
795 - char p[6 + UNAMESZ];
796 + char p[sizeof (_PATH_DEV) + UNAMESZ];
799 static int reenter = 0;
800 @@ -1899,6 +1950,8 @@
809 @@ -1913,7 +1966,6 @@
811 (void) signal(SIGTERM, SIG_DFL);
813 - (void) signal(SIGALRM, endtty);
815 (void) signal(SIGTTOU, SIG_IGN);
816 (void) sigsetmask(0);
817 @@ -1929,7 +1981,7 @@
818 /* is this slot used? */
819 if (ut.ut_name[0] == '\0')
821 - if (ut.ut_type == LOGIN_PROCESS)
822 + if (ut.ut_type != USER_PROCESS)
824 if (!(strcmp (ut.ut_name,"LOGIN"))) /* paranoia */
826 @@ -1959,6 +2011,7 @@
829 if (setjmp(ttybuf) == 0) {
830 + (void) signal(SIGALRM, endtty);
832 /* open the terminal */
833 ttyf = open(p, O_WRONLY|O_NOCTTY);