source: patches/sysklogd-1.4.1-fixes-1.patch@ 0058597

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 0058597 was 69cde8d, checked in by Jim Gifford <clfs@…>, 19 years ago

Added: All patches needed for the book.

  • Property mode set to 100644
File size: 27.4 KB
  • CHANGES

    Submitted By: Robert Connolly <robert at linuxfromscratch dot org> (ashes)
    Date: 2005-01-23
    Initial Package Version: 1.4.1
    Upstream Status: Not submitted
    Origin: http://www.infodrom.org/projects/sysklogd/cvs.php3
    Description: This patch is a cvs snapshot update as of 20050123.
    Minus the debain and CVS directories. See the CHANGES.
    
    diff -Naur sysklogd-1.4.1/CHANGES sysklogd-20050123/CHANGES
    old new  
     1Version 1.4.2
     2
     3 . Dmitry V. Levin <ldv@altlinux.org>
     4   - Close file descriptor in FindSymbolFile() in ksym.c in order not to
     5     leak file descriptors.
     6 . Solar Designer <solar@openwall.com>
     7   - improve crunch_list()
     8   - Prevent potential buffer overflow in reading messages from the
     9     kernel log ringbuffer.
     10   - Ensure that "len" is not placed in a register, and that the
     11     endtty() signal handler is not installed too early which could
     12     cause a segmentation fault or worse.
     13 . Steve Grubb <linux_4ever@yahoo.com>
     14   - fix memory calculation in crunch_list()
     15 . Martin Schulze <joey@infodrom.org>
     16   - klogd will reconnect to the logger (mostly syslogd) after it went
     17     away
     18   - On heavily loaded system syslog will not spit out error messages
     19     anymore when recvfrom() results in EAGAIN
     20   - Makefile improvements
     21   - Local copy of module.h
     22   - Improved sysklogd.8
     23   - Always log with syslogd's timezone and locale
     24   - Remove trailing newline when forwarding messages
     25 . Jon Burgess <Jon_Burgess@eur.3com.com>
     26   - Moved the installation of the signal handler up a little bit so it
     27     guaranteed to be available when the child is forked, hence, fixing a
     28     race condition.  This used to create problems with UML and fast
     29     machines.
     30 . Greg Trounson <gregt@maths.otago.ac.nz>
     31   - Improved README.linux
     32 . Ulf Härnhammar <Ulf.Harnhammar.9485@student.uu.se>
     33   - Bondary check for fscanf() in InitKsyms() and CheckMapVersion()
     34 . Colin Phipps <cph@cph.demon.co.uk>
     35   - Don't block on the network socket in case of package los
     36 . Dirk Mueller <mueller@kde.org>
     37   - Don't crash when filesize limit is reached (e.g. without LFS)
     38
     39
    140Version 1.4.1
    241
    342 . klogd will set the console log level only if `-c' is given on the
     
    3069 . Olaf Kirch <okir@caldera.de>
    3170   - Remove Unix Domain Sockets and switch to Datagram Unix Sockets
    3271 . Several bugfixes and improvements, please refer to the .c files
     72
     73
     74Local variables:
     75mode: indented-text
     76fill-column: 72
     77End:
  • klogd.8

    diff -Naur sysklogd-1.4.1/klogd.8 sysklogd-20050123/klogd.8
    old new  
    321321.B klogd
    322322to reload the module symbol information whenever a protection fault
    323323is detected.  Caution should be used before invoking the program in
    324 \'paranoid\' mode.  The stability of the kernel and the operating
     324\&'paranoid\&' mode.  The stability of the kernel and the operating
    325325environment is always under question when a protection fault occurs.
    326326Since the klogd daemon must execute system calls in order to read the
    327327module symbol information there is the possibility that the system may
  • klogd.c

    diff -Naur sysklogd-1.4.1/klogd.c sysklogd-20050123/klogd.c
    old new  
    243243 *      people have submitted patches: Troels Walsted Hansen
    244244 *      <troels@thule.no>, Wolfgang Oertl <Wolfgang.Oertl@uibk.ac.at>
    245245 *      and Thomas Roessler.
     246 * Thu Apr 29 15:24:07 2004: Solar Designer <solar@openwall.com>
     247 *      Prevent potential buffer overflow in reading messages from the
     248 *      kernel log rinbuffer.
    246249 */
    247250
    248251
     
    938941         * messages into this fresh buffer.
    939942         */
    940943        memset(log_buffer, '\0', sizeof(log_buffer));
    941         if ( (rdcnt = ksyslog(2, log_buffer, sizeof(log_buffer))) < 0 )
     944        if ( (rdcnt = ksyslog(2, log_buffer, sizeof(log_buffer)-1)) < 0 )
    942945        {
    943946                if ( errno == EINTR )
    944947                        return;
  • ksym.c

    diff -Naur sysklogd-1.4.1/ksym.c sysklogd-20050123/ksym.c
    old new  
    105105 *
    106106 * Tue Sep 12 23:48:12 CEST 2000: Martin Schulze <joey@infodrom.ffis.de>
    107107 *      Close symbol file in InitKsyms() when an error occurred.
     108 *
     109 * Thu Apr 29 18:07:16 CEST 2004: Dmitry Levin <ldv@altlinux.org>
     110 *      Close file descriptor in FindSymbolFile() in order not to leak
     111 *      file descriptors.
     112 *
     113 * Fri Jul 16 08:32:49 CEST 2004: Ulf Härnhammar <Ulf.Harnhammar.9485@student.uu.se>
     114 *      Added boundary check for fscanf() in InitKsyms() and
     115 *      CheckMapVersion() to prevent an unintended crash when reading
     116 *      an incorrect System.map.
    108117 */
    109118
    110119
     
    236245         */
    237246        while ( !feof(sym_file) )
    238247        {
    239                 if ( fscanf(sym_file, "%lx %c %s\n", &address, &type, sym)
     248                if ( fscanf(sym_file, "%lx %c %511s\n", &address, &type, sym)
    240249                    != 3 )
    241250                {
    242251                        Syslog(LOG_ERR, "Error in symbol table input (#1).");
     
    344353                if ( (sym_file = fopen(symfile, "r")) != (FILE *) 0 ) {
    345354                        if (CheckMapVersion(symfile) == 1)
    346355                                file = symfile;
     356                        fclose (sym_file);
    347357                }
    348358                if (sym_file == (FILE *) 0 || file == (char *) 0) {
    349359                        sprintf (symfile, "%s", *mf);
     
    352362                        if ( (sym_file = fopen(symfile, "r")) != (FILE *) 0 ) {
    353363                                if (CheckMapVersion(symfile) == 1)
    354364                                        file = symfile;
     365                                fclose (sym_file);
    355366                        }
    356367                }
    357368
     
    533544                version = 0;
    534545                while ( !feof(sym_file) && (version == 0) )
    535546                {
    536                         if ( fscanf(sym_file, "%lx %c %s\n", &address, \
     547                        if ( fscanf(sym_file, "%lx %c %511s\n", &address, \
    537548                                    &type, sym) != 3 )
    538549                        {
    539550                                Syslog(LOG_ERR, "Error in symbol table input (#2).");
     
    899910        return;
    900911}
    901912#endif
     913
     914/*
     915 * Local variables:
     916 *  c-indent-level: 8
     917 *  c-basic-offset: 8
     918 *  tab-width: 8
     919 * End:
     920 */
  • ksym_mod.c

    diff -Naur sysklogd-1.4.1/ksym_mod.c sysklogd-20050123/ksym_mod.c
    old new  
    7878 *
    7979 * Tue Sep 12 23:11:13 CEST 2000: Martin Schulze <joey@infodrom.ffis.de>
    8080 *      Changed llseek() to lseek64() in order to skip a libc warning.
     81 *
     82 * Wed Mar 31 17:35:01 CEST 2004: Martin Schulze <joey@infodrom.org>
     83 *      Removed references to <linux/module.h> since it doesn't work
     84 *      anymore with its recent content from Linux 2.4/2.6, created
     85 *      module.h locally instead.
    8186 */
    8287
    8388
     
    8994#include <errno.h>
    9095#include <sys/fcntl.h>
    9196#include <sys/stat.h>
     97#include "module.h"
    9298#if !defined(__GLIBC__)
    9399#include <linux/time.h>
    94 #include <linux/module.h>
     100#include <linux/linkage.h>
    95101#else /* __GLIBC__ */
    96 #include <linux/module.h>
     102#include <linux/linkage.h>
    97103extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
    98104extern int get_kernel_syms __P ((struct kernel_sym *__table));
    99105#endif /* __GLIBC__ */
     
    107113
    108114#if !defined(__GLIBC__)
    109115/*
    110  * The following bit uses some kernel/library magic to product what
     116 * The following bit uses some kernel/library magic to produce what
    111117 * looks like a function call to user level code.  This function is
    112118 * actually a system call in disguise.  The purpose of the getsyms
    113119 * call is to return a current copy of the in-kernel symbol table.
  • Makefile

    diff -Naur sysklogd-1.4.1/Makefile sysklogd-20050123/Makefile
    old new  
    44#CFLAGS= -g -DSYSV -Wall
    55#LDFLAGS= -g
    66CFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce
     7# -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
    78LDFLAGS= -s
    89
    910# Look where your install program is.
    1011INSTALL = /usr/bin/install
    11 BINDIR = /usr/sbin
    12 MANDIR = /usr/man
     12
     13# Destination paths, set prefix=/opt if required
     14BINDIR = $(prefix)/usr/sbin
     15MANDIR = $(prefix)/usr/share/man
    1316
    1417# There is one report that under an all ELF system there may be a need to
    1518# explicilty link with libresolv.a.  If linking syslogd fails you may wish
     
    3437# The following define establishes ownership for the man pages.
    3538# Avery tells me that there is a difference between Debian and
    3639# Slackware.  Rather than choose sides I am leaving it up to the user.
    37 MAN_OWNER = root
    38 # MAN_OWNER = man
     40MAN_USER = root
     41MAN_GROUP = root
     42MAN_PERMS = 644
    3943
    4044# The following define establishes the name of the pid file for the
    4145# syslogd daemon.  The library include file (paths.h) defines the
     
    116120        ${INSTALL} -m 500 -s klogd ${BINDIR}/klogd
    117121
    118122install_man:
    119         ${INSTALL} -o ${MAN_OWNER} -g ${MAN_OWNER} -m 644 sysklogd.8 ${MANDIR}/man8/sysklogd.8
    120         ${INSTALL} -o ${MAN_OWNER} -g ${MAN_OWNER} -m 644 syslogd.8 ${MANDIR}/man8/syslogd.8
    121         ${INSTALL} -o ${MAN_OWNER} -g ${MAN_OWNER} -m 644 syslog.conf.5 ${MANDIR}/man5/syslog.conf.5
    122         ${INSTALL} -o ${MAN_OWNER} -g ${MAN_OWNER} -m 644 klogd.8 ${MANDIR}/man8/klogd.8
     123        ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} sysklogd.8 ${MANDIR}/man8/sysklogd.8
     124        ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} syslogd.8 ${MANDIR}/man8/syslogd.8
     125        ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} syslog.conf.5 ${MANDIR}/man5/syslog.conf.5
     126        ${INSTALL} -o ${MAN_USER} -g ${MAN_GROUP} -m ${MAN_PERMS} klogd.8 ${MANDIR}/man8/klogd.8
  • module.h

    diff -Naur sysklogd-1.4.1/module.h sysklogd-20050123/module.h
    old new  
     1/*
     2    module.h - Miscellaneous module definitions
     3    Copyright (c) 1996 Richard Henderson <rth@tamu.edu>
     4    Copyright (c) 2004 Martin Schulze <joey@infodrom.org>
     5
     6    This file is part of the sysklogd package.
     7
     8    This program is free software; you can redistribute it and/or modify
     9    it under the terms of the GNU General Public License as published by
     10    the Free Software Foundation; either version 2 of the License, or
     11    (at your option) any later version.
     12
     13    This program is distributed in the hope that it will be useful,
     14    but WITHOUT ANY WARRANTY; without even the implied warranty of
     15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16    GNU General Public License for more details.
     17
     18    You should have received a copy of the GNU General Public License
     19    along with this program; if not, write to the Free Software
     20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     21*/
     22
     23/* ChangeLog:
     24 *
     25 * Wed Mar 31 17:35:01 CEST 2004: Martin Schulze <joey@infodrom.org>
     26 *      Created local copy of module.h based on the content of Linux
     27 *      2.2 since <linux/module.h> doesn't work anymore with its
     28 *      recent content from Linux 2.4/2.6.
     29 */
     30
     31#include <asm/atomic.h>
     32
     33#define MODULE_NAME_LEN 60
     34
     35struct kernel_sym
     36{
     37        unsigned long value;
     38        char name[MODULE_NAME_LEN];
     39};
     40
     41
     42struct list_head {
     43        struct list_head *next, *prev;
     44};
     45
     46
     47struct module_info
     48{
     49        unsigned long addr;
     50        unsigned long size;
     51        unsigned long flags;
     52        long usecount;
     53};
     54
     55
     56struct module
     57{
     58        unsigned long size_of_struct;   /* == sizeof(module) */
     59        struct module *next;
     60        const char *name;
     61        unsigned long size;
     62
     63        union
     64        {
     65                int usecount;
     66                long pad;
     67        } uc;                           /* Needs to keep its size - so says rth */
     68
     69        unsigned long flags;            /* AUTOCLEAN et al */
     70
     71        unsigned nsyms;
     72        unsigned ndeps;
     73
     74        struct module_symbol *syms;
     75        struct module_ref *deps;
     76        struct module_ref *refs;
     77        int (*init)(void);
     78        void (*cleanup)(void);
     79        const struct exception_table_entry *ex_table_start;
     80        const struct exception_table_entry *ex_table_end;
     81#ifdef __alpha__
     82        unsigned long gp;
     83#endif
     84        /* Members past this point are extensions to the basic
     85           module support and are optional.  Use mod_opt_member()
     86           to examine them.  */
     87        const struct module_persist *persist_start;
     88        const struct module_persist *persist_end;
     89        int (*can_unload)(void);
     90};
  • pidfile.c

    diff -Naur sysklogd-1.4.1/pidfile.c sysklogd-20050123/pidfile.c
    old new  
    8787  int fd;
    8888  int pid;
    8989
    90   if ( ((fd = open(pidfile, O_RDWR|O_CREAT, 0644)) == -1)
     90  if ( ((fd = open(pidfile, O_RDWR|O_CREAT|O_TRUNC, 0644)) == -1)
    9191       || ((f = fdopen(fd, "r+")) == NULL) ) {
    9292      fprintf(stderr, "Can't open or create %s.\n", pidfile);
    9393      return 0;
  • README.1st

    diff -Naur sysklogd-1.4.1/README.1st sysklogd-20050123/README.1st
    old new  
    1 Very important information before using version 1.3
    2 ---------------------------------------------------
     1Important information
     2---------------------
    33
    44The included version of syslogd behaves in a slightly different manner
    55to the one in former releases.  Please review the following important
     
    6363  these scripts should remove all old .pid files found in /var/run.
    6464  This will insure that klogd and syslogd start properly even if prior
    6565  executions have been terminated harshly.
     66
     67* Large file support, i.e. support to write to log files that are
     68  larger than 2 GB is not part of syslogd, but a matter of the Glibc
     69  emitting different system calls to the kernel interface.  To support
     70  large files you'll have to compile syslogd with the compiler defines
     71  -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE so that glibc adjusts the
     72  system calls.
  • README.linux

    diff -Naur sysklogd-1.4.1/README.linux sysklogd-20050123/README.linux
    old new  
    4040a useful addition to the software gene pool.
    4141
    4242There is a mailing list covering this package and syslog in general.
    43 The lists address is sysklogd@Infodrom.North.DE .  To subscribe send a
    44 mail to Majordomo@Infodrom.North.DE with a line "subscribe sysklogd"
     43The lists address is infodrom-sysklogd@lists.infodrom.org .  To subscribe send a
     44mail to majordomo@lists.infodrom.org with a line "subscribe infodrom-sysklogd"
    4545in the message body.
    4646
    47 New versions of this package will be available at Joey's ftp server.
    48 ftp://ftp.infodrom.north.de/pub/people/joey/sysklogd/
     47A second mailing list exists as infodrom-sysklogd-cvs@lists.infodrom.org.  Only
     48CVS messages and diffs are distributed there. Whenever new code is added to
     49sysklogd, CVS generates a mail from these changes which will be sent to
     50this list.  Discussions will take place on the first list.
     51
     52The latest version of this software can be found at:
     53http://www.infodrom.org/projects/sysklogd/download.php3
    4954
    5055Best regards,
    5156
     
    6772
    6873Martin Schulze
    6974Infodrom Oldenburg
    70 joey@linux.de
     75joey@infodrom.org
    7176
    72 And a host of bug reporters whose contributions cannot be underestimated.
     77And a number of bug reporters whose contributions cannot be underestimated.
  • sysklogd.8

    diff -Naur sysklogd-1.4.1/sysklogd.8 sysklogd-20050123/sysklogd.8
    old new  
    8484.B MAXFUNIX
    8585within the syslogd.c source file.  An example for a chroot() daemon is
    8686described by the people from OpenBSD at
    87 http://www.psionic.com/papers/dns.html.
     87<http://www.guides.sk/psionic/dns/>.
    8888.TP
    8989.B "\-d"
    9090Turns on debug mode.  Using this the daemon will not proceed a
     
    117117between two \fI-- MARK --\fR lines is 20 minutes.  This can be changed
    118118with this option.  Setting the
    119119.I interval
    120 to zero turns it off entirely.
     120to zero turns it off entirely.  Depending on other log messages
     121generated these lines may not be written consecutively.
    121122.TP
    122123.B "\-n"
    123124Avoid auto-backgrounding.  This is needed especially if the
     
    364365
    365366To avoid this in further times no messages that were received from a
    366367remote host are sent out to another (or the same) remote host
    367 anymore.  If there are scenarios where this doesn't make sense, please
    368 drop me (Joey) a line.
     368anymore.  If you experience are setup in which this doesn't make
     369sense, please use the
     370.B \-h
     371commandline switch.
    369372
    370373If the remote host is located in the same domain as the host,
    371374.B syslogd
  • syslog.c

    diff -Naur sysklogd-1.4.1/syslog.c sysklogd-20050123/syslog.c
    old new  
    4747 * Sun Mar 11 20:23:44 CET 2001: Martin Schulze <joey@infodrom.ffis.de>
    4848 *      Use SOCK_DGRAM for loggin, renables it to work.
    4949 *
     50 * Wed Aug 27 17:48:16 CEST 2003: Martin Schulze <joey@Infodrom.org>
     51 *      Improved patch by Michael Pomraning <mjp@securepipe.com> to
     52 *      reconnect klogd to the logger after it went away.
    5053 */
    5154
    5255#include <sys/types.h>
     
    98101        register char *p;
    99102        time_t now;
    100103        int fd, saved_errno;
     104        int result;
    101105        char tbuf[2048], fmt_cpy[1024], *stdp = (char *) 0;
    102106
    103107        saved_errno = errno;
     
    167171        }
    168172
    169173        /* output the message to the local logger */
    170         if (write(LogFile, tbuf, cnt + 1) >= 0 || !(LogStat&LOG_CONS))
     174        result = write(LogFile, tbuf, cnt + 1);
     175
     176        if (result == -1
     177            && (errno == ECONNRESET || errno == ENOTCONN || errno == ECONNREFUSED)) {
     178                closelog();
     179                openlog(LogTag, LogStat | LOG_NDELAY, LogFacility);
     180                result = write(LogFile, tbuf, cnt + 1);
     181        }
     182
     183        if (result >= 0 || !(LogStat&LOG_CONS))
    171184                return;
    172185
    173186        /*
  • syslog.conf.5

    diff -Naur sysklogd-1.4.1/syslog.conf.5 sysklogd-20050123/syslog.conf.5
    old new  
    6464The
    6565.I facility
    6666is one of the following keywords:
    67 .BR auth ", " authpriv ", " cron ", " daemon ", " kern ", " lpr ", "
     67.BR auth ", " authpriv ", " cron ", " daemon ", " ftp ", " kern ", " lpr ", "
    6868.BR mail ", " mark ", " news ", " security " (same as " auth "), "
    6969.BR syslog ", " user ", " uucp " and " local0 " through " local7 .
    7070The keyword
     
    121121
    122122This
    123123.BR syslogd (8)
    124 has a syntax extension to the original BSD source, that makes its use
     124has a syntax extension to the original BSD source, which makes its use
    125125more intuitively.  You may precede every priority with an equation sign
    126 (``='') to specify only this single priority and not any of the
    127 above.  You may also (both is valid, too) precede the priority with an
    128 exclamation mark (``!'') to ignore all that priorities, either exact
    129 this one or this and any higher priority.  If you use both extensions
     126(``='') to specify that
     127.B syslogd
     128should only refer to this single priority and not this priority and
     129all higher priorities.
     130
     131You may also precide the priority with an exclamation mark (``!'') if
     132you want
     133.B syslogd
     134to ignore this priority and all higher priorities.
     135You may even use both, the exclamation mark and the equation sign if
     136you want
     137.B syslogd
     138to ignore only this single priority.  If you use both extensions
    130139than the exclamation mark must occur before the equation sign, just
    131140use it intuitively.
    132141
     
    300309.B syslogd
    301310log all messages that come with either the
    302311.BR info " or the " notice
    303 facility into the file
     312priority into the file
    304313.IR /var/log/messages ,
    305314except for all messages that use the
    306315.B mail
  • syslogd.c

    diff -Naur sysklogd-1.4.1/syslogd.c sysklogd-20050123/syslogd.c
    old new  
    441441 *      Don't return a closed fd if `-a' is called with a wrong path.
    442442 *      Thanks to Bill Nottingham <notting@redhat.com> for providing
    443443 *      a patch.
     444 * Thu Apr 13 05:08:10 CEST 2001: Jon Burgess <Jon_Burgess@eur.3com.com>
     445 *      Moved the installation of the signal handler up a little bit
     446 *      so it guaranteed to be available when the child is forked,
     447 *      hence, fixing a  race condition.  This used to create problems
     448 *      with UML and fast machines.
     449 *
     450 * Sat Apr 17 18:03:05 CEST 2004: Steve Grubb <linux_4ever@yahoo.com>
     451 *      Correct memory allocation for for commandline arguments in
     452 *      crunch_list().
     453 *
     454 * Thu Apr 29 12:38:39 CEST 2004: Solar Designer <solar@openwall.com>
     455 *      Applied Openwall paranoia patches to improve crunch_list().
     456 *
     457 * Tue May  4 16:47:30 CEST 2004: Solar Designer <solar@openwall.com>
     458 *      Ensure that "len" is not placed in a register, and that the
     459 *      endtty() signal handler is not installed too early which could
     460 *      cause a segmentation fault or worse.
     461 *
     462 * Tue May  4 16:52:01 CEST 2004: Solar Designer <solar@openwall.com>
     463 *      Adjust the size of a variable to prevent a buffer overflow
     464 *      should _PATH_DEV ever contain something different than "/dev/".
     465 *
     466 * Tue Nov  2 20:28:23 CET 2004: Colin Phipps <cph@cph.demon.co.uk>
     467 *      Don't block on the network socket, in case a packet gets lost
     468 *      between select and recv.
     469 *
     470 * Sun Nov  7 12:28:47 CET 2004: Martin Schulze <joey@infodrom.org>
     471 *      Discard any timestamp information found in received syslog
     472 *      messages.  This will affect local messages sent from a
     473 *      different timezone.
     474 *
     475 * Sun Nov  7 13:47:00 CET 2004: Martin Schulze <joey@infodrom.org>
     476 *      Remove trailing newline when forwarding messages.
    444477 */
    445478
    446479
     
    890923                dprintf("Checking pidfile.\n");
    891924                if (!check_pid(PidFile))
    892925                {
     926                        signal (SIGTERM, doexit);
    893927                        if (fork()) {
    894928                                /*
    895929                                 * Parent process
    896930                                 */
    897                                 signal (SIGTERM, doexit);
    898931                                sleep(300);
    899932                                /*
    900933                                 * Not reached unless something major went wrong.  5
     
    9921025        (void) signal(SIGCHLD, reapchild);
    9931026        (void) signal(SIGALRM, domark);
    9941027        (void) signal(SIGUSR1, Debug ? debug_switch : SIG_IGN);
     1028        (void) signal(SIGXFSZ, SIG_IGN);
    9951029        (void) alarm(TIMERINTVL);
    9961030
    9971031        /* Create a partial message table for all file descriptors. */
     
    11411175                                 */
    11421176                                printchopped(from, line, \
    11431177                                             i + 2,  finet);
    1144                         } else if (i < 0 && errno != EINTR) {
     1178                        } else if (i < 0 && errno != EINTR && errno != EAGAIN) {
    11451179                                dprintf("INET socket error: %d = %s.\n", \
    11461180                                        errno, strerror(errno));
    11471181                                logerror("recvfrom inet");
    11481182                                /* should be harmless now that we set
    11491183                                 * BSDCOMPAT on the socket */
    1150                                 sleep(10);
     1184                                sleep(1);
    11511185                        }
    11521186                }
    11531187#endif
     
    12161250{
    12171251        int fd, on = 1;
    12181252        struct sockaddr_in sin;
     1253        int sockflags;
    12191254
    12201255        fd = socket(AF_INET, SOCK_DGRAM, 0);
    12211256        if (fd < 0) {
     
    12411276                close(fd);
    12421277                return -1;
    12431278        }
     1279        /* We must not block on the network socket, in case a packet
     1280         * gets lost between select and recv, otherise the process
     1281         * will stall until the timeout, and other processes trying to
     1282         * log will also stall.
     1283         */
     1284        if ((sockflags = fcntl(fd, F_GETFL)) != -1) {
     1285                sockflags |= O_NONBLOCK;
     1286                /*
     1287                 * SETFL could fail too, so get it caught by the subsequent
     1288                 * error check.
     1289                 */
     1290                sockflags = fcntl(fd, F_SETFL, sockflags);
     1291        }
     1292        if (sockflags == -1) {
     1293                logerror("fcntl(O_NONBLOCK), suspending inet");
     1294                close(fd);
     1295                return -1;
     1296        }
    12441297        if (bind(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
    12451298                logerror("bind, suspending inet");
    12461299                close(fd);
     
    12541307crunch_list(list)
    12551308        char *list;
    12561309{
    1257         int count, i;
     1310        int i, m, n;
    12581311        char *p, *q;
    12591312        char **result = NULL;
    12601313
    12611314        p = list;
    12621315       
    12631316        /* strip off trailing delimiters */
    1264         while (p[strlen(p)-1] == LIST_DELIMITER) {
    1265                 count--;
     1317        while (*p && p[strlen(p)-1] == LIST_DELIMITER)
    12661318                p[strlen(p)-1] = '\0';
    1267         }
    12681319        /* cut off leading delimiters */
    1269         while (p[0] == LIST_DELIMITER) {
    1270                 count--;
     1320        while (p[0] == LIST_DELIMITER)
    12711321                p++;
    1272         }
    12731322       
    1274         /* count delimiters to calculate elements */
    1275         for (count=i=0; p[i]; i++)
    1276                 if (p[i] == LIST_DELIMITER) count++;
     1323        /* count delimiters to calculate the number of elements */
     1324        for (n = i = 0; p[i]; i++)
     1325                if (p[i] == LIST_DELIMITER) n++;
    12771326       
    1278         if ((result = (char **)malloc(sizeof(char *) * count+2)) == NULL) {
     1327        if ((result = (char **)malloc(sizeof(char *) * (n + 2))) == NULL) {
    12791328                printf ("Sorry, can't get enough memory, exiting.\n");
    1280                 exit(0);
     1329                exit(1);
    12811330        }
    12821331       
    12831332        /*
     
    12851334         * characters are different from any delimiters,
    12861335         * so we don't have to care about this.
    12871336         */
    1288         count = 0;
    1289         while ((q=strchr(p, LIST_DELIMITER))) {
    1290                 result[count] = (char *) malloc((q - p + 1) * sizeof(char));
    1291                 if (result[count] == NULL) {
     1337        m = 0;
     1338        while ((q = strchr(p, LIST_DELIMITER)) && m < n) {
     1339                result[m] = (char *) malloc((q - p + 1) * sizeof(char));
     1340                if (result[m] == NULL) {
    12921341                        printf ("Sorry, can't get enough memory, exiting.\n");
    1293                         exit(0);
     1342                        exit(1);
    12941343                }
    1295                 strncpy(result[count], p, q - p);
    1296                 result[count][q - p] = '\0';
     1344                memcpy(result[m], p, q - p);
     1345                result[m][q - p] = '\0';
    12971346                p = q; p++;
    1298                 count++;
     1347                m++;
    12991348        }
    1300         if ((result[count] = \
    1301              (char *)malloc(sizeof(char) * strlen(p) + 1)) == NULL) {
     1349        if ((result[m] = strdup(p)) == NULL) {
    13021350                printf ("Sorry, can't get enough memory, exiting.\n");
    1303                 exit(0);
     1351                exit(1);
    13041352        }
    1305         strcpy(result[count],p);
    1306         result[++count] = NULL;
     1353        result[++m] = NULL;
    13071354
    13081355#if 0
    1309         count=0;
    1310         while (result[count])
    1311                 dprintf ("#%d: %s\n", count, StripDomains[count++]);
     1356        m = 0;
     1357        while (result[m])
     1358                dprintf ("#%d: %s\n", m, result[m++]);
    13121359#endif
    13131360        return result;
    13141361}
     
    15481595
    15491596        /*
    15501597         * Check to see if msg looks non-standard.
     1598         *
     1599         * A message looks like
     1600         * Nov 17 11:42:33 CRON[
     1601         * 01234567890123456
     1602         *    ^  ^  ^  ^  ^
     1603         *
     1604         * Remote messages are not accompanied by a timestamp.
     1605         * Local messages are accompanied by a timestamp (program's timezone)
    15511606         */
    15521607        msglen = strlen(msg);
    1553         if (msglen < 16 || msg[3] != ' ' || msg[6] != ' ' ||
    1554             msg[9] != ':' || msg[12] != ':' || msg[15] != ' ')
    1555                 flags |= ADDDATE;
    1556 
    1557         (void) time(&now);
    1558         if (flags & ADDDATE)
    1559                 timestamp = ctime(&now) + 4;
    1560         else {
    1561                 timestamp = msg;
     1608        if (!(msglen < 16 || msg[3] != ' ' || msg[6] != ' ' ||
     1609            msg[9] != ':' || msg[12] != ':' || msg[15] != ' ')) {
    15621610                msg += 16;
    15631611                msglen -= 16;
    15641612        }
    15651613
     1614        (void) time(&now);
     1615        timestamp = ctime(&now) + 4;
     1616
    15661617        /* extract facility and priority level */
    15671618        if (flags & MARK)
    15681619                fac = LOG_NFACILITIES;
     
    17711822                        dprintf("Not sending message to remote.\n");
    17721823                else {
    17731824                        f->f_time = now;
    1774                         (void) snprintf(line, sizeof(line), "<%d>%s\n", f->f_prevpri, \
     1825                        (void) snprintf(line, sizeof(line), "<%d>%s", f->f_prevpri, \
    17751826                                (char *) iov[4].iov_base);
    17761827                        l = strlen(line);
    17771828                        if (l > MAXLINE)
     
    18151866                        v->iov_len = 1;
    18161867                }
    18171868        again:
    1818                 /* f->f_file == -1 is an indicator that the we couldn't
     1869                /* f->f_file == -1 is an indicator that we couldn't
    18191870                   open the file at startup. */
    18201871                if (f->f_file == -1)
    18211872                        break;
     
    18521903                                errno = e;
    18531904                                logerror(f->f_un.f_fname);
    18541905                        }
    1855                 } else if (f->f_flags & SYNC_FILE)
     1906                } else if (f->f_type == F_FILE && (f->f_flags & SYNC_FILE))
    18561907                        (void) fsync(f->f_file);
    18571908                break;
    18581909
     
    18911942        register struct filed *f;
    18921943        struct iovec *iov;
    18931944{
    1894         char p[6 + UNAMESZ];
     1945        char p[sizeof (_PATH_DEV) + UNAMESZ];
    18951946        register int i;
    18961947        int ttyf, len;
    18971948        static int reenter = 0;
     
    18991950        struct utmp *uptr;
    19001951        char greetings[200];
    19011952
     1953        (void) &len;
     1954
    19021955        if (reenter++)
    19031956                return;
    19041957
     
    19131966        if (fork() == 0) {
    19141967                (void) signal(SIGTERM, SIG_DFL);
    19151968                (void) alarm(0);
    1916                 (void) signal(SIGALRM, endtty);
    19171969#ifndef SYSV
    19181970                (void) signal(SIGTTOU, SIG_IGN);
    19191971                (void) sigsetmask(0);
     
    19291981                        /* is this slot used? */
    19301982                        if (ut.ut_name[0] == '\0')
    19311983                                continue;
    1932                         if (ut.ut_type == LOGIN_PROCESS)
     1984                        if (ut.ut_type != USER_PROCESS)
    19331985                                continue;
    19341986                        if (!(strcmp (ut.ut_name,"LOGIN"))) /* paranoia */
    19351987                                continue;
     
    19592011                                iov[1].iov_len = 0;
    19602012                        }
    19612013                        if (setjmp(ttybuf) == 0) {
     2014                                (void) signal(SIGALRM, endtty);
    19622015                                (void) alarm(15);
    19632016                                /* open the terminal */
    19642017                                ttyf = open(p, O_WRONLY|O_NOCTTY);
Note: See TracBrowser for help on using the repository browser.