Changes in / [30:20]


Ignore:
Location:
/trunk
Files:
2 added
6 deleted
98 edited

Legend:

Unmodified
Added
Removed
  • /trunk/COPYING

    r30 r20  
    131131
    132132  (vi) Support for the MD5 hash algorithm is provided by code
    133   from busybox which is distributed under the GPL.
    134 
    135    /* md5.c - Functions to compute MD5 message digest of files or memory blocks
    136     *         according to the definition of MD5 in RFC 1321 from April 1992.
    137     * Copyright (C) 1995, 1996 Free Software Foundation, Inc.
    138     *
    139     * NOTE: The canonical source of this file is maintained with the GNU C
    140     * Library.  Bugs can be reported to bug-glibc@prep.ai.mit.edu.
    141     *
    142     * This program is free software; you can redistribute it and/or modify it
    143     * under the terms of the GNU General Public License as published by the
    144     * Free Software Foundation; either version 2, or (at your option) any
    145     * later version.
    146     *
    147     * This program is distributed in the hope that it will be useful,
    148     * but WITHOUT ANY WARRANTY; without even the implied warranty of
    149     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    150     * GNU General Public License for more details.
    151     *
    152     * You should have received a copy of the GNU General Public License
    153     * along with this program; if not, write to the Free Software Foundation,
    154     * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    155     */
    156 
    157    /* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.  */
    158 
     133  from beecrypt which is distributed under the LGPL.
     134
     135      /*
     136       * md5.c
     137       *
     138       * MD5 hash function, code
     139       *
     140       * Copyright (c) 2000 Virtual Unlimited B.V.
     141       *
     142       * Author: Bob Deblier <bob@virtualunlimited.com>
     143       *
     144       * This library is free software; you can redistribute it and/or
     145       * modify it under the terms of the GNU Lesser General Public
     146       * License as published by the Free Software Foundation; either
     147       * version 2.1 of the License, or (at your option) any later version.
     148       *
     149       * This library is distributed in the hope that it will be useful,
     150       * but WITHOUT ANY WARRANTY; without even the implied warranty of
     151       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     152       * Lesser General Public License for more details.
     153       *
     154       * You should have received a copy of the GNU Lesser General Public
     155       * License along with this library; if not, write to the Free Software
     156       * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
     157       * USA
     158       */
    159159
    160160  (vi) Support for the SHA-1 hash algorithm is provided by code
  • /trunk/Makefile.in

    r30 r20  
    152152        testtimesrv.sh \
    153153        testext.sh testrc_1ext.in test_ext.c.in \
    154         testrun_1.sh testrun_1a.sh testrun_1b.sh testrun_1c.sh testrc_1 \
     154        testrun_1.sh testrun_1a.sh testrun_1b.sh testrc_1 \
    155155        testrun_2.sh testrun_2a.sh testrun_2b.sh testrc_2.in \
    156156        testrun_2c.sh testrun_2d.sh
     
    793793        echo $(top_srcdir)/docs/HOWTO-client+server.html >> debian/docs; \
    794794        echo $(top_srcdir)/docs/HOWTO-samhain+GnuPG.html >> debian/docs; \
    795         echo $(top_srcdir)/docs/MANUAL-2_2.html.tar      >> debian/docs; \
    796         echo $(top_srcdir)/docs/MANUAL-2_2.pdf           >> debian/docs; \
     795        echo $(top_srcdir)/docs/MANUAL-2_0.html.tar      >> debian/docs; \
     796        echo $(top_srcdir)/docs/MANUAL-2_0.ps            >> debian/docs; \
    797797        echo $(top_srcdir)/docs/README.gcc_bug           >> debian/docs; \
    798798        echo $(top_srcdir)/docs/README.LZO               >> debian/docs; \
     
    10901090
    10911091CUTEST_SOURCES = $(srcsrc)/cutest_sh_tools.c \
    1092                 $(srcsrc)/cutest_sh_utils.c \
    1093                 $(srcsrc)/cutest_sh_unix.c \
    1094                 $(srcsrc)/cutest_slib.c \
    10951092                $(srcsrc)/cutest_zAVLTree.c \
    10961093                $(srcsrc)/cutest_sh_tiger0.c
    10971094
    1098 CUTEST_OBJECTS = cutest_sh_tools.o \
    1099         cutest_sh_utils.o \
    1100         cutest_sh_unix.o \
    1101         cutest_slib.o \
    1102         cutest_zAVLTree.o \
    1103         cutest_sh_tiger0.o
     1095CUTEST_OBJECTS = cutest_sh_tools.o cutest_zAVLTree.o cutest_sh_tiger0.o
    11041096
    11051097$(CUTEST_OBJECTS): $(CUTEST_SOURCES)
     
    16091601sh_err_console.o: $(srcsrc)/sh_err_console.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h
    16101602sh_err_syslog.o: $(srcsrc)/sh_err_syslog.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h
    1611 sh_schedule.o: $(srcsrc)/sh_schedule.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_schedule.h
     1603sh_schedule.o: $(srcsrc)/sh_schedule.c Makefile config_xor.h $(srcinc)/sh_mem.h $(srcinc)/sh_schedule.h
    16121604bignum.o: $(srcsrc)/bignum.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/bignum.h
    16131605mkhdr.o: $(srcsrc)/mkhdr.c Makefile config.h
  • /trunk/configure.ac

    r30 r20  
    3737dnl start
    3838dnl
    39 AM_INIT_AUTOMAKE(samhain, 2.2.0rc3)
     39AM_INIT_AUTOMAKE(samhain, 2.2.0rc1)
    4040AC_CANONICAL_HOST
    4141
     
    763763               ;;
    764764               *)
    765                AM_PATH_LIBPRELUDE([0.9.6],
     765               AM_PATH_LIBPRELUDE([0.9.0],
    766766               [
    767767                AC_DEFINE(HAVE_LIBPRELUDE,1,[Have libprelude])
  • /trunk/depend.dep

    r30 r20  
    3434sh_err_console.o: $(srcsrc)/sh_err_console.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h
    3535sh_err_syslog.o: $(srcsrc)/sh_err_syslog.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h
    36 sh_schedule.o: $(srcsrc)/sh_schedule.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_schedule.h
     36sh_schedule.o: $(srcsrc)/sh_schedule.c Makefile config_xor.h $(srcinc)/sh_mem.h $(srcinc)/sh_schedule.h
    3737bignum.o: $(srcsrc)/bignum.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/bignum.h
    3838mkhdr.o: $(srcsrc)/mkhdr.c Makefile config.h
  • /trunk/depend.sum

    r30 r20  
    1 2018699483
     13476546078
  • /trunk/deploy.sh.in

    r30 r20  
    11#! /bin/sh
    2 
    3 #
    4 # Copyright Rainer Wichmann (2005)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    212
    223#VERSION2.0
  • /trunk/docs/Changelog

    r30 r20  
    112.2.0:
    2         * patch by Jim Simmons for samhainadmin.pl.in
    3         * fix testsuite portability problems
    4         * fix md5 endianess problem detected on HP-UX 11i / PA-RISC 8700
    5         * fix potential NULL dereference in sh_utmp_endutent()
    6         * patch by Neil Gorsuch for suidchk.c (do not scan lustre, afs, mmfs)
    7         * fix sh_ext_popen (OpenBSD needs non-null argv[0] in execve)
    8         * fix make_tests.sh portability (echo '"\n"' does not work on OpenBSD)
    9         * fix bug in sh_utils_obscurename (check isascii)
    10         * scan h_aliases for FQDN if h_name is not
    11         * add copyright/license info to test scripts
    12         * add copyright/license info to deployment system scripts
    13         * support server-to-server relay
    14         * new CL option --server-port
    15         * minor improvements in manual
    16         * patch by Yoann Vandoorselaere for sh_prelude.c
    17         * allow --longopt arg as well as --longopt=arg
    18         * verify checksum of growing log files (up to previous size)
    19         * rewrite of the test suite
    202        * added a bit of unit testing
     3        * improved the windows howto according to suggestions by
     4          Jorge Morgado
    215        * minor optimizations in various places
    226        * optimized implementation of tiger checksum algorithm
     
    3115        * slib.c: remove fcntl's from sl_read_timeout (caller sets O_NONBLOCK),
    3216          add function sl_read_timeout_prep
    33 
    34 2.1.3 (13-03-2006):
    35         * fix compile problem in slib.c (reported by Lawrence Bowie)
    36         * fix bug with combination of one-shot update mode and file check
    37           schedule (reportedby Dan Track)
    38         * improved the windows howto according to suggestions by
    39           Jorge Morgado
    40         * fix samhain_hide kernel module for new linux kernel versions
    41         * fix minor problem with dead client detection (problem reported
    42           by Michal Kustosik)
    4317
    44182.1.2 (10-01-2006):
  • /trunk/docs/README.UPGRADE

    r30 r20  
    1 
    2 since 2.2.0: server-to-server relay is possible
    3 
    4   -- this implies that problems will arise if your server is misconfigured
    5      to connect to itself (SetExportSeverity is explicitely set
    6      to a threshold different from 'none', and the logserver is set to
    7      localhost). The server may deadlock in this case.
    8 
    9 
    10 
    111since 2.1.0: update and daemon mode can be combined
    122
  • /trunk/dsys/comBUILD

    r30 r20  
    44#
    55#########################################################################
    6 #
    7 # Copyright Rainer Wichmann (2005)
    8 #
    9 # License Information:
    10 # This program is free software; you can redistribute it and/or modify
    11 # it under the terms of the GNU General Public License as published by
    12 # the Free Software Foundation; either version 2 of the License, or
    13 # (at your option) any later version.
    14 #
    15 # This program is distributed in the hope that it will be useful,
    16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18 # GNU General Public License for more details.
    19 #
    20 # You should have received a copy of the GNU General Public License
    21 # along with this program; if not, write to the Free Software
    22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    23 #
    246
    257commandBUILD() {
  • /trunk/dsys/comCHECKSRC

    r30 r20  
    44#
    55#########################################################################
    6 #
    7 # Copyright Rainer Wichmann (2005)
    8 #
    9 # License Information:
    10 # This program is free software; you can redistribute it and/or modify
    11 # it under the terms of the GNU General Public License as published by
    12 # the Free Software Foundation; either version 2 of the License, or
    13 # (at your option) any later version.
    14 #
    15 # This program is distributed in the hope that it will be useful,
    16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18 # GNU General Public License for more details.
    19 #
    20 # You should have received a copy of the GNU General Public License
    21 # along with this program; if not, write to the Free Software
    22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    23 #
    246
    257commandCHECKSRC() {
  • /trunk/dsys/comCLEAN

    r30 r20  
    44#
    55#########################################################################
    6 #
    7 # Copyright Rainer Wichmann (2005)
    8 #
    9 # License Information:
    10 # This program is free software; you can redistribute it and/or modify
    11 # it under the terms of the GNU General Public License as published by
    12 # the Free Software Foundation; either version 2 of the License, or
    13 # (at your option) any later version.
    14 #
    15 # This program is distributed in the hope that it will be useful,
    16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18 # GNU General Public License for more details.
    19 #
    20 # You should have received a copy of the GNU General Public License
    21 # along with this program; if not, write to the Free Software
    22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    23 #
    246
    257commandCLEAN() {
  • /trunk/dsys/comDOWNLOAD

    r30 r20  
    44#
    55#########################################################################
    6 #
    7 # Copyright Rainer Wichmann (2005)
    8 #
    9 # License Information:
    10 # This program is free software; you can redistribute it and/or modify
    11 # it under the terms of the GNU General Public License as published by
    12 # the Free Software Foundation; either version 2 of the License, or
    13 # (at your option) any later version.
    14 #
    15 # This program is distributed in the hope that it will be useful,
    16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18 # GNU General Public License for more details.
    19 #
    20 # You should have received a copy of the GNU General Public License
    21 # along with this program; if not, write to the Free Software
    22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    23 #
    246
    257commandDOWNLOAD() {
     
    129111    if test -z "$command"
    130112    then
    131         printFATAL "No wget, curl, lynx, links, lwp-request, fetch, fget in your \$PATH, cannot download"
     113        printFATAL "No wget, curl, lynx, links, lwp-request, fetch in your \$PATH, cannot download"
    132114    fi
    133115
  • /trunk/dsys/comINSTALL

    r30 r20  
    44#
    55#########################################################################
    6 #
    7 # Copyright Rainer Wichmann (2005)
    8 #
    9 # License Information:
    10 # This program is free software; you can redistribute it and/or modify
    11 # it under the terms of the GNU General Public License as published by
    12 # the Free Software Foundation; either version 2 of the License, or
    13 # (at your option) any later version.
    14 #
    15 # This program is distributed in the hope that it will be useful,
    16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18 # GNU General Public License for more details.
    19 #
    20 # You should have received a copy of the GNU General Public License
    21 # along with this program; if not, write to the Free Software
    22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    23 #
    246
    257commandINSTALL() {
  • /trunk/dsys/comUNINSTALL

    r30 r20  
    44#
    55#########################################################################
    6 #
    7 # Copyright Rainer Wichmann (2005)
    8 #
    9 # License Information:
    10 # This program is free software; you can redistribute it and/or modify
    11 # it under the terms of the GNU General Public License as published by
    12 # the Free Software Foundation; either version 2 of the License, or
    13 # (at your option) any later version.
    14 #
    15 # This program is distributed in the hope that it will be useful,
    16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18 # GNU General Public License for more details.
    19 #
    20 # You should have received a copy of the GNU General Public License
    21 # along with this program; if not, write to the Free Software
    22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    23 #
    246
    257commandUNINSTALL() {
  • /trunk/dsys/funcBUILD

    r30 r20  
    44#
    55#########################################################################
    6 #
    7 # Copyright Rainer Wichmann (2005)
    8 #
    9 # License Information:
    10 # This program is free software; you can redistribute it and/or modify
    11 # it under the terms of the GNU General Public License as published by
    12 # the Free Software Foundation; either version 2 of the License, or
    13 # (at your option) any later version.
    14 #
    15 # This program is distributed in the hope that it will be useful,
    16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18 # GNU General Public License for more details.
    19 #
    20 # You should have received a copy of the GNU General Public License
    21 # along with this program; if not, write to the Free Software
    22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    23 #
    246
    257#------------------------------------------------------------------------
  • /trunk/dsys/funcDB

    r30 r20  
    44#
    55#########################################################################
    6 #
    7 # Copyright Rainer Wichmann (2005)
    8 #
    9 # License Information:
    10 # This program is free software; you can redistribute it and/or modify
    11 # it under the terms of the GNU General Public License as published by
    12 # the Free Software Foundation; either version 2 of the License, or
    13 # (at your option) any later version.
    14 #
    15 # This program is distributed in the hope that it will be useful,
    16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18 # GNU General Public License for more details.
    19 #
    20 # You should have received a copy of the GNU General Public License
    21 # along with this program; if not, write to the Free Software
    22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    23 #
    246
    257DBFTEST=0
  • /trunk/dsys/funcDIALOG

    r30 r20  
    44#
    55#########################################################################
    6 #
    7 # Copyright Rainer Wichmann (2005)
    8 #
    9 # License Information:
    10 # This program is free software; you can redistribute it and/or modify
    11 # it under the terms of the GNU General Public License as published by
    12 # the Free Software Foundation; either version 2 of the License, or
    13 # (at your option) any later version.
    14 #
    15 # This program is distributed in the hope that it will be useful,
    16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18 # GNU General Public License for more details.
    19 #
    20 # You should have received a copy of the GNU General Public License
    21 # along with this program; if not, write to the Free Software
    22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    23 #
    246
    257# print without newline
  • /trunk/dsys/funcEXE

    r30 r20  
    44#
    55#########################################################################
    6 #
    7 # Copyright Rainer Wichmann (2005)
    8 #
    9 # License Information:
    10 # This program is free software; you can redistribute it and/or modify
    11 # it under the terms of the GNU General Public License as published by
    12 # the Free Software Foundation; either version 2 of the License, or
    13 # (at your option) any later version.
    14 #
    15 # This program is distributed in the hope that it will be useful,
    16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18 # GNU General Public License for more details.
    19 #
    20 # You should have received a copy of the GNU General Public License
    21 # along with this program; if not, write to the Free Software
    22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    23 #
    246
    257findEXE() {
  • /trunk/dsys/funcINSTALL

    r30 r20  
    44#
    55#########################################################################
    6 #
    7 # Copyright Rainer Wichmann (2005)
    8 #
    9 # License Information:
    10 # This program is free software; you can redistribute it and/or modify
    11 # it under the terms of the GNU General Public License as published by
    12 # the Free Software Foundation; either version 2 of the License, or
    13 # (at your option) any later version.
    14 #
    15 # This program is distributed in the hope that it will be useful,
    16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18 # GNU General Public License for more details.
    19 #
    20 # You should have received a copy of the GNU General Public License
    21 # along with this program; if not, write to the Free Software
    22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    23 #
    246
    257getconfopts () {
  • /trunk/dsys/funcPRINT

    r30 r20  
    44#
    55#########################################################################
    6 #
    7 # Copyright Rainer Wichmann (2005)
    8 #
    9 # License Information:
    10 # This program is free software; you can redistribute it and/or modify
    11 # it under the terms of the GNU General Public License as published by
    12 # the Free Software Foundation; either version 2 of the License, or
    13 # (at your option) any later version.
    14 #
    15 # This program is distributed in the hope that it will be useful,
    16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18 # GNU General Public License for more details.
    19 #
    20 # You should have received a copy of the GNU General Public License
    21 # along with this program; if not, write to the Free Software
    22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    23 #
    246
    257# Fatal error
  • /trunk/dsys/funcSETUP

    r30 r20  
    44#
    55#########################################################################
    6 #
    7 # Copyright Rainer Wichmann (2005)
    8 #
    9 # License Information:
    10 # This program is free software; you can redistribute it and/or modify
    11 # it under the terms of the GNU General Public License as published by
    12 # the Free Software Foundation; either version 2 of the License, or
    13 # (at your option) any later version.
    14 #
    15 # This program is distributed in the hope that it will be useful,
    16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18 # GNU General Public License for more details.
    19 #
    20 # You should have received a copy of the GNU General Public License
    21 # along with this program; if not, write to the Free Software
    22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    23 #
    246
    257# test setup
  • /trunk/dsys/initscript

    r30 r20  
    11#! /bin/sh
    2 
    3 #
    4 # Copyright Rainer Wichmann (2005)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    212
    223startup=no
  • /trunk/dsys/postinstall

    r30 r20  
    11#! /bin/sh
    2 
    3 #
    4 # Copyright Rainer Wichmann (2005)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    212
    223name=`./samhain-install.sh --print-config name`
  • /trunk/dsys/preinstall

    r30 r20  
    11#! /bin/sh
    2 #
    3 # Copyright Rainer Wichmann (2005)
    4 #
    5 # License Information:
    6 # This program is free software; you can redistribute it and/or modify
    7 # it under the terms of the GNU General Public License as published by
    8 # the Free Software Foundation; either version 2 of the License, or
    9 # (at your option) any later version.
    10 #
    11 # This program is distributed in the hope that it will be useful,
    12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14 # GNU General Public License for more details.
    15 #
    16 # You should have received a copy of the GNU General Public License
    17 # along with this program; if not, write to the Free Software
    18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    19 #
    202
    213name=`./samhain-install.sh --print-config name`
  • /trunk/include/samhain.h

    r30 r20  
    138138  SH_LEVEL_USER0       = 7,
    139139  SH_LEVEL_USER1       = 8,
    140   SH_LEVEL_USER2       = 9,
    141   SH_LEVEL_USER3       = 10,
    142   SH_LEVEL_USER4       = 11,
    143   SH_LEVEL_PRELINK     = 12
     140  SH_LEVEL_PRELINK     = 9
    144141};
    145142
     
    293290/*@null@*/ extern sh_key_t  *skey;
    294291
    295 /**************************************************
    296  *
    297  * macros
    298  *
    299  **************************************************/
    300 
    301 /* signal-safe log function
    302  */
    303 int  safe_logger (int signal, int method, char * details);
    304 void safe_fatal  (int signal, int method, char * details, char *f, int l);
    305 
    306 #define SH_VALIDATE_EQ(a,b) \
    307      do { \
    308          if ((a) != (b)) safe_fatal(0, 0, #a " != " #b, FIL__, __LINE__);\
    309      } while (0)
    310 
    311 #define SH_VALIDATE_NE(a,b) \
    312      do { \
    313          if ((a) == (b)) safe_fatal(0, 0, #a " == " #b, FIL__, __LINE__);\
    314      } while (0)
    315292
    316293#if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK)
  • /trunk/include/sh_calls.h

    r30 r20  
    3333/* Set aud functions
    3434 */
    35 int sh_aud_set_functions(const char * str_s);
     35int sh_aud_set_functions(char * str_s);
    3636
    3737
  • /trunk/include/sh_database.h

    r30 r20  
    55int sh_database_insert (char * message);
    66
    7 int sh_database_use_persistent (const char * str);
     7int sh_database_use_persistent (char * str);
    88
    9 int sh_database_set_database (const char * str);
    10 int sh_database_set_table (const char * str);
    11 int sh_database_set_host (const char * str);
    12 int sh_database_set_user (const char * str);
    13 int sh_database_set_password (const char * str);
    14 int sh_database_add_to_hash  (const char * str);
    15 int set_enter_wrapper (const char * str);
     9int sh_database_set_database (char * str);
     10int sh_database_set_table (char * str);
     11int sh_database_set_host (char * str);
     12int sh_database_set_user (char * str);
     13int sh_database_set_password (char * str);
     14int sh_database_add_to_hash  (char * str);
     15int set_enter_wrapper (char * str);
    1616#endif
  • /trunk/include/sh_error.h

    r30 r20  
    3030  SH_ERR_T_START  = 0,
    3131
    32   /* 1-13 = SH_LEVEL_XXX */
     32  /* 1-9 = SH_LEVEL_XXX */
    3333
    3434  SH_ERR_T_RO      = SH_LEVEL_READONLY,
     
    4040  SH_ERR_T_USER0   = SH_LEVEL_USER0, 
    4141  SH_ERR_T_USER1   = SH_LEVEL_USER1, 
    42   SH_ERR_T_USER2   = SH_LEVEL_USER2, 
    43   SH_ERR_T_USER3   = SH_LEVEL_USER3, 
    44   SH_ERR_T_USER4   = SH_LEVEL_USER4, 
    4542  SH_ERR_T_PRELINK = SH_LEVEL_PRELINK, 
    4643
    47   SH_ERR_T_DIR    = 13,
    48   SH_ERR_T_FILE   = 14,
    49   SH_ERR_T_NAME   = 15,
     44  SH_ERR_T_DIR    = 10,
     45  SH_ERR_T_FILE   = 11,
     46  SH_ERR_T_NAME   = 12,
    5047
    51   SH_ERR_T_END    = 16
     48  SH_ERR_T_END    = 13
    5249};
    5350
     
    8481/* set mask for message class
    8582 */
    86 int sh_error_log_mask (const char * c);
    87 int sh_error_print_mask (const char * c);
    88 int sh_error_mail_mask (const char * c);
    89 int sh_error_export_mask (const char * c);
    90 int sh_error_syslog_mask (const char * c);
    91 int sh_error_external_mask (const char * c);
    92 int sh_error_database_mask (const char * c);
    93 int sh_error_prelude_mask (const char * c);
     83int sh_error_log_mask (char * c);
     84int sh_error_print_mask (char * c);
     85int sh_error_mail_mask (char * c);
     86int sh_error_export_mask (char * c);
     87int sh_error_syslog_mask (char * c);
     88int sh_error_external_mask (char * c);
     89int sh_error_database_mask (char * c);
     90int sh_error_prelude_mask (char * c);
    9491
    9592
     
    10299#ifdef SH_WITH_SERVER
    103100void sh_error_set_peer(const char * str);
    104 int  set_flag_sep_log (const char * str);
     101int  set_flag_sep_log (char * str);
    105102#endif
    106103
     
    111108/* convert a string to a numeric priority
    112109 */
    113 int sh_error_convert_level (const char * str_s);
     110int sh_error_convert_level (char * str_s);
    114111
    115112/* only to stderr (GOOD/BAD)
     
    119116/* set syslog facility
    120117 */
    121 int  sh_log_set_facility (const char * c);
     118int  sh_log_set_facility (char * c);
    122119
    123120/* define message header
    124121 */
    125 int sh_error_ehead (/*@null@*/const char * s);
     122int sh_error_ehead (/*@null@*/char * s);
    126123
    127124/* set level for error logging
     
    131128/* set severity levels
    132129 */
    133 int sh_error_set_iv (int iv, const char *  severity_s);
     130int sh_error_set_iv (int iv, char *  severity_s);
    134131
    135132/* set priorities
     
    181178/* (re)set the console device(s)
    182179 */
    183 int sh_log_set_console (const char * address);
     180int sh_log_set_console (char * address);
    184181void reset_count_dev_console(void);
    185182
     
    191188/* enable message queue
    192189 */
    193 int enable_msgq(const char * foo);
     190int enable_msgq(char * foo);
    194191#endif
    195192 
  • /trunk/include/sh_extern.h

    r30 r20  
    4343 * -- add CL argument, return # of arguments
    4444 */
    45 int sh_ext_tas_add_argv(sh_tas_t * tas, const char * val);
     45int sh_ext_tas_add_argv(sh_tas_t * tas, char * val);
    4646/*
    4747 * -- remove last CL argument
     
    5151 * -- add environment variable, return # of variables
    5252 */
    53 int sh_ext_tas_add_envv(sh_tas_t * tas, const char * key, const char * val);
     53int sh_ext_tas_add_envv(sh_tas_t * tas, char * key, char * val);
    5454/*
    5555 * -- set command
    5656 */
    57 void sh_ext_tas_command(sh_tas_t * tas, const char * command);
     57void sh_ext_tas_command(sh_tas_t * tas, char * command);
    5858/*
    5959 * -- initialize task structure
     
    7171 * -- start a new external command, and add it to the list
    7272 */
    73 int sh_ext_setcommand(const char * cmd);
     73int sh_ext_setcommand(char * cmd);
    7474
    7575/*
     
    8181 * -- set deadtime
    8282 */
    83 int sh_ext_deadtime (const char * str);
     83int sh_ext_deadtime (char * str);
    8484
    8585/*
    8686 * -- add keywords to the OR filter
    8787 */
    88 int sh_ext_add_or (const char * str);
     88int sh_ext_add_or (char * str);
    8989
    9090/*
    9191 * -- add keywords to the AND filter
    9292 */
    93 int sh_ext_add_and (const char * str);
     93int sh_ext_add_and (char * str);
    9494
    9595/*
    9696 * -- add keywords to the NOT filter
    9797 */
    98 int sh_ext_add_not (const char * str);
     98int sh_ext_add_not (char * str);
    9999
    100100/*
    101101 * -- add keywords to the CL argument list
    102102 */
    103 int sh_ext_add_argv (const char * str);
     103int sh_ext_add_argv (char * str);
    104104
    105105/*
    106106 * -- add a path to the environment
    107107 */
    108 int sh_ext_add_default (const char * str);
     108int sh_ext_add_default (char * str);
    109109
    110110/*
    111111 * -- add an environment variable
    112112 */
    113 int sh_ext_add_environ (const char * str);
     113int sh_ext_add_environ (char * str);
    114114
    115115/*
    116116 * -- define type
    117117 */
    118 int sh_ext_type (const char * str);
     118int sh_ext_type (char * str);
    119119
    120120/*
    121121 * -- define checksum
    122122 */
    123 int sh_ext_checksum (const char * str);
     123int sh_ext_checksum (char * str);
    124124
    125125/*
    126126 * -- choose privileges
    127127 */
    128 int sh_ext_priv (const char * c);
     128int sh_ext_priv (char * c);
    129129
    130130/*
  • /trunk/include/sh_files.h

    r30 r20  
    2323/* register exceptions to hardlink check
    2424 */
    25 int sh_files_hle_reg (const char * str);
     25int sh_files_hle_reg (char * str);
    2626
    2727/* check the setup
     
    3535/* activate hardlink check
    3636 */
    37 int sh_files_check_hardlinks (const char * opt);
     37int sh_files_check_hardlinks (char * opt);
    3838
    3939/* set recursion depth
     
    4343/* report only once
    4444 */
    45 int sh_files_reportonce(const char * c);
     45int sh_files_reportonce(char * c);
    4646
    4747/* report full details
    4848 */
    49 int sh_files_fulldetail(const char * c);
     49int sh_files_fulldetail(char * c);
    5050
    5151/* reset the 'checked' flag
     
    6767/* push a directory on the stack USER0
    6868 */
    69 int  sh_files_pushdir_user0 (const char * dirName);
     69int  sh_files_pushdir_user0 (char * dirName);
    7070
    7171/* push a directory on the stack USER1
    7272 */
    73 int  sh_files_pushdir_user1 (const char * dirName);
    74 
    75 /* push a directory on the stack USER2
    76  */
    77 int  sh_files_pushdir_user2 (const char * dirName);
    78 
    79 /* push a directory on the stack USER3
    80  */
    81 int  sh_files_pushdir_user3 (const char * dirName);
    82 
    83 /* push a directory on the stack USER4
    84  */
    85 int  sh_files_pushdir_user4 (const char * dirName);
     73int  sh_files_pushdir_user1 (char * dirName);
    8674
    8775/* push a directory on the stack PRELINK
    8876 */
    89 int  sh_files_pushdir_prelink (const char * dirName);
     77int  sh_files_pushdir_prelink (char * dirName);
    9078
    9179/* push a directory on the stack ATTR
    9280 */
    93 int  sh_files_pushdir_attr (const char * dirName);
     81int  sh_files_pushdir_attr (char * dirName);
    9482
    9583/* push a directory on the stack READONLY
    9684 */
    97 int  sh_files_pushdir_ro (const char * dirName);
     85int  sh_files_pushdir_ro (char * dirName);
    9886
    9987/* push a directory on the stack LOGFILE
    10088 */
    101 int  sh_files_pushdir_log (const char * dirName);
     89int  sh_files_pushdir_log (char * dirName);
    10290
    10391/* push a directory on the stack GROWING LOGFILE
    10492 */
    105 int  sh_files_pushdir_glog (const char * dirName);
     93int  sh_files_pushdir_glog (char * dirName);
    10694
    10795/* push a directory on the stack IGNORE NONE
    10896 */
    109 int  sh_files_pushdir_noig (const char * dirName);
     97int  sh_files_pushdir_noig (char * dirName);
    11098
    11199/* push a directory on the stack IGNORE ALL
    112100 */
    113 int  sh_files_pushdir_allig (const char * dirName);
     101int  sh_files_pushdir_allig (char * dirName);
    114102
    115103
    116104/* push a file on the stack USER0
    117105 */
    118 int  sh_files_pushfile_user0 (const char * dirName);
     106int  sh_files_pushfile_user0 (char * dirName);
    119107
    120108/* push a file on the stack USER1
    121109 */
    122 int  sh_files_pushfile_user1 (const char * dirName);
    123 
    124 /* push a file on the stack USER2
    125  */
    126 int  sh_files_pushfile_user2 (const char * dirName);
    127 
    128 /* push a file on the stack USER3
    129  */
    130 int  sh_files_pushfile_user3 (const char * dirName);
    131 
    132 /* push a file on the stack USER4
    133  */
    134 int  sh_files_pushfile_user4 (const char * dirName);
     110int  sh_files_pushfile_user1 (char * dirName);
    135111
    136112/* push a file on the stack PRELINK
    137113 */
    138 int  sh_files_pushfile_prelink (const char * dirName);
     114int  sh_files_pushfile_prelink (char * dirName);
    139115
    140116/* push a file on the stack ATTR
    141117 */
    142 int  sh_files_pushfile_attr (const char * dirName);
     118int  sh_files_pushfile_attr (char * dirName);
    143119
    144120/* push a file on the stack READONLY
    145121 */
    146 int  sh_files_pushfile_ro (const char * dirName);
     122int  sh_files_pushfile_ro (char * dirName);
    147123
    148124/* push a file on the stack LOGFILE
    149125 */
    150 int  sh_files_pushfile_log (const char * dirName);
     126int  sh_files_pushfile_log (char * dirName);
    151127
    152128/* push a file on the stack GROWING LOGFILE
    153129 */
    154 int  sh_files_pushfile_glog (const char * dirName);
     130int  sh_files_pushfile_glog (char * dirName);
    155131
    156132/* push a file on the stack IGNORE NONE
    157133 */
    158 int  sh_files_pushfile_noig (const char * dirName);
     134int  sh_files_pushfile_noig (char * dirName);
    159135
    160136/* push a file on the stack IGNORE ALL
    161137 */
    162 int  sh_files_pushfile_allig (const char * dirName);
     138int  sh_files_pushfile_allig (char * dirName);
    163139
    164140
     
    177153/* redefine policies
    178154 */
    179 int sh_files_redef_user0(const char * str);
    180 int sh_files_redef_user1(const char * str);
    181 int sh_files_redef_user2(const char * str);
    182 int sh_files_redef_user3(const char * str);
    183 int sh_files_redef_user4(const char * str);
    184 int sh_files_redef_prelink(const char * str);
    185 int sh_files_redef_readonly(const char * str);
    186 int sh_files_redef_loggrow(const char * str);
    187 int sh_files_redef_logfiles(const char * str);
    188 int sh_files_redef_attributes(const char * str);
    189 int sh_files_redef_noignore(const char * str);
    190 int sh_files_redef_allignore(const char * str);
     155int sh_files_redef_user0(char * str);
     156int sh_files_redef_user1(char * str);
     157int sh_files_redef_prelink(char * str);
     158int sh_files_redef_readonly(char * str);
     159int sh_files_redef_loggrow(char * str);
     160int sh_files_redef_logfiles(char * str);
     161int sh_files_redef_attributes(char * str);
     162int sh_files_redef_noignore(char * str);
     163int sh_files_redef_allignore(char * str);
    191164
    192165
  • /trunk/include/sh_forward.h

    r30 r20  
    3232/* set time limit
    3333 */
    34 int sh_forward_set_time_limit(const char * str);
     34int sh_forward_set_time_limit(char * str);
    3535
    3636/* error level for lookup failure
    3737 */
    38 int sh_forward_lookup_level (const char * c);
     38int sh_forward_lookup_level (char * c);
    3939
    4040/* create client entry for given password
     
    4242int sh_forward_make_client (const char * str);
    4343
    44 /* set port to which we connect
    45  */
    46 int sh_forward_server_port (const char * str);
    47 
    4844#ifdef SH_WITH_SERVER
    4945
    5046#ifdef INET_SYSLOG
    51 int set_syslog_active(const char * c);
     47int set_syslog_active(char * c);
    5248#endif
    5349
     
    5955 * and set by accept()
    6056 */
    61 int set_socket_peer (const char * c);
     57int set_socket_peer (char * c);
    6258
    6359/* whether to use client severity
    6460 */
    65 int sh_forward_use_clt_sev (const char * c);
     61int sh_forward_use_clt_sev (char * c);
    6662
    6763/* whether to use client class
    6864 */
    69 int sh_forward_use_clt_class (const char * c);
     65int sh_forward_use_clt_class (char * c);
    7066
    7167/* server port
    7268 */
    73 int sh_forward_set_port(const char * c);
     69int sh_forward_set_port(char * c);
    7470
    7571/* server interface
    7672 */
    77 int sh_forward_set_interface(const char * c);
     73int sh_forward_set_interface(char * c);
    7874
    7975/* a wrapper function
     
    8379/* register a client
    8480 */
    85 int sh_forward_register_client (const char * str);
     81int sh_forward_register_client (char * str);
    8682
    8783/* start server
     
    9591#endif
    9692
    97 #if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     93#ifdef SH_WITH_CLIENT
    9894/* talk to server
    9995 */
    10096long  sh_forward (char * errmsg);
    10197
    102 /* set log server
    103  */
    104 int sh_forward_setlogserver (const char * address);
    105 void reset_count_dev_server(void);
    106 #endif
    107 
    108 #ifdef SH_WITH_CLIENT
    10998
    11099/* request file from server. file may be "CONF" or "DATA".
     
    112101long sh_forward_req_file (char * file);
    113102
     103/* set log server
     104 */
     105int sh_forward_setlogserver (char * address);
     106void reset_count_dev_server(void);
     107
    114108#endif
    115109
  • /trunk/include/sh_hash.h

    r30 r20  
    4242/* version string for database
    4343 */
    44 int sh_hash_version_string(const char * str);
     44int sh_hash_version_string(char * str);
    4545
    4646/* List database content
  • /trunk/include/sh_ignore.h

    r30 r20  
    22#define SH_IGNORE_H
    33
    4 int sh_ignore_add_del (const char * addpath);
    5 int sh_ignore_add_new (const char * addpath);
     4int sh_ignore_add_del (char * addpath);
     5int sh_ignore_add_new (char * addpath);
    66
    77int sh_ignore_chk_del (const char * chkpath);
  • /trunk/include/sh_mail.h

    r30 r20  
    2626/* set a relay server
    2727 */
    28 int sh_mail_set_relay (const char * str_s);
     28int sh_mail_set_relay (char * str_s);
    2929
    3030/* send to all recpts. in one mail
    3131 */
    32 int sh_mail_setFlag (const char * str);
     32int sh_mail_setFlag (char * str);
    3333
    3434/* set the subject string
    3535 */
    36 int set_mail_subject (const char * str);
     36int set_mail_subject (char * str);
    3737
    3838/* test mailbox
     
    4444#define SH_MAX_FAIL    48
    4545
    46 int sh_mail_setNum (const char * str);
     46int sh_mail_setNum (char * str);
    4747
    48 int sh_mail_setaddress (const char * address);
     48int sh_mail_setaddress (char * address);
    4949void reset_count_dev_mail(void);
    50 int sh_mail_setaddress_int (const char * address);
     50int sh_mail_setaddress_int (char * address);
    5151
    5252/* call if not urgent
     
    6060/* set sender of mail
    6161 */
    62 int sh_mail_set_sender (const char *str);
     62int sh_mail_set_sender (char *str);
    6363
    64 int sh_mail_add_or  (const char * str);
    65 int sh_mail_add_and (const char * str);
    66 int sh_mail_add_not (const char * str);
     64int sh_mail_add_or  (char * str);
     65int sh_mail_add_and (char * str);
     66int sh_mail_add_not (char * str);
    6767
    6868#endif
  • /trunk/include/sh_prelink.h

    r30 r20  
    1414/* configuration
    1515 */
    16 int sh_prelink_set_path (const char * str);
    17 int sh_prelink_set_hash (const char * str);
     16int sh_prelink_set_path (char * str);
     17int sh_prelink_set_hash (char * str);
    1818#endif
  • /trunk/include/sh_prelude.h

    r30 r20  
    66int  sh_prelude_init();
    77
    8 int sh_prelude_set_profile(const char *arg);
     8int sh_prelude_set_profile(char *arg);
    99
    1010int sh_prelude_alert (int priority, int class, char * message,
     
    1313/* map severity levels
    1414 */
    15 int sh_prelude_map_info (const char * str);
    16 int sh_prelude_map_low (const char * str);
    17 int sh_prelude_map_medium (const char * str);
    18 int sh_prelude_map_high (const char * str);
     15int sh_prelude_map_info (char * str);
     16int sh_prelude_map_low (char * str);
     17int sh_prelude_map_medium (char * str);
     18int sh_prelude_map_high (char * str);
    1919
    2020#endif
  • /trunk/include/sh_tiger.h

    r30 r20  
    2222/* NEW Thu Oct 18 19:59:08 CEST 2001
    2323 */
    24 int sh_tiger_hashtype (const char * c);
     24int sh_tiger_hashtype (char * c);
    2525char * sh_tiger_generic_hash (char * filename, TigerType what,
    2626                              UINT64 Length, int timeout);
  • /trunk/include/sh_tools.h

    r30 r20  
    5353
    5454
    55 #if defined (SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     55#if defined (SH_WITH_CLIENT)
    5656
    5757unsigned long write_port (int sockfd, char *buf, unsigned long nbytes,
     
    6565                 unsigned long * length, char * u);
    6666
    67 /*
    68   SL_TICKET open_tmp (void);
    69   int close_tmp (SL_TICKET fd);
    70   int rewind_tmp (SL_TICKET fd);
    71 */
     67
     68SL_TICKET open_tmp (void);
     69int close_tmp (SL_TICKET fd);
     70int rewind_tmp (SL_TICKET fd);
    7271
    7372void sh_tools_server_cmd(const char * srvcmd);
     
    7978#endif
    8079
    81 #if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER) || defined(SH_STEALTH) || defined(WITH_GPG) || defined(WITH_PGP)
    82 SL_TICKET open_tmp (void);
    83 int close_tmp (SL_TICKET fd);
    84 int rewind_tmp (SL_TICKET fd);
    85 #endif
    8680
    8781#endif
  • /trunk/include/sh_unix.h

    r30 r20  
    9999extern  unsigned long mask_USER0;
    100100extern  unsigned long mask_USER1;
    101 extern  unsigned long mask_USER2;
    102 extern  unsigned long mask_USER3;
    103 extern  unsigned long mask_USER4;
    104101/* like READONLY, but without MTM,CTM,SIZ,INO, abd with PREL)
    105102 */
     
    144141int sh_unix_munlock(void * addr, size_t len);
    145142int sh_unix_count_mlock();
    146 /* public for unit tests */
    147 int sh_unix_pagesize();
    148 unsigned long sh_unix_lookup_page(void * in_addr, size_t len, int * num_pages);
    149143
    150144/* chroot directory
     
    154148/* whether to use localtime for file timesatams in logs
    155149 */
    156 int sh_unix_uselocaltime (const char * c);
     150int sh_unix_uselocaltime (char * c);
    157151
    158152/* set I/O limit
    159153 */
    160 int  sh_unix_set_io_limit (const char * c);
     154int  sh_unix_set_io_limit (char * c);
    161155void sh_unix_io_pause ();
    162156
     
    205199/* checksum of own binary
    206200 */
    207 int sh_unix_self_hash (const char * c);
     201int sh_unix_self_hash (char * c);
    208202
    209203/* return BAD on failure
     
    213207/* add a trusted user to the list
    214208 */
    215 int tf_add_trusted_user(const char *);
     209int tf_add_trusted_user(char *);
    216210
    217211/* check a file
     
    230224/* set the timeserver address
    231225 */
    232 int sh_unix_settimeserver (const char * address);
     226int sh_unix_settimeserver (char * address);
    233227void reset_count_dev_time(void);
    234228
  • /trunk/include/sh_utils.h

    r30 r20  
    6565/* set signature type HASH-TIGER/HMAC-TIGER
    6666 */
    67 int sh_util_sigtype (const char * c);
     67int sh_util_sigtype (char * c);
    6868
    6969/* compute a signature
     
    8383/* don't log output files
    8484 */
    85 int sh_util_hidesetup(const char * c);
     85int sh_util_hidesetup(char * c);
    8686
    8787/* exceptions to obscure name check
    8888 */
    89 int sh_util_obscure_ok (const char * str);
     89int sh_util_obscure_ok (char * str);
    9090
    9191/* read a hexchar
  • /trunk/man/samhain.8

    r30 r20  
    4848.SS "MISCELLANEOUS"
    4949.PP
    50 
    51 .B samhain
    52 .RI \-\-server\-port= portnumber
    5350
    5451.B samhain
     
    303300.SS "MISCELLANEOUS OPTIONS"
    304301.PP
    305 
    306 .B samhain
    307 .RI \-\-server\-port= portnumber
    308 
    309 Choose the port on the server host to which the client will connect.
    310302
    311303.B samhain
  • /trunk/man/samhainrc.5

    r30 r20  
    9696.TP
    9797.I "[User1]"
    98 .TP
    99 .I "[User2]"
    100 .TP
    101 .I "[User3]"
    102 .TP
    103 .I "[User4]"
    10498These are reserved for user-defined policies.
    10599.TP
     
    178172.br
    179173.BI  SeverityUser0= val,
    180 .br
    181 .BI  SeverityUser1= val,
    182 .br
    183 .BI  SeverityUser2= val,
    184 .br
    185 .BI  SeverityUser3= val,
    186174and
    187175.br
    188 .BI  SeverityUser4= val
     176.BI  SeverityUser1= val
    189177define the error levels for failures to verify the integrity of
    190178files/directories of the respective types. I.e. if such a file shows
     
    526514sets the hostname for the log server.
    527515.br
    528 .BI SetServerPort= portnumber
    529 sets the port on the server to connect to.
    530 .br
    531516.BI SetDatabasePath= AUTO|/path
    532517Path to database (AUTO to tack hostname on compiled-in path).
     
    562547.BI RedefUser1= +/-XXX,+/-YYY,...
    563548Add or subtract tests XXX from the User1 policy.
    564 .br
    565 .BI RedefUser2= +/-XXX,+/-YYY,...
    566 Add or subtract tests XXX from the User2 policy.
    567 .br
    568 .BI RedefUser3= +/-XXX,+/-YYY,...
    569 Add or subtract tests XXX from the User3 policy.
    570 .br
    571 .BI RedefUser4= +/-XXX,+/-YYY,...
    572 Add or subtract tests XXX from the User4 policy.
    573549.TP
    574550.B Server Only
  • /trunk/scripts/README

    r30 r20  
    4040   This script will do this automatically. Run 'samhainrc_update.sh -h'
    4141   for usage instructions. You may need to change the location of the
    42    samhainrc file by editing the line 'cfgfile="/etc/samhainrc"'
     42   samhainrc file by editing the line 'SAMHAIN_CFG="/etc/samhainrc"'
    4343   at the beginning of the script.
    4444 
  • /trunk/scripts/samhainadmin.pl.in

    r30 r20  
    2929use Fcntl qw(:DEFAULT :flock);
    3030
    31 # Do I/O to the data file in binary mode (so it
    32 # wouldn't complain about invalid UTF-8 characters).
    33 use bytes;
    34 
    3531File::Temp->safe_level( File::Temp::HIGH );
    3632
     
    519515    $action = 'f';
    520516}
    521 elsif (defined ($opts{'create-datafile'})) {
     517elsif (defined ($opts{'create-cfgfile'})) {
    522518    $action = 'D';
    523519}
    524 elsif (defined ($opts{'print-datafile'})) {
     520elsif (defined ($opts{'print-cfgfile'})) {
    525521    $action = 'd';
    526522}
  • /trunk/scripts/samhainrc_update.sh

    r30 r20  
    1 #! /bin/sh
    2 
    3 # -----------------------------------------------------------------------
    4 # The default configuration file
    5 # -----------------------------------------------------------------------
    6 
    7 cfgfile="/etc/samhainrc"
    8 
    9 # -----------------------------------------------------------------------
    10 # Be Bourne compatible
    11 # -----------------------------------------------------------------------
    12 
    13 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
    14   emulate sh
    15   NULLCMD=:
    16 elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
    17   set -o posix
     1#!/bin/bash
     2# -----------------------------------------------------------------------------
     3# @brief: update the kernel options in the samhain configuration
     4#         file, after a new kernel has been compiled
     5# @author: marc heisterkamp <marzheister@web.de>
     6# -----------------------------------------------------------------------------
     7
     8SAMHAIN_CFG="/etc/samhainrc"
     9
     10BLUE="[34;01m"
     11CYAN="[36;01m"
     12GREEN="[32;01m"
     13DARK_GREEN="[32m"
     14RED="[31;01m"
     15PURPLE="[35;01m"
     16WHITE="[37;01m"
     17DARK_GRAY="[30;01m"
     18LIGHT_GRAY="[37m"
     19YELLOW="[33;01m"
     20BROWN="[33m"
     21OFF="[0m"
     22
     23
     24SYSTEM_MAP=""
     25new_cfg=''
     26scriptname="$0"
     27
     28# global variables for system adresses (extracted from System.map)
     29SYS_CALL=''
     30SYS_CALL_TABLE=''
     31PROC_ROOT=''
     32PROC_ROOT_IOPS=''
     33PROC_ROOT_LOOKUP=''
     34
     35# Make sure the user has root permissions
     36if [ $UID -ne 0 ] ; then
     37  echo "You must be root to run this script. Exiting."
     38  exit 1
    1839fi
    1940
    20 programname="$0"
    21 sysmap=
    22 
    23 # -----------------------------------------------------------------------
    24 # Print help
    25 # -----------------------------------------------------------------------
    26 
    27 showhelp() {
    28     echo
    29     echo "$programname - update samhain config file after kernel update"
    30     echo
    31     echo "OPTIONS:"
    32     echo
    33     echo " -u|--update </path/to/System.map>"
    34     echo "         Update the configuration file with new"
    35     echo "         settings as taken from </path/to/System.map>"
    36     echo
    37     echo " -c|--config-file </path/to/config-file>"
    38     echo "         Specify the configuration file to update [${cfgfile}]"
    39     echo
    40     echo " -p|--print-only </path/to/System.map>"
    41     echo "         Print new settings, don't modify anything"
    42     echo
    43     echo " -h|--help"
    44     echo "         Print this help"
    45     echo
    46     echo " -n|--nocolor"
    47     echo "         (ignored, legacy support)"
    48     echo
    49 }
    50 
    51 
    52 # -----------------------------------------------------------------------
    53 # Death strikes
    54 # -----------------------------------------------------------------------
    55 
    56 die() {
    57     echo ${1+"$@"} >&2
    58     { (exit 1); exit 1; }
    59 }
    60 
    61 # -----------------------------------------------------------------------
    62 # Get new settings from </path/to/System.map>
    63 # -----------------------------------------------------------------------
    64 
    65 system_call=
    66 syscall_table=
    67 proc_root=
    68 proc_root_inode_operations=
    69 proc_root_lookup=
    70 
    71 get_new_settings() {
    72 
    73     if [ -z "$sysmap" ]; then
    74         die "No System.map specified"
    75     fi
    76     if [ -f "$sysmap" ]; then
    77         if [ -r "$sysmap" ]; then
    78             system_call=`egrep '[[:alnum:]]{8}[[:space:]]+[[:alpha:]]{1}[[:space:]]+system_call$' ${sysmap} | awk '{ print $1 }'`
    79             syscall_table=`egrep '[[:alnum:]]{8}[[:space:]]+[[:alpha:]]{1}[[:space:]]+sys_call_table$' ${sysmap} | awk '{ print $1 }'`
    80             proc_root=`egrep '[[:alnum:]]{8}[[:space:]]+[[:alpha:]]{1}[[:space:]]+proc_root$' ${sysmap} | awk '{ print $1 }'`
    81             proc_root_inode_operations=`egrep '[[:alnum:]]{8}[[:space:]]+[[:alpha:]]{1}[[:space:]]+proc_root_inode_operations$' ${sysmap} | awk '{ print $1 }'`
    82             proc_root_lookup=`egrep '[[:alnum:]]{8}[[:space:]]+[[:alpha:]]{1}[[:space:]]+proc_root_lookup$' ${sysmap} | awk '{ print $1 }'`
    83         else
    84             die "System.map ${sysmap} not readable"
    85         fi
    86     else
    87         die "System.map ${sysmap} not found"
    88     fi
    89     test -z "${system_call}" && die "system_call not found in ${cfgfile}"
    90     test -z "${syscall_table}" && die "sys_call_table not found in ${cfgfile}"
    91     test -z "${proc_root}" && die "proc_root not found in ${cfgfile}"
    92     test -z "${proc_root_inode_operations}" && die "proc_root_inode_operations not found in ${cfgfile}"
    93     test -z "${proc_root_lookup}" && die "proc_root_lookup not found in ${cfgfile}"
    94 
    95 }
    96 
    97 # -----------------------------------------------------------------------
    98 # Print new settings
    99 # -----------------------------------------------------------------------
    100 
    101 run_print() {
    102     get_new_settings
    103     echo
    104     echo "KernelSystemCall =     0x${system_call}"
    105     echo "KernelSyscallTable =   0x${syscall_table}"
    106     echo "KernelProcRoot =       0x${proc_root}"
    107     echo "KernelProcRootIops =   0x${proc_root_inode_operations}"
    108     echo "KernelProcRootLookup = 0x${proc_root_lookup}"
    109     echo
    110 }
    111 
    112 # -----------------------------------------------------------------------
    113 # Replace a setting
    114 # -----------------------------------------------------------------------
    115 
    116 # set ignorecase
    117 # search pattern
    118 # delete current line
    119 # insert
    120 # single dot == end of insert text
    121 # save and exit
    122 
    123 run_replace() {
    124     item="$1"
    125     address="$2"
    126     ex -s "$cfgfile" <<EOF
    127 :set ic
    128 :/^[[:blank:]]*$1[[:blank:]]*=
    129 :d
    130 :i
    131 $item = $address
    132 .
    133 :x
    134 EOF
    135 }
    136 
    137 # -----------------------------------------------------------------------
    138 # Add a setting
    139 # -----------------------------------------------------------------------
    140 
    141 # set ignorecase
    142 # search pattern ([Kernel] section)
    143 # append (next line)
    144 # single dot == end of insert text
    145 # save and exit
    146 
    147 run_add() {
    148     item="$1"
    149     address="$2"
    150     ex -s "$cfgfile" <<EOF
    151 :set ic
    152 :/^[[:space:]]*\[Kernel\]
    153 :a
    154 $item = $address
    155 .
    156 :x
    157 EOF
    158 }
    159 
    160 # -----------------------------------------------------------------------
    161 # Update with new settings
    162 # -----------------------------------------------------------------------
    163 
    164 run_update() {
    165 
    166     get_new_settings
    167 
    168     if [ -z "$cfgfile" ]; then
    169         die "No configuration file specified"
    170     fi
    171     if [ ! -w "$cfgfile" ]; then
    172         die "Configuration file ${cfgfile} not writeable"
    173     fi
    174     egrep '^[[:space:]]*\[Kernel\]' "$cfgfile" >/dev/null
    175     if [ $? -ne 0 ]; then
    176         die "No [Kernel] section in configuration file $cfgfile"
    177     fi
    178 
    179     cat "$cfgfile" | egrep -i 'KernelProcRootLookup' >/dev/null
    180     if [ $? -eq 0 ]; then
    181         run_replace 'KernelProcRootLookup' "0x${proc_root_lookup}"
    182     else
    183         run_add 'KernelProcRootLookup' "0x${proc_root_lookup}"
    184     fi
    185  
    186     cat "$cfgfile" | egrep -i 'KernelProcRootIops' >/dev/null
    187     if [ $? -eq 0 ]; then
    188         run_replace 'KernelProcRootIops' "0x${proc_root_inode_operations}"
    189     else
    190         run_add 'KernelProcRootIops' "0x${proc_root_inode_operations}"
    191     fi
    192 
    193     cat "$cfgfile" | egrep -i 'KernelProcRoot[[:space:]]*=' >/dev/null
    194     if [ $? -eq 0 ]; then
    195         run_replace 'KernelProcRoot' "0x${proc_root}"
    196     else
    197         run_add 'KernelProcRoot' "0x${proc_root}"
    198     fi
    199 
    200     cat "$cfgfile" | egrep -i 'KernelSyscallTable' >/dev/null
    201     if [ $? -eq 0 ]; then
    202         run_replace 'KernelSyscallTable' "0x${syscall_table}"
    203     else
    204         run_add 'KernelSyscallTable' "0x${syscall_table}"
    205     fi
    206 
    207     cat "$cfgfile" | egrep -i 'KernelSystemCall' >/dev/null
    208     if [ $? -eq 0 ]; then
    209         run_replace 'KernelSystemCall' "0x${system_call}"
    210     else
    211         run_add 'KernelSystemCall' "0x${system_call}"
    212     fi
    213 
    214 }
    215 
    216 # -----------------------------------------------------------------------
    217 # Parse command line
    218 # -----------------------------------------------------------------------
    219 
    220 sysmap=
    221 action=
    222 
    223 for option
    224 do
    225 
    226   # If the previous option needs an argument, assign it.
    227   #
    228   if test -n "$opt_prev"; then
    229     eval "$opt_prev=\$option"
    230     eval export "$opt_prev"
    231     opt_prev=
    232     continue
     41
     42#------------------------------------------------------------------------------
     43# usage
     44#------------------------------------------------------------------------------
     45function print_usage() {
     46
     47  cat >&2 <<EOHELP
     48
     49  update the samhainrc configuration file with new kernel system addresses
     50  (i.e: after kernel compilation) by extracting these from the new System.map
     51  file
     52
     53  SYNOPSIS
     54     $scriptname [ ${GREEN}--help${OFF} ]
     55                           [ ${GREEN}--nocolor${OFF} ]
     56                           [ ${GREEN}--print-only${OFF} ] <System.map>
     57                           [ ${GREEN}--update${OFF} ]     <System.map>
     58
     59  OPTIONS
     60     ${GREEN}-h${OFF} ${GREEN}--help${OFF}
     61        Show help.
     62
     63     ${GREEN}--nocolor${OFF}
     64        Disable color hilighting for non ANSI-compatible terms.
     65
     66     ${GREEN}-p${OFF} ${GREEN}--print-only${OFF} <System.map>
     67        Print the extracted system adresses and do not write them to the
     68        samhain configuration file.
     69
     70     ${GREEN}-u${OFF} ${GREEN}--update${OFF} <System.map>
     71        Update the samhainrc configuration file with new kernel system
     72        addresses from the given System.map file
     73
     74EOHELP
     75 exit 0
     76}
     77
     78
     79#------------------------------------------------------------------------------
     80# parses the command line options
     81# param in: all parameters given to the script
     82#------------------------------------------------------------------------------
     83function parse_cmd_line() {
     84
     85  # parse the command-line
     86  while [ -n "$1" ]; do
     87    case "$1" in
     88      --help|-h)
     89        print_usage
     90        ;;
     91      --nocolor|-n)
     92        unset DARK_GREEN GREEN RED BROWN LIGHT_GRAY WHITE OFF
     93        ;;
     94      --print-only|-p)
     95        shift
     96        SYSTEM_MAP="$1"
     97        get_system_addresses
     98        print_system_addresses
     99        break
     100        ;;
     101      --update|-u)
     102        shift
     103        SYSTEM_MAP="$1"
     104        get_system_addresses
     105        print_system_addresses
     106        replace_system_addresses
     107        ;;
     108      -*)
     109        echo "$scriptname: unknown option $1. Exiting" >&2
     110        exit 1
     111        ;;
     112    esac
     113    shift
     114  done
     115}
     116
     117
     118#------------------------------------------------------------------------------
     119# extract system adresses from given System.map file and save to global
     120# variables
     121#------------------------------------------------------------------------------
     122function get_system_addresses() {
     123
     124  if [ -z "$SYSTEM_MAP" ] ; then
     125    echo
     126    echo "No System.map specified. Exiting" >&2
     127    echo
     128    exit 1
    233129  fi
    234130
    235   case "$option" in
    236       -*=*)
    237           optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'`
    238           ;;
    239       *)
    240           optarg=
    241           ;;
    242   esac
    243 
    244   case "$option" in
    245 
    246       -h|--help)
    247           showhelp
    248           exit 0
    249           ;;
    250 
    251       -n|--nocolor)
    252           ;;
    253 
    254       -c|--config-file)
    255           opt_prev=cfgfile
    256           ;;
    257 
    258       -c=* | --config-file=*)
    259           cfgfile="$optarg"
    260           ;;
    261 
    262       -p|--print-only)
    263           opt_prev=sysmap
    264           action=p
    265           ;;
    266 
    267 
    268       -p=* | --print-only=*)
    269           sysmap="$optarg"
    270           action=p
    271           ;;
    272    
    273       -u|--update)
    274           opt_prev=sysmap
    275           action=u
    276           ;;
    277 
    278       -u=* | --update=*)
    279           sysmap="$optarg"
    280           action=u
    281           ;;
    282 
    283   esac
    284 
    285 done
    286 
    287 if [ x"$action" = xp ]; then
    288     run_print
    289     exit 0
     131  if [ ! -f "$SYSTEM_MAP" ] ; then
     132    echo
     133    echo "Could not find System.map: $SYSTEM_MAP. Exiting" >&2
     134    echo
     135    exit 1
     136  fi
     137
     138  # 1. this is the address of system_call (grep system_call System.map)
     139  #    KernelSystemCall = 0xc0106cf8
     140  SYS_CALL="0x`grep system_call $SYSTEM_MAP | cut -d' ' -f1`"
     141
     142  # 2. this is the address of sys_call_table (grep ' sys_call_table' System.map)
     143  #    KernelSyscallTable = 0xc01efb98
     144  SYS_CALL_TABLE="0x`grep sys_call_table $SYSTEM_MAP | cut -d' ' -f1`"
     145
     146  # 3. this is the address of proc_root (grep ' proc_root$' System.map)
     147  #    KernelProcRoot = 0xc01efb98
     148  PROC_ROOT="0x`grep ' proc_root$' $SYSTEM_MAP | cut -d' ' -f1`"
     149
     150  # 4. this is the address of proc_root_inode_operations
     151  #    (grep proc_root_inode_operations System.map)
     152  #    KernelProcRootIops = 0xc01efb98
     153  PROC_ROOT_IOPS="0x`grep proc_root_inode_operations $SYSTEM_MAP | cut -d' ' -f1`"
     154
     155  # 5. this is the address of proc_root_lookup
     156  #    (grep proc_root_lookup System.map)
     157  #    KernelProcRootLookup = 0xc01efb98
     158  PROC_ROOT_LOOKUP="0x`grep proc_root_lookup $SYSTEM_MAP | cut -d' ' -f1`"
     159}
     160
     161
     162#------------------------------------------------------------------------------
     163# extract system adresses from given System.map file and save to global
     164# variables
     165#------------------------------------------------------------------------------
     166function replace_system_addresses() {
     167
     168  if [ -z "$SAMHAIN_CFG" ] ; then
     169    echo "Could not find your samhainrc config file: $SAMHAIN_CFG. Exiting" >&2
     170    exit 1
     171  fi
     172
     173  echo
     174  echo "Replacing current kernel system addresses in: $SAMHAIN_CFG"
     175
     176  # 1. replace current 'KernelSystemCall' setting
     177  new_cfg=`sed -e "s/^\(KernelSystemCall[[:blank:]]*=\)[[:blank:]]*\(.*\)/\1 ${SYS_CALL}/" $SAMHAIN_CFG`
     178
     179  # 2. replace current 'KernelSyscallTable' setting
     180  new_cfg=`echo "$new_cfg" | sed -e "s/^\(KernelSyscallTable[[:blank:]]*=\)[[:blank:]]*\(.*\)/\1 ${SYS_CALL_TABLE}/"`
     181
     182  # 3. replace current 'KernelProcRoot' setting
     183  new_cfg=`echo "$new_cfg" | sed -e "s/^\(KernelProcRoot[[:blank:]]*=\)[[:blank:]]*\(.*\)/\1 ${PROC_ROOT}/"`
     184
     185  # 4. replace current 'KernelProcRootIops' setting
     186  new_cfg=`echo "$new_cfg" | sed -e "s/^\(KernelProcRootIops[[:blank:]]*=\)[[:blank:]]*\(.*\)/\1 ${PROC_ROOT_IOPS}/"`
     187
     188  # 5. replace current 'KernelSystemCall' setting
     189  new_cfg=`echo "$new_cfg" | sed -e "s/^\(KernelProcRootLookup[[:blank:]]*=\)[[:blank:]]*\(.*\)/\1 ${PROC_ROOT_LOOKUP}/"`
     190
     191  echo "Backup old samhainrc $SAMHAIN_CFG to $SAMHAIN_CFG.bak"
     192
     193  # backup old samhainrc config file
     194  mv "$SAMHAIN_CFG" "$SAMHAIN_CFG.bak"
     195
     196  # write new samhainrc config file
     197  echo "$new_cfg" > "$SAMHAIN_CFG"
     198
     199  echo "Successfully updated kernel system addresses."
     200  echo
     201}
     202
     203
     204#------------------------------------------------------------------------------
     205# print samhain required system adresses
     206#------------------------------------------------------------------------------
     207function print_system_addresses() {
     208
     209  echo
     210  echo "your kernel system addresses from: `basename $SYSTEM_MAP`"
     211  echo
     212  echo "  KernelSystemCall     = $SYS_CALL"
     213  echo "  KernelSyscallTable   = $SYS_CALL_TABLE"
     214  echo "  KernelProcRoot       = $PROC_ROOT"
     215  echo "  KernelProcRootIops   = $PROC_ROOT_IOPS"
     216  echo "  KernelProcRootLookup = $PROC_ROOT_LOOKUP"
     217  echo
     218
     219}
     220
     221if [ $# -eq 0 ] ; then
     222  print_usage
    290223fi
    291 if [ x"$action" = xu ]; then
    292     run_update
    293     exit 0
    294 fi
    295 
    296 showhelp
    297 exit 1
     224
     225parse_cmd_line $*
     226
     227exit 0
  • /trunk/src/make-tests.sh

    r30 r20  
    4949    CuSuiteDetails(suite, output);
    5050    if (suite->failCount > 0)
    51       fprintf(stderr, "%s%c", output->buffer, 0x0A);
     51      fprintf(stderr, "%s\n", output->buffer);
    5252    else
    53       fprintf(stdout, "%s%c", output->buffer, 0x0A);
     53      fprintf(stdout, "%s\n", output->buffer);
    5454    return suite->failCount;
    5555}
  • /trunk/src/samhain.c

    r30 r20  
    382382   */
    383383  (void) sl_strlcpy (sh.host.name,  _("localhost"),  SH_MINIBUF);
    384   sh.host.system[0]     = '\0'; /* flawfinder: ignore *//* ff bug */
     384  sh.host.system[0]     = '\0';
    385385  sh.host.release[0]    = '\0';
    386386  sh.host.machine[0]    = '\0';
     
    582582  skey->mailkey_old[0]  = '\0';
    583583  skey->mailkey_new[0]  = '\0';
    584   skey->crypt[0]        = '\0'; /* flawfinder: ignore *//* ff bug */
     584  skey->crypt[0]        = '\0';
    585585  skey->session[0]      = '\0';
    586586  skey->vernam[0]       = '\0';
     
    725725  char         exef[128];
    726726
    727   if (!pidlist)
    728     return NULL;
    729 
    730727  for (i = 0; i < 65535; ++i) pidlist[i] = 0;
    731728  i = 0;
    732729
    733730  if (0 != stat(SH_INSTALL_PATH, &buf))
    734     {
    735       free(pidlist);
    736       return NULL;
    737     }
     731    return NULL;
    738732
    739733  ino = (long) buf.st_ino;
    740734   
    741735  if (NULL == (dp = opendir("/proc")))
    742     {
    743       free(pidlist);
    744       return NULL;
    745     }
     736    return NULL;
    746737  while (NULL != (d = readdir(dp)) && i < 65535)
    747738    {
     
    869860
    870861
    871   fullpath = strdup (SH_INSTALL_PATH);
     862  fullpath = malloc(strlen(SH_INSTALL_PATH)+1);
    872863  if (fullpath == NULL)
    873     { perror(_("strdup")); exit (1); }
    874 
    875   argp[0]  = strdup (SH_INSTALL_PATH);
     864    { perror(_("malloc")); exit (1); }
     865  else
     866    strcpy(fullpath, SH_INSTALL_PATH);                 /* known to fit  */
     867
     868  argp[0] = malloc(strlen(SH_INSTALL_PATH)+1);
    876869  if (argp[0] == NULL)
    877     { perror(_("strdup")); exit (1); }
     870    { perror(_("malloc")); exit (1); }
     871  else
     872    strcpy(argp[0], SH_INSTALL_PATH);                  /* known to fit  */
     873
    878874
    879875  for (times = 1; times < 32; ++times)  argp[times] = NULL;
     
    883879  for (times = 2; times < res; ++times) 
    884880    {
    885       argp[times-1] = strdup (argv[times]);
     881      argp[times-1] = malloc(strlen(argv[times])+1);
    886882      if (argp[times-1] == NULL)
    887         { perror(_("strdup")); exit (1); }
     883        { perror(_("malloc")); exit (1); }
     884      else
     885        strcpy(argp[times-1], argv[times]);              /* known to fit  */
    888886    }
    889887
     
    905903            _exit(4);
    906904          }
    907         (void) execv(fullpath, argp); /* flawfinder: ignore *//* wtf? */
     905        (void) execv(fullpath, argp);
    908906        if (errno == EPERM)
    909907          _exit(4);
     
    943941      pidlist = procdirSamhain ();
    944942      if (pid == 0 && NULL == pidlist) /* pid file not found */
    945         {
    946           free(fullpath);
    947           return (0);
    948         }
     943        return (0);
    949944         
    950945      status = 0;
     
    961956            }
    962957        }
    963       free(fullpath);
    964958      if (status == 7)
    965959        return 0;
     
    998992        }
    999993    }
    1000   free(fullpath); /* silence smatch false positive */
     994
    1001995  exit (1); /* no exit handler installed yet */
    1002996  /*@notreached@*/
     
    10281022/* Add a new schedule to the linked list of schedules
    10291023 */
    1030 static sh_schedule_t * sh_set_schedule_int (const char * str,
     1024static sh_schedule_t * sh_set_schedule_int (char * str,
    10311025                                            sh_schedule_t * FileSchedIn,
    10321026                                            /*@out@*/ int * status)
     
    10581052/* Add a new schedule to the linked list FileSchedOne
    10591053 */
    1060 int sh_set_schedule_one (const char * str)
     1054int sh_set_schedule_one (char * str)
    10611055{
    10621056  int status;
     
    10671061/* Add a new schedule to the linked list FileSchedTwo
    10681062 */
    1069 int sh_set_schedule_two (const char * str)
     1063int sh_set_schedule_two (char * str)
    10701064{
    10711065  int status;
     
    12201214  /* Save the timezone.
    12211215   */
    1222   if (NULL != (tzptr = getenv("TZ"))) /* flawfinder: ignore */
     1216  if ((tzptr = getenv("TZ")) != NULL)
    12231217    {
    12241218      tzlen       = strlen(tzptr);
    1225       if (tzlen < 1024)
    1226         {
    1227           sh.timezone = malloc (tzlen + 1);
    1228           if (sh.timezone != NULL)
    1229             (void) sl_strlcpy (sh.timezone, tzptr, tzlen + 1);
    1230         }
    1231       else
    1232         sh.timezone = NULL;
     1219       sh.timezone = malloc (tzlen + 1);
     1220      if (sh.timezone != NULL)
     1221         (void) sl_strlcpy (sh.timezone, tzptr, tzlen + 1);
    12331222    }
    12341223  else
     
    17951784      /* see whether its time to check files
    17961785       */
    1797       if      (sh.flag.checkSum == SH_CHECK_INIT ||
    1798                (sh.flag.checkSum == SH_CHECK_CHECK &&
    1799                 (sh.flag.isdaemon == S_FALSE && sh.flag.loop == S_FALSE)))
     1786      if      (sh.flag.checkSum == SH_CHECK_INIT)
    18001787        {
    18011788          flag_check_1 = 1;
  • /trunk/src/samhain_setpwd.c

    r30 r20  
    11#include "config_xor.h"
     2
     3#ifdef HAVE_BROKEN_INCLUDES
     4#define _ANSI_C_SOURCE
     5#define _POSIX_SOURCE
     6#endif
    27
    38#include <stdio.h>
     
    813#include <unistd.h>
    914#include <sys/types.h>
    10 #include <sys/wait.h>
    1115#include <sys/stat.h>
    1216#include <fcntl.h>
    13 #include <errno.h>
    14 #include <sys/time.h>
    1517#include <time.h>
    1618
    17 #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_YIELD)
    18 #include <sched.h>
    19 #endif
    20 
    21 #if defined(HAVE_INT_32)
    22 typedef unsigned int UINT32;
    23 #elif defined(HAVE_LONG_32)
    24 typedef unsigned long UINT32;
    25 #elif defined(HAVE_SHORT_32)
    26 typedef unsigned short UINT32;
    27 #endif
    28 
    29 #define TAUS_MAX 4294967295UL
    30 
    31 static UINT32 taus_state[3];
    32 
    33 static UINT32 taus_get ()
    34 {
    35 
    36 #define TAUSWORTHE(s,a,b,c,d) ((s &c) <<d) ^ (((s <<a) ^s) >>b)
    37   taus_state[0] = TAUSWORTHE (taus_state[0], 13, 19, 4294967294UL, 12);
    38   taus_state[1] = TAUSWORTHE (taus_state[1],  2, 25, 4294967288UL,  4);
    39   taus_state[2] = TAUSWORTHE (taus_state[2],  3, 11, 4294967280UL, 17);
    40   return (taus_state[0] ^ taus_state[1] ^ taus_state[2]);
    41 }
    42 
    43 static void taus_seed ()
    44 {
    45   unsigned char buf[12];
    46   unsigned char buf2[12];
    47   unsigned char buf3[12];
    48   ssize_t count;
    49   size_t nbytes = sizeof(buf);
    50   size_t where  = 0;
    51 
    52   struct timeval t1, t2;
    53   UINT32 delta, k[3];
    54   int i, j;
    55 
    56   int fd = open ("/dev/urandom", O_RDONLY);
    57 
    58   if (fd == -1)
    59     {
    60       gettimeofday(&t1, NULL);
    61       delta = t1.tv_usec;
    62       memcpy(&buf[0], &delta, 4);
    63       gettimeofday(&t1, NULL);
    64       delta = t1.tv_usec;
    65       memcpy(&buf[4], &delta, 4);
    66       gettimeofday(&t1, NULL);
    67       delta = t1.tv_usec;
    68       memcpy(&buf[8], &delta, 4);
    69       goto second;
    70     }
    71 
    72   while (nbytes) {
    73     count = read(fd, &buf[where], nbytes);
    74     if (count == -1 && errno == EINTR)
    75       continue;
    76     where  += count;
    77     nbytes -= count;
    78   } while (count == -1 && errno == EINTR);
    79 
    80   close(fd);
    81 
    82  second:
    83   for (i = 0; i < 12; ++i)
    84     {
    85       gettimeofday(&t1, NULL);
    86       if (0 == fork())
    87         _exit(EXIT_SUCCESS);
    88       wait(NULL);
    89       gettimeofday(&t2, NULL);
    90       delta = t2.tv_usec - t1.tv_usec;
    91       buf2[i] = (unsigned char) delta;
    92     }
    93 
    94   for (i = 0; i < 12; ++i)
    95     {
    96       gettimeofday(&t1, NULL);
    97       for (j = 0; j < 32768; ++j)
    98         {
    99           if (0 == kill (j,0))
    100             k[i % 3] ^= j;
    101         }
    102       gettimeofday(&t2, NULL);
    103       delta = t2.tv_usec - t1.tv_usec;
    104       buf3[i] ^= (unsigned char) delta;
    105     }
    106 
    107   memcpy(&taus_state[0], &buf3[0], 4);
    108   memcpy(&taus_state[1], &buf3[4], 4);
    109   memcpy(&taus_state[2], &buf3[8], 4);
    110 
    111   taus_state[0] ^= k[0];
    112   taus_state[1] ^= k[1];
    113   taus_state[2] ^= k[2];
    114  
    115   memcpy(&k[0], &buf2[0], 4);
    116   memcpy(&k[1], &buf2[4], 4);
    117   memcpy(&k[2], &buf2[8], 4);
    118 
    119   taus_state[0] ^= k[0];
    120   taus_state[1] ^= k[1];
    121   taus_state[2] ^= k[2];
    122  
    123   memcpy(&k[0], &buf[0], 4);
    124   memcpy(&k[1], &buf[4], 4);
    125   memcpy(&k[2], &buf[8], 4);
    126 
    127   taus_state[0] ^= k[0];
    128   taus_state[1] ^= k[1];
    129   taus_state[2] ^= k[2];
    130 
    131   taus_state[0] |= (UINT32) 0x03;
    132   taus_state[1] |= (UINT32) 0x09;
    133   taus_state[2] |= (UINT32) 0x17;
    134 }
    13519
    13620#ifdef SH_STEALTH
     
    228112
    229113  char * newn;
    230   size_t nlen;
    231114  int    oldf;
    232115  int    newf;
     
    313196  (void) umask (0);
    314197
    315   taus_seed();
     198  srand(time(NULL) ^ getpid());
    316199
    317200  bytecount = 0;
     
    323206  oldf = open(argv[1], O_RDONLY);
    324207
    325   nlen = strlen(argv[1])+strlen(argv[2])+2;
    326   newn = (char *) malloc (nlen);
    327   strncpy(newn, argv[1], nlen); newn[nlen-1] = '\0';
    328   strncat(newn, ".", nlen);     newn[nlen-1] = '\0';
    329   strncat(newn, argv[2], nlen); newn[nlen-1] = '\0';
     208  newn = (char *) malloc (strlen(argv[1])+strlen(argv[2])+2);
     209  strcpy(newn, argv[1]);
     210  strcat(newn, ".");
     211  strcat(newn, argv[2]);
    330212  newf = open(newn, O_WRONLY|O_CREAT|O_TRUNC, S_IRWXU);
    331213
     
    383265                      (unsigned char) *found_it);
    384266
    385               ccd = (unsigned char) (256.0 * (taus_get()/(TAUS_MAX+1.0)));
     267              ccd = (unsigned char) (256.0 * rand()/(RAND_MAX+1.0));
    386268              sprintf(&newpwd[i*2], _("%02x"),
    387269                      (unsigned char) ccd);
     
    458340                      (unsigned char) *found_it);
    459341
    460               ccd = (unsigned char) (256.0 * taus_get()/(TAUS_MAX+1.0));
     342              ccd = (unsigned char) (256.0 * rand()/(RAND_MAX+1.0));
    461343              sprintf(&newpwd[i*2], _("%02x"),
    462344                      (unsigned char) ccd);
  • /trunk/src/sh_calls.c

    r30 r20  
    8282/* Set aud functions
    8383 */
    84 int sh_aud_set_functions(const char * str_s)
     84int sh_aud_set_functions(char * str_s)
    8585{
    8686  int i = 0;
  • /trunk/src/sh_database.c

    r30 r20  
    4040#include "sh_error.h"
    4141#include "sh_utils.h"
     42
     43extern int safe_logger (int signal, int method, pid_t thepid);
    4244
    4345#undef  FIL__
     
    225227typedef unsigned char uint8;
    226228
    227 typedef struct md5_ctx
    228 {
    229   uint32 A;
    230   uint32 B;
    231   uint32 C;
    232   uint32 D;
    233 
    234   uint32 total[2];
    235   uint32 buflen;
    236   char buffer[128];
     229typedef struct
     230{
     231        uint32 h[4];
     232        uint32 data[16];
     233        uint8  offset;
     234        uint32  nblocks;
     235        int  count;
    237236} md5Param;
     237
    238238
    239239
     
    253253static int  sh_persistent_dbconn = S_TRUE;
    254254
    255 int sh_database_use_persistent (const char * str)
     255int sh_database_use_persistent (char * str)
    256256{
    257257  return sh_util_flagval (str, &sh_persistent_dbconn);
    258258}
    259259
    260 static int insert_value (char * ptr, const char * str)
     260static int insert_value (char * ptr, char * str)
    261261{
    262262  if (!ptr || !str)
     
    276276 
    277277
    278 int sh_database_set_database (const char * str)
     278int sh_database_set_database (char * str)
    279279{
    280280  return insert_value (db_name, str);
    281281}
    282 int sh_database_set_table (const char * str)
     282int sh_database_set_table (char * str)
    283283{
    284284  return insert_value (db_table, str);
    285285}
    286 int sh_database_set_host (const char * str)
     286int sh_database_set_host (char * str)
    287287{
    288288  return insert_value (db_host, str);
    289289}
    290 int sh_database_set_user (const char * str)
     290int sh_database_set_user (char * str)
    291291{
    292292  return insert_value (db_user, str);
    293293}
    294 int sh_database_set_password (const char * str)
     294int sh_database_set_password (char * str)
    295295{
    296296  return insert_value (db_password, str);
     
    568568 oracle_doconnect:
    569569
    570   if (!getenv("ORACLE_HOME")) /* flawfinder: ignore */
     570  if (!getenv("ORACLE_HOME"))
    571571    {
    572572      sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
     
    11941194        }
    11951195    }
    1196 
     1196#if 0
     1197  /* apparently slower, see gyule.7 */
     1198  len = (long) strlen(val);
     1199
     1200  if ((val[0] != '\0') && (*size > 2))
     1201    {
     1202      if (flag == 1)
     1203        {
     1204          *end = ',';  ++end;
     1205          *end = '\''; ++end; (*size) -= 2;
     1206          *end = '\0';
     1207       
     1208          if ((long) *size > (len+2))
     1209            {
     1210              (void) sl_strlcat(end, val, (size_t) *size);
     1211              end   += len; (*size) -= len;
     1212              *end = '\''; ++end;  (*size) -= 1;
     1213            }
     1214          *end = '\0';
     1215        }
     1216      else
     1217        {
     1218          *end = ',';  ++end; (*size) -= 1;
     1219          *end = '\0';
     1220       
     1221          if ((long) *size > (len+1))
     1222            {
     1223              (void) sl_strlcat(end, val, (size_t) *size);
     1224              end   += len; (*size) -= len;
     1225            }
     1226          *end = '\0';
     1227        }
     1228    }
     1229#endif
    11971230  return end;
    11981231}
     
    14491482}
    14501483
    1451 int sh_database_add_to_hash  (const char * str)
     1484int sh_database_add_to_hash  (char * str)
    14521485{
    14531486  int i;
     
    16591692static int enter_wrapper = 1;
    16601693
    1661 int set_enter_wrapper (const char * str)
     1694int set_enter_wrapper (char * str)
    16621695{
    16631696  return sh_util_flagval(str, &enter_wrapper);
    16641697}
    16651698
    1666 /* recursively enter linked list of messages into database, last first
    1667  */
    1668 int sh_database_insert_rec (dbins * curr, unsigned int depth)
    1669 {
     1699int sh_database_insert (char * message)
     1700{
     1701  dbins * db_entry;
     1702  dbins * prev;
     1703  dbins * curr;
    16701704  long    id = 0;
    1671   dbins * prev;
    1672 
    1673   SL_ENTER(_("sh_database_insert_rec"));
    1674 
    1675   if (curr->next)
    1676     {
    1677       prev = curr->next;
    1678       sl_strlcpy(prev->host, curr->host, 64);
    1679       id = sh_database_insert_rec (curr->next, (depth + 1));
    1680     }
    1681 
    1682   if (id != 0)                       /* this is a server wrapper          */
    1683     {
    1684       if (enter_wrapper != 0)
    1685         {
    1686           id = sh_database_entry (curr, id);
    1687         }
    1688     }
    1689   else
    1690     {
    1691       /*
    1692        * id = -1 is the client message; log_ref will be NULL
    1693        */
    1694       if (depth > 0)                  /* this is a client message         */
    1695         id = sh_database_entry (curr, -1);
    1696       else                            /* this is a generic server message */
    1697         id = sh_database_entry (curr, 0);
    1698     }
    1699 
    1700   SH_FREE(curr);
    1701 
    1702   SL_RETURN(id, _("sh_database_insert"));
    1703 }
    1704 
    1705 int sh_database_insert (char * message)
    1706 {
    1707   dbins * db_entry;
     1705#ifdef HOST_SWITCH
     1706  char  * temp[64];
     1707#endif
    17081708
    17091709  SL_ENTER(_("sh_database_insert"));
     
    17161716  (void) sh_database_parse (message, db_entry);
    17171717
    1718   /* recursively enter the linked list into the database
    1719    */
    1720   (void) sh_database_insert_rec (db_entry, 0);
     1718  /* Enter the list into the database. Actually, the list can only have
     1719   * two entries at most.
     1720   */
     1721  curr = db_entry;
     1722  if (curr->next)
     1723    {
     1724      prev = curr->next;
     1725#ifdef HOST_SWITCH
     1726      strncpy(temp, prev->host,       64);
     1727#endif
     1728      strncpy(prev->host, curr->host, 64);
     1729#ifdef HOST_SWITCH
     1730      strncpy(curr->host, temp,       64);
     1731#endif
     1732      id = sh_database_entry (prev, -1);
     1733      SH_FREE(prev);
     1734    }
     1735
     1736  if (id != 0)                       /* this is a server wrapper          */
     1737    {
     1738      if (enter_wrapper != 0)
     1739        (void) sh_database_entry (curr, id);
     1740    }
     1741  else                                /* this is a generic server message */
     1742    {
     1743      (void) sh_database_entry (curr, 0);
     1744    }
     1745  SH_FREE(curr);
    17211746
    17221747  SL_RETURN(0, _("sh_database_insert"));
  • /trunk/src/sh_entropy.c

    r30 r20  
    170170        memset( &addr, 0, sizeof(addr) );
    171171        addr.sun_family = AF_UNIX;
    172         sl_strlcpy( addr.sun_path, name, sizeof(addr.sun_path) );
     172        strcpy( addr.sun_path, name );              /* known to fit  */
    173173        addr_len = offsetof( struct sockaddr_un, sun_path )
    174174                   + strlen( addr.sun_path );
     
    478478static
    479479char   * com_path[] = {
    480   N_("/usr/bin/xpg4/"),
    481480  N_("/usr/ucb/"),
    482481  N_("/bin/"),
     
    571570  char * arg[4];
    572571  char * envp[2];
    573   size_t len;
    574572
    575573  SL_ENTER(_("sh_popen"));
     
    582580  if (sh.timezone != NULL)
    583581    {
    584       len = sl_strlen(sh.timezone) + 4;
    585       envp[0] = malloc (len);     /* free() ok     */
     582      envp[0] = malloc (sl_strlen(sh.timezone) + 4);     /* free() ok     */
    586583      if (envp[0] != NULL)
    587         sl_snprintf (envp[0], len, "TZ=%s", sh.timezone);
     584        sprintf (envp[0], "TZ=%s", sh.timezone);         /* known to fit  */
    588585      else
    589586        envp[0] = NULL;
     
    781778        sl_strlcat(combuf, _(source[i].command), 80);
    782779
    783         /* flawfinder: ignore */
    784780        if ( access (combuf, X_OK) == 0)
    785781          {
  • /trunk/src/sh_err_console.c

    r30 r20  
    112112/* Enable the message queue
    113113 */
    114 int enable_msgq(const char * foo)
     114int enable_msgq(char * foo)
    115115{
    116116  int i;
     
    234234/* ---- Set the console device. ----
    235235 */
    236 int sh_log_set_console (const char * address)
     236int sh_log_set_console (char * address)
    237237{
    238238  SL_ENTER(_("sh_log_set_console"));
  • /trunk/src/sh_err_log.c

    r30 r20  
    604604  char            sigkey_old[KEY_LEN+1];
    605605  char            sigkey_new[KEY_LEN+1];
    606   char            crypto[KEY_LEN+1];
     606  char            crypt[KEY_LEN+1];
    607607  struct  lfstc * next;
    608608} open_logfile;
     
    613613
    614614#ifdef SH_WITH_SERVER
    615 int set_flag_sep_log (const char * str)
     615int set_flag_sep_log (char * str)
    616616{
    617617  return sh_util_flagval(str, &flag_sep_log);
     
    642642  char               * sigkey_new;
    643643  char               * sigkey_old;
    644   char               * crypto;
     644  char               * crypt;
    645645
    646646  SL_ENTER(_("sh_log_file"));
     
    734734      memset(current->sigkey_old, (int)'\0', KEY_LEN+1);
    735735      memset(current->sigkey_new, (int)'\0', KEY_LEN+1);
    736       memset(current->crypto,     (int)'\0', KEY_LEN+1);
     736      memset(current->crypt,      (int)'\0', KEY_LEN+1);
    737737      current->next            = logfile_list;
    738738      logfile_list             = current;
     
    841841      sigkey_old = current->sigkey_old;
    842842      sigkey_new = current->sigkey_new;
    843       crypto     = current->crypto;
     843      crypt      = current->crypt;
    844844    }
    845845  else
     
    847847      sigkey_old = skey->sigkey_old;
    848848      sigkey_new = skey->sigkey_new;
    849       crypto     = skey->crypt;      /* flawfinder: ignore */
     849      crypt      = skey->crypt;
    850850    }
    851851
     
    869869      /* Copy it to 'crypt' for encryption.
    870870       */
    871       (void) sl_strlcpy(crypto, sigkey_new, KEY_LEN+1);
     871      (void) sl_strlcpy(crypt, sigkey_new, KEY_LEN+1);
    872872
    873873      /* Use message and compiled-in key to encrypt.
    874874       */
    875875      BREAKEXIT(sh_util_encode);
    876       sh_util_encode(crypto, log_msg.msg, 0, 'B');
     876      sh_util_encode(crypt, log_msg.msg, 0, 'B');
    877877
    878878      /* Send out the key.
     
    900900
    901901      sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_START_KEY_MAIL,
    902                        sh.prg_name, crypto,
    903                        crypto, log_msg.timestamp);
     902                       sh.prg_name, crypt,
     903                       crypt, log_msg.timestamp);
    904904
    905905      /* send to other allowed channels
     
    913913
    914914      sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_START_KEY,
    915                        sh.prg_name, crypto);
     915                       sh.prg_name, crypt);
    916916
    917917      /* Cleanup.
     
    926926
    927927
    928       memset (crypto, (int) '\0', KEY_LEN);
     928      memset (crypt, (int) '\0', KEY_LEN);
    929929      sh.flag.log_start    = S_FALSE; 
    930930      current->log_start   = S_FALSE;
     
    949949  (void) sl_strlcpy (sigkey_old, sigkey_new, KEY_LEN+1);
    950950
    951   /*@-usedef@*/
     951  /*@-bufferoverflowhigh -usedef@*/
    952952#ifdef SH_USE_XML
    953953  if (log_msg.timestamp[0] != '\0')
    954     sl_snprintf(log_msg.sig, sizeof(log_msg.sig),
     954    sprintf(log_msg.sig,                            /* known to fit  */
    955955#ifdef FIX_XML
    956                 _("\n<sig>%s%s</sig></log>\n"),          /* <sig> FIX XML */
    957 #else
    958                 _("\nsig>%s%s</sig></log>\n"),          /* <sig> FIX XML */
    959 #endif
    960                 log_msg.signature, log_msg.timestamp);
     956            _("\n<sig>%s%s</sig></log>\n"),          /* <sig> FIX XML */
     957#else
     958            _("\nsig>%s%s</sig></log>\n"),          /* <sig> FIX XML */
     959#endif
     960            log_msg.signature, log_msg.timestamp);
    961961  else
    962     sl_snprintf(log_msg.sig, sizeof(log_msg.sig),
     962    sprintf(log_msg.sig,                            /* known to fit  */
    963963#ifdef FIX_XML
    964                 _("\n<sig>%s</sig></log>\n"),            /* <sig> FIX XML */
    965 #else
    966                 _("\nsig>%s</sig></log>\n"),            /* <sig> FIX XML */
    967 #endif
    968                 log_msg.signature);
    969   /*@+usedef@*/
     964            _("\n<sig>%s</sig></log>\n"),            /* <sig> FIX XML */
     965#else
     966            _("\nsig>%s</sig></log>\n"),            /* <sig> FIX XML */
     967#endif
     968            log_msg.signature);
     969  /*@+bufferoverflowhigh +usedef@*/
    970970
    971971#ifdef SH_STEALTH
  • /trunk/src/sh_err_syslog.c

    r30 r20  
    110110/* set syslog facility
    111111 */
    112 int  sh_log_set_facility (const char * c)
     112int  sh_log_set_facility (char * c)
    113113{
    114114  int loop = 0;
  • /trunk/src/sh_error.c

    r30 r20  
    102102/* convert a string to a numeric priority
    103103 */
    104 int sh_error_convert_level (const char * str_s);
     104int sh_error_convert_level (char * str_s);
    105105
    106106static int  IsInitialized = BAD;
     
    219219}
    220220
    221 static int sh_error_set_classmask (const char * str, int * facility_mask)
     221static int sh_error_set_classmask (/*@notnull@*/char * c, int * facility_mask)
    222222{
    223223  char * p;
     
    225225  unsigned int    i;
    226226  size_t len;
    227   char * c;
    228227
    229228  SL_ENTER(_("sh_error_set_classmask"));
    230229 
    231   if (str == NULL)
     230  if (c == NULL)
    232231    SL_RETURN( -1, _("sh_error_set_classmask"));
    233232
     
    235234    (void) sh_error_init();
    236235
    237   if (str[0] == (char) 34)
    238     ++str;
    239   len = strlen(str);
    240 
    241   c = SH_ALLOC(len+1);
    242   sl_strlcpy(c, str, len+1);
    243 
     236  if (c[0] == (char) 34)
     237    ++c;
     238  len = strlen(c);
    244239  if (c[len-1] == (char) 34)
    245240    c[len-1] = '\0';
     
    278273  } while (p);
    279274
    280   SH_FREE(c);
    281275  SL_RETURN( 0, _("sh_error_set_classmask"));
    282276}
    283277
    284 int sh_error_log_mask (const char * c)
     278int sh_error_log_mask (char * c)
    285279{
    286280  return (sh_error_set_classmask(c, &(errFlags.log_class)));
    287281}
    288 int sh_error_mail_mask (const char * c)
     282int sh_error_mail_mask (char * c)
    289283{
    290284  return (sh_error_set_classmask(c, &(errFlags.mail_class)));
    291285}
    292 int sh_error_print_mask (const char * c)
     286int sh_error_print_mask (char * c)
    293287{
    294288  return (sh_error_set_classmask(c, &(errFlags.print_class)));
    295289}
    296 int sh_error_export_mask (const char * c)
     290int sh_error_export_mask (char * c)
    297291{
    298292  return (sh_error_set_classmask(c, &(errFlags.export_class)));
    299293}
    300 int sh_error_syslog_mask (const char * c)
     294int sh_error_syslog_mask (char * c)
    301295{
    302296  return (sh_error_set_classmask(c, &(errFlags.syslog_class)));
    303297}
    304 int sh_error_external_mask (const char * c)
     298int sh_error_external_mask (char * c)
    305299{
    306300  return (sh_error_set_classmask(c, &(errFlags.external_class)));
    307301}
    308 int sh_error_database_mask (const char * c)
     302int sh_error_database_mask (char * c)
    309303{
    310304  return (sh_error_set_classmask(c, &(errFlags.database_class)));
    311305}
    312 int sh_error_prelude_mask (const char * c)
     306int sh_error_prelude_mask (char * c)
    313307{
    314308  return (sh_error_set_classmask(c, &(errFlags.prelude_class)));
     
    452446};
    453447
    454 int sh_error_convert_level (const char * str_s)
     448int sh_error_convert_level (char * str_s)
    455449{
    456450  int i;
     
    478472/* --- Set severity levels. ---
    479473 */
    480 int sh_error_set_iv (int iv, const char *  str_s)
     474int sh_error_set_iv (int iv, char *  str_s)
    481475{
    482476  int level = (-1);
     
    639633}
    640634
    641 #if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     635#ifdef SH_WITH_CLIENT
    642636/* set severity for TCP export
    643637 */
     
    843837#endif
    844838
    845 #if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     839#ifdef SH_WITH_CLIENT
    846840  char   * ex_msg;
    847841#endif
     
    862856  static int syslog_block = 0;
    863857  static int log_block    = 0;
    864 #if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     858#if defined(SH_WITH_CLIENT)
    865859  static int export_block = 0;
    866860#endif
     
    926920    severity = sev;
    927921
    928   /* these are messages from remote sources
    929    */
    930922  if ((severity  & SH_ERR_INET) != 0)
    931923    {
     
    941933       ( (errFlags.sysloglevel  & severity    ) == 0 ||
    942934         (errFlags.syslog_class & (1 << class)) == 0 )     &&
    943 #if defined(SH_WITH_CLIENT) || defined(SH_WITH_CLIENT)
     935#ifdef SH_WITH_CLIENT
    944936       ( (errFlags.exportlevel  & severity    ) == 0 ||
    945937         (errFlags.export_class & (1 << class)) == 0 )     &&
     
    960952         (errFlags.mail_class    & (1 << class)) == 0 )
    961953#ifdef SH_WITH_SERVER
    962        && (flag_inet == S_FALSE) /* still log messages from remote sources */
     954      && (flag_inet == S_FALSE)
    963955#endif
    964956       )
     
    11211113       * to log server
    11221114       ****************************************************/
    1123 #if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     1115#ifdef SH_WITH_CLIENT
    11241116      /* Export by TCP.
    11251117       */
    1126 
    1127       if ( ((errFlags.exportlevel  & severity  )   != 0 &&
    1128             (errFlags.export_class & (1 << class)) != 0 &&
    1129             (errFlags.exportlevel  & SH_ERR_NOT)   == 0 &&
    1130             class != AUD                               )
    1131 #ifdef SH_WITH_SERVER
    1132            || (flag_inet == S_TRUE) /* always log inet to export */
    1133 #endif
    1134           /* sh.flag.isserver != GOOD                    && */
    1135           /* (flag_inet == S_FALSE) */ /* don't log inet to export */
    1136            )
     1118      if ((errFlags.exportlevel  & severity  )   != 0 &&
     1119          (errFlags.export_class & (1 << class)) != 0 &&
     1120          (errFlags.exportlevel  & SH_ERR_NOT)   == 0 &&
     1121          class != AUD                                &&
     1122          sh.flag.isserver != GOOD                    &&
     1123          (flag_inet == S_FALSE) ) /* don't log inet to export */
    11371124        {
    11381125          if (export_block == 0)
    11391126            {
    11401127              int retval;
    1141               size_t ex_len;
    11421128
    11431129              /* will truncate to 65280 bytes
    11441130               */
    11451131              export_block = 1;
    1146               ex_len = 64 + sl_strlen(lmsg->msg) + 1;
    1147               ex_msg = SH_ALLOC (ex_len);
    1148 
    1149               sl_snprintf(ex_msg, ex_len, _("%d?%u?%s"),
    1150                       severity, class, lmsg->msg);
     1132              ex_msg = SH_ALLOC (64 + sl_strlen(lmsg->msg) + 1);
     1133              /*@-bufferoverflowhigh@*/
     1134              sprintf(ex_msg, _("%d?%u?%s"),             /* known to fit  */
     1135                           severity, class, lmsg->msg);
     1136              /*@-bufferoverflowhigh@*/
    11511137              retval = sh_forward (ex_msg);
    11521138              SH_FREE(ex_msg);
     
    13201306/* allocate space for user-defined message header
    13211307 */
    1322 int sh_error_ehead (/*@null@*/const char * str_s)
     1308int sh_error_ehead (/*@null@*/char * str_s)
    13231309{
    13241310  size_t size;
    1325   const char * s;
     1311  char * s;
    13261312
    13271313  SL_ENTER(_("sh_error_ehead"));
     
    13381324 
    13391325  size = /*@i@*/strlen(s);
    1340   if (/*@i@*/s[size-1] == (char) 34) --size; /* truncate */
     1326  if (/*@i@*/s[size-1] == (char) 34) --size;
    13411327
    13421328  if (ehead_format != NULL)
     
    14961482      len      = sl_strlen(lmsg->msg);
    14971483      /*@i@*/required = sl_vsnprintf(&(lmsg->msg[len]),
    1498                                      (lmsg->msg_len - len), lmsg->format, vl);
     1484                              (lmsg->msg_len - len), lmsg->format, vl);
    14991485      if ( (required + len) > (lmsg->msg_len - 4) )
    15001486        {
  • /trunk/src/sh_extern.c

    r30 r20  
    115115  FILE * outf = NULL;
    116116  char * envp[1];
    117   char * argp[2];
     117  char * argp[1];
    118118
    119119  char * errfile;
     
    133133   *         needs a valid *envp[] with envp[0] = NULL;
    134134   *         and similarly for argp
    135    * OpenBSD finally needs non-null argp[0] ...
    136135   */
    137   argp[0] = task->command;
    138   argp[1] = NULL;
    139136  envp[0] = NULL;
     137  argp[0] = NULL;
    140138
    141139  /*
     
    366364             
    367365              PDBGC(5);
    368               sl_snprintf(pname, sizeof(pname), _("/proc/self/fd/%d"), pfd);
    369               if (access(pname, R_OK|X_OK) == 0) /* flawfinder: ignore */
     366              sprintf(pname, _("/proc/self/fd/%d"),      /* known to fit  */
     367                           pfd);
     368              if (access(pname, R_OK|X_OK) == 0)
    370369                {
    371370                  PDBGC(6);
     
    403402           * --  execute path if executable
    404403           */
    405           if (0 == access(task->command, R_OK|X_OK)) /* flawfinder: ignore */
     404          if (0 == access(task->command, R_OK|X_OK))
    406405            {
    407406              PDBGC(5);
     
    545544              task->exit_status = WEXITSTATUS(task->exit_status);
    546545              if ((flag_err_debug == SL_TRUE) || (task->exit_status != 0))
    547                 sl_snprintf(infomsg, sizeof(infomsg),
    548                             _("Subprocess exited normally with status %d"),
    549                             task->exit_status);
     546                sprintf(infomsg,                         /* known to fit  */
     547                        _("Subprocess exited normally with status %d"),
     548                        task->exit_status);
    550549            }
    551550          else if (WIFSIGNALED(task->exit_status) != 0)
    552551            {
    553               sl_snprintf(infomsg, sizeof(infomsg),
    554                           _("Subprocess terminated by signal %d"),
    555                           WTERMSIG(task->exit_status));
     552              sprintf(infomsg,                           /* known to fit  */
     553                      _("Subprocess terminated by signal %d"),
     554                      WTERMSIG(task->exit_status));
    556555              task->exit_status = EXIT_FAILURE;
    557556            }
    558557          else if (WIFSTOPPED(task->exit_status) != 0)
    559558            {
    560               sl_snprintf(infomsg, sizeof(infomsg),
    561                           _("Subprocess stopped by signal %d, killing"),
    562                           WSTOPSIG(task->exit_status));
     559              sprintf(infomsg,                           /* known to fit  */
     560                      _("Subprocess stopped by signal %d, killing"),
     561                      WSTOPSIG(task->exit_status));
    563562              task->exit_status = EXIT_FAILURE;
    564563              (void) aud_kill (FIL__, __LINE__, task->pid, 9);
     
    568567          else
    569568            {
    570               sl_snprintf(infomsg, sizeof(infomsg),
    571                           _("Subprocess exit status unknown"));
     569              sprintf(infomsg,                           /* known to fit  */
     570                      _("Subprocess exit status unknown"));
    572571              task->exit_status = EXIT_FAILURE;
    573572            }
     
    582581            }
    583582          (void) aud_kill (FIL__, __LINE__, task->pid, 9);
    584           sl_snprintf(infomsg, sizeof(infomsg),
    585                       _("Subprocess not yet exited, killing"));
     583          sprintf(infomsg,                               /* known to fit  */
     584                  _("Subprocess not yet exited, killing"));
    586585          task->exit_status = EXIT_FAILURE;
    587586          (void) waitpid (task->pid, NULL, 0);
     
    589588      else
    590589        {
    591           sl_snprintf(infomsg, sizeof(infomsg),
    592                       _("Waitpid returned error %d\n"), errno);
     590          sprintf(infomsg,                               /* known to fit  */
     591                  _("Waitpid returned error %d\n"), errno);
    593592          task->exit_status = EXIT_FAILURE;
    594593        }
     
    647646
    648647
    649 int sh_ext_tas_add_envv(sh_tas_t * tas, const char * key, const char * val)
     648int sh_ext_tas_add_envv(sh_tas_t * tas, char * key, char * val)
    650649{
    651650  size_t sk = 0, sv = 0;
     
    698697}
    699698
    700 int sh_ext_tas_add_argv(sh_tas_t * tas, const char * val)
     699int sh_ext_tas_add_argv(sh_tas_t * tas, char * val)
    701700{
    702701  size_t sv = 0;
     
    723722}
    724723
    725 void sh_ext_tas_command(sh_tas_t * tas, const char * command)
     724void sh_ext_tas_command(sh_tas_t * tas, char * command)
    726725{
    727726  size_t len = sl_strlen(command);
     
    843842
    844843static
    845 int sh_ext_add_envv(const char * key, const char * val)
     844int sh_ext_add_envv(char * key, char * val)
    846845{
    847846  SL_ENTER(_("sh_ext_add_envv"));
     
    862861
    863862static
    864 int sh_ext_init(const char * command)
     863int sh_ext_init(char * command)
    865864{
    866865  sh_com_t * retval;
     
    897896
    898897static
    899 int sh_ext_uid (const char * user, /*@out@*/uid_t * uid, /*@out@*/gid_t * gid)
     898int sh_ext_uid (char * user, /*@out@*/uid_t * uid, /*@out@*/gid_t * gid)
    900899{
    901900  struct passwd * tempres;
     
    923922
    924923static
    925 int sh_ext_add (const char * argstring, int * ntok, char * stok[])
     924int sh_ext_add (char * argstring, int * ntok, char * stok[])
    926925{
    927926  int    i = 0;
    928927  size_t s;
    929928  char * p;
    930   char * new;
    931   size_t len;
    932929
    933930  SL_ENTER(_("sh_ext_add"));
     
    938935    }
    939936
    940   len = strlen(argstring) + 1;
    941   new = SH_ALLOC(len);
    942   sl_strlcpy(new, argstring, len);
    943 
    944937  do
    945938    {
    946939      if (i == 0)
    947         p = strtok (new, ", \t");
     940        p = strtok (argstring, ", \t");
    948941      else
    949942        p = strtok (NULL, ", \t");
     
    964957
    965958  *ntok = i;
    966   SH_FREE(new);
    967959
    968960  SL_RETURN (0, _("sh_ext_add"));
     
    979971 * -- start a new external command, and add it to the list
    980972 */
    981 int sh_ext_setcommand(const char * cmd)
     973int sh_ext_setcommand(char * cmd)
    982974{
    983975  int i;
     
    10261018 * -- add keywords to the OR filter
    10271019 */
    1028 int sh_ext_add_or (const char * str)
     1020int sh_ext_add_or (char * str)
    10291021{
    10301022  if (ext_coms == NULL || ext_failed == (-1))
     
    10361028 * -- add keywords to the AND filter
    10371029 */
    1038 int sh_ext_add_and (const char * str)
     1030int sh_ext_add_and (char * str)
    10391031{
    10401032  if (ext_coms == NULL || ext_failed == (-1))
     
    10461038 * -- add keywords to the NOT filter
    10471039 */
    1048 int sh_ext_add_not (const char * str)
     1040int sh_ext_add_not (char * str)
    10491041{
    10501042  if (ext_coms == NULL || ext_failed == (-1))
     
    10561048 * -- add keywords to the CL argument list
    10571049 */
    1058 int sh_ext_add_argv (const char * str)
     1050int sh_ext_add_argv (char * str)
    10591051{
    10601052  if (ext_coms == NULL || ext_failed == (-1))
     
    10661058 * -- add a path to the environment
    10671059 */
    1068 int sh_ext_add_default (const char * dummy)
    1069 {
    1070   (void) dummy;
    1071   char * p = NULL;
     1060int sh_ext_add_default (char * dummy)
     1061{
     1062  /* while this assignment looks ridiculous, it is here to avoid
     1063   * an 'unused parameter' warning
     1064   */
     1065  char * p = (dummy == NULL ? dummy : NULL);
    10721066  int    i;
    10731067
     
    10901084 * -- add an environment variable
    10911085 */
    1092 int sh_ext_add_environ (const char * str)
     1086int sh_ext_add_environ (char * str)
    10931087{
    10941088  int i;
     
    11011095 * -- set deadtime
    11021096 */
    1103 int sh_ext_deadtime (const char * str)
     1097int sh_ext_deadtime (char * str)
    11041098{
    11051099  long    deadtime = 0;
     
    11251119 * -- define type
    11261120 */
    1127 int sh_ext_type (const char * str)
     1121int sh_ext_type (char * str)
    11281122{
    11291123  SL_ENTER(_("sh_ext_type"));
     
    11601154 * -- define checksum
    11611155 */
    1162 int sh_ext_checksum (const char * str)
     1156int sh_ext_checksum (char * str)
    11631157{
    11641158  SL_ENTER(_("sh_ext_checksum"));
     
    11811175 * -- choose privileges
    11821176 */
    1183 int sh_ext_priv (const char * c)
     1177int sh_ext_priv (char * c)
    11841178{
    11851179
  • /trunk/src/sh_fifo.c

    r30 r20  
    8787    }
    8888
    89   sl_strlcpy (item->data, indat, len+1);
     89  strcpy (item->data, indat);                   /* known to fit  */
    9090  item->data[len] = '\0';
    9191
     
    143143    }
    144144
    145   sl_strlcpy (item->data, indat, len+1);
     145  strcpy (item->data, indat);                          /* known to fit  */
    146146  item->data[len] = '\0';
    147147
     
    195195  len         = sl_strlen(getit->data);
    196196  retval      = SH_ALLOC(len+1);
    197   sl_strlcpy (retval, getit->data, len+1);
     197  strcpy (retval, getit->data);                        /* known to fit  */
     198  retval[len] = '\0';
    198199 
    199200  memset(getit->data, 0, len);
  • /trunk/src/sh_files.c

    r30 r20  
    7272#define FIL__  _("sh_files.c")
    7373
     74extern int safe_logger (int signal, int method, pid_t thepid);
     75
    7476extern int flag_err_debug;
    7577extern int flag_err_info;
    7678
    77 int sh_files_reportonce(const char * c)
     79int sh_files_reportonce(char * c)
    7880{
    7981  int i;
     
    8486}
    8587   
    86 int sh_files_fulldetail(const char * c)
     88int sh_files_fulldetail(char * c)
    8789{
    8890  int i;
     
    154156static int        sh_files_fullpath  (char * testdir, char * d_name,
    155157                                      char * statpath);
    156 static int        sh_files_pushdir   (int class, const char * str_s);
    157 static int        sh_files_pushfile  (int class, const char * str_s);
     158static int        sh_files_pushdir   (int class, char * str_s);
     159static int        sh_files_pushfile  (int class, char * str_s);
    158160static int        sh_files_checkdir  (int class, int rdepth, char * dirName,
    159161                                      char * relativeName);
     
    444446
    445447
    446 int sh_files_pushfile_prelink (const char * str_s)
     448int sh_files_pushfile_prelink (char * str_s)
    447449{
    448450  return (sh_files_pushfile (SH_LEVEL_PRELINK, str_s));
    449451}
    450452
    451 int sh_files_pushfile_user0 (const char * str_s)
     453int sh_files_pushfile_user0 (char * str_s)
    452454{
    453455  return (sh_files_pushfile (SH_LEVEL_USER0, str_s));
    454456}
    455457
    456 int sh_files_pushfile_user1 (const char * str_s)
     458
     459int sh_files_pushfile_user1 (char * str_s)
    457460{
    458461  return (sh_files_pushfile (SH_LEVEL_USER1, str_s));
    459462}
    460463
    461 int sh_files_pushfile_user2 (const char * str_s)
    462 {
    463   return (sh_files_pushfile (SH_LEVEL_USER2, str_s));
    464 }
    465 
    466 int sh_files_pushfile_user3 (const char * str_s)
    467 {
    468   return (sh_files_pushfile (SH_LEVEL_USER3, str_s));
    469 }
    470 
    471 int sh_files_pushfile_user4 (const char * str_s)
    472 {
    473   return (sh_files_pushfile (SH_LEVEL_USER4, str_s));
    474 }
    475 
    476 
    477 int sh_files_pushfile_ro (const char * str_s)
     464
     465int sh_files_pushfile_ro (char * str_s)
    478466{
    479467  return (sh_files_pushfile (SH_LEVEL_READONLY, str_s));
    480468}
    481469
    482 int sh_files_pushfile_attr (const char * str_s)
     470int sh_files_pushfile_attr (char * str_s)
    483471{
    484472  return (sh_files_pushfile (SH_LEVEL_ATTRIBUTES, str_s));
    485473}
    486474
    487 int sh_files_pushfile_log (const char * str_s)
     475int sh_files_pushfile_log (char * str_s)
    488476{
    489477  return (sh_files_pushfile (SH_LEVEL_LOGFILES, str_s));
    490478}
    491479
    492 int sh_files_pushfile_glog (const char * str_s)
     480int sh_files_pushfile_glog (char * str_s)
    493481{
    494482  return (sh_files_pushfile (SH_LEVEL_LOGGROW, str_s));
    495483}
    496484
    497 int sh_files_pushfile_noig (const char * str_s)
     485int sh_files_pushfile_noig (char * str_s)
    498486{
    499487  return (sh_files_pushfile (SH_LEVEL_NOIGNORE, str_s));
    500488}
    501489
    502 int sh_files_pushfile_allig (const char * str_s)
     490int sh_files_pushfile_allig (char * str_s)
    503491{
    504492  return (sh_files_pushfile (SH_LEVEL_ALLIGNORE, str_s));
     
    523511/* set mask(class)
    524512 */
    525 static int sh_files_parse_mask (unsigned long * mask, const char * str)
     513static int sh_files_parse_mask (unsigned long * mask, char * str)
    526514{
    527515  int l, i = 0, act = 0, k = 0;
     
    614602}
    615603
    616 int sh_files_redef_prelink(const char * str)
     604int sh_files_redef_prelink(char * str)
    617605{
    618606  return (sh_files_parse_mask(&mask_PRELINK, str));
    619607}
    620 int sh_files_redef_user0(const char * str)
     608int sh_files_redef_user0(char * str)
    621609{
    622610  return (sh_files_parse_mask(&mask_USER0, str));
    623611}
    624 int sh_files_redef_user1(const char * str)
     612int sh_files_redef_user1(char * str)
    625613{
    626614  return (sh_files_parse_mask(&mask_USER1, str));
    627615}
    628 int sh_files_redef_user2(const char * str)
    629 {
    630   return (sh_files_parse_mask(&mask_USER2, str));
    631 }
    632 int sh_files_redef_user3(const char * str)
    633 {
    634   return (sh_files_parse_mask(&mask_USER3, str));
    635 }
    636 int sh_files_redef_user4(const char * str)
    637 {
    638   return (sh_files_parse_mask(&mask_USER4, str));
    639 }
    640 int sh_files_redef_readonly(const char * str)
     616int sh_files_redef_readonly(char * str)
    641617{
    642618  return (sh_files_parse_mask(&mask_READONLY, str));
    643619}
    644 int sh_files_redef_loggrow(const char * str)
     620int sh_files_redef_loggrow(char * str)
    645621{
    646622  return (sh_files_parse_mask(&mask_LOGGROW, str));
    647623}
    648 int sh_files_redef_logfiles(const char * str)
     624int sh_files_redef_logfiles(char * str)
    649625{
    650626  return (sh_files_parse_mask(&mask_LOGFILES, str));
    651627}
    652 int sh_files_redef_attributes(const char * str)
     628int sh_files_redef_attributes(char * str)
    653629{
    654630  return (sh_files_parse_mask(&mask_ATTRIBUTES, str));
    655631}
    656 int sh_files_redef_noignore(const char * str)
     632int sh_files_redef_noignore(char * str)
    657633{
    658634  return (sh_files_parse_mask(&mask_NOIGNORE, str));
    659635}
    660 int sh_files_redef_allignore(const char * str)
     636int sh_files_redef_allignore(char * str)
    661637{
    662638  return (sh_files_parse_mask(&mask_ALLIGNORE, str));
     
    683659    case SH_LEVEL_USER1:
    684660      return (unsigned long) mask_USER1;
    685     case SH_LEVEL_USER2:
    686       return (unsigned long) mask_USER2;
    687     case SH_LEVEL_USER3:
    688       return (unsigned long) mask_USER3;
    689     case SH_LEVEL_USER4:
    690       return (unsigned long) mask_USER4;
    691661    case SH_LEVEL_PRELINK:
    692662      return (unsigned long) mask_PRELINK;
     
    755725      if (zfileList == NULL)
    756726        {
    757           (void) safe_logger (0, 0, NULL);
     727          (void) safe_logger (0, 0, getpid());
    758728          aud__exit(FIL__, __LINE__, EXIT_FAILURE);
    759729        }
     
    764734  if (-1 == ret)
    765735    {
    766       (void) safe_logger (0, 0, NULL);
     736      (void) safe_logger (0, 0, getpid());
    767737      aud__exit(FIL__, __LINE__, EXIT_FAILURE);
    768738    }
     
    775745
    776746
    777 static int sh_files_pushfile (int class, const char * str_s)
    778 {
     747static int sh_files_pushfile (int class, char * str_s)
     748{
     749  char  * tmp;
    779750  int     len;
    780   char  * tmp;
    781   char  * p;
    782751#ifdef HAVE_GLOB_H
     752  glob_t  pglob;
    783753  int     globstatus = -1;
    784754  unsigned int     gloop;
    785   glob_t  pglob;
    786755#endif
    787756
     
    839808       * special case of the root directory.
    840809       */
    841       p = sh_util_strdup (str_s);
    842       if (p[len-1] == '/' && len > 1)
     810      if (str_s[len-1] == '/' && len > 1)
    843811        {
    844           p[len-1] = '\0';
     812          str_s[len-1] = '\0';
    845813          --len;
    846814        }
     
    849817
    850818#ifdef HAVE_GLOB_H
    851   if (0 == sh_files_has_metachar(p))
    852     {
    853       sh_files_push_file_int (class, p, len);
     819  if (0 == sh_files_has_metachar(str_s))
     820    {
     821      sh_files_push_file_int (class, str_s, len);
    854822    }
    855823  else
    856824    {
    857825      pglob.gl_offs = 0;
    858       globstatus    = glob (p, 0, sh_files_globerr, &pglob);
     826      globstatus    = glob (str_s, 0, sh_files_globerr, &pglob);
    859827
    860828      if (globstatus == 0 && pglob.gl_pathc > 0)
     
    866834      else
    867835        {
    868           tmp = sh_util_safe_name (p);
     836          tmp = sh_util_safe_name (str_s);
    869837
    870838          if (pglob.gl_pathc == 0
     
    901869
    902870#else
    903   sh_files_push_file_int (class, p, len);
    904 #endif
    905 
    906   SH_FREE(p);
     871  sh_files_push_file_int (class, str_s, len);
     872#endif
     873
    907874  SL_RETURN((0),_("sh_files_pushfile"));
    908875}
     
    10611028}
    10621029
    1063 int sh_files_pushdir_prelink (const char * str_s)
     1030int sh_files_pushdir_prelink (char * str_s)
    10641031{
    10651032  return (sh_files_pushdir (SH_LEVEL_PRELINK, str_s));
    10661033}
    10671034
    1068 int sh_files_pushdir_user0 (const char * str_s)
     1035int sh_files_pushdir_user0 (char * str_s)
    10691036{
    10701037  return (sh_files_pushdir (SH_LEVEL_USER0, str_s));
    10711038}
    10721039
    1073 int sh_files_pushdir_user1 (const char * str_s)
     1040int sh_files_pushdir_user1 (char * str_s)
    10741041{
    10751042  return (sh_files_pushdir (SH_LEVEL_USER1, str_s));
    10761043}
    10771044
    1078 int sh_files_pushdir_user2 (const char * str_s)
    1079 {
    1080   return (sh_files_pushdir (SH_LEVEL_USER2, str_s));
    1081 }
    1082 
    1083 int sh_files_pushdir_user3 (const char * str_s)
    1084 {
    1085   return (sh_files_pushdir (SH_LEVEL_USER3, str_s));
    1086 }
    1087 
    1088 int sh_files_pushdir_user4 (const char * str_s)
    1089 {
    1090   return (sh_files_pushdir (SH_LEVEL_USER4, str_s));
    1091 }
    1092 
    1093 int sh_files_pushdir_attr (const char * str_s)
     1045int sh_files_pushdir_attr (char * str_s)
    10941046{
    10951047  return (sh_files_pushdir (SH_LEVEL_ATTRIBUTES, str_s));
    10961048}
    10971049
    1098 int sh_files_pushdir_ro (const char * str_s)
     1050int sh_files_pushdir_ro (char * str_s)
    10991051{
    11001052  return (sh_files_pushdir (SH_LEVEL_READONLY, str_s));
    11011053}
    11021054
    1103 int sh_files_pushdir_log (const char * str_s)
     1055int sh_files_pushdir_log (char * str_s)
    11041056{
    11051057  return (sh_files_pushdir (SH_LEVEL_LOGFILES, str_s));
    11061058}
    11071059
    1108 int sh_files_pushdir_glog (const char * str_s)
     1060int sh_files_pushdir_glog (char * str_s)
    11091061{
    11101062  return (sh_files_pushdir (SH_LEVEL_LOGGROW, str_s));
    11111063}
    11121064
    1113 int sh_files_pushdir_noig (const char * str_s)
     1065int sh_files_pushdir_noig (char * str_s)
    11141066{
    11151067  return (sh_files_pushdir (SH_LEVEL_NOIGNORE, str_s));
    11161068}
    11171069
    1118 int sh_files_pushdir_allig (const char * str_s)
     1070int sh_files_pushdir_allig (char * str_s)
    11191071{
    11201072  return (sh_files_pushdir (SH_LEVEL_ALLIGNORE, str_s));
     
    11681120      if (tree == NULL)
    11691121        {
    1170           (void) safe_logger (0, 0, NULL);
     1122          (void) safe_logger (0, 0, getpid());
    11711123          aud__exit(FIL__, __LINE__, EXIT_FAILURE);
    11721124        }
     
    11811133  if (-1 == ret)
    11821134    {
    1183       (void) safe_logger (0, 0, NULL);
     1135      (void) safe_logger (0, 0, getpid());
    11841136      aud__exit(FIL__, __LINE__, EXIT_FAILURE);
    11851137    }
     
    11911143}
    11921144
    1193 static int sh_files_pushdir (int class, const char * str_s)
     1145static int sh_files_pushdir (int class, char * str_s)
    11941146{
    11951147  char  * tmp;
     
    11971149  int     rdepth = 0;
    11981150  char  * tail = NULL;
    1199   char  * p;
    12001151
    12011152#ifdef HAVE_GLOB_H
     
    12151166    SL_RETURN((-1), _("sh_files_pushdir"));
    12161167 
    1217   p = sh_util_strdup (str_s);
    1218 
    1219   if (p[0] != '/')
    1220     {
    1221       rdepth = strtol(p, &tail, 10);
    1222       if (tail == p)
    1223         {
    1224           SH_FREE(p);
    1225           SL_RETURN((-1), _("sh_files_pushdir"));
    1226         }
     1168
     1169  if (str_s[0] != '/')
     1170    {
     1171      rdepth = strtol(str_s, &tail, 10);
     1172      if (tail == str_s)
     1173        SL_RETURN((-1), _("sh_files_pushdir"));
    12271174    }
    12281175  else
    1229     tail   = p;
     1176    tail   = str_s;
    12301177 
    12311178
    1232   if (rdepth < (-1) || tail == p || rdepth > 99)
     1179  if (rdepth < (-1) || tail == str_s || rdepth > 99)
    12331180    rdepth = (-2);
    12341181
     
    12411188                       tmp);
    12421189      SH_FREE(tmp);
    1243       SH_FREE(p);
    12441190      SL_RETURN((-1), _("sh_files_pushdir"));
    12451191    }
    12461192  else if (len < 1)
    12471193    {
    1248       SH_FREE(p);
    12491194      SL_RETURN((-1), _("sh_files_pushdir"));
    12501195    }
     
    12551200                       tmp);
    12561201      SH_FREE(tmp);
    1257       SH_FREE(p);
    12581202      SL_RETURN((-1), _("sh_files_pushdir"));
    12591203    }
     
    13241268#endif
    13251269
    1326   SH_FREE(p);
    13271270  SL_RETURN((0), _("sh_files_pushdir"));
    13281271
     
    13791322/* Simply sets our boolean as to whether this check is active
    13801323 */
    1381 int sh_files_check_hardlinks (const char * opt)
     1324int sh_files_check_hardlinks (char * opt)
    13821325{
    13831326  int i;
     
    13951338static struct sh_hle_struct * sh_hl_exc = NULL;
    13961339
    1397 int sh_files_hle_reg (const char * str)
     1340int sh_files_hle_reg (char * str)
    13981341{
    13991342  long   offset;
  • /trunk/src/sh_forward.c

    r30 r20  
    335335#endif
    336336
    337 #if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     337#ifdef SH_WITH_CLIENT
    338338
    339339static int count_dev_server = 0;
     
    345345}
    346346
    347 int sh_forward_setlogserver (const char * address)
     347int sh_forward_setlogserver (char * address)
    348348{
    349349  SL_ENTER(_("sh_forward_setlogserver"));
     
    708708static long sh_forward_try (char * errmsg);
    709709
    710 static unsigned int ServerPort = SH_DEFAULT_PORT;
    711 
    712 int sh_forward_server_port (const char * str)
    713 {
    714   unsigned long l;
    715   char * endptr;
    716 
    717   SL_ENTER(_("sh_forward_server_port"));
    718 
    719   l = strtoul (str, &endptr, 0);
    720   if (l > 65535 || endptr == str)
    721     {
    722       SL_RETURN (-1, _("sh_forward_server_port"));
    723     }
    724   ServerPort = (unsigned int) l;
    725   SL_RETURN (0, _("sh_forward_server_port"));
    726 }
    727710
    728711long sh_forward (char * errmsg)
     
    897880
    898881  sockfd = connect_port_2 (sh.srvexport.name, sh.srvexport.alt,
    899                            ServerPort,
     882                           SH_DEFAULT_PORT,
    900883                           error_call, &error_num, error_msg, 256);
    901884
     
    14581441                                                flag_err,
    14591442                                                MSG_TCP_NOCONF);
    1460                               }
    1461 #ifdef SH_WITH_CLIENT
    1462                               else {
     1443                              } else {
    14631444                                sh_socket_server_cmd(buffer);
    14641445                              }
    1465 #endif
    14661446                              flag_err = 0;
    14671447
     
    19311911
    19321912
    1933 int sh_forward_use_clt_class (const char * c)
     1913int sh_forward_use_clt_class (char * c)
    19341914{
    19351915  int i;
     
    19391919}
    19401920
    1941 int sh_forward_use_clt_sev (const char * c)
     1921int sh_forward_use_clt_sev (char * c)
    19421922{
    19431923  int i;
     
    19701950}
    19711951
    1972 
    1973 int sh_forward_register_client (const char * str)
     1952extern int safe_logger (int signal, int method, pid_t thepid);
     1953
     1954int sh_forward_register_client (char * str)
    19741955{
    19751956  client_t   * newclt;
    19761957  client_t   * testclt;
    19771958
    1978   const char * ptr;
     1959  char      * ptr;
    19791960  int          sepnum = 0;
    19801961  int          sep[2];
     
    19991980      if (all_clients == NULL)
    20001981        {
    2001           (void) safe_logger (0, 0, NULL);
     1982          (void) safe_logger (0, 0, getpid());
    20021983          aud__exit(FIL__, __LINE__, EXIT_FAILURE);
    20031984        }
     
    20312012        newclt->status_arr[i] = CLT_INACTIVE;
    20322013      sl_strlcpy(newclt->timestamp[CLT_INACTIVE],   sh_unix_time(0), TIM_MAX);
    2033       /* truncate */
    20342014      sl_strlcpy(newclt->hostname,  &str[0],        sep[0]+1);
    2035       /* truncate */
    20362015      sl_strlcpy(newclt->salt,      &str[sep[0]+1], sep[1]-sep[0]);
    20372016      sl_strlcpy(newclt->verifier,  &str[sep[1]+1], sl_strlen(str)-sep[1]+1);
     
    24072386
    24082387#if defined(WITH_EXTERNAL)
    2409   sl_snprintf(msg, sizeof(msg), _("%s %s %s"),
    2410               conn->hostname, conn->timestamp[status], _(clt_stat[status]));
     2388  sprintf(msg, _("%s %s %s"),                       /* known to fit  */
     2389          conn->hostname,
     2390          conn->timestamp[status],
     2391          _(clt_stat[status]));
    24112392  sh_ext_execute('s', 'r', 'v', msg, 0);
    24122393#endif
     
    24172398static time_t time_client_limit = 86400;
    24182399
    2419 int sh_forward_set_time_limit (const char * c)
     2400int sh_forward_set_time_limit (char * c)
    24202401{
    24212402  long val;
     
    24672448static int lookup_err = SH_ERR_SEVERE;
    24682449
    2469 int sh_forward_lookup_level (const char * c)
     2450int sh_forward_lookup_level (char * c)
    24702451{
    24712452  int ci =  sh_error_convert_level (c);
     
    26222603static int UseSocketPeer = S_FALSE;
    26232604
    2624 int set_socket_peer (const char * c)
     2605int set_socket_peer (char * c)
    26252606{
    26262607  return sh_util_flagval(c, &UseSocketPeer);
     
    27502731  char       hash[SH_MAXMSGLEN + KEY_LEN + KEY_LEN + 1];
    27512732  char     * buffer;
     2733  long       len;
    27522734
    27532735  int        clt_sev;
     
    27552737
    27562738  UINT32     ticks;
    2757   size_t     len;
    27582739  int        i;
    27592740  char     * test;
     
    28402821                    sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FAUTH,
    28412822                                    &(conn->buf[KEY_LEN]));
    2842                   len = sl_strlen(&(conn->buf[KEY_LEN])) + 1;
    2843                   /* &(conn->buf[KEY_LEN]) is hostname         */
    2844                   /* may overlap, thus only memmove is correct */
    2845                   memmove(conn->buf, &(conn->buf[KEY_LEN]), len);
     2823                  strcpy(conn->buf,                      /* known to fit  */
     2824                         &(conn->buf[KEY_LEN]));
    28462825                  this_client->session_key[0]    = '\0';
    28472826                  this_client->session_key_timer = (time_t) 1;
     
    28562835                  conn->K = NULL;
    28572836                }
    2858               len = sl_strlen(&(conn->buf[KEY_LEN])) + KEY_LEN + 1;
    2859               conn->K = SH_ALLOC(len);
     2837              i = sl_strlen(&(conn->buf[KEY_LEN])) + KEY_LEN + 1;
     2838              conn->K = SH_ALLOC(i);
    28602839
    28612840              sl_strlcpy (conn->K,
     
    29352914              conn->A = SH_ALLOC(3*KEY_LEN+1);
    29362915              sl_strlcpy (conn->A, conn->K, KEY_LEN+1);
    2937               sl_strlcat(conn->A, conn->buf, /* truncate */
     2916              sl_strlcat(conn->A, conn->buf, /* ignore remainder */
    29382917                         2*KEY_LEN+1);
    29392918              sl_strlcat(conn->A, conn->client_entry->session_key,
     
    32993278                    sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FAUTH,
    33003279                                    &(conn->buf[KEY_LEN]));
    3301                   len = sl_strlen(&(conn->buf[KEY_LEN])) + 1;
    3302                   /* &(conn->buf[KEY_LEN]) is hostname         */
    3303                   /* may overlap, thus only memmove is correct */
    3304                   memmove(conn->buf, &(conn->buf[KEY_LEN]), len);
     3280                  strcpy(conn->buf,                      /* known to fit  */
     3281                         &(conn->buf[KEY_LEN]));
    33053282                  this_client->session_key[0]    = '\0';
    33063283                  this_client->session_key_timer = (time_t) 1;
     
    33163293                  conn->K = NULL;
    33173294                }
    3318               len = sl_strlen(&(conn->buf[KEY_LEN])) + KEY_LEN + 1;
    3319               conn->K = SH_ALLOC(len);
     3295              i = sl_strlen(&(conn->buf[KEY_LEN])) + KEY_LEN + 1;
     3296              conn->K = SH_ALLOC(i);
    33203297
    33213298              sl_strlcpy (conn->K,
     
    46234600static unsigned int server_port = SH_DEFAULT_PORT;
    46244601
    4625 int sh_forward_set_port (const char * str)
     4602int sh_forward_set_port (char * str)
    46264603{
    46274604  int retval = 0;
    46284605  unsigned long   i;
    4629   char * endptr;
     4606  char * endptr = str;
    46304607 
    46314608  SL_ENTER(_("sh_forward_set_port"));
     
    46444621static int            use_server_interface = 0;
    46454622
    4646 int sh_forward_set_interface (const char * str)
     4623int sh_forward_set_interface (char * str)
    46474624{
    46484625  if (0 == strcmp(str, _("INADDR_ANY")))
     
    48374814   */
    48384815  new_act.sa_handler = SIG_IGN;
    4839   sigemptyset( &new_act.sa_mask );         /* set an empty mask       */
    4840   new_act.sa_flags = 0;                    /* init sa_flags           */
    48414816  retry_sigaction (FIL__, __LINE__, SIGPIPE, &new_act, &old_act);
    48424817
     
    55965571}
    55975572
    5598 int set_syslog_active(const char * c)
     5573int set_syslog_active(char * c)
    55995574{
    56005575  return sh_util_flagval(c, &enable_syslog_socket);
  • /trunk/src/sh_getopt.c

    r30 r20  
    8080    sh_util_set_interactive },
    8181#endif
    82 #if defined(SH_WITH_SERVER) || defined(SH_WITH_CLIENT)
    83   { N_("server-port"), 
    84     '-',
    85     N_("Set the server port to connect to"), 
    86     HAS_ARG_YES,
    87     sh_forward_server_port },
    88 #endif
    8982#ifdef SH_WITH_SERVER
    9083  { N_("server"), 
     
    119112    HAS_ARG_YES,
    120113    sh_calls_set_bind_addr },
    121 #if defined(SH_WITH_SERVER) || defined(SH_WITH_CLIENT)
     114#ifdef SH_WITH_CLIENT
    122115  { N_("set-export-severity"), 
    123116    'e',
     
    398391    if (op_table[i].hasArg == HAS_ARG_NO) {
    399392      if (sl_strlen(op_table[i].longopt) < 10)
    400         sl_strlcpy(fmt,_("%c%c%c        --%-s,\t\t\t %s\n"), sizeof(fmt));
     393        strcpy(fmt,_("%c%c%c        --%-s,\t\t\t %s\n"));/* known to fit  */
    401394      else if (sl_strlen(op_table[i].longopt) < 17)
    402         sl_strlcpy(fmt, _("%c%c%c        --%-s,\t\t %s\n"), sizeof(fmt));
     395        strcpy(fmt, _("%c%c%c        --%-s,\t\t %s\n")); /* known to fit  */
    403396      else
    404         sl_strlcpy(fmt, _("%c%c%c        --%-s,\t %s\n"), sizeof(fmt));
    405       /* flawfinder: ignore */
    406       fprintf (stdout, fmt,
     397        strcpy(fmt, _("%c%c%c        --%-s,\t %s\n"));   /* known to fit  */
     398      /*@-formatconst@*/
     399      fprintf (stdout,
     400               fmt,
    407401               (op_table[i].shortopt == '-') ? ' ' : '-',
    408402               (op_table[i].shortopt == '-') ? ' ' : op_table[i].shortopt,
     
    410404               _(op_table[i].longopt),
    411405               _(op_table[i].usage));
     406      /*@+formatconst@*/
    412407    } else {
    413408      if (sl_strlen(op_table[i].longopt) < 12)
    414         sl_strlcpy(fmt, _("%c%c %s  --%-s=<arg>,\t\t %s\n"), sizeof(fmt)); 
     409        strcpy(fmt,                                      /* known to fit  */
     410               _("%c%c %s  --%-s=<arg>,\t\t %s\n")); 
    415411      else
    416         sl_strlcpy(fmt, _("%c%c %s  --%-s=<arg>,\t %s\n"), sizeof(fmt));   
    417       /* flawfinder: ignore */
    418       fprintf (stdout, fmt,
     412        strcpy(fmt,                                      /* known to fit  */
     413               _("%c%c %s  --%-s=<arg>,\t %s\n"));   
     414      /*@-formatconst@*/
     415      fprintf (stdout,
     416               fmt,
    419417               (op_table[i].shortopt == '-') ? ' ' : '-',
    420418               (op_table[i].shortopt == '-') ? ' ' : op_table[i].shortopt,
     
    422420               _(op_table[i].longopt),
    423421               _(op_table[i].usage));
     422      /*@+formatconst@*/
    424423    }
    425424  }
     
    561560          for (i = 0; op_table[i].longopt != NULL; ++i)
    562561            {
    563 
     562     
    564563              if (sl_strncmp(_(op_table[i].longopt),
    565564                             &argv[1][2],
     
    569568                  if ( op_table[i].hasArg == HAS_ARG_YES )
    570569                    {
    571                       theequal = strchr(argv[1], '=');
    572                       if (theequal == NULL)
     570                      if ( (theequal = strchr(argv[1], '=')) == NULL)
    573571                        {
    574572                          if (argc < 3)
  • /trunk/src/sh_gpg.c

    r30 r20  
    209209  FILE * outf = NULL;
    210210  char * envp[2];
    211   size_t len;
    212211  char   path[256];
    213212  char   cc1[32];
     
    371370  if (sh.effective.home != NULL)
    372371    {
    373       len = sl_strlen(sh.effective.home) + 6;
    374       envp[0] = malloc (len); /* free() ok   */
     372      envp[0] = malloc (sl_strlen(sh.effective.home) + 6); /* free() ok   */
    375373      if (envp[0] != NULL)
    376         sl_snprintf (envp[0], len, "HOME=%s", sh.effective.home);
     374        sprintf (envp[0], "HOME=%s",                     /* known to fit  */
     375                 sh.effective.home);
    377376      envp[1] = NULL;
    378377    }
     
    487486
    488487      pfd = get_the_fd(checkfd);
    489       sl_snprintf(pname, sizeof(pname), _("/proc/self/fd/%d"), pfd);
    490       if (0 == access(pname, R_OK|X_OK))               /* flawfinder: ignore */
    491 
     488      sprintf(pname, _("/proc/self/fd/%d"),             /* known to fit  */
     489                   pfd);
     490      if (0 == access(pname, R_OK|X_OK))
    492491        {
    493492          fcntl  (pfd, F_SETFD, FD_CLOEXEC);
  • /trunk/src/sh_hash.c

    r30 r20  
    297297    N_("[User0]"),
    298298    N_("[User1]"),
    299     N_("[User2]"),
    300     N_("[User3]"),
    301     N_("[User4]"),
    302299    N_("[Prelink]"),
    303300    NULL
     
    12711268}
    12721269
    1273 int sh_hash_version_string(const char * str)
     1270int sh_hash_version_string(char * str)
    12741271{
    12751272  int i;
  • /trunk/src/sh_html.c

    r30 r20  
    296296            {
    297297              entry_orig = realloc(entry_orig,           /* free() ok     */
    298                                    entry_size + line_size + 1);
     298                                   entry_size + line_size);
    299299              if (entry_orig) { add_size = line_size; }
    300300            }
     
    302302            {
    303303              entry_orig = malloc(line_size + 1);        /* free() ok     */
    304               if (entry_orig) { entry_orig[0] = '\0'; add_size = line_size; }
     304              if (entry_orig) { entry_orig[0] = '\0'; add_size = line_size + 1; }
    305305            }
    306306          if (!entry_orig)
     
    311311            }
    312312
    313           sl_strlcat(&entry_orig[entry_size], line, line_size + 1);
     313          strcat(&entry_orig[entry_size], line);         /* known to fit  */
    314314          entry_size += add_size;
    315           SH_VALIDATE_EQ(entry_orig[entry_size], '\0');
    316315        }
    317316      sl_close(fd);
  • /trunk/src/sh_ignore.c

    r30 r20  
    5353
    5454static struct sh_ignore_list * sh_ignore_add_int(struct sh_ignore_list * list,
    55                                                  const char * addpath)
     55                                                 char * addpath)
    5656{
    5757  struct sh_ignore_list * new;
     
    9696}
    9797
    98 int sh_ignore_add_del (const char * addpath)
     98int sh_ignore_add_del (char * addpath)
    9999{
    100100  if ((addpath == NULL) || (addpath[0] != '/'))
     
    106106}
    107107
    108 int sh_ignore_add_new (const char * addpath)
     108int sh_ignore_add_new (char * addpath)
    109109{
    110110  if ((addpath == NULL) || (addpath[0] != '/'))
  • /trunk/src/sh_kern.c

    r30 r20  
    431431  int (*rename) (int *, int *,
    432432                 int *, int *);
    433   /* flawfinder: ignore */
    434433  int (*readlink) (int *, char *,int);
    435434  int (*follow_link) (int *, int *);
  • /trunk/src/sh_mail.c

    r30 r20  
    271271
    272272static
    273 int sh_filter_filteradd (const char * argstring,
    274                          sh_filter_type * filter, int ftype)
     273int sh_filter_filteradd (char * argstring, sh_filter_type * filter, int ftype)
    275274{
    276275  int     i = 0;
     
    373372 */
    374373static
    375 int sh_filter_filter (const char * message, sh_filter_type * filter)
     374int sh_filter_filter (char * message, sh_filter_type * filter)
    376375{
    377376  int i;
     
    433432 * -- add keywords to the OR filter
    434433 */
    435 int sh_mail_add_or (const char * str)
     434int sh_mail_add_or (char * str)
    436435{
    437436  return (sh_filter_filteradd (str, &(mail_filter), SH_FILT_OR));
     
    441440 * -- add keywords to the AND filter
    442441 */
    443 int sh_mail_add_and (const char * str)
     442int sh_mail_add_and (char * str)
    444443{
    445444  return (sh_filter_filteradd (str, &(mail_filter), SH_FILT_AND));
     
    449448 * -- add keywords to the NOT filter
    450449 */
    451 int sh_mail_add_not (const char * str)
     450int sh_mail_add_not (char * str)
    452451{
    453452  return (sh_filter_filteradd (str, &(mail_filter), SH_FILT_NOT));
     
    474473}
    475474
    476 int sh_mail_setaddress (const char * address)
     475int sh_mail_setaddress (char * address)
    477476{
    478477  char     *     p;
     
    524523}
    525524
    526 int sh_mail_setaddress_int (const char * address)
     525int sh_mail_setaddress_int (char * address)
    527526{
    528527  int i;
     
    534533}
    535534
    536 int sh_mail_setNum (const char * str)
     535int sh_mail_setNum (char * str)
    537536{
    538537  int i = atoi (str);
     
    550549static int all_in_one = S_FALSE;
    551550
    552 int sh_mail_setFlag (const char * str)
     551int sh_mail_setFlag (char * str)
    553552{
    554553  int i;
     
    560559static char * mail_subject = NULL;
    561560
    562 int set_mail_subject (const char * str)
     561int set_mail_subject (char * str)
    563562{
    564563  SL_ENTER(_("set_mail_subject"));
     
    10071006        /* reveal first signature key
    10081007         */
    1009         /* flawfinder: ignore */
    1010         (void) sl_strlcpy(skey->crypt, skey->mailkey_new, KEY_LEN+1);
     1008        (void) sl_strlcpy(skey->crypt, skey->mailkey_new, KEY_LEN+1);
    10111009
    10121010        BREAKEXIT(sh_util_encode);
    1013         /* flawfinder: ignore */
    10141011        sh_util_encode(skey->crypt, bufcompress, 0, 'A');
    10151012
    1016         /* flawfinder: ignore */
    10171013        (void) sl_strlcat (mailMsg, skey->crypt, msgbufsize);
    1018         /* flawfinder: ignore */
    10191014        memset (skey->crypt, 0, KEY_LEN);
    10201015        isfirst = 0;
     
    10261021    (void) sl_strlcpy (skey->mailkey_old, skey->mailkey_new, KEY_LEN+1);
    10271022
    1028     sl_snprintf(subject, sizeof(subject), _("%06d %010ld::%s\r\n"),
    1029                 mailcount, (long) id_audit, sh.host.name);
     1023    /*@-bufferoverflowhigh@*/
     1024    sprintf(subject, _("%06d %010ld::%s\r\n"),         /* known to fit  */
     1025            mailcount, (long) id_audit, sh.host.name);
     1026    /*@+bufferoverflowhigh@*/
    10301027
    10311028    (void) sl_strlcat (mailMsg, subject, msgbufsize);
     
    12251222static char * relay_host = NULL;
    12261223
    1227 int sh_mail_set_relay (const char * str_s)
     1224int sh_mail_set_relay (char * str_s)
    12281225{
    12291226  size_t i = 0;
     
    12541251static char * mail_sender = NULL;
    12551252
    1256 int sh_mail_set_sender (const char *str)
     1253int sh_mail_set_sender (char *str)
    12571254{
    12581255  if (mail_sender != NULL)
     
    17381735      if (g != 1)
    17391736        {
    1740           sl_snprintf(errmsg, sizeof(errmsg),
    1741                       _("Bad response (%d), expected %d"), rcode, code);
    1742 
     1737          /*@-bufferoverflowhigh@*/
     1738          sprintf(errmsg,                              /* known to fit  */
     1739                  _("Bad response (%d), expected %d"), rcode, code);
     1740          /*@+bufferoverflowhigh@*/
    17431741          sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_NET,
    17441742                          errmsg, _("sh_mail_wait"),
     
    18851883  int  ret, length, status;
    18861884  mx * result;
    1887   size_t len;
    18881885
    18891886  typedef union
     
    20682065       */
    20692066      result[count].pref = pref;
    2070       len = strlen (expanded) + 1;
    2071       result[count].address = SH_ALLOC (len);
    2072       sl_strlcpy (result[count].address, expanded, len);
     2067      result[count].address = SH_ALLOC (strlen (expanded) + 1);
     2068      strcpy (result[count].address, expanded);        /* known to fit  */
    20732069    }
    20742070  while (ret > 0 && comp_dn < eom && count);
     
    21052101  mx     * result;
    21062102  dnsrep * retval;
    2107   char     errmsg[128];
    2108   size_t   len;
     2103  char     errmsg[128];
    21092104
    21102105  SL_ENTER(_("return_mx"));
     
    21332128                           _("get_mx"));
    21342129#else
    2135           /* flawfinder: ignore *//* test code only */
    21362130          strcpy  (errmsg,                               /* known to fit  */
    21372131                   _("No MX record for domain "));
     
    21612155      result->pref  = 0;
    21622156      /*@-type@*/
    2163       len = strlen (host->h_name) + 1;
    2164       result->address = SH_ALLOC (len);
    2165       sl_strlcpy (result->address, host->h_name, len);
     2157      result->address = SH_ALLOC (strlen (host->h_name) + 1);
     2158      strcpy (result->address, host->h_name);          /* known to fit  */
    21662159      /*@+type@*/
    21672160      SL_RETURN (retval, _("return_mx"));
  • /trunk/src/sh_mem.c

    r30 r20  
    3939#include "sh_mem.h"
    4040
    41 extern int safe_logger (int signal, int method, char * details);
     41extern int safe_logger (int signal, int method, pid_t thepid);
    4242
    4343#undef  FIL__
     
    228228        {
    229229          eblock = 1;
    230           (void) safe_logger (0, 0, NULL);
     230          (void) safe_logger (0, 0, getpid());
    231231          /*
    232232          sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MMEM,
     
    320320        {
    321321          eblock = 1;
    322           (void) safe_logger(0, 0, NULL);
     322          (void) safe_logger(0, 0, getpid());
    323323          /*
    324324          sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MMEM,
     
    456456        {
    457457          eblock = 1;
    458           (void) safe_logger(0, 0, NULL);
     458          (void) safe_logger(0, 0, getpid());
    459459          /*
    460460          sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MMEM);
  • /trunk/src/sh_prelink.c

    r30 r20  
    3838static char * prelink_hash = NULL;
    3939
    40 int sh_prelink_set_path (const char * str)
     40int sh_prelink_set_path (char * str)
    4141{
    4242  size_t len;
     
    5555}
    5656
    57 int sh_prelink_set_hash (const char * str)
     57int sh_prelink_set_hash (char * str)
    5858{
    5959  size_t len;
     
    245245  sl_read_timeout_prep (task.pipeTI);
    246246
    247   sl_strlcpy(file_hash,
    248              sh_tiger_generic_hash (path, TIGER_FD, 0, alert_timeout),
    249              KEY_LEN+1);
     247  strcpy(file_hash,                        /* known to fit */
     248         sh_tiger_generic_hash (path, TIGER_FD, 0, alert_timeout));
    250249
    251250  /* restore old signal handler
  • /trunk/src/sh_prelude.c

    r30 r20  
    133133}
    134134
    135 static int set_prelude_severity_int (const char * str, int prelude_sev)
    136 {
    137         char * p;
    138         char * dup = strdup (str);
    139 
    140         if (!dup)
    141                 return -1;
    142 
    143         p = strtok (dup, ", \t");
     135static int set_prelude_severity_int (char * str, int prelude_sev)
     136{
     137        char * p = strtok (str, ", \t");
     138
    144139        if (p) {
    145140                do {
     
    160155                        else if (0 == strcmp (p, _("info")))
    161156                                clear_and_set (prelude_sev, SH_ERR_INFO);
    162                         else {
    163                                 free (dup);
     157                        else
    164158                                return -1;
    165                         }
    166159                        p = strtok (NULL, ", \t");
    167160                } while (p);
    168161        }
    169         free(dup);
    170162        return 0;
    171163}
    172164
    173 int sh_prelude_map_info (const char * str)
     165int sh_prelude_map_info (char * str)
    174166{
    175167        return (set_prelude_severity_int(str,(int)IDMEF_IMPACT_SEVERITY_INFO));
    176168}
    177 int sh_prelude_map_low (const char * str)
     169int sh_prelude_map_low (char * str)
    178170{
    179171        return (set_prelude_severity_int(str,(int)IDMEF_IMPACT_SEVERITY_LOW));
    180172}
    181 int sh_prelude_map_medium (const char * str)
     173int sh_prelude_map_medium (char * str)
    182174{
    183175        return (set_prelude_severity_int(str,(int)IDMEF_IMPACT_SEVERITY_MEDIUM));
    184176}
    185 int sh_prelude_map_high (const char * str)
     177int sh_prelude_map_high (char * str)
    186178{
    187179        return (set_prelude_severity_int(str,(int)IDMEF_IMPACT_SEVERITY_HIGH));
     
    308300}
    309301
    310 /* flawfinder: ignore *//* is part of name, not access() */
    311302static void get_access_info(idmef_file_access_t *access, char * mode, int pos, int mpos)
    312303{
     
    317308        do {
    318309                if ( mode[pos] == 'r' ) {
    319                         /* flawfinder: ignore *//* is part of name, not access() */
    320                         ret = idmef_file_access_new_permission(access, &str, IDMEF_LIST_APPEND);
     310                        ret = idmef_file_access_new_permission(access, &str, -1);
    321311                        if ( ret < 0 )
    322312                                return;
     
    325315                }
    326316                else if ( mode[pos] == 'w' ) {
    327                         /* flawfinder: ignore *//* is part of name, not access() */
    328                         ret = idmef_file_access_new_permission(access, &str, IDMEF_LIST_APPEND);
     317                        ret = idmef_file_access_new_permission(access, &str, -1);
    329318                        if ( ret < 0 )
    330319                                return;
     
    333322                }
    334323                else if ( mode[pos] == 'x' || mode[pos] == 's' || mode[pos] == 't') {
    335                         /* flawfinder: ignore *//* is part of name, not access() */
    336                         ret = idmef_file_access_new_permission(access, &str, IDMEF_LIST_APPEND);
     324                        ret = idmef_file_access_new_permission(access, &str, -1);
    337325                        if ( ret < 0 )
    338326                                return;
     
    352340
    353341        if ( got == 0 ) {
    354                 /* flawfinder: ignore *//* is part of name, not access() */
    355                 ret = idmef_file_access_new_permission(access, &str, IDMEF_LIST_APPEND);
     342                ret = idmef_file_access_new_permission(access, &str, -1);
    356343                if ( ret < 0 )
    357344                        return;
     
    373360        prelude_string_t *str;
    374361        idmef_checksum_t *checksum;
    375         idmef_file_access_t *access; /* flawfinder: ignore */
     362        idmef_file_access_t *access;
    376363        idmef_user_id_t *userid;
    377364        const char *suffix = (category == IDMEF_FILE_CATEGORY_CURRENT) ? "_new" : "_old";
    378365        char *mode = NULL;
    379366               
    380         ret = idmef_target_new_file(target, &file, IDMEF_LIST_APPEND);
     367        ret = idmef_target_new_file(target, &file, -1);
    381368        if ( ret < 0  )
    382369                return;
     
    442429        ptr = get_value(msg, _("chksum"), suffix);
    443430        if ( ptr ) {
    444                 ret = idmef_file_new_checksum(file, &checksum, IDMEF_LIST_APPEND);
     431                ret = idmef_file_new_checksum(file, &checksum, 0);
    445432                if ( ret < 0 )
    446433                        return;
     
    472459        mode = get_value(msg, _("mode"), suffix);
    473460        if ( mode ) {
    474                 /* flawfinder: ignore *//* is part of name, not access() */
    475                 ret = idmef_file_new_file_access(file, &access, IDMEF_LIST_APPEND);
    476                 if ( ret < 0 )
    477                         return;
    478 
    479                 /* flawfinder: ignore *//* is part of name, not access() */
     461                ret = idmef_file_new_file_access(file, &access, -1);
     462                if ( ret < 0 )
     463                        return;
     464
    480465                ret = idmef_file_access_new_user_id(access, &userid);
    481466                if ( ret < 0 )
     
    483468                idmef_user_id_set_type(userid, IDMEF_USER_ID_TYPE_OTHER_PRIVS);
    484469
    485                 /* flawfinder: ignore *//* is part of name, not access() */
    486470                get_access_info ( access, mode, 7, 9 );
    487471        }
     
    491475                struct passwd *pw;
    492476               
    493                 /* flawfinder: ignore *//* is part of name, not access() */
    494                 ret = idmef_file_new_file_access(file, &access, IDMEF_LIST_APPEND);
    495                 if ( ret < 0 )
    496                         return;
    497 
    498                 /* flawfinder: ignore *//* is part of name, not access() */
     477                ret = idmef_file_new_file_access(file, &access, 0);
     478                if ( ret < 0 )
     479                        return;
     480
    499481                ret = idmef_file_access_new_user_id(access, &userid);
    500482                if ( ret < 0 )
     
    515497
    516498                if ( mode ) {
    517                         /* flawfinder: ignore *//* is part of name, not access() */
    518499                        get_access_info ( access, mode, 1, 3 );
    519500                }
     
    524505                struct group *gr;
    525506               
    526                 /* flawfinder: ignore *//* is part of name, not access() */
    527                 ret = idmef_file_new_file_access(file, &access, IDMEF_LIST_APPEND);
    528                 if ( ret < 0 )
    529                         return;
    530 
    531                 /* flawfinder: ignore *//* is part of name, not access() */
     507                ret = idmef_file_new_file_access(file, &access, -1);
     508                if ( ret < 0 )
     509                        return;
     510
    532511                ret = idmef_file_access_new_user_id(access, &userid);
    533512                if ( ret < 0 )
     
    548527
    549528                if ( mode ) {
    550                         get_access_info ( access, mode, 4, 6 ); /* flawfinder: ignore */
     529                        get_access_info ( access, mode, 4, 6 );
    551530                }
    552531        }
     
    650629        if ( ptr ) {
    651630                if ( ! source ) {
    652                         ret = idmef_alert_new_source(alert, &source, IDMEF_LIST_APPEND);
     631                        ret = idmef_alert_new_source(alert, &source, -1);
    653632                        if ( ret < 0 ) {
    654633                                free(ptr);
     
    663642                }
    664643               
    665                 ret = idmef_node_new_address(node, &address, IDMEF_LIST_APPEND);
     644                ret = idmef_node_new_address(node, &address, -1);
    666645                if ( ret < 0 ) {
    667646                        free(ptr);
     
    684663                else {
    685664                        if ( ! source ) {
    686                                 ret = idmef_alert_new_source(alert, &source, IDMEF_LIST_APPEND);
     665                                ret = idmef_alert_new_source(alert, &source, -1);
    687666                                if ( ret < 0 ) {
    688667                                        free(ptr);
     
    717696                idmef_user_set_category(user, IDMEF_USER_CATEGORY_OS_DEVICE);
    718697               
    719                 ret = idmef_user_new_user_id(user, &user_id, IDMEF_LIST_APPEND);
     698                ret = idmef_user_new_user_id(user, &user_id, -1);
    720699                if ( ret < 0 ) {
    721700                        free(ptr);
     
    791770                goto err;
    792771
    793         idmef_alert_set_analyzer(alert, idmef_analyzer_ref(prelude_client_get_analyzer(client)), IDMEF_LIST_PREPEND);
     772        idmef_alert_set_analyzer(alert, idmef_analyzer_ref(prelude_client_get_analyzer(client)), 0);
    794773       
    795774        ret = idmef_time_new_from_gettimeofday(&time);
     
    807786                goto err;
    808787       
    809         ret = idmef_alert_new_target(alert, &target, IDMEF_LIST_APPEND);
     788        ret = idmef_alert_new_target(alert, &target, -1);
    810789        if ( ret < 0 )
    811790                goto err;
     
    865844        idmef_confidence_set_rating(confidence, IDMEF_CONFIDENCE_RATING_HIGH);
    866845       
    867         ret = idmef_alert_new_additional_data(alert, &data, IDMEF_LIST_APPEND);
     846        ret = idmef_alert_new_additional_data(alert, &data, -1);
    868847        if ( ret < 0 )
    869848                goto err;
     
    911890
    912891
    913 int sh_prelude_set_profile(const char *arg)
     892int sh_prelude_set_profile(char *arg)
    914893{
    915894        if ( profile ) {
  • /trunk/src/sh_readconf.c

    r30 r20  
    5252#endif
    5353
    54 extern int set_reverse_lookup (const char * c);
     54extern int set_reverse_lookup (char * c);
    5555
    5656#undef  FIL__
     
    6969  SH_SECTION_USER0,
    7070  SH_SECTION_USER1,
    71   SH_SECTION_USER2,
    72   SH_SECTION_USER3,
    73   SH_SECTION_USER4,
    7471  SH_SECTION_PRELINK,
    7572#if defined (SH_WITH_MAIL)
     
    111108  { N_("[User0]"),            SH_SECTION_USER0},
    112109  { N_("[User1]"),            SH_SECTION_USER1},
    113   { N_("[User2]"),            SH_SECTION_USER2},
    114   { N_("[User3]"),            SH_SECTION_USER3},
    115   { N_("[User4]"),            SH_SECTION_USER4},
    116110  { N_("[Prelink]"),          SH_SECTION_PRELINK},
    117111#ifdef WITH_EXTERNAL
     
    288282  /* The system type, release, and machine.
    289283   */
    290   sl_snprintf(myident, sizeof(myident), _("%s:%s:%s"), 
    291               sh.host.system, /* flawfinder: ignore */
    292               sh.host.release, sh.host.machine);
     284  sprintf(myident, _("%s:%s:%s"),                  /* known to fit  */
     285          sh.host.system, sh.host.release, sh.host.machine);
    293286
    294287
     
    587580}
    588581
    589 int sh_readconf_set_path (char * which, const char * what)
     582int sh_readconf_set_path (char * which, char * what)
    590583{
    591584  int len;
     
    628621}
    629622
    630 int sh_readconf_set_database_path (const char * what)
     623int sh_readconf_set_database_path (char * what)
    631624{
    632625  return (sh_readconf_set_path(sh.data.path, what));
    633626}
    634627
    635 int sh_readconf_set_logfile_path (const char * what)
     628int sh_readconf_set_logfile_path (char * what)
    636629{
    637630  return (sh_readconf_set_path(sh.srvlog.name, what));
    638631}
    639632
    640 int sh_readconf_set_lockfile_path (const char * what)
     633int sh_readconf_set_lockfile_path (char * what)
    641634{
    642635  return( sh_readconf_set_path(sh.srvlog.alt, what));
     
    652645 
    653646   
    654 int sh_readconf_setTime (const char * str, ShTimerItem what)
     647int sh_readconf_setTime (char * str, ShTimerItem what)
    655648{
    656649  unsigned long i = atoi (str);
     
    681674}
    682675
    683 int sh_readconf_setMailtime (const char * c)
     676int sh_readconf_setMailtime (char * c)
    684677{
    685678  return sh_readconf_setTime (c, SET_MAILTIME);
    686679}
    687680
    688 int sh_readconf_setFiletime (const char * c)
     681int sh_readconf_setFiletime (char * c)
    689682{
    690683  return sh_readconf_setTime (c, SET_FILETIME);
    691684}
    692685
    693 int sh_readconf_set_nice (const char * c)
     686int sh_readconf_set_nice (char * c)
    694687{
    695688  long val;
     
    711704
    712705#ifdef FANCY_LIBCAP
    713 int sh_readconf_setCaps(const char * c)
     706int sh_readconf_setCaps(char * c)
    714707{
    715708  int i;
     
    725718  ShSectionType   section;
    726719  ShSectionType   alt_section;
    727   int (*func)(const char * opt);
     720  int (*func)(char * opt);
    728721} cfg_options;
    729722
    730723#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
    731 extern int sh_set_schedule_one(const char * str);
    732 extern int sh_set_schedule_two(const char * str);
     724extern int sh_set_schedule_one(char * str);
     725extern int sh_set_schedule_two(char * str);
    733726#endif
    734727#if defined (SH_WITH_SERVER)
    735 extern int sh_socket_use (const char * c);
    736 extern int sh_socket_uid (const char * c);
    737 extern int sh_socket_password (const char * c);
    738 #endif
    739 
     728extern int sh_socket_use (char * c);
     729extern int sh_socket_uid (char * c);
     730extern int sh_socket_password (char * c);
     731#endif
     732
     733/* Yes, this isn't very elegant ;)
     734 */
     735#if defined(WITH_EXTERNAL)
     736int sh_error_set_external_wrap (char * str) {
     737  return sh_error_set_external ((const char *) str);
     738}
     739#endif
     740#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
     741int sh_files_setrecursion_wrap (char * str) {
     742  return sh_files_setrecursion ((const char *) str);
     743}
     744int sh_util_setchecksum_wrap (char * str) {
     745  return sh_util_setchecksum ((const char *) str);
     746}
     747#endif
     748int sh_util_setlooptime_wrap (char * str) {
     749  return sh_util_setlooptime ((const char *) str);
     750}
     751#ifdef SH_WITH_MAIL
     752int sh_error_setseverity_wrap (char * str) {
     753  return sh_error_setseverity ((const char *) str);
     754}
     755#endif
     756int sh_calls_set_bind_addr_wrap (char * str) {
     757  return sh_calls_set_bind_addr ((const char *) str);
     758}
     759int sh_unix_setdeamon_wrap (char * str) {
     760  return sh_unix_setdeamon ((const char *) str);
     761}
     762int sh_error_setprint_wrap (char * str) {
     763  return sh_error_setprint ((const char *) str);
     764}
     765int sh_error_setlog_wrap (char * str) {
     766  return sh_error_setlog ((const char *) str);
     767}
     768int sh_error_set_syslog_wrap (char * str) {
     769  return sh_error_set_syslog ((const char *) str);
     770}
     771#ifdef HAVE_LIBPRELUDE
     772int sh_error_set_prelude_wrap (char * str) {
     773  return sh_error_set_prelude ((const char *) str);
     774}
     775#endif
     776#ifdef SH_WITH_CLIENT
     777int sh_error_setexport_wrap (char * str) {
     778  return sh_error_setexport ((const char *) str);
     779}
     780#endif
     781#ifdef SH_WITH_SERVER
     782int sh_forward_set_strip_wrap (char * str) {
     783  return sh_forward_set_strip ((const char *) str);
     784}
     785int sh_unix_set_chroot_wrap (char * str) {
     786  return sh_unix_set_chroot ((const char *) str);
     787}
     788#endif
     789#if defined(WITH_DATABASE)
     790int sh_error_set_database_wrap (char * str) {
     791  return sh_error_set_database ((const char *) str);
     792}
     793#endif
     794 
    740795cfg_options ext_table[] = {
    741796#if defined(WITH_EXTERNAL)
     
    763818    sh_ext_add_or },
    764819  { N_("externalseverity"),SH_SECTION_LOG,      SH_SECTION_EXTERNAL, 
    765     sh_error_set_external },
     820    sh_error_set_external_wrap },
    766821  { N_("externalclass"),   SH_SECTION_LOG,      SH_SECTION_EXTERNAL, 
    767822    sh_error_external_mask },
     
    790845    set_enter_wrapper },
    791846#endif
    792 
    793847
    794848#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
     
    826880  { N_("file"),           SH_SECTION_USER1,      SH_SECTION_NONE,
    827881    sh_files_pushfile_user1 },
    828   { N_("dir"),            SH_SECTION_USER2,      SH_SECTION_NONE,
    829     sh_files_pushdir_user2 },
    830   { N_("file"),           SH_SECTION_USER2,      SH_SECTION_NONE,
    831     sh_files_pushfile_user2 },
    832   { N_("dir"),            SH_SECTION_USER3,      SH_SECTION_NONE,
    833     sh_files_pushdir_user3 },
    834   { N_("file"),           SH_SECTION_USER3,      SH_SECTION_NONE,
    835     sh_files_pushfile_user3 },
    836   { N_("dir"),            SH_SECTION_USER4,      SH_SECTION_NONE,
    837     sh_files_pushdir_user4 },
    838   { N_("file"),           SH_SECTION_USER4,      SH_SECTION_NONE,
    839     sh_files_pushfile_user4 },
    840882  { N_("dir"),            SH_SECTION_PRELINK,    SH_SECTION_NONE,
    841883    sh_files_pushdir_prelink },
     
    860902    sh_util_obscure_ok },
    861903  { N_("setrecursionlevel"),  SH_SECTION_MISC,   SH_SECTION_NONE,
    862     sh_files_setrecursion },
     904    sh_files_setrecursion_wrap },
    863905  { N_("checksumtest"),       SH_SECTION_MISC,   SH_SECTION_NONE,
    864     sh_util_setchecksum },
     906    sh_util_setchecksum_wrap },
    865907  { N_("reportonlyonce"),     SH_SECTION_MISC,   SH_SECTION_NONE,
    866908    sh_files_reportonce },
     
    911953    sh_files_redef_user1 },
    912954
    913   { N_("redefuser2"),           SH_SECTION_MISC,   SH_SECTION_NONE,
    914     sh_files_redef_user2 },
    915 
    916   { N_("redefuser3"),           SH_SECTION_MISC,   SH_SECTION_NONE,
    917     sh_files_redef_user3 },
    918 
    919   { N_("redefuser4"),           SH_SECTION_MISC,   SH_SECTION_NONE,
    920     sh_files_redef_user4 },
    921 
    922955  { N_("redefprelink"),         SH_SECTION_MISC,   SH_SECTION_NONE,
    923956    sh_files_redef_prelink },
     
    928961  { N_("setprelinkchecksum"),   SH_SECTION_MISC,   SH_SECTION_NONE,
    929962    sh_prelink_set_hash },
    930 
    931963  /* client or standalone
    932964   */
     
    945977    sh_socket_password },
    946978  { N_("setstripdomain"),      SH_SECTION_SRV,  SH_SECTION_MISC,
    947     sh_forward_set_strip },
     979    sh_forward_set_strip_wrap },
    948980  { N_("useseparatelogs"),     SH_SECTION_SRV,  SH_SECTION_MISC,
    949981    set_flag_sep_log },
    950982  { N_("setchrootdir"),        SH_SECTION_SRV,  SH_SECTION_MISC,
    951     sh_unix_set_chroot },
     983    sh_unix_set_chroot_wrap },
    952984  { N_("setclienttimelimit"),  SH_SECTION_SRV,  SH_SECTION_MISC,
    953985    sh_forward_set_time_limit },
     
    9681000#endif
    9691001
    970 #if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     1002#ifdef SH_WITH_CLIENT
    9711003  { N_("exportseverity"),      SH_SECTION_LOG,  SH_SECTION_NONE,
    972     sh_error_setexport },
     1004    sh_error_setexport_wrap },
    9731005  { N_("exportclass"),         SH_SECTION_LOG,  SH_SECTION_NONE,
    9741006    sh_error_export_mask },
    975 #if defined(SH_WITH_SERVER)
    976   { N_("setlogserver"),        SH_SECTION_SRV,  SH_SECTION_MISC,
    977     sh_forward_setlogserver },
    978 #else
    9791007  { N_("setlogserver"),        SH_SECTION_CLT,  SH_SECTION_MISC,
    9801008    sh_forward_setlogserver },
    981 #endif
    9821009#endif
    9831010  { N_("setfilechecktime"),  SH_SECTION_MISC,   SH_SECTION_NONE,
    9841011    sh_readconf_setFiletime },
    9851012  { N_("setlooptime"),     SH_SECTION_MISC,  SH_SECTION_NONE,
    986     sh_util_setlooptime },
     1013    sh_util_setlooptime_wrap },
    9871014
    9881015#ifdef SH_WITH_MAIL
    9891016  { N_("mailseverity"),      SH_SECTION_LOG,   SH_SECTION_NONE,
    990     sh_error_setseverity },
     1017    sh_error_setseverity_wrap },
    9911018  { N_("mailclass"),         SH_SECTION_LOG,   SH_SECTION_NONE,
    9921019    sh_error_mail_mask },
     
    10131040#endif
    10141041  { N_("setbindaddress"),    SH_SECTION_MISC,  SH_SECTION_NONE,
    1015     sh_calls_set_bind_addr },
     1042    sh_calls_set_bind_addr_wrap },
    10161043  { N_("daemon"),            SH_SECTION_MISC,  SH_SECTION_NONE,
    1017     sh_unix_setdeamon },
     1044    sh_unix_setdeamon_wrap },
    10181045  { N_("samhainpath"),       SH_SECTION_MISC,  SH_SECTION_NONE,
    10191046    sh_unix_self_hash },
     
    10241051
    10251052  { N_("printseverity"),     SH_SECTION_LOG,   SH_SECTION_NONE,
    1026     sh_error_setprint },
     1053    sh_error_setprint_wrap },
    10271054  { N_("printclass"),        SH_SECTION_LOG,   SH_SECTION_NONE,
    10281055    sh_error_print_mask },
    10291056
    10301057  { N_("logseverity"),       SH_SECTION_LOG,   SH_SECTION_NONE,
    1031     sh_error_setlog },
     1058    sh_error_setlog_wrap },
    10321059  { N_("logclass"),          SH_SECTION_LOG,   SH_SECTION_NONE,
    10331060    sh_error_log_mask },
    10341061
    10351062  { N_("syslogseverity"),    SH_SECTION_LOG,   SH_SECTION_NONE,
    1036     sh_error_set_syslog },
     1063    sh_error_set_syslog_wrap },
    10371064  { N_("syslogclass"),       SH_SECTION_LOG,   SH_SECTION_NONE,
    10381065    sh_error_syslog_mask },
    10391066#ifdef HAVE_LIBPRELUDE
    10401067  { N_("preludeseverity"),   SH_SECTION_LOG,   SH_SECTION_NONE,
    1041     sh_error_set_prelude },
     1068    sh_error_set_prelude_wrap },
    10421069  { N_("preludeclass"),      SH_SECTION_LOG,   SH_SECTION_NONE,
    10431070    sh_error_prelude_mask },
     
    11201147    N_("severityuser0"),
    11211148    N_("severityuser1"),
    1122     N_("severityuser2"),
    1123     N_("severityuser3"),
    1124     N_("severityuser4"),
    11251149    N_("severityprelink"),
    11261150    NULL
     
    11391163    SH_ERR_T_USER0,       
    11401164    SH_ERR_T_USER1,       
    1141     SH_ERR_T_USER2,       
    1142     SH_ERR_T_USER3,       
    1143     SH_ERR_T_USER4,       
    11441165    SH_ERR_T_PRELINK,       
    11451166  };
  • /trunk/src/sh_schedule.c

    r30 r20  
    5353#endif
    5454
    55 #include "samhain.h"
    5655#include "sh_mem.h"
    5756
     
    319318  char * copy;
    320319  int    i = 0;
    321   size_t len;
    322320
    323321  if (!ssched || !isched)
    324322    return -1;
    325323
    326   len = strlen(ssched)+1;
    327324#ifdef TESTONLY
    328   copy = malloc(len);                 /* testonly code */
    329 #else
    330   copy = SH_ALLOC(len);
    331 #endif
    332   sl_strlcpy(copy, ssched, len);
     325  copy = malloc(strlen(ssched)+1);                 /* testonly code */
     326#else
     327  copy = SH_ALLOC(strlen(ssched)+1);
     328#endif
     329  strcpy(copy, ssched);                            /* known to fit  */
    333330
    334331  p = strtok(copy, " \t"); /* parse crontab-style schedule */
  • /trunk/src/sh_socket.c

    r30 r20  
    244244}
    245245
    246 int sh_socket_use (const char * c)
     246int sh_socket_use (char * c)
    247247{
    248248  return sh_util_flagval(c, &sh_socket_flaguse);
     
    289289#endif
    290290
    291 int sh_socket_uid (const char * c)
     291int sh_socket_uid (char * c)
    292292{
    293293  uid_t val = (uid_t) strtol (c, (char **)NULL, 10);
     
    301301}
    302302
    303 int sh_socket_password (const char * c)
     303int sh_socket_password (char * c)
    304304{
    305305#if defined(NEED_PASSWORD_AUTH)
     
    378378
    379379  name.sun_family = AF_FILE;
    380   sl_strlcpy (name.sun_path, sh_sockname, sizeof(name.sun_path));
     380  strcpy (name.sun_path, sh_sockname);
    381381
    382382  size = (offsetof (struct sockaddr_un, sun_path)
     
    878878
    879879  new = SH_ALLOC(sizeof(struct socket_cmd));
    880   sl_strlcpy (new->cmd, in->cmd, sizeof(new->cmd));
    881   sl_strlcpy (new->clt, in->clt, sizeof(new->clt));
    882   sl_strlcpy (new->cti, sh_unix_time(0), sizeof(new->cti));
     880  strcpy (new->cmd, in->cmd);
     881  strcpy (new->clt, in->clt);
     882  strcpy (new->cti, sh_unix_time(0));
    883883  new->next = cmdlist;
    884884  cmdlist   = new;
     
    896896      if (0 == sl_strcmp(new->clt, client_name))
    897897        {
    898           sl_strlcpy (new->cmd, in->cmd, sizeof(new->cmd));
    899           sl_strlcpy (new->clt, in->clt, sizeof(new->clt));
    900           sl_strlcpy (new->cti, sh_unix_time(0), sizeof(new->cti));
     898          strcpy (new->cmd, in->cmd);
     899          strcpy (new->clt, in->clt);
     900          strcpy (new->cti, sh_unix_time(0));
    901901          return;
    902902        }
     
    905905
    906906  new = SH_ALLOC(sizeof(struct socket_cmd));
    907   sl_strlcpy (new->cmd, in->cmd, sizeof(new->cmd));
    908   sl_strlcpy (new->clt, in->clt, sizeof(new->clt));
    909   sl_strlcpy (new->cti, sh_unix_time(0), sizeof(new->cti));
     907  strcpy (new->cmd, in->cmd);
     908  strcpy (new->clt, in->clt);
     909  strcpy (new->cti, sh_unix_time(0));
    910910  new->next = runlist;
    911911  runlist   = new;
  • /trunk/src/sh_srp.c

    r30 r20  
    121121        }
    122122      siz_str_internal = size;
    123       sl_strlcpy (get_str_internal, str, siz_str_internal);
     123      strcpy (get_str_internal, str);                   /* known to fit  */
    124124      for (i = 0; i < (size-1); ++i)
    125125        if (get_str_internal[i] >= 'a' && get_str_internal[i] <= 'f' )
     
    384384}
    385385
    386 #if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     386#ifdef SH_WITH_CLIENT
    387387 
    388388
     
    489489 
    490490 
    491 #if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     491#ifdef SH_WITH_CLIENT
    492492 
    493493char * sh_srp_S_c (char * u_str, char * B_str)
  • /trunk/src/sh_static.c

    r30 r20  
    5959#endif
    6060
    61 extern  int sl_strlcpy(char * dst, /*@null@*/const char * src, size_t siz);
    62 extern  int sl_strlcat(char * dst, /*@null@*/const char * src, size_t siz);
    6361
    6462
     
    886884
    887885#ifdef DEBUG
    888 /* flawfinder: ignore *//* definition of debug macro */
    889886#define DPRINTF(X,args...) fprintf(stderr, X, ##args)
    890887#else
     
    11971194                        goto fail;
    11981195
    1199                 sl_strlcpy(lookup,name,MAXDNAME);
     1196                strncpy(lookup,name,MAXDNAME);
    12001197                BIGLOCK;
    12011198                if (variant < __searchdomains && strchr(lookup, '.') == NULL)
    12021199                {
    1203                     sl_strlcat(lookup,".", MAXDNAME);
    1204                     sl_strlcat(lookup,__searchdomain[variant], MAXDNAME);
     1200                    strncat(lookup,".", MAXDNAME);
     1201                    strncat(lookup,__searchdomain[variant], MAXDNAME);
    12051202                }
    12061203                BIGUNLOCK;
  • /trunk/src/sh_suidchk.c

    r30 r20  
    415415  long            sl_status = SL_ENONE;
    416416  struct stat     fileInfo;
    417   struct stat     fileInfo_F;
    418   int             file_d;
    419417
    420418  file_type       theFile;
    421419  char            fileHash[2*(KEY_LEN + 1)];
    422 
    423   mode_t          umask_old;
    424   int             cperm_status;
    425420
    426421  SL_ENTER(_("sh_suidchk_check_internal"));
     
    524519               */
    525520              fs = filesystem_type (tmpcat, tmpcat, &buf);
    526               if (fs != NULL
    527 #ifndef SH_SUIDTESTDIR
    528                   &&
    529                   0 != strncmp (_("afs"),     fs, 3) &&
     521              if (fs != NULL &&
     522                  0 != strncmp (_("nfs"),     fs, 3) &&
     523                  0 != strncmp (_("proc"),    fs, 4) &&
     524                  0 != strncmp (_("iso9660"), fs, 7) &&
     525                  0 != strncmp (_("vfat"),    fs, 4) &&
     526                  0 != strncmp (_("msdos"),   fs, 5) &&
    530527                  0 != strncmp (_("devfs"),   fs, 5) &&
    531                   0 != strncmp (_("iso9660"), fs, 7) &&
    532                   0 != strncmp (_("lustre"),  fs, 6) &&
    533                   0 != strncmp (_("mmfs"),    fs, 4) &&
    534                   0 != strncmp (_("msdos"),   fs, 5) &&
    535                   0 != strncmp (_("nfs"),     fs, 3) &&
    536                   0 != strncmp (_("nosuid"),  fs, 6) &&
    537                   0 != strncmp (_("proc"),    fs, 4) &&
    538                   0 != strncmp (_("vfat"),    fs, 4)
    539 #endif
     528                  0 != strncmp (_("nosuid"),  fs, 6)
    540529                  )
    541530                {
     
    677666                                    break;
    678667                                  case SH_Q_CHANGEPERM:
    679                                     cperm_status = 0;
    680                                     file_d = -1;
    681668                                    if (retry_lstat(FIL__, __LINE__, tmpcat, &fileInfo) == -1)
    682669                                      {
     
    690677                                                         tmp );
    691678                                        SH_FREE(msg);
    692                                         cperm_status = -1;
    693679                                      }
    694 
    695                                     if (cperm_status == 0)
     680                                    else
    696681                                      {
    697682                                        if (0 != (caperr = sl_get_cap_qdel()))
     
    701686                                                            sh_error_message (caperr),
    702687                                                            _("sl_get_cap_qdel"));
    703                                             cperm_status = -1;
    704688                                          }
    705                                       }
    706 
    707                                     if (cperm_status == 0)
    708                                       {
    709                                         file_d = aud_open (FIL__, __LINE__, SL_YESPRIV,
    710                                                            tmpcat, O_RDONLY, 0);
    711                                         if (-1 == file_d)
    712                                           {
    713                                             status = errno;
    714                                             msg = SH_ALLOC(SH_BUFSIZE);
    715                                             (void) sl_snprintf(msg, SH_BUFSIZE, _("I/O error.  errno = %ld"), status);
    716                                             sh_error_handle (ShSuidchkSeverity,
    717                                                              FIL__, __LINE__,
    718                                                              status,
    719                                                              MSG_SUID_QREPORT, msg,
    720                                                              tmp );
    721                                             SH_FREE(msg);
    722                                             cperm_status = -1;
    723                                           }
    724                                       }
    725 
    726                                     if (cperm_status == 0)
    727                                       {
    728                                         if (retry_fstat(FIL__, __LINE__, file_d, &fileInfo_F) == -1)
    729                                           {
    730                                             status = errno;
    731                                             msg = SH_ALLOC(SH_BUFSIZE);
    732                                             (void) sl_snprintf(msg, SH_BUFSIZE,
    733                                                                _("I/O error.  errno = %ld"), status);
    734                                             sh_error_handle (ShSuidchkSeverity,
    735                                                              FIL__, __LINE__,
    736                                                              status,
    737                                                              MSG_SUID_QREPORT, msg,
    738                                                              tmp );
    739                                             SH_FREE(msg);
    740                                             cperm_status = -1;
    741                                           }
    742                                       }
    743 
    744                                     if (cperm_status == 0)
    745                                       {
    746                                         if (fileInfo_F.st_ino  != fileInfo.st_ino ||
    747                                             fileInfo_F.st_dev  != fileInfo.st_dev ||
    748                                             fileInfo_F.st_mode != fileInfo.st_mode)
    749                                           {
    750                                             status = errno;
    751                                             msg = SH_ALLOC(SH_BUFSIZE);
    752                                             (void) sl_snprintf(msg, SH_BUFSIZE,
    753                                                                _("Race detected.  errno = %ld"), status);
    754                                             sh_error_handle (ShSuidchkSeverity,
    755                                                              FIL__, __LINE__,
    756                                                              status,
    757                                                              MSG_SUID_QREPORT, msg,
    758                                                              tmp );
    759                                             SH_FREE(msg);
    760                                             cperm_status = -1;
    761                                           }
    762                                       }
    763 
    764                                     if ((fileInfo.st_mode & S_ISUID) > 0)
    765                                       fileInfo.st_mode -= S_ISUID;
    766                                     if ((fileInfo.st_mode & S_ISGID) > 0)
    767                                       fileInfo.st_mode -= S_ISGID;
    768 
    769                                     if (cperm_status == 0)
    770                                       {
    771                                         if (fchmod(file_d, fileInfo.st_mode) == -1)
     689
     690                                        if ((fileInfo.st_mode & S_ISUID) > 0)
     691                                          fileInfo.st_mode -= S_ISUID;
     692                                        if ((fileInfo.st_mode & S_ISGID) > 0)
     693                                          fileInfo.st_mode -= S_ISGID;
     694                                        if (chmod(tmpcat, fileInfo.st_mode) == -1)
    772695                                          {
    773696                                            status = errno;
     
    790713                                                             tmp );
    791714                                          }
    792                                       }
    793 
    794                                     if (0 != (caperr = sl_drop_cap_qdel()))
    795                                       {
    796                                         sh_error_handle((-1), FIL__, __LINE__,
    797                                                         caperr, MSG_E_SUBGEN,
    798                                                         sh_error_message (caperr),
    799                                                         _("sl_drop_cap_qdel"));
    800                                       }
    801 
    802                                     if (file_d != -1)
    803                                       {
    804                                         do {
    805                                           status = close (file_d);
    806                                         } while (status == -1 && errno == EINTR);
    807 
    808                                         if (-1 == status)
     715                                        if (0 != (caperr = sl_drop_cap_qdel()))
    809716                                          {
    810                                             status = errno;
    811                                             msg = SH_ALLOC(SH_BUFSIZE);
    812                                             (void) sl_snprintf(msg, SH_BUFSIZE,
    813                                                                _("I/O error.  errno = %ld"), status);
    814                                             sh_error_handle (ShSuidchkSeverity,
    815                                                              FIL__, __LINE__,
    816                                                              status,
    817                                                              MSG_SUID_QREPORT, msg,
    818                                                              tmp );
    819                                             SH_FREE(msg);
    820                                             cperm_status = -1;
     717                                            sh_error_handle((-1), FIL__, __LINE__,
     718                                                            caperr, MSG_E_SUBGEN,
     719                                                            sh_error_message (caperr),
     720                                                            _("sl_drop_cap_qdel"));
    821721                                          }
    822722                                      }
     
    825725                                    dir = SH_ALLOC(PATH_MAX+1);
    826726                                    (void) sl_strlcpy (dir, DEFAULT_QDIR, PATH_MAX+1);
    827                                     if (retry_stat (FIL__, __LINE__, dir, &fileInfo) != 0)
     727                                    if (access (dir, F_OK) != 0)
    828728                                      {
    829729                                        status = errno;
    830730                                        msg = SH_ALLOC(SH_BUFSIZE);
    831                                         (void) sl_snprintf(msg, SH_BUFSIZE, _("Problem quarantining file.  File NOT quarantined.  errno = %ld (stat)"), status);
     731                                        (void) sl_snprintf(msg, SH_BUFSIZE, _("Problem quarantining file.  File NOT quarantined.  errno = %ld (access)"), status);
    832732                                        sh_error_handle (ShSuidchkSeverity,
    833733                                                         FIL__, __LINE__,
     
    915815                                                                   DEFAULT_QDIR,
    916816                                                                   basename(theFile.fullpath));
    917                                                 /*
    918                                                  * avoid chmod by setting umask
    919                                                  */
    920                                                 umask_old = umask (0077);
    921817                                                filePtr = fopen (filetmp, "w+");
    922818                                                /*@-usedef@*/
     
    932828                                                  }
    933829                                                /*@+usedef@*/
    934                                                 umask (umask_old);
    935830                                       
    936831                                                sh_error_handle (ShSuidchkSeverity,
     
    939834                                                                 _("Quarantine method applied"),
    940835                                                                 tmp );
     836                                                if (chmod(filetmp, S_IRUSR | S_IWUSR) == -1)
     837                                                  {
     838                                                    status = errno;
     839                                                    msg = SH_ALLOC(SH_BUFSIZE);
     840                                                    (void) sl_snprintf(msg, SH_BUFSIZE, _("Problem setting permissions on quarantined file.  errno = %ld"), status);
     841                                                    sh_error_handle (ShSuidchkSeverity,
     842                                                                     FIL__,__LINE__,
     843                                                                     status, MSG_SUID_QREPORT,
     844                                                                     msg, tmp );
     845                                                    SH_FREE(msg);
     846                                                  }
    941847                                              }
    942848                                            SH_FREE(filetmp);
     
    1070976  FileLimTotal      = 0;
    1071977
    1072 #ifdef SH_SUIDTESTDIR
    1073   status = sh_suidchk_check_internal (SH_SUIDTESTDIR);
    1074 #else
    1075978  status = sh_suidchk_check_internal ("/");
    1076 #endif
    1077979
    1078980  sh_error_handle ((-1), FIL__, __LINE__, EINVAL, MSG_SUID_SUMMARY,
     
    12671169  long val;
    12681170  int  ret = 0;
    1269   struct stat buf;
    12701171
    12711172  SL_ENTER(_("sh_suidchk_set_qmethod"));
     
    12891190          break;
    12901191        case SH_Q_MOVE:
    1291           if (retry_stat (FIL__, __LINE__, DEFAULT_QDIR, &buf) != 0)
     1192          if (access (DEFAULT_QDIR, F_OK) != 0)
    12921193            {
    12931194              if (mkdir (DEFAULT_QDIR, 0750) == -1)
  • /trunk/src/sh_tiger0.c

    r30 r20  
    404404#ifdef USE_MD5
    405405/*@-type@*/
    406 /* md5.c - Functions to compute MD5 message digest of files or memory blocks
    407  *         according to the definition of MD5 in RFC 1321 from April 1992.
    408  * Copyright (C) 1995, 1996 Free Software Foundation, Inc.
     406/************************************************************************
    409407 *
    410  * NOTE: The canonical source of this file is maintained with the GNU C
    411  * Library.  Bugs can be reported to bug-glibc@prep.ai.mit.edu.
     408 *  md5.h - Declaration of functions and data types used for MD5 sum
     409 *  computing library functions.
    412410 *
    413  * This program is free software; you can redistribute it and/or modify it
    414  * under the terms of the GNU General Public License as published by the
    415  * Free Software Foundation; either version 2, or (at your option) any
    416  * later version.
    417  *
    418  * This program is distributed in the hope that it will be useful,
    419  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    420  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    421  * GNU General Public License for more details.
    422  *
    423  * You should have received a copy of the GNU General Public License
    424  * along with this program; if not, write to the Free Software Foundation,
    425  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    426  */
    427 
    428 /* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.  */
    429 
     411 ************************************************************************/
     412
     413/* Written Bob Deblier <bob@virtualunlimited.com>         */
    430414/* Hacked to work with samhain by R. Wichmann             */
    431 
    432 typedef UINT32 md5_uint32;
     415/* Need for 64bit type removed, fix for Mac OS X compiler */
     416
     417typedef sh_word32     uint32;
     418typedef unsigned char uint8;
     419
     420
     421
    433422
    434423
    435424/* Structure to save state of computation between the single steps.  */
    436 typedef struct md5_ctx
    437 {
    438   md5_uint32 A;
    439   md5_uint32 B;
    440   md5_uint32 C;
    441   md5_uint32 D;
    442 
    443   md5_uint32 total[2];
    444   md5_uint32 buflen;
    445   char buffer[128];
     425typedef struct
     426{
     427        uint32 h[4];
     428        uint32 data[16];
     429        uint8  offset;
     430        uint32  nblocks;
     431        int  count;
    446432} md5Param;
    447433
    448 /*
    449  * The following three functions are build up the low level used in
    450  * the functions `md5_stream' and `md5_buffer'.
    451  */
    452 
    453 /* Initialize structure containing state of computation.
    454    (RFC 1321, 3.3: Step 3)  */
    455 static void md5_init_ctx (struct md5_ctx *ctx);
    456 
    457 /* Starting with the result of former calls of this function (or the
    458    initialization function update the context for the next LEN bytes
    459    starting at BUFFER.
    460    It is necessary that LEN is a multiple of 64!!! */
    461 static void md5_process_block (const void *buffer, size_t len,
    462                                     struct md5_ctx *ctx);
    463 
    464 /* Starting with the result of former calls of this function (or the
    465    initialization function update the context for the next LEN bytes
    466    starting at BUFFER.
    467    It is NOT required that LEN is a multiple of 64.  */
    468 static void md5_process_bytes (const void *buffer, size_t len,
    469                                     struct md5_ctx *ctx);
    470 
    471 /* Process the remaining bytes in the buffer and put result from CTX
    472    in first 16 bytes following RESBUF.  The result is always in little
    473    endian byte order, so that a byte-wise output yields to the wanted
    474    ASCII representation of the message digest.
    475 
    476    IMPORTANT: On some systems it is required that RESBUF is correctly
    477    aligned for a 32 bits value.  */
    478 static void *md5_finish_ctx (struct md5_ctx *ctx, void *resbuf);
    479 
    480 
    481 /* Put result from CTX in first 16 bytes following RESBUF.  The result is
    482    always in little endian byte order, so that a byte-wise output yields
    483    to the wanted ASCII representation of the message digest.
    484 
    485    IMPORTANT: On some systems it is required that RESBUF is correctly
    486    aligned for a 32 bits value.  */
    487 static void *md5_read_ctx (const struct md5_ctx *ctx, void *resbuf);
    488 
    489 #if WORDS_BIGENDIAN
    490 static md5_uint32 swapu32(md5_uint32 n)
    491 {
    492   return (    ((n & 0xffU) << 24) |
    493               ((n & 0xff00U) << 8) |
    494               ((n & 0xff0000U) >> 8) |
    495               ((n & 0xff000000U) >> 24) );
    496 }
    497 #define SWAP(n) swapu32(n)
    498 #else
    499 #define SWAP(n) (n)
    500 #endif
    501 
    502 /* This array contains the bytes used to pad the buffer to the next
    503    64-byte boundary.  (RFC 1321, 3.1: Step 1)  */
    504 static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ...  */  };
    505 
    506 /* Initialize structure containing state of computation.
    507    (RFC 1321, 3.3: Step 3)  */
    508 static void md5_init_ctx(struct md5_ctx *ctx)
    509 {
    510   ctx->A = 0x67452301;
    511   ctx->B = 0xefcdab89;
    512   ctx->C = 0x98badcfe;
    513   ctx->D = 0x10325476;
    514 
    515   ctx->total[0] = ctx->total[1] = 0;
    516   ctx->buflen = 0;
    517 }
    518 
    519 /* Put result from CTX in first 16 bytes following RESBUF.  The result
    520    must be in little endian byte order.
    521 
    522    IMPORTANT: On some systems it is required that RESBUF is correctly
    523    aligned for a 32 bits value.  */
    524 static void *md5_read_ctx(const struct md5_ctx *ctx, void *resbuf)
    525 {
    526   ((md5_uint32 *) resbuf)[0] = SWAP(ctx->A);
    527   ((md5_uint32 *) resbuf)[1] = SWAP(ctx->B);
    528   ((md5_uint32 *) resbuf)[2] = SWAP(ctx->C);
    529   ((md5_uint32 *) resbuf)[3] = SWAP(ctx->D);
    530 
    531   return resbuf;
    532 }
    533 
    534 /* Process the remaining bytes in the internal buffer and the usual
    535    prolog according to the standard and write the result to RESBUF.
    536 
    537    IMPORTANT: On some systems it is required that RESBUF is correctly
    538    aligned for a 32 bits value.  */
    539 static void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
    540 {
    541   /* Take yet unprocessed bytes into account.  */
    542   md5_uint32 bytes = ctx->buflen;
    543   size_t pad;
    544 
    545   /* Now count remaining bytes.  */
    546   ctx->total[0] += bytes;
    547   if (ctx->total[0] < bytes)
    548     ++ctx->total[1];
    549 
    550   pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
    551   memcpy(&ctx->buffer[bytes], fillbuf, pad);
    552 
    553   /* Put the 64-bit file length in *bits* at the end of the buffer.  */
    554   *(md5_uint32 *) & ctx->buffer[bytes + pad] = SWAP(ctx->total[0] << 3);
    555   *(md5_uint32 *) & ctx->buffer[bytes + pad + 4] =
    556     SWAP((ctx->total[1] << 3) | (ctx->total[0] >> 29));
    557 
    558   /* Process last bytes.  */
    559   md5_process_block(ctx->buffer, bytes + pad + 8, ctx);
    560 
    561   return md5_read_ctx(ctx, resbuf);
    562 }
    563 
    564 /* Compute MD5 message digest for LEN bytes beginning at BUFFER.  The
    565    result is always in little endian byte order, so that a byte-wise
    566    output yields to the wanted ASCII representation of the message
    567    digest.  */
    568 void *md5_buffer(const char *buffer, size_t len, void *resblock)
    569 {
    570   struct md5_ctx ctx;
    571 
    572   /* Initialize the computation context.  */
    573   md5_init_ctx(&ctx);
    574 
    575   /* Process whole buffer but last len % 64 bytes.  */
    576   md5_process_bytes(buffer, len, &ctx);
    577 
    578   /* Put result in desired memory area.  */
    579   return md5_finish_ctx(&ctx, resblock);
    580 }
    581 
    582 static void md5_process_bytes(const void *buffer, size_t len, struct md5_ctx *ctx)
    583 {
    584   /* When we already have some bits in our internal buffer concatenate
    585      both inputs first.  */
    586   if (ctx->buflen != 0) {
    587     size_t left_over = ctx->buflen;
    588     size_t add = 128 - left_over > len ? len : 128 - left_over;
    589 
    590     memcpy(&ctx->buffer[left_over], buffer, add);
    591     ctx->buflen += add;
    592 
    593     if (left_over + add > 64) {
    594       md5_process_block(ctx->buffer, (left_over + add) & ~63, ctx);
    595       /* The regions in the following copy operation cannot overlap.  */
    596       memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
    597              (left_over + add) & 63);
    598       ctx->buflen = (left_over + add) & 63;
    599     }
    600 
    601     buffer = (const char *) buffer + add;
    602     len -= add;
    603   }
    604 
    605   /* Process available complete blocks.  */
    606   if (len > 64) {
    607     md5_process_block(buffer, len & ~63, ctx);
    608     buffer = (const char *) buffer + (len & ~63);
    609     len &= 63;
    610   }
    611 
    612   /* Move remaining bytes in internal buffer.  */
    613   if (len > 0) {
    614     memcpy(ctx->buffer, buffer, len);
    615     ctx->buflen = len;
    616   }
    617 }
    618 
    619 /* These are the four functions used in the four steps of the MD5 algorithm
    620    and defined in the RFC 1321.  The first function is a little bit optimized
    621    (as found in Colin Plumbs public domain implementation).  */
    622 /* #define FF(b, c, d) ((b & c) | (~b & d)) */
    623 #define FF(b, c, d) (d ^ (b & (c ^ d)))
    624 #define FG(b, c, d) FF (d, b, c)
    625 #define FH(b, c, d) (b ^ c ^ d)
    626 #define FI(b, c, d) (c ^ (b | ~d))
    627 
    628 /* Process LEN bytes of BUFFER, accumulating context into CTX.
    629    It is assumed that LEN % 64 == 0.  */
    630 static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
    631 {
    632   md5_uint32 correct_words[16];
    633   const md5_uint32 *words = buffer;
    634   size_t nwords = len / sizeof(md5_uint32);
    635   const md5_uint32 *endp = words + nwords;
    636   md5_uint32 A = ctx->A;
    637   md5_uint32 B = ctx->B;
    638   md5_uint32 C = ctx->C;
    639   md5_uint32 D = ctx->D;
    640 
    641   /* First increment the byte count.  RFC 1321 specifies the possible
    642      length of the file up to 2^64 bits.  Here we only compute the
    643      number of bytes.  Do a double word increment.  */
    644   ctx->total[0] += len;
    645   if (ctx->total[0] < len)
    646     ++ctx->total[1];
    647 
    648   /* Process all bytes in the buffer with 64 bytes in each round of
    649      the loop.  */
    650   while (words < endp) {
    651     md5_uint32 *cwp = correct_words;
    652     md5_uint32 A_save = A;
    653     md5_uint32 B_save = B;
    654     md5_uint32 C_save = C;
    655     md5_uint32 D_save = D;
    656 
    657     /* First round: using the given function, the context and a constant
    658        the next context is computed.  Because the algorithms processing
    659        unit is a 32-bit word and it is determined to work on words in
    660        little endian byte order we perhaps have to change the byte order
    661        before the computation.  To reduce the work for the next steps
    662        we store the swapped words in the array CORRECT_WORDS.  */
    663 
    664 #define OP(a, b, c, d, s, T)                                            \
    665       do                                                                \
    666         {                                                               \
    667           a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T;             \
    668           ++words;                                                      \
    669           CYCLIC (a, s);                                                \
    670           a += b;                                                       \
    671         }                                                               \
    672       while (0)
    673 
    674     /* It is unfortunate that C does not provide an operator for
    675        cyclic rotation.  Hope the C compiler is smart enough.  */
    676 #define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
    677 
    678     /* Before we start, one word to the strange constants.
    679        They are defined in RFC 1321 as
    680 
    681        T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
    682     */
    683 
    684     /* Round 1.  */
    685     OP(A, B, C, D, 7, 0xd76aa478);
    686     OP(D, A, B, C, 12, 0xe8c7b756);
    687     OP(C, D, A, B, 17, 0x242070db);
    688     OP(B, C, D, A, 22, 0xc1bdceee);
    689     OP(A, B, C, D, 7, 0xf57c0faf);
    690     OP(D, A, B, C, 12, 0x4787c62a);
    691     OP(C, D, A, B, 17, 0xa8304613);
    692     OP(B, C, D, A, 22, 0xfd469501);
    693     OP(A, B, C, D, 7, 0x698098d8);
    694     OP(D, A, B, C, 12, 0x8b44f7af);
    695     OP(C, D, A, B, 17, 0xffff5bb1);
    696     OP(B, C, D, A, 22, 0x895cd7be);
    697     OP(A, B, C, D, 7, 0x6b901122);
    698     OP(D, A, B, C, 12, 0xfd987193);
    699     OP(C, D, A, B, 17, 0xa679438e);
    700     OP(B, C, D, A, 22, 0x49b40821);
    701     /* For the second to fourth round we have the possibly swapped words
    702        in CORRECT_WORDS.  Redefine the macro to take an additional first
    703        argument specifying the function to use.  */
    704 #undef OP
    705 #define OP(f, a, b, c, d, k, s, T)                                      \
    706       do                                                                \
    707         {                                                               \
    708           a += f (b, c, d) + correct_words[k] + T;                      \
    709           CYCLIC (a, s);                                                \
    710           a += b;                                                       \
    711         }                                                               \
    712       while (0)
    713 
    714     /* Round 2.  */
    715     OP(FG, A, B, C, D, 1, 5, 0xf61e2562);
    716     OP(FG, D, A, B, C, 6, 9, 0xc040b340);
    717     OP(FG, C, D, A, B, 11, 14, 0x265e5a51);
    718     OP(FG, B, C, D, A, 0, 20, 0xe9b6c7aa);
    719     OP(FG, A, B, C, D, 5, 5, 0xd62f105d);
    720     OP(FG, D, A, B, C, 10, 9, 0x02441453);
    721     OP(FG, C, D, A, B, 15, 14, 0xd8a1e681);
    722     OP(FG, B, C, D, A, 4, 20, 0xe7d3fbc8);
    723     OP(FG, A, B, C, D, 9, 5, 0x21e1cde6);
    724     OP(FG, D, A, B, C, 14, 9, 0xc33707d6);
    725     OP(FG, C, D, A, B, 3, 14, 0xf4d50d87);
    726     OP(FG, B, C, D, A, 8, 20, 0x455a14ed);
    727     OP(FG, A, B, C, D, 13, 5, 0xa9e3e905);
    728     OP(FG, D, A, B, C, 2, 9, 0xfcefa3f8);
    729     OP(FG, C, D, A, B, 7, 14, 0x676f02d9);
    730     OP(FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
    731 
    732     /* Round 3.  */
    733     OP(FH, A, B, C, D, 5, 4, 0xfffa3942);
    734     OP(FH, D, A, B, C, 8, 11, 0x8771f681);
    735     OP(FH, C, D, A, B, 11, 16, 0x6d9d6122);
    736     OP(FH, B, C, D, A, 14, 23, 0xfde5380c);
    737     OP(FH, A, B, C, D, 1, 4, 0xa4beea44);
    738     OP(FH, D, A, B, C, 4, 11, 0x4bdecfa9);
    739     OP(FH, C, D, A, B, 7, 16, 0xf6bb4b60);
    740     OP(FH, B, C, D, A, 10, 23, 0xbebfbc70);
    741     OP(FH, A, B, C, D, 13, 4, 0x289b7ec6);
    742     OP(FH, D, A, B, C, 0, 11, 0xeaa127fa);
    743     OP(FH, C, D, A, B, 3, 16, 0xd4ef3085);
    744     OP(FH, B, C, D, A, 6, 23, 0x04881d05);
    745     OP(FH, A, B, C, D, 9, 4, 0xd9d4d039);
    746     OP(FH, D, A, B, C, 12, 11, 0xe6db99e5);
    747     OP(FH, C, D, A, B, 15, 16, 0x1fa27cf8);
    748     OP(FH, B, C, D, A, 2, 23, 0xc4ac5665);
    749 
    750     /* Round 4.  */
    751     OP(FI, A, B, C, D, 0, 6, 0xf4292244);
    752     OP(FI, D, A, B, C, 7, 10, 0x432aff97);
    753     OP(FI, C, D, A, B, 14, 15, 0xab9423a7);
    754     OP(FI, B, C, D, A, 5, 21, 0xfc93a039);
    755     OP(FI, A, B, C, D, 12, 6, 0x655b59c3);
    756     OP(FI, D, A, B, C, 3, 10, 0x8f0ccc92);
    757     OP(FI, C, D, A, B, 10, 15, 0xffeff47d);
    758     OP(FI, B, C, D, A, 1, 21, 0x85845dd1);
    759     OP(FI, A, B, C, D, 8, 6, 0x6fa87e4f);
    760     OP(FI, D, A, B, C, 15, 10, 0xfe2ce6e0);
    761     OP(FI, C, D, A, B, 6, 15, 0xa3014314);
    762     OP(FI, B, C, D, A, 13, 21, 0x4e0811a1);
    763     OP(FI, A, B, C, D, 4, 6, 0xf7537e82);
    764     OP(FI, D, A, B, C, 11, 10, 0xbd3af235);
    765     OP(FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
    766     OP(FI, B, C, D, A, 9, 21, 0xeb86d391);
    767 
    768     /* Add the starting values of the context.  */
    769     A += A_save;
    770     B += B_save;
    771     C += C_save;
    772     D += D_save;
    773   }
    774 
    775   /* Put checksum in context given as argument.  */
    776   ctx->A = A;
    777   ctx->B = B;
    778   ctx->C = C;
    779   ctx->D = D;
    780 }
    781 
    782 
    783 /*----------------------------------------------------------------------------
    784  *--------end of md5.c
    785  *----------------------------------------------------------------------------*/
     434static uint32 md5hinit[4] = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476 };
    786435
    787436 
     
    789438{
    790439        unsigned int i;
    791 
    792         md5_init_ctx(p);
     440        memcpy(p->h, md5hinit, 16);
    793441       
    794442        for (i = 0; i < 16; i += 8)
    795443          {
    796             p->buffer[i]   = 0x00;
    797             p->buffer[i+1] = 0x00;
    798             p->buffer[i+2] = 0x00;
    799             p->buffer[i+3] = 0x00;
    800             p->buffer[i+4] = 0x00;
    801             p->buffer[i+5] = 0x00;
    802             p->buffer[i+6] = 0x00;
    803             p->buffer[i+7] = 0x00;
     444            p->data[i]   = 0x00;
     445            p->data[i+1] = 0x00;
     446            p->data[i+2] = 0x00;
     447            p->data[i+3] = 0x00;
     448            p->data[i+4] = 0x00;
     449            p->data[i+5] = 0x00;
     450            p->data[i+6] = 0x00;
     451            p->data[i+7] = 0x00;
    804452          }
    805453       
     454        /* memset(p->data, 0x00, 64); */
     455        p->offset = (uint8) 0;
     456        p->nblocks = 0;
    806457        return 0;
    807458}
    808459
     460#if defined(__GNUC__) && defined(__i386__)
     461static inline UINT32
     462ROTL32( UINT32 x, int s)
     463{
     464        __asm__("roll %%cl,%0"
     465                :"=r" (x)
     466                :"0" (x),"c" (s));
     467        return x;
     468}
     469#else
     470#define ROTL32(x, s) (((x) << (s)) | ((x) >> (32 - (s))))
     471#endif
     472
     473
     474#define FF(a, b, c, d, w, s, t) \
     475        a += ((b&(c^d))^d) + w + t;     \
     476        a = ROTL32(a, s);       \
     477        a += b;
     478
     479#define GG(a, b, c, d, w, s, t) \
     480        a += ((d&(b^c))^c) + w + t;     \
     481        a = ROTL32(a, s);       \
     482        a += b;
     483
     484#define HH(a, b, c, d, w, s, t) \
     485        a += (b^c^d) + w + t;   \
     486        a = ROTL32(a, s);       \
     487        a += b;
     488
     489#define II(a, b, c, d, w, s, t) \
     490        a += (c^(b|~d)) + w + t;        \
     491        a = ROTL32(a, s);       \
     492        a += b;
     493
     494#if WORDS_BIGENDIAN
     495uint32 swapu32(uint32 n)
     496{
     497        return (    ((n & 0xffU) << 24) |
     498                                ((n & 0xff00U) << 8) |
     499                                ((n & 0xff0000U) >> 8) |
     500                                ((n & 0xff000000U) >> 24) );
     501}
     502#endif
     503
     504static
     505void md5Process(md5Param* p)
     506{
     507        register uint32 a,b,c,d;
     508        register uint32* w;
     509        #if WORDS_BIGENDIAN
     510        register sh_byte t;
     511        #endif
     512
     513        w = p->data;
     514        #if WORDS_BIGENDIAN
     515        t = 16;
     516        while (t--)
     517        {
     518                register uint32 temp = swapu32(*w);
     519                *(w++) = temp;
     520        }
     521        w = p->data;
     522        #endif
     523
     524        a = p->h[0]; b = p->h[1]; c = p->h[2]; d = p->h[3];
     525
     526        FF(a, b, c, d, (*w++),  7, 0xd76aa478);
     527        FF(d, a, b, c, (*w++), 12, 0xe8c7b756);
     528        FF(c, d, a, b, (*w++), 17, 0x242070db);
     529        FF(b, c, d, a, (*w++), 22, 0xc1bdceee);
     530        FF(a, b, c, d, (*w++),  7, 0xf57c0faf);
     531        FF(d, a, b, c, (*w++), 12, 0x4787c62a);
     532        FF(c, d, a, b, (*w++), 17, 0xa8304613);
     533        FF(b, c, d, a, (*w++), 22, 0xfd469501);
     534        FF(a, b, c, d, (*w++),  7, 0x698098d8);
     535        FF(d, a, b, c, (*w++), 12, 0x8b44f7af);
     536        FF(c, d, a, b, (*w++), 17, 0xffff5bb1);
     537        FF(b, c, d, a, (*w++), 22, 0x895cd7be);
     538        FF(a, b, c, d, (*w++),  7, 0x6b901122);
     539        FF(d, a, b, c, (*w++), 12, 0xfd987193);
     540        FF(c, d, a, b, (*w++), 17, 0xa679438e);
     541        FF(b, c, d, a, (*w++), 22, 0x49b40821);
     542
     543        w = p->data;
     544
     545        GG(a, b, c, d, w[ 1],  5, 0xf61e2562);
     546        GG(d, a, b, c, w[ 6],  9, 0xc040b340);
     547        GG(c, d, a, b, w[11], 14, 0x265e5a51);
     548        GG(b, c, d, a, w[ 0], 20, 0xe9b6c7aa);
     549        GG(a, b, c, d, w[ 5],  5, 0xd62f105d);
     550        GG(d, a, b, c, w[10],  9, 0x02441453);
     551        GG(c, d, a, b, w[15], 14, 0xd8a1e681);
     552        GG(b, c, d, a, w[ 4], 20, 0xe7d3fbc8);
     553        GG(a, b, c, d, w[ 9],  5, 0x21e1cde6);
     554        GG(d, a, b, c, w[14],  9, 0xc33707d6);
     555        GG(c, d, a, b, w[ 3], 14, 0xf4d50d87);
     556        GG(b, c, d, a, w[ 8], 20, 0x455a14ed);
     557        GG(a, b, c, d, w[13],  5, 0xa9e3e905);
     558        GG(d, a, b, c, w[ 2],  9, 0xfcefa3f8);
     559        GG(c, d, a, b, w[ 7], 14, 0x676f02d9);
     560        GG(b, c, d, a, w[12], 20, 0x8d2a4c8a);
     561
     562        HH(a, b, c, d, w[ 5],  4, 0xfffa3942);
     563        HH(d, a, b, c, w[ 8], 11, 0x8771f681);
     564        HH(c, d, a, b, w[11], 16, 0x6d9d6122);
     565        HH(b, c, d, a, w[14], 23, 0xfde5380c);
     566        HH(a, b, c, d, w[ 1],  4, 0xa4beea44);
     567        HH(d, a, b, c, w[ 4], 11, 0x4bdecfa9);
     568        HH(c, d, a, b, w[ 7], 16, 0xf6bb4b60);
     569        HH(b, c, d, a, w[10], 23, 0xbebfbc70);
     570        HH(a, b, c, d, w[13],  4, 0x289b7ec6);
     571        HH(d, a, b, c, w[ 0], 11, 0xeaa127fa);
     572        HH(c, d, a, b, w[ 3], 16, 0xd4ef3085);
     573        HH(b, c, d, a, w[ 6], 23, 0x04881d05);
     574        HH(a, b, c, d, w[ 9],  4, 0xd9d4d039);
     575        HH(d, a, b, c, w[12], 11, 0xe6db99e5);
     576        HH(c, d, a, b, w[15], 16, 0x1fa27cf8);
     577        HH(b, c, d, a, w[ 2], 23, 0xc4ac5665);
     578
     579        II(a, b, c, d, w[ 0],  6, 0xf4292244);
     580        II(d, a, b, c, w[ 7], 10, 0x432aff97);
     581        II(c, d, a, b, w[14], 15, 0xab9423a7);
     582        II(b, c, d, a, w[ 5], 21, 0xfc93a039);
     583        II(a, b, c, d, w[12],  6, 0x655b59c3);
     584        II(d, a, b, c, w[ 3], 10, 0x8f0ccc92);
     585        II(c, d, a, b, w[10], 15, 0xffeff47d);
     586        II(b, c, d, a, w[ 1], 21, 0x85845dd1);
     587        II(a, b, c, d, w[ 8],  6, 0x6fa87e4f);
     588        II(d, a, b, c, w[15], 10, 0xfe2ce6e0);
     589        II(c, d, a, b, w[ 6], 15, 0xa3014314);
     590        II(b, c, d, a, w[13], 21, 0x4e0811a1);
     591        II(a, b, c, d, w[ 4],  6, 0xf7537e82);
     592        II(d, a, b, c, w[11], 10, 0xbd3af235);
     593        II(c, d, a, b, w[ 2], 15, 0x2ad7d2bb);
     594        II(b, c, d, a, w[ 9], 21, 0xeb86d391);
     595
     596        p->h[0] += a;
     597        p->h[1] += b;
     598        p->h[2] += c;
     599        p->h[3] += d;
     600}
     601
    809602int md5Update(md5Param* p, const sh_byte* data, int size)
    810603{
    811   md5_process_bytes(data, size, p);
    812   return 0;
    813 }
    814 
    815 static void md5Finish(md5Param* p, void *resblock)
    816 {
    817   (void) md5_finish_ctx(p, resblock);
    818 }
    819 
    820 int md5Digest(md5Param* p, md5_uint32* data)
    821 {
    822         md5Finish(p, data);
     604        register int proclength;
     605
     606        while (size > 0)
     607        {
     608          proclength = (((int)p->offset + size) > 64) ?
     609            (64 - (int)p->offset) : size;
     610          memcpy(((sh_byte *) p->data) + p->offset, data, (size_t) proclength);
     611          size -= proclength;
     612          data += proclength;
     613          p->offset += proclength;
     614         
     615          if (p->offset == (uint8) 64)
     616            {
     617              md5Process(p);
     618              p->offset = (uint8) 0;
     619              p->nblocks++;
     620            }
     621        }
     622        return 0;
     623}
     624
     625static void md5Finish(md5Param* p)
     626{
     627        uint32 t, msb, lsb;
     628        uint8 * pp;
     629        register uint8 *ptr;
     630
     631        msb = 0;
     632        t = p->nblocks;
     633        if( (lsb = t << 6) < t ) /* multiply by 64 to make a byte count */
     634          msb++;
     635        msb += t >> 26;
     636        t = lsb;
     637        if( (lsb = t + (uint32)p->offset) < t ) /* add the count */
     638          msb++;
     639        t = lsb;
     640        if( (lsb = t << 3) < t ) /* multiply by 8 to make a bit count */
     641          msb++;
     642        msb += t >> 29;
     643
     644        ptr = ((uint8 *) p->data) + p->offset++;
     645
     646 
     647        *(ptr++) = (uint8) 0x80;
     648
     649        if (p->offset > (uint8)56)
     650        {
     651                while (p->offset++ < 64)
     652                        *(ptr++) = 0;
     653
     654                md5Process(p);
     655                p->offset = 0;
     656        }
     657
     658        ptr = ((uint8 *) p->data) + p->offset;
     659        while (p->offset++ < 56)
     660                *(ptr++) = 0;
     661
     662        /* append the 64 bit count */
     663        *(ptr++) = lsb     ;
     664        *(ptr++) = lsb >>  8;
     665        *(ptr++) = lsb >> 16;
     666        *(ptr++) = lsb >> 24;
     667        *(ptr++) = msb     ;
     668        *(ptr++) = msb >>  8;
     669        *(ptr++) = msb >> 16;
     670        *(ptr++) = msb >> 24;
     671
     672        md5Process(p);
     673
     674        pp = (uint8 *) p->data;
     675#ifdef WORDS_BIGENDIAN
     676#define X(a) do { *pp++ = (*p).a; *pp++ = (*p).a >> 8;      \
     677                  *pp++ = (*p).a >> 16; *pp++ = (*p).a >> 24; } while(0)
     678#else /* little endian */
     679    /*#define X(a) do { *(uint32*)p = p->##a ; p += 4; } while(0)*/
     680    /* Unixware's cpp doesn't like the above construct so we do it his way:
     681     * (reported by Allan Clark) */
     682#define X(a) do { *(uint32*)pp = (*p).a ; pp += 4; } while(0)
     683#endif
     684        X(h[0]);
     685        X(h[1]);
     686        X(h[2]);
     687        X(h[3]);
     688#undef X
     689
     690        p->offset = 0;
     691}
     692
     693int md5Digest(md5Param* p, uint32* data)
     694{
     695        md5Finish(p);
     696        memcpy(data, p->h, 16);
    823697        (void) md5Reset(p);
    824698        return 0;
    825699}
    826700/*@+type@*/
    827 
    828701
    829702/* Compute MD5 message digest for bytes read from STREAM.  The
     
    835708  /* Important: BLOCKSIZE must be a multiple of 64.  */
    836709  static const int BLOCKSIZE = 8192;
    837   struct md5_ctx ctx;
     710  md5Param ctx;
    838711  char buffer[8264]; /* BLOCKSIZE + 72  AIX compiler chokes */
    839   size_t sum;
    840 
     712  off_t sum = 0;
    841713  SL_TICKET  fd;
    842714  char * tmp;
     
    925797       BLOCKSIZE % 64 == 0
    926798    */
    927     md5_process_block(buffer, BLOCKSIZE, &ctx);
     799    (void) md5Update(&ctx, (sh_byte*) buffer, BLOCKSIZE);
    928800    sh.statistics.bytes_hashed += BLOCKSIZE;
    929801
     
    944816  if (sum > 0)
    945817    {
    946       md5_process_bytes(buffer, sum, &ctx);
     818      (void) md5Update(&ctx, (sh_byte*) buffer, (int) sum);
    947819      sh.statistics.bytes_hashed += BLOCKSIZE;
    948820    }
     
    15201392}
    15211393
    1522 int sh_tiger_hashtype (const char * c)
     1394int sh_tiger_hashtype (char * c)
    15231395{
    15241396  SL_ENTER( _("sh_tiger_hashtype"));
     
    15881460  if (res != NULL)
    15891461    {
     1462      /*@-bufferoverflowhigh -formatconst@*/
    15901463#if defined(TIGER_64_BIT)
    1591       sl_snprintf(out,
    1592                   sizeof(out),
    1593                   MYFORMAT,
    1594                   (sh_word32)(res[0]>>32),
    1595                   (sh_word32)(res[0]),
    1596                   (sh_word32)(res[1]>>32),
    1597                   (sh_word32)(res[1]),
    1598                   (sh_word32)(res[2]>>32),
    1599                   (sh_word32)(res[2]) );
     1464      sprintf(out,                                   /* known to fit  */
     1465              MYFORMAT,
     1466              (sh_word32)(res[0]>>32),
     1467              (sh_word32)(res[0]),
     1468              (sh_word32)(res[1]>>32),
     1469              (sh_word32)(res[1]),
     1470              (sh_word32)(res[2]>>32),
     1471              (sh_word32)(res[2]) );
    16001472#else
    1601       sl_snprintf(out,
    1602                   sizeof(out),
    1603                   MYFORMAT,
    1604                   (sh_word32)(res[1]),
    1605                   (sh_word32)(res[0]),
    1606                   (sh_word32)(res[3]),
    1607                   (sh_word32)(res[2]),
    1608                   (sh_word32)(res[5]),
    1609                   (sh_word32)(res[4]) );
    1610 #endif
    1611       out[sizeof(out)-1] = '\0';
     1473      sprintf(out,                                   /* known to fit  */
     1474              MYFORMAT,
     1475              (sh_word32)(res[1]),
     1476              (sh_word32)(res[0]),
     1477              (sh_word32)(res[3]),
     1478              (sh_word32)(res[2]),
     1479              (sh_word32)(res[5]),
     1480              (sh_word32)(res[4]) );
     1481#endif
     1482      /*@+bufferoverflowhigh@*/
     1483      out[KEY_LEN] = '\0';
    16121484      SL_RETURN( out, _("sh_tiger_hash_internal"));
    16131485
     
    16351507  if (res != NULL)
    16361508    {
     1509      /*@-bufferoverflowhigh -formatconst@*/
    16371510#if defined(TIGER_64_BIT)
    1638       sl_snprintf(outhash,
    1639                   sizeof(outhash),
    1640                   GPGFORMAT,
    1641                   (sh_word32)(res[0]>>32),
    1642                   (sh_word32)(res[0]),
    1643                   (sh_word32)(res[1]>>32),
    1644                   (sh_word32)(res[1]),
    1645                   (sh_word32)(res[2]>>32),
    1646                   (sh_word32)(res[2]) );
     1511      sprintf(outhash,                               /* known to fit  */
     1512              GPGFORMAT,
     1513              (sh_word32)(res[0]>>32),
     1514              (sh_word32)(res[0]),
     1515              (sh_word32)(res[1]>>32),
     1516              (sh_word32)(res[1]),
     1517              (sh_word32)(res[2]>>32),
     1518              (sh_word32)(res[2]) );
    16471519#else
    1648       sl_snprintf(outhash,
    1649                   sizeof(outhash),
    1650                   GPGFORMAT,
    1651                   (sh_word32)(res[1]),
    1652                   (sh_word32)(res[0]),
    1653                   (sh_word32)(res[3]),
    1654                   (sh_word32)(res[2]),
    1655                   (sh_word32)(res[5]),
    1656                   (sh_word32)(res[4]) );
    1657 #endif
    1658       outhash[sizeof(outhash)-1] = '\0';
     1520      sprintf(outhash,                               /* known to fit  */
     1521              GPGFORMAT,
     1522              (sh_word32)(res[1]),
     1523              (sh_word32)(res[0]),
     1524              (sh_word32)(res[3]),
     1525              (sh_word32)(res[2]),
     1526              (sh_word32)(res[5]),
     1527              (sh_word32)(res[4]) );
     1528#endif
     1529      /*@+bufferoverflowhigh@*/
     1530      outhash[48 + 6] = '\0';
    16591531    }
    16601532  else
    16611533    {
    1662       sl_strlcpy(outhash,
    1663                  _("00000000 00000000 00000000  00000000 00000000 00000000"),
    1664                  sizeof(outhash));
     1534      /*@-bufferoverflowhigh@*/
     1535      sprintf(outhash,                               /* known to fit  */
     1536              _("00000000 00000000 00000000  00000000 00000000 00000000"));
     1537      /*@+bufferoverflowhigh@*/
    16651538    }
    16661539
  • /trunk/src/sh_tools.c

    r30 r20  
    127127  unsigned char c, d;
    128128  const  char * p;
     129  char   *q;
    129130  char   tmp[4];
    130131  char * outstr;
     
    146147
    147148  p = instr;
     149  q = outstr;
    148150
    149151#if !defined(SH_USE_XML)
     
    439441int DoReverseLookup = S_TRUE;
    440442
    441 int set_reverse_lookup (const char * c)
     443int set_reverse_lookup (char * c)
    442444{
    443445  return sh_util_flagval(c, &DoReverseLookup);
     
    460462
    461463  int    retval;
    462   size_t len;
    463464
    464465  sin_cache * check_cache = conn_cache;
     
    534535                  else
    535536                    {
    536                       len = sl_strlen(host_entry->h_name) + 1;
    537                       host_name = SH_ALLOC(len);
    538                       if (len > 1)
    539                         sl_strlcpy(host_name, host_entry->h_name, len);
     537                      host_name = SH_ALLOC(sl_strlen(host_entry->h_name) + 1);
     538                      if (sl_strlen(host_entry->h_name) > 0)
     539                        strcpy(host_name,                /* known to fit  */
     540                               host_entry->h_name);
    540541                      else
    541542                        host_name[0] = '\0';
     
    693694}
    694695
    695 #if defined(HAVE_NTIME) || defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     696#if defined(HAVE_NTIME) || defined(SH_WITH_CLIENT)
    696697static
    697698int sh_write_select(int type, int sockfd,
     
    713714   */
    714715  new_act.sa_handler = SIG_IGN;
    715   sigemptyset( &new_act.sa_mask );         /* set an empty mask       */
    716   new_act.sa_flags = 0;                    /* init sa_flags           */
    717716  sigaction (SIGPIPE, &new_act, &old_act);
    718717 
     
    840839#endif
    841840
    842 #if defined (SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     841#if defined (SH_WITH_CLIENT)
    843842unsigned long write_port (int sockfd, char *buf, unsigned long nbytes,
    844843                          int * w_error, int timeout)
     
    860859#endif
    861860
    862 #if defined(HAVE_NTIME) || defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     861#if defined(HAVE_NTIME) || defined(SH_WITH_CLIENT)
    863862
    864863unsigned long read_port (int sockfd, char *buf, unsigned long nbytes,
     
    896895#endif
    897896
    898 #if defined (SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     897#if defined (SH_WITH_CLIENT)
    899898
    900899int check_request (char * have, char * need)
     
    950949#endif
    951950
    952 #if defined (SH_WITH_CLIENT) || defined (SH_WITH_SERVER)
     951#if defined (SH_WITH_CLIENT)
    953952
    954953void get_header (unsigned char * head, unsigned long * bytes, char * u)
     
    10301029 * (msg_size = payload_size - key_len = payload_size - 48)
    10311030 */
    1032 
    1033 /*
    1034  * only SH_V2_FULLSIZE is used, and only once
    1035  */
    1036 #if 0
    10371031#ifdef SH_WITH_SERVER
    10381032#define SH_V2_FULLSIZE  240
     
    10441038#define SH_V2_MESSAGE   960
    10451039#endif
    1046 #endif
    1047 #define SH_V2_FULLSIZE 1024
    10481040
    10491041#ifdef SH_ENCRYPT
     
    13881380#endif
    13891381
    1390 #if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     1382#if defined (SH_WITH_CLIENT)
    13911383
    13921384/* verify the checksum of a buffer; checksum comes first
     
    15401532#endif
    15411533
    1542 #if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER) || defined(SH_STEALTH) || defined(WITH_GPG) || defined(WITH_PGP)
     1534#if defined(SH_WITH_CLIENT) || defined(SH_STEALTH) || defined(WITH_GPG) || defined(WITH_PGP)
    15431535
    15441536/* --------- secure temporary file ------------ */
  • /trunk/src/sh_unix.c

    r30 r20  
    127127unsigned long mask_USER0        = MASK_USER_;
    128128unsigned long mask_USER1        = MASK_USER_;
    129 unsigned long mask_USER2        = MASK_USER_;
    130 unsigned long mask_USER3        = MASK_USER_;
    131 unsigned long mask_USER4        = MASK_USER_;
    132129unsigned long mask_ALLIGNORE    = MASK_ALLIGNORE_;
    133130unsigned long mask_ATTRIBUTES   = MASK_ATTRIBUTES_;
     
    145142  mask_USER0        = MASK_USER_;
    146143  mask_USER1        = MASK_USER_;
    147   mask_USER2        = MASK_USER_;
    148   mask_USER3        = MASK_USER_;
    149   mask_USER4        = MASK_USER_;
    150144  mask_ALLIGNORE    = MASK_ALLIGNORE_;
    151145  mask_ATTRIBUTES   = MASK_ATTRIBUTES_;
     
    313307    *p = '0' + (u % 10);
    314308    u /= 10;
    315   } while (u && (p != str));
    316   if ((iisneg == 1) && (p != str)) {
     309  } while (u);
     310  if (iisneg == 1) {
    317311    --p;
    318312    *p = '-';
     
    329323extern int OnlyStderr;
    330324
    331 int safe_logger (int signal, int method, char * details)
     325int safe_logger (int signal, int method, pid_t thepid)
    332326{
    333327  int i = 0;
     
    337331  char  str[128];
    338332  char  * p;
    339  
     333
    340334  char l0[64], l1[64], l2[64], l3[64];
    341335  char a0[32], a1[32], a2[32];
    342336  char e0[128];
    343337  char msg[128];
    344  
     338
    345339  char * locations[] = { NULL, NULL, NULL, NULL, NULL };
    346340  char * envp[]      = { NULL, NULL };
    347341  char * argp[]      = { NULL, NULL, NULL, NULL, NULL };
    348  
    349   pid_t  thepid = getpid();
    350  
     342
    351343  if ((sh.flag.isdaemon == S_FALSE) || (OnlyStderr == S_TRUE))
    352344    method = 1;
    353  
     345
    354346  /* seems that solaris cc needs this way of initializing ...
    355347   */
     
    358350  locations[2] = l2;
    359351  locations[3] = l3;
    360  
     352
    361353  envp[0] = e0;
    362  
     354
    363355  argp[0] = a0;
    364356  argp[1] = a1;
    365357  argp[2] = a2;
    366  
     358
     359  strcpy (l0, _("/usr/bin/logger"));                   /* known to fit  */
     360  strcpy (l1, _("/usr/sbin/logger"));                  /* known to fit  */
     361  strcpy (l2, _("/usr/ucb/logger"));                   /* known to fit  */
     362  strcpy (l3, _("/bin/logger"));                       /* known to fit  */
     363
     364  strcpy (a0, _("logger"));                            /* known to fit  */
     365  strcpy (a1, _("-p"));                                /* known to fit  */
     366  strcpy (a2, _("daemon.alert"));                      /* known to fit  */
     367
     368  strcpy (e0,                                          /* known to fit  */
     369          _("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ucb:/usr/local/bin"));
     370
    367371  sl_strlcpy(msg, _("samhain["), 128);
    368372  p = safe_itoa((int) thepid, str, 128);
     
    371375  if (signal == 0)
    372376    {
    373       if (details == NULL) {
    374         sl_strlcat(msg, _("]: out of memory"), 128);
    375       } else {
    376         sl_strlcat(msg, _("]: "), 128);
    377         sl_strlcat(msg, details, 128);
    378       }
     377      sl_strlcat(msg, _("]: out of memory"), 128);
    379378    }
    380379  else
     
    394393    return 0;
    395394  }
    396 
    397   sl_strlcpy (l0, _("/usr/bin/logger"), 64);
    398   sl_strlcpy (l1, _("/usr/sbin/logger"), 64);
    399   sl_strlcpy (l2, _("/usr/ucb/logger"), 64);
    400   sl_strlcpy (l3, _("/bin/logger"), 64);
    401 
    402   sl_strlcpy (a0, _("logger"), 32);
    403   sl_strlcpy (a1, _("-p"), 32);
    404   sl_strlcpy (a2, _("daemon.alert"), 32);
    405 
    406   sl_strlcpy (e0,
    407               _("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ucb:/usr/local/bin"),
    408               128);
    409 
    410395  while (locations[i] != NULL) {
    411396    status = stat(locations[i], &buf);
     
    429414}
    430415
    431 void safe_fatal (int signal, int method, char * details,
    432                 char * file, int line)
    433 {
    434   char msg[128];
    435   char str[128];
    436   char * p;
    437   p = safe_itoa((int) line, str, 128);
    438   sl_strlcpy(msg, _("FATAL: "), 128);
    439   sl_strlcat(msg, file, 128);
    440   sl_strlcat(msg, ": ", 128);
    441   if (p && (*p)) {
    442     sl_strlcat(msg, p   , 128);
    443     sl_strlcat(msg, ": ", 128);
    444   }
    445   sl_strlcat(msg, details, 128);
    446   safe_logger (signal, method, msg);
    447   _exit(EXIT_FAILURE);
    448 }
    449416
    450417extern char sh_sig_msg[64];
     
    484451        {
    485452          chdir ("/");
    486           safe_logger (mysignal, 0, NULL);
     453          safe_logger (mysignal, 0, getpid());
    487454        }
    488455      _exit(mysignal);
     
    537504    memset (skey, '\0', sizeof(sh_key_t));
    538505  if (immediate_exit_fast < 2)
    539     safe_logger (mysignal, 0, NULL);
     506    safe_logger (mysignal, 0, getpid());
    540507  _exit(mysignal);
    541508#else
     
    551518      close_ipc ();
    552519#endif
    553       safe_logger (mysignal, 0, NULL);
     520      safe_logger (mysignal, 0, getpid());
    554521      chdir ("/");
    555522      raise(SIGFPE);
     
    852819/* checksum the own binary
    853820 */
    854 int sh_unix_self_hash (const char * c)
     821int sh_unix_self_hash (char * c)
    855822{
    856823  char message[512];
     
    924891
    925892/* added    Tue Feb 22 10:36:44 NFT 2000 Rainer Wichmann            */
    926 static int tf_add_trusted_user_int(const char * c)
     893static int tf_add_trusted_user_int(char * c)
    927894{
    928895  register struct passwd *          w;
     
    952919}
    953920
    954 int tf_add_trusted_user(const char * c)
     921int tf_add_trusted_user(char * c)
    955922{
    956923  int    i;
     
    12621229  char ** env1;
    12631230  int   envlen = 0;
    1264   size_t len;
    12651231
    12661232  SL_ENTER(_("sh_unix_copyenv"));
     
    12821248  envlen = 0;
    12831249
    1284   while (env0 != NULL && env0[envlen] != NULL) {
    1285     len = strlen(env0[envlen]) + 1;
    1286     env1[envlen] = malloc (len); /* only once */
     1250  while (env0 != NULL && env0[envlen] != NULL) {
     1251    env1[envlen] = malloc (strlen(env0[envlen]) + 1); /* only once */
    12871252    if (env1[envlen] == NULL)
    12881253      {
     
    12901255        SL_RET0(_("sh_unix_copyenv"));
    12911256      }
    1292     sl_strlcpy(env1[envlen], env0[envlen], len);
     1257    strcpy(env1[envlen], env0[envlen]);                /* known to fit  */
    12931258    ++envlen;
    12941259  }
     
    14511416#include <arpa/inet.h>
    14521417
    1453 char * sh_unix_h_name (struct hostent * host_entry)
    1454 {
    1455         char ** p;
    1456         if (strchr(host_entry->h_name, '.')) {
    1457                 return host_entry->h_name;
    1458         } else {
    1459                 for (p = host_entry->h_aliases; *p; ++p) {
    1460                         if (strchr(*p, '.'))
    1461                                 return *p;
    1462                 }
    1463         }
    1464         return host_entry->h_name;
    1465 }
    1466 
    14671418/* uname() on FreeBSD is broken, because the 'nodename' buf is too small
    14681419 * to hold a valid (leftmost) domain label.
     
    14841435
    14851436  (void) uname (&buf);
    1486   /* flawfinder: ignore */ /* ff bug, ff sees system() */
     1437
    14871438  sl_strlcpy (sh.host.system,  buf.sysname, SH_MINIBUF);
    14881439  sl_strlcpy (sh.host.release, buf.release, SH_MINIBUF);
     
    15351486  else
    15361487    {
    1537       sl_strlcpy (sh.host.name, sh_unix_h_name(he1), SH_PATHBUF);
     1488      sl_strlcpy (sh.host.name, he1->h_name, SH_PATHBUF);
    15381489    }
    15391490 
     
    15831534  if (he1 != NULL)
    15841535    {
    1585       sl_strlcpy (sh.host.name, sh_unix_h_name(he1), SH_PATHBUF);
     1536      sl_strlcpy (sh.host.name, he1->h_name, SH_PATHBUF);
    15861537    }
    15871538  else
     
    16881639          aud_exit(FIL__, __LINE__, EXIT_FAILURE);
    16891640        }
    1690       /* flawfinder: ignore */
    16911641      return (chroot(chroot_dir));
    16921642    }
     
    19731923}
    19741924
    1975 int sh_unix_settimeserver (const char * address)
     1925int sh_unix_settimeserver (char * address)
    19761926{
    19771927
     
    21462096/* whether to use localtime for file timesatams in logs
    21472097 */
    2148 int sh_unix_uselocaltime (const char * c)
     2098int sh_unix_uselocaltime (char * c)
    21492099{
    21502100  int i;
     
    27822732}
    27832733
    2784 int sh_unix_set_io_limit (const char * c)
     2734int sh_unix_set_io_limit (char * c)
    27852735{
    27862736  long val;
     
    28222772  if (tmpFile.size < fbuf->st_size)
    28232773    {
    2824       sl_strlcpy(fileHash,
    2825                 sh_tiger_generic_hash (filename, TIGER_FD, tmpFile.size,
    2826                                        alert_timeout),
    2827                 KEY_LEN+1);
     2774      strcpy(fileHash,                         /* known to fit */
     2775             sh_tiger_generic_hash (filename, TIGER_FD, tmpFile.size,
     2776                                    alert_timeout));
    28282777
    28292778      /* return */
     
    28322781
    28332782 out:
    2834   sl_strlcpy(fileHash,
    2835              _("000000000000000000000000000000000000000000000000"),
    2836              KEY_LEN+1);
     2783  strcpy(fileHash,                              /* known to fit */
     2784         _("000000000000000000000000000000000000000000000000"));
    28372785  SL_RETURN( -1, _("sh_unix_checksum_size"));
    28382786}
     
    29552903    {
    29562904      if (fileHash != NULL)
    2957         sl_strlcpy(fileHash,
    2958                    _("000000000000000000000000000000000000000000000000"),
    2959                    KEY_LEN+1);
     2905        strcpy(fileHash,                              /* known to fit */
     2906               _("000000000000000000000000000000000000000000000000"));
    29602907    }
    29612908 
     
    29732920          if ((theFile->check_mask & MODI_CHK) == 0)
    29742921            {
    2975               sl_strlcpy(fileHash,
    2976                          _("000000000000000000000000000000000000000000000000"),
    2977                          KEY_LEN+1);
     2922              strcpy(fileHash,                         /* known to fit */
     2923                     _("000000000000000000000000000000000000000000000000"));
    29782924            }
    29792925          else if ((theFile->check_mask & MODI_PREL) != 0 &&
     
    29832929              if (0 != sh_prelink_run (theFile->fullpath,
    29842930                                       fileHash, alert_timeout))
    2985                 sl_strlcpy(fileHash,
    2986                            _("000000000000000000000000000000000000000000000000"),
    2987                            KEY_LEN+1);
     2931                strcpy(fileHash,                       /* known to fit */
     2932                       _("000000000000000000000000000000000000000000000000"));
    29882933            }
    29892934          else
    29902935            {
    29912936              tiger_fd = rval_open;
    2992               sl_strlcpy(fileHash,
    2993                          sh_tiger_generic_hash (theFile->fullpath,
    2994                                                 TIGER_FD, 0,
    2995                                                 alert_timeout),
    2996                          KEY_LEN+1);
     2937              strcpy(fileHash,                         /* known to fit */
     2938                     sh_tiger_generic_hash (theFile->fullpath, TIGER_FD, 0,
     2939                                            alert_timeout));
    29972940              if ((theFile->check_mask & MODI_SGROW) != 0)
    29982941                {
     
    30172960          if ((theFile->check_mask & MODI_CHK) == 0)
    30182961            {
    3019               sl_strlcpy(fileHash,
    3020                          _("000000000000000000000000000000000000000000000000"),
    3021                          KEY_LEN+1);
     2962              strcpy(fileHash,                         /* known to fit */
     2963                     _("000000000000000000000000000000000000000000000000"));
    30222964            }
    30232965          else if (policy == SH_LEVEL_PRELINK &&
     
    30272969              if (0 != sh_prelink_run (theFile->fullpath,
    30282970                                       fileHash, alert_timeout))
    3029                 sl_strlcpy(fileHash,
    3030                            _("000000000000000000000000000000000000000000000000"),
    3031                            KEY_LEN+1);
     2971                strcpy(fileHash,                       /* known to fit */
     2972                       _("000000000000000000000000000000000000000000000000"));
    30322973            }
    30332974          else
     
    32043145      linknamebuf = SH_ALLOC(PATH_MAX);
    32053146
    3206       /* flawfinder: ignore */
    32073147      linksize    = readlink (theFile->fullpath, linknamebuf, PATH_MAX-1);
    32083148
     
    32203160          SH_FREE(tmp2);
    32213161          SH_FREE(linknamebuf);
    3222           theFile->linkpath[0] = '-';
    3223           theFile->linkpath[1] = '\0';
    32243162          SL_RETURN((-1),_("sh_unix_getinfo"));
    32253163        }
     
    40443982    {
    40453983#ifdef WITH_TPT
    4046       sl_snprintf(str, sizeof(str), _("file: %s line: %d page: %d"),
     3984      sl_snprintf(str, 128, _("file: %s line: %d page: %d"),
    40473985                  page_list->file, page_list->line, i+1);
    40483986      sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, i, MSG_E_SUBGEN,
     
    40523990      ++i;
    40533991    }
    4054   sl_snprintf(str, sizeof(str), _("%d pages locked"), i);
     3992  sl_snprintf(str, 128, _("%d pages locked"), i);
    40553993  sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, i, MSG_E_SUBGEN,
    40563994                  str, _("sh_unix_count_mlock"));
  • /trunk/src/sh_userfiles.c

    r30 r20  
    221221    else if ( strstr(s, "user0")     != NULL ) new->level = SH_LEVEL_USER0;
    222222    else if ( strstr(s, "user1")     != NULL ) new->level = SH_LEVEL_USER1;
    223     else if ( strstr(s, "user2")     != NULL ) new->level = SH_LEVEL_USER2;
    224     else if ( strstr(s, "user3")     != NULL ) new->level = SH_LEVEL_USER3;
    225     else if ( strstr(s, "user4")     != NULL ) new->level = SH_LEVEL_USER4;
    226223    else if ( strstr(s, "prelink")   != NULL ) new->level = SH_LEVEL_PRELINK;
    227224    else            /* The default */          new->level = default_level;
     
    335332                    (void) sh_files_pushfile_user1(filepath);
    336333                    break;
    337                 case SH_LEVEL_USER2:
    338                     (void) sh_files_pushfile_user2(filepath);
    339                     break;
    340                 case SH_LEVEL_USER3:
    341                     (void) sh_files_pushfile_user3(filepath);
    342                     break;
    343                 case SH_LEVEL_USER4:
    344                     (void) sh_files_pushfile_user4(filepath);
    345                     break;
    346334                case SH_LEVEL_PRELINK:
    347335                    (void) sh_files_pushfile_prelink(filepath);
  • /trunk/src/sh_utils.c

    r30 r20  
    189189}
    190190
    191 int sh_util_hidesetup(const char * c)
     191int sh_util_hidesetup(char * c)
    192192{
    193193  int i;
     
    205205  SL_ENTER(_("sh_util_strdup"));
    206206
    207   SH_VALIDATE_NE(str, NULL);
    208 
    209   len = sl_strlen(str);
    210   p   = SH_ALLOC (len + 1);
    211   (void) sl_strlcpy (p, str, len+1);
    212 
     207  if (str != NULL)
     208    {
     209      len = sl_strlen(str);
     210      p   = SH_ALLOC (len + 1);
     211      (void) sl_strlcpy (p, str, len+1);
     212    }
    213213  SL_RETURN( p, _("sh_util_strdup"));
    214214}
     
    224224  ret = *str;
    225225
    226   SH_VALIDATE_NE(ret, NULL);
     226  if (ret == NULL) {
     227    SL_RETURN(ret, _("sh_util_strsep"));
     228  }
    227229
    228230  for (c = *str; *c != '\0'; c++) {
     
    644646static int sigtype = TYPE_HMAC;
    645647
    646 int sh_util_sigtype (const char * c)
     648int sh_util_sigtype (char * c)
    647649{
    648650  SL_ENTER(_("sh_util_sigtype"));
     
    955957  char * key;
    956958  char * path;
    957   char * outpath = NULL;
     959  char * outpath;
    958960  unsigned char * image = NULL;
    959961  long s = 0;
     
    961963  long ii, k = 0;
    962964  UINT32    * h1;
    963   char * new = NULL;
     965  char * new;
    964966
    965967  if (0 != sl_is_suid())
     
    997999      fprintf(stderr,
    9981000              _("ERROR: no path to executable given\n Argument must be 'key@path'\n"));
    999       free(new);
    10001001      _exit (EXIT_FAILURE);
    10011002      /*@notreached@*/
     
    10041005  else
    10051006    path = &new[j];
    1006 
    1007   len = strlen(path) + 1 + 4;
    10081007  /*@-usedef@*/
    1009   if (NULL == (outpath = malloc(len)))
     1008  if (NULL == (outpath = malloc(strlen(path) + 1 + 4)))
    10101009    goto bail_mem;
    10111010  /*@-usedef@*/
    1012   sl_snprintf (outpath, len, _("%s.out"), path);
     1011  /*@-bufferoverflowhigh@*/
     1012  sprintf (outpath, _("%s.out"), path);               /* known to fit  */
     1013  /*@+bufferoverflowhigh@*/
    10131014
    10141015  fp = sl_open_read(path, SL_NOPRIV);
     
    10171018      fprintf(stderr,
    10181019              _("ERROR: cannot open %s for read (errnum = %ld)\n"), path, fp);
    1019       free(new); free (outpath);
    10201020      _exit (EXIT_FAILURE);
    10211021      /*@notreached@*/
     
    10281028      fprintf(stderr,
    10291029              _("ERROR: cannot open %s (errnum = %ld)\n"), outpath, fout);
    1030       free(new); free (outpath);
    10311030      _exit (EXIT_FAILURE);
    10321031      /*@notreached@*/
     
    10691068          (void) sl_close (fout);
    10701069          printf(_("new file %s written\n"), outpath);
    1071           free(new); free (outpath); free(image);
    10721070          _exit (EXIT_SUCCESS);
    10731071          /*@notreached@*/
     
    10781076  fprintf(stderr,
    10791077          _("ERROR: old key not found\n"));
    1080   free(new); free (outpath); free(image);
    10811078  _exit (EXIT_FAILURE);
    10821079  /*@notreached@*/
     
    10871084  fprintf(stderr,
    10881085          _("ERROR: out of memory\n"));
    1089   if (new) free(new);
    1090   if (outpath) free (outpath);
    1091   if (image) free (image);
    10921086  _exit (EXIT_FAILURE);
    10931087  /*@notreached@*/
     
    13351329static unsigned char sh_obscure_index[256];
    13361330
    1337 int sh_util_obscure_ok (const char * str)
     1331int sh_util_obscure_ok (char * str)
    13381332{
    13391333  unsigned long   i;
    1340   char * endptr = NULL;
    1341 
    1342   SL_ENTER(_("sh_util_obscure_ok"));
     1334  char * endptr = str;
     1335
     1336  SL_ENTER(_("sh_util_obscure_ex"));
    13431337
    13441338  if (0 == sl_strncmp("all", str, 3))
     
    13481342          sh_obscure_index[i] = (unsigned char)1;
    13491343        }
    1350       SL_RETURN(0, _("sh_util_obscure_ok"));
     1344      SL_RETURN(0, _("sh_util_obscure_ex"));
    13511345    }
    13521346
     
    13551349      sh_obscure_index[i] = (unsigned char)0;
    13561350    }
    1357 
    1358   i = strtoul (str, &endptr, 0);
    1359   if (i > 255)
    1360     {
    1361       SL_RETURN(-1, _("sh_util_obscure_ok"));
    1362     }
    1363   sh_obscure_index[i] = (unsigned char)1;
    1364   if (*endptr == ',')
    1365     ++endptr;
    13661351
    13671352  while (*endptr != '\0')
     
    13701355      if (i > 255)
    13711356        {
    1372           SL_RETURN(-1, _("sh_util_obscure_ok"));
     1357          SL_RETURN(-1, _("sh_util_obscure_ex"));
    13731358        }
    13741359      sh_obscure_index[i] = (unsigned char)1;
     
    13761361        ++endptr;
    13771362    }
    1378   SL_RETURN(0, _("sh_util_obscure_ok"));
     1363  SL_RETURN(0, _("sh_util_obscure_ex"));
    13791364}
    13801365
    13811366int sh_util_obscurename (ShErrLevel level, char * name_orig, int flag)
    13821367{
    1383   unsigned char * name = (unsigned char *) name_orig;
     1368  char * name = name_orig;
    13841369  char * safe;
    13851370  unsigned int i;
     
    13931378  while (*name != '\0')
    13941379    {
    1395       if ( (*name) >  0x7F || (*name) == '"'  || (*name) == '\t' ||
     1380      if ( (*name) == '"'  || (*name) == '\t' ||
    13961381           (*name) == '\b' || (*name) == '\f' ||
    13971382           (*name) == '\n' || (*name) == '\r' ||
     
    15771562    } else if (!isgraph ((int) *p)) {    /* not printable    */
    15781563      /*@-bufferoverflowhigh -formatconst@*/
    1579       /* flawfinder: ignore */
    15801564      sprintf(oct, format, '\\',                 /* known to fit  */
    15811565              (unsigned char) *p);
  • /trunk/src/sh_utmp.c

    r30 r20  
    331331{
    332332  SL_ENTER(_("sh_utmp_endutent"));
    333   if (NULL != sh_utmpfile)
    334     (void) fclose(sh_utmpfile);
     333  (void) fclose(sh_utmpfile);
    335334  sh_utmpfile = NULL;
    336335  SL_RET0(_("sh_utmp_endutent"));
  • /trunk/src/slib.c

    r30 r20  
    231231  if (flag == 1)
    232232    {
    233       sl_snprintf    (val, 81, _("\n---------  %10s "), file);
     233      sprintf        (val, _("\n---------  %10s "), file);
    234234      sl_strlcpy     (msg,    val,   80);
    235       sl_snprintf    (val, 81, _(" --- %6d ---------\n"), line);
     235      sprintf        (val, _(" --- %6d ---------\n"), line);
    236236      sl_strlcat     (msg,     val,   80);
    237237      sh_log_console (msg);
     
    577577
    578578#if !defined(HOST_IS_I86SOLARIS)
    579 #if !defined (_GNU_SOURCE) && !defined(__linux__)
    580 /* flawfinder: ignore */
     579#if !defined (_GNU_SOURCE)
    581580extern int vsnprintf ( char *str, size_t n,
    582581                       const char *format, va_list ap );
     
    778777
    779778#if defined(HAVE_VSNPRINTF) && !defined(HAVE_BROKEN_VSNPRINTF)
    780   len = vsnprintf (str, n, format, vl);                /* flawfinder: ignore */
     779  len = vsnprintf (str, n, format, vl);
    781780  str[n-1] = '\0';
    782781#else
    783   VA_COPY (vl2, vl);                     /* save the argument list           */
     782  VA_COPY (vl2, vl);                   /* save the argument list           */
    784783  total = sl_printf_count (format, vl);
    785   len = (int) total;
     784  len   = (int) total;
    786785  if (total < n)
    787786    {
    788       /* flawfinder: ignore */
    789787      vsprintf (str, format, vl2);       /* program has checked that it fits */
    790788      str[n-1] = '\0';
     
    806804 * ENULL:  src || format == NULL
    807805 * ERANGE: n out of range
    808  * ETRUNC: truncated (unimplemented)
     806 * ETRUNC: truncated
    809807 */
    810808int sl_snprintf(char *str, size_t n,
     
    823821  va_start (vl, format);
    824822#if defined(HAVE_VSNPRINTF) && !defined(HAVE_BROKEN_VSNPRINTF)
    825   /* flawfinder: ignore */
    826823  vsnprintf (str, n, format, vl);
    827824  str[n-1] = '\0';
     
    831828  if (total < n)
    832829    {
    833       /* flawfinder: ignore */
    834830      vsprintf (str, format, vl2);     /* program has checked that it fits */
    835831      str[n-1] = '\0';
     
    15721568SL_TICKET sl_make_ticket (int fd, char * filename)
    15731569{
    1574   size_t    len;
    15751570  SL_TICKET ticket;
    15761571  SL_ENTER(_("sl_make_ticket"));
     
    15921587    }
    15931588
    1594   len = sl_strlen(filename)+1;
    1595 
    1596   if ( (ofiles[fd]->path = (char *) malloc(len) ) == NULL)
     1589   if ( (ofiles[fd]->path = (char *) malloc( strlen(filename)+1) ) == NULL)
    15971590    {
    15981591      free(ofiles[fd]);
     
    16121605    }
    16131606
    1614   sl_strlcpy (ofiles[fd]->path, filename, len);
     1607  strcpy (ofiles[fd]->path, filename);                    /* Known to fit  */
    16151608  ofiles[fd]->ticket = ticket;
    16161609  ofiles[fd]->fd     = fd;
     
    16531646  int           fd;
    16541647  int           sflags;
    1655   size_t        len;
    16561648  SL_TICKET     ticket;
    16571649 
     
    18281820    }
    18291821
    1830   len = sl_strlen(filename)+1;
    1831 
    1832   if ( (ofiles[fd]->path = (char *) malloc(len) ) == NULL)
     1822   if ( (ofiles[fd]->path = (char *) malloc( strlen(filename)+1) ) == NULL)
    18331823    {
    18341824      free(ofiles[fd]);
     
    18501840    }
    18511841
    1852   sl_strlcpy (ofiles[fd]->path, filename, len);
     1842  strcpy (ofiles[fd]->path, filename);                    /* Known to fit  */
    18531843  ofiles[fd]->ticket = ticket;
    18541844  ofiles[fd]->fd     = fd;
     
    19841974    {
    19851975      TPT((0, FIL__, __LINE__,
    1986            _("msg=<Error closing file.>, path=<%s>, fd=<%d>, err=<%s>\n"),
    1987            ofiles[fd]->path, fd, strerror(errno)));
     1976           _("msg=<Error closing file.>, path=<%s>, fd=<%d>\n"),
     1977           ofiles[fd]->path, fd));
    19881978    }
    19891979
  • /trunk/src/yulectl.c

    r30 r20  
    300300  if (0 != good)
    301301    {
    302       fprintf (stderr, _("ERROR: Bounced message != original message (possible reason: superfluous password).\n"));
     302      fprintf (stderr, _("ERROR: Bounced message != original message.\n"));
    303303      return -1;
    304304    }
     
    321321  printf(_("          transfer to the client <client_hostname> when\n"));
    322322  printf(_("          this client connects to deliver a message.\n\n"));
    323   printf(_("          If password is required, it is read from\n"));
    324   printf(_("          $HOME/.yulectl_cred or taken from the environment\n"));
    325   printf(_("          variable YULECTL_PASSWORD (not recommended).\n\n"));
    326323
    327324  printf(_("Commands: RELOAD    <reload configuration>\n"));
     
    340337  FILE * fp;
    341338  struct passwd * pwent;
    342   char * pw;
    343 
    344   pw = getenv(_("YULECTL_PASSWORD"));
    345   if (pw && strlen(pw) < 15)
    346     {
    347       strcpy(password, pw);
    348       strcpy(message2, password);
    349       goto do_msg;
    350     }
     339
    351340 
    352341  pwent = getpwuid(geteuid());
     
    399388      exit(EXIT_FAILURE);
    400389    }
    401   if (strlen(message2) > 14)
     390  if (strlen(message2) > 15)
    402391    {
    403392      fprintf (stderr,
     
    411400    }
    412401  strcpy(password, message2);
     402  strcat(message2, "@");
    413403  fclose(fp);
    414  do_msg:
    415   strcat(message2, "@");
    416404
    417405  strncat(message2, message, SH_MAXMSG - strlen(message2) -1);
  • /trunk/test/test.sh

    r30 r20  
    11#! /bin/sh
    2 
    3 #
    4 # Copyright Rainer Wichmann (2006)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    21 
    22 # -----------------------------------------------------------------------
    23 # Be Bourne compatible
    24 # -----------------------------------------------------------------------
    25 
    26 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
    27   emulate sh
    28   NULLCMD=:
    29 elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
    30   set -o posix
    31 fi
    32 
    33 # -----------------------------------------------------------------------
    34 # Make sure we support functions (from the autoconf manual)
    35 # -----------------------------------------------------------------------
    36 
    37 TSHELL="${TSHELL-/bin/sh}"
    38 if test x"$1" = "x--re-executed"
    39 then
    40     shift
    41 elif "$TSHELL" -c 'foo () { (exit 0); exit 0; }; foo' >/dev/null 2>&1
    42 then
    43     :
    44 else
    45     for cmd in sh bash ash bsh ksh zsh sh5; do
    46         X="$PATH:/bin:/usr/bin:/usr/afsws/bin:/usr/ucb:/usr/xpg4/bin";
    47         OLD_IFS=${IFS}
    48         IFS=':'; export IFS
    49         for dir in $X; do
    50             shell="$dir/$cmd"
    51             if (test -f "$shell" || test -f "$shell.exe")
    52             then
    53                 if "$shell" -c  'foo () { (exit 0); exit 0; }; foo' >/dev/null 2>&1
    54                 then
    55                     TSHELL="$shell"; export TSHELL
    56                     IFS=${OLD_IFS}; export IFS
    57                     exec "$shell" "$0" --re-executed ${1+"$@"}
    58                 fi
    59             fi
    60         done
    61         IFS=${OLD_IFS}; export IFS
    62     done
    63     echo "-----------------------------------------------------------------"
    64     echo "ERROR: Unable to locate a shell interpreter with function support" >&2
    65     echo "-----------------------------------------------------------------"
    66     { (exit 1); exit 1; }
    67 fi
    68 
    69 # -----------------------------------------------------------------------
    70 # Make sure we support 'let' (from the autoconf manual)
    71 # -----------------------------------------------------------------------
    72 
    73 TSHELL="${TSHELL-/bin/sh}"
    74 if test x"$1" = "x--re-run"
    75 then
    76     shift
    77 elif "$TSHELL" -c 'a=5; let "a = a + 5"' >/dev/null 2>&1
    78 then
    79     :
    80 else
    81     for cmd in sh bash ash bsh ksh zsh sh5; do
    82         X="$PATH:/bin:/usr/bin:/usr/afsws/bin:/usr/ucb:/usr/xpg4/bin";
    83         OLD_IFS=${IFS}
    84         IFS=':'; export IFS
    85         for dir in $X; do
    86             shell="$dir/$cmd"
    87             if (test -f "$shell" || test -f "$shell.exe")
    88             then
    89                 if "$shell" -c  'foo () { (exit 0); exit 0; }; foo' >/dev/null 2>&1
    90                 then
    91                     if "$shell" -c  'a=5; let "a = a + 5"' >/dev/null 2>&1
    92                     then
    93                         TSHELL="$shell"; export TSHELL
    94                         IFS=${OLD_IFS}; export IFS
    95                         exec "$shell" "$0" --re-run ${1+"$@"}
    96                     fi
    97                 fi
    98             fi
    99         done
    100         IFS=${OLD_IFS}; export IFS
    101     done
    102     echo "-----------------------------------------------------------------"
    103     echo "ERROR: Unable to locate a shell interpreter with support for 'let'" >&2
    104     echo "-----------------------------------------------------------------"
    105     { (exit 1); exit 1; }
    106 fi
    107 
    108 
    109 umask 0022
    1102
    1113isok=`test -t 1 2>&1 | wc -c`
     
    14840    echo "  ${S}test.sh  6${E}  -- Controlling the daemon"
    14941    echo "  ${S}test.sh  7${E}  -- GnuPG signed files / prelude log"
    150     echo "  ${S}test.sh  8${E}  -- Suidcheck"
    15142
    15243    echo "  ${S}test.sh 10${E}  -- Test c/s init/check      (testrc_2.in)"
     
    15546    echo "  ${S}test.sh 13${E}  -- Test full c/s w/mysql    (testrc_2.in)"
    15647    echo "  ${S}test.sh 14${E}  -- Test full c/s w/postgres (testrc_2.in)"
    157     echo "  ${S}test.sh all${E} -- All tests"
    158 }
    159 scripts () {
     48    echo "  ${S}test.sh all${E} -- All except 12+"
     49   
    16050    echo
    161     echo "Scripts used by tests:"
     51    echo "Scripts used by tests (located in ${SCRIPTDIR}):"
    16252    echo "  (1) testcompile.sh (2) testhash.sh     (3) testrun_1.sh   (4) testrun_1a.sh"
    163     echo "  (5) testext.sh     (6) testtimesrv.sh  (7) testrun_1b.sh  (8) testrun_1c.sh"
    164     echo " (10) testrun_2.sh  (11) testrun_2a.sh  (12) testrun_2b.sh (13) testrun_2c.sh"
    165     echo " (14) testrun_2d.sh"
     53    echo "  (5) testext.sh     (6) testtimesrv.sh  (7) testrun_1b.sh (10) testrun_2.sh"
     54    echo " (11) testrun_2a.sh (12) testrun_2b.sh  (13) testrun_2c.sh (14) testrun_2d.sh"
    16655}
    16756
     
    17564cleanup=on
    17665doall=
    177 usevalgrind=
    17866
    17967while [ $# -gt 0 ]
     
    18169    case "$1" in
    18270        -h|--help)     usage; exit 0;;
    183         --scripts)     usage; scripts; exit 0;;
    18471        -v|--verbose)  verbose=on; quiet= ;;
    18572        -q|--quiet)    quiet=on; verbose= ;;
     
    18774        --no-cleanup) cleanup= ;;
    18875        --really-all) doall=on;;
    189         --valgrind) usevalgrind=on;;
    19076        --srcdir=*)    TOP_SRCDIR=`echo $1 | sed s,--srcdir=,,`; export TOP_SRCDIR;;
    19177        --color=*)     
     
    274160
    275161PW_DIR=`pwd`; export PW_DIR
    276 
    277 #
    278 # group/world writeable will cause problems
    279 #
    280 chmod go-w .
    281162#
    282163#
     
    401282    rm -f testrc_1.dyn
    402283    rm -f testrc_2
    403     rm -f testrc_22
    404284    rm -f ./.samhain_file
    405285    rm -f ./.samhain_log*
    406     rm -f ./.samhain_lock*
    407     test -d testrun_testdata && chmod -R 0700 testrun_testdata
    408     test -d .quarantine && rm -rf .quarantine
    409     rm -rf testrun_testdata
     286    rm -f ./.samhain_lock
     287    test -d testrun_data && chmod -R 0700 testrun_data
     288    rm -rf testrun_data
    410289    rm -f test_log_db
    411290    rm -f test_log_prelude
    412     rm -f test_log_valgrind*
    413     rm -f test_log_yulectl
    414     rm -f yule.html
    415     rm -f yule.html2
    416291}
    417292
     
    455330        tmp="localhost"
    456331    fi
    457     #
    458     # first one is hostname, others are aliases
    459     #
    460     tmp2=`cat /etc/hosts | egrep "^ *[0123456789].* $tmp" | awk '{ print $2 }'`
    461     if [ -z "$tmp2" ]; then
    462         echo "$tmp"
    463     else
    464         echo "$tmp2"
    465     fi
     332    echo "$tmp"
    466333}
    467334
     
    474341    hostname="127.0.0.1"
    475342fi
    476 
    477 # Seems that 'valgrind' causes random hangs :-(
    478 #
    479 if [ -z "$usevalgrind" ]; then
    480     VALGRIND=
    481 else
    482     VALGRIND=`find_path valgrind`;
    483 fi
    484 [ -z "$VALGRIND" ] || {
    485     VALGRIND="$VALGRIND --quiet --tool=memcheck --suppressions=.test.supp";
    486     export VALGRIND;
    487     [ -z "$verbose" ] || log_msg_ok "using valgrind"
    488 cat > ".test.supp" <<End-of-data
    489 #
    490 # there are unitialized bytes in the struct...
    491 #
    492 {
    493    pushdata_01
    494    Memcheck:Param
    495    write(buf)
    496    obj:/lib/ld-*.so
    497    fun:sh_hash_pushdata
    498    fun:sh_files_filecheck
    499    fun:sh_dirs_chk
    500 }
    501 {
    502    pushdata_02
    503    Memcheck:Param
    504    write(buf)
    505    obj:/lib/ld-*.so
    506    fun:sh_hash_pushdata
    507    fun:sh_files_filecheck
    508    fun:sh_files_checkdir
    509 }
    510 {
    511    pushdata_03
    512    Memcheck:Param
    513    write(buf)
    514    obj:/lib/ld-*.so
    515    fun:sh_hash_pushdata
    516    fun:sh_hash_writeout
    517    fun:main
    518 }
    519 
    520 End-of-data
    521 }
    522343
    523344if test x$1 = x1; then
     
    564385    exit $?
    565386fi
    566 if test x$1 = x8; then
    567     . ${SCRIPTDIR}/testrun_1.sh
    568     . ${SCRIPTDIR}/testrun_1c.sh
    569     testrun1c
    570     print_summary
    571     exit $?
    572 fi
    573387if test x$1 = x10; then
    574388    . ${SCRIPTDIR}/testrun_2.sh
     
    620434    . ${SCRIPTDIR}/testrun_1b.sh
    621435    let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
    622     . ${SCRIPTDIR}/testrun_1c.sh
    623     let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
    624436    . ${SCRIPTDIR}/testrun_2.sh
    625437    let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
     
    659471    MAXTEST=${TEST_MAX}; export MAXTEST
    660472    testrun1b
    661     #
    662     . ${SCRIPTDIR}/testrun_1.sh
    663     . ${SCRIPTDIR}/testrun_1c.sh
    664     MAXTEST=${TEST_MAX}; export MAXTEST
    665     testrun1c
    666473    #
    667474    . ${SCRIPTDIR}/testrun_2.sh
  • /trunk/test/testcompile.sh

    r30 r20  
    11#! /bin/sh
    22
    3 #
    4 # Copyright Rainer Wichmann (2006)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    21 
    22 MAXTEST=57; export MAXTEST
    23 
    24 run_flawfinder ()
    25 {
    26     flawfinder --minlevel=3 --quiet src/s*.c | \
    27         egrep '^No hits found.' >/dev/null 2>&1
    28     if [ $? -eq 0 ]; then
    29         [ -z "$quiet" ] &&     log_ok   $2 ${MAXTEST} "$TEST";
    30     else
    31         flawfinder --minlevel=3 --quiet src/s*.c >test_log 2>&1
    32         [ -z "$quiet" ] && log_fail $2 ${MAXTEST} "$TEST";
    33         return 1
    34     fi
    35 }
    36 
    37 run_smatch ()
    38 {
    39     export CDIR=`pwd`;
    40 
    41     if [ -z "$doall" ]; then
    42         [ -z "$quiet" ] && log_skip $2 ${MAXTEST} "$TEST (smatch)";
    43         return 0
    44     fi
    45 
    46     if [ "x$3" = "xdebug" ]; then memcheck=debug; else memcheck=simple; fi
    47     if [ -f ../sm_scripts/smatch.pm ]; then
    48         (
    49             cd ../sm_scripts;
    50            
    51             for i in ${CDIR}/*.c.sm ; do
    52                 # echo $i;
    53                 cat $i | ./unreached_code.pl;
    54                 cat $i | ./ampersand_missing.sh;
    55                 cat $i | ./uninitialized.pl;
    56                 cat $i | ./eqeq.pl;
    57                 cat $i | ./for_bounds.pl;
    58                 cat $i | ./unchecked_returns.pl;
    59                 cat $i | ./unreached_code.pl;
    60                 cat $i | ./uninitialized.pl;
    61                 # from http://people.redhat.com/mstefani/wine/smatch/
    62                 if [ -f ./while_for_check.pl ]; then
    63                     cat $i | ./while_for_check.pl;
    64                 fi
    65                 # --> end wine <--
    66                 # samhain specific
    67                 if [ $memcheck = xsimple ]; then
    68                     if [ -f ./samhain_unfree.pl ]; then
    69                         cat $i | ./samhain_unfree.pl | \
    70                             egrep -v 'x_cutest_.*Test_' | \
    71                             egrep -v 'x_sh_unix.c .... .... sh_unix_copyenv';
    72                     fi
    73                 fi
    74                 if [ $memcheck = xdebug ]; then
    75                     if [ -f ./samhain_unfree_debug.pl ]; then
    76                         cat $i | ./samhain_unfree_debug.pl | \
    77                             egrep -v 'x_cutest_.*Test_' | \
    78                             egrep -v 'x_sh_unix.c .... .... sh_unix_copyenv';
    79                     fi
    80                 fi
    81                 # --> end samhain specific <--
    82                 #cat $i | ./unfree.pl | \
    83                 #    egrep -v 'x_cutest_.*Test_' | \
    84                 #    grep -v 'x_sh_unix.c .... .... sh_unix_copyenv';
    85                 touch list_null_funcs_uniq;
    86                 cat $i | ./deference_check.pl;
    87                 rm -f list_null_funcs_uniq;
    88                 rm -f $i
    89             done
    90         ) >test_log_smatch 2>&1
    91         if [ -f test_log_smatch ]; then
    92             lines=`cat test_log_smatch | wc -l`
    93             if [ $lines -ne 0 ]; then
    94                 cat test_log_smatch
    95                 rm -f test_log_smatch
    96                 [ -z "$quiet" ] && log_fail $2 ${MAXTEST} "$TEST (smatch)";
    97                 return 1
    98             fi
    99         fi
    100         [ -z "$quiet" ] && log_ok $2 ${MAXTEST} "$TEST (smatch)";
    101         return 0
    102     fi
    103     [ -z "$quiet" ] && log_skip $2 ${MAXTEST} "$TEST (smatch)";
    104     return 0
    105 }
     3MAXTEST=28; export MAXTEST
    1064
    1075testmake ()
     
    1108        if test x$1 = x0; then
    1119                [ -z "$verbose" ]     ||  log_msg_ok  "configure...  $TEST";
    112                 $MAKE ${SMATCH} cutest > /dev/null 2>> test_log
     10                $MAKE cutest > /dev/null 2>> test_log
    11311                if test x$? = x0; then
    11412                    [ -z "$verbose" ] || log_msg_ok   "make cutest... $TEST";
     
    13634        log_start "COMPILE"
    13735
    138         if [ -f /usr/local/gcc-smatch/bin/gcc ]; then
    139             SAVE_CC="${CC}"
    140             SMATCH="DBGDEF=--smatch"; export SMATCH
    141             CC="/usr/local/gcc-smatch/bin/gcc"; export CC
    142         fi
    143 
    14436        num=0
    14537        numfail=0
    14638
    14739        #
    148         # test flawfinder
    149         #
    150         TEST="${S}check w/flawfinder${E}"
    151         #
    152         #
    153         let "num = num + 1" >/dev/null
    154         FLAWFINDER=`find_path flawfinder`
    155         #
    156         if [ -z "$FLAWFINDER" ]; then
    157             log_skip $num $MAXTEST 'check w/flawfinder (not in PATH)'
    158         else
    159             run_flawfinder 0 $num || let "numfail = numfail + 1"  >/dev/null
    160         fi
    161         #
    162 
    163         #
    16440        # test standalone compilation
    16541        #
    166         TEST="${S}standalone w/suidcheck${E}"
     42        TEST="${S}standalone agent w/suidcheck${E}"
    16743        #
    16844        if test -r "Makefile"; then
     
    17450        let "num = num + 1" >/dev/null
    17551        testmake $? $num || let "numfail = numfail + 1"  >/dev/null
    176         let "num = num + 1" >/dev/null
    177         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    17852
    17953        #
    18054        # test standalone compilation
    18155        #
    182         TEST="${S}standalone w/mounts-check w/userfiles${E}"
     56        TEST="${S}standalone agent w/mounts-check and w/userfiles${E}"
    18357        #
    18458        if test -r "Makefile"; then
     
    19064        let "num = num + 1" >/dev/null
    19165        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    192         let "num = num + 1" >/dev/null
    193         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    19466
    19567
     
    19769        # test standalone compilation
    19870        #
    199         TEST="${S}standalone w/timeserver and w/msgqueue${E}"
     71        TEST="${S}standalone agent w/timeserver and w/message-queue${E}"
    20072        #
    20173        if test -r "Makefile"; then
     
    20779        let "num = num + 1" >/dev/null
    20880        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    209         let "num = num + 1" >/dev/null
    210         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    21181
    21282        #
    21383        # test standalone compilation with --with-nocl=PW
    21484        #
    215         TEST="${S}standalone w/nocl${E}"
     85        TEST="${S}standalone agent w/nocl${E}"
    21686        #
    21787        if test -r "Makefile"; then
     
    22393        let "num = num + 1" >/dev/null
    22494        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    225         let "num = num + 1" >/dev/null
    226         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    22795
    22896        #
    22997        # test standalone compilation w/ debug
    23098        #
    231         TEST="${S}standalone w/debug${E}"
     99        TEST="${S}standalone agent w/debug${E}"
    232100        #
    233101        if test -r "Makefile"; then
     
    239107        let "num = num + 1" >/dev/null
    240108        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    241         let "num = num + 1" >/dev/null
    242         run_smatch $? $num debug || let "numfail = numfail + 1"  >/dev/null
    243109
    244110        #
    245111        # test standalone compilation w/ gpg
    246112        #
    247         TEST="${S}standalone w/gpg${E}"
     113        TEST="${S}standalone agent w/gpg${E}"
    248114        #
    249115        GPG=`find_path gpg`
     
    252118        if [ -z "$GPG" ]; then
    253119            log_skip $num $MAXTEST 'gpg not in PATH'
    254             let "num = num + 1" >/dev/null
    255120        else
    256121            if test -r "Makefile"; then
     
    261126            #
    262127            testmake $? $num || let "numfail = numfail + 1" >/dev/null
    263             let "num = num + 1" >/dev/null
    264             run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    265128        fi
    266129
     
    268131        # test standalone compilation w/stealth
    269132        #
    270         TEST="${S}standalone w/stealth${E}"
     133        TEST="${S}standalone agent w/stealth${E}"
    271134        #
    272135        if test -r "Makefile"; then
     
    278141        let "num = num + 1" >/dev/null
    279142        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    280         let "num = num + 1" >/dev/null
    281         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    282143
    283144        #
    284145        # test standalone compilation w/logwatch
    285146        #
    286         TEST="${S}standalone w/login-watch${E}"
     147        TEST="${S}standalone agent w/login-watch${E}"
    287148        #
    288149        if test -r "Makefile"; then
     
    294155        let "num = num + 1" >/dev/null
    295156        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    296         let "num = num + 1" >/dev/null
    297         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    298157
    299158        #
    300159        # test standalone compilation w/mysql
    301160        #
    302         TEST="${S}standalone w/mysql${E}"
     161        TEST="${S}standalone agent w/mysql${E}"
    303162        #
    304163        if test -r "Makefile"; then
     
    310169        let "num = num + 1" >/dev/null
    311170        testmake $? $num "skip" || let "numfail = numfail + 1" >/dev/null
    312         let "num = num + 1" >/dev/null
    313         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    314171
    315172        #
    316173        # test standalone compilation w/postgresql
    317174        #
    318         TEST="${S}standalone w/postgresql${E}"
     175        TEST="${S}standalone agent w/postgresql${E}"
    319176        #
    320177        if test -r "Makefile"; then
     
    326183        let "num = num + 1" >/dev/null
    327184        testmake $? $num "skip" || let "numfail = numfail + 1" >/dev/null
    328         let "num = num + 1" >/dev/null
    329         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    330185
    331186        #
    332187        # test standalone compilation
    333188        #
    334         TEST="${S}standalone w/o mail${E}"
     189        TEST="${S}standalone agent w/o mail${E}"
    335190        #
    336191        if test -r "Makefile"; then
     
    342197        let "num = num + 1" >/dev/null
    343198        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    344         let "num = num + 1" >/dev/null
    345         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    346199
    347200        #
    348201        # test standalone compilation
    349202        #
    350         TEST="${S}standalone w/o external${E}"
     203        TEST="${S}standalone agent w/o external scripts${E}"
    351204        #
    352205        if test -r "Makefile"; then
     
    358211        let "num = num + 1" >/dev/null
    359212        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    360         let "num = num + 1" >/dev/null
    361         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    362213
    363214        # echo; echo "${S}__ TEST CLIENT/SERVER __${E}"; echo;
     
    376227        let "num = num + 1" >/dev/null
    377228        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    378         let "num = num + 1" >/dev/null
    379         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    380229       
    381230        if test -r "Makefile"; then
     
    387236        let "num = num + 1" >/dev/null
    388237        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    389         let "num = num + 1" >/dev/null
    390         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    391238
    392239        #
     
    400247        if [ -z "$GPG" ]; then
    401248            log_skip $num $MAXTEST 'gpg not in PATH'
    402             let "num = num + 3" >/dev/null
     249            let "num = num + 1" >/dev/null
     250            log_skip $num $MAXTEST 'gpg not in PATH'
    403251        else
    404252            if test -r "Makefile"; then
     
    409257            #
    410258            testmake $? $num || let "numfail = numfail + 1" >/dev/null
    411             let "num = num + 1" >/dev/null
    412             run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    413259            #
    414260            if test -r "Makefile"; then
     
    420266            let "num = num + 1" >/dev/null
    421267            testmake $? $num || let "numfail = numfail + 1" >/dev/null
    422             let "num = num + 1" >/dev/null
    423             run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    424268        fi
    425269
     
    438282        let "num = num + 1" >/dev/null
    439283        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    440         let "num = num + 1" >/dev/null
    441         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    442284        #
    443285        if test -r "Makefile"; then
     
    449291        let "num = num + 1" >/dev/null
    450292        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    451         let "num = num + 1" >/dev/null
    452         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    453293
    454294        #
     
    465305        let "num = num + 1" >/dev/null
    466306        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    467         let "num = num + 1" >/dev/null
    468         run_smatch $? $num debug || let "numfail = numfail + 1"  >/dev/null
    469307        #
    470308        if test -r "Makefile"; then
     
    476314        let "num = num + 1" >/dev/null
    477315        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    478         let "num = num + 1" >/dev/null
    479         run_smatch $? $num debug || let "numfail = numfail + 1"  >/dev/null
    480316
    481317        #
     
    492328        let "num = num + 1" >/dev/null
    493329        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    494         let "num = num + 1" >/dev/null
    495         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    496330        #
    497331        if test -r "Makefile"; then
     
    503337        let "num = num + 1" >/dev/null
    504338        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    505         let "num = num + 1" >/dev/null
    506         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    507339
    508340        #
     
    519351        let "num = num + 1" >/dev/null
    520352        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    521         let "num = num + 1" >/dev/null
    522         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    523353        #
    524354        if test -r "Makefile"; then
     
    530360        let "num = num + 1" >/dev/null
    531361        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    532         let "num = num + 1" >/dev/null
    533         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    534362
    535363        #
     
    546374        let "num = num + 1" >/dev/null
    547375        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    548         let "num = num + 1" >/dev/null
    549         run_smatch $? $num debug || let "numfail = numfail + 1"  >/dev/null
    550376        #
    551377        if test -r "Makefile"; then
     
    557383        let "num = num + 1" >/dev/null
    558384        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    559         let "num = num + 1" >/dev/null
    560         run_smatch $? $num debug || let "numfail = numfail + 1"  >/dev/null
    561385
    562386        #
    563387        # test client/server compilation
    564388        #
    565         TEST="${S}client/server application w/o external${E}"
     389        TEST="${S}client/server application w/o external scripts${E}"
    566390        #
    567391        if test -r "Makefile"; then
     
    573397        let "num = num + 1" >/dev/null
    574398        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    575         let "num = num + 1" >/dev/null
    576         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    577399        #
    578400        if test -r "Makefile"; then
     
    584406        let "num = num + 1" >/dev/null
    585407        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    586         let "num = num + 1" >/dev/null
    587         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    588 
    589         [ -z "${SMATCH}" ] || { CC="${SAVE_CC}"; export CC; }
    590408
    591409        log_end "COMPILE"
  • /trunk/test/testext.sh

    r30 r20  
    11#! /bin/sh
    2 
    3 #
    4 # Copyright Rainer Wichmann (2006)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    212
    223MAXTEST=1; export MAXTEST
     
    5839        if test x$? = x0; then
    5940            [ -z "$verbose" ] ||     log_msg_ok "configure...";
    60             $MAKE  >/dev/null 2>>test_log
     41            $MAKE  > /dev/null
    6142            if test x$? = x0; then
    6243                [ -z "$verbose" ] || log_msg_ok "make...";
     
    9879        rm -f $PW_DIR/pdbg.child
    9980        rm -f $PW_DIR/pdbg.main
    100         ./samhain -p none
     81        ./samhain -p none 
    10182   
    10283        # The shell is too fast ...
  • /trunk/test/testhash.sh

    r30 r20  
    11#! /bin/sh
    2 
    3 #
    4 # Copyright Rainer Wichmann (2006)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    212
    223RCFILE="$PW_DIR/testrc_1.dyn";  export RCFILE
  • /trunk/test/testrc_2.in

    r30 r20  
    130130
    131131SetUseSocket = yes
    132 SetSocketAllowUid=0
    133 SetSocketPassword=samhain
    134132
    135133SetClientFromAccept = yes
  • /trunk/test/testrun_1.sh

    r30 r20  
    11#! /bin/sh
    2 
    3 #
    4 # Copyright Rainer Wichmann (2006)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    212
    223RCFILE="$PW_DIR/testrc_1.dyn";  export RCFILE
     
    4122testrun1_setup=0
    4223
    43 MAXTEST=11; export MAXTEST
     24MAXTEST=10; export MAXTEST
    4425
    4526test_dirs () {
     
    6546        fi
    6647    done
    67 }
    68 
    69 #
    70 # combine file check schedule with one-shot mode
    71 #
    72 TESTPOLICY_11="
    73 [ReadOnly]
    74 dir=99${BASE}
    75 "
    76 
    77 mod_testdata_11 () {
    78     sleep 1
    79     echo "foobar" >"${BASE}/c/x"; # bad
    80     chmod 0555  "${BASE}/a/y";    # bad
    81     ORIGINAL='SetFilecheckTime=60'
    82     REPLACEMENT='FileCheckScheduleOne = 6 12 * * *'
    83     ex $RCFILE <<EOF
    84 %s/${ORIGINAL}/${REPLACEMENT}/g
    85 wq
    86 EOF
    87 }
    88 
    89 chk_testdata_11 () {
    90     # CDIRS="a b c a/a a/b a/c a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c";
    91     tmp=`grep CRIT $LOGFILE | wc -l`
    92     if [ $tmp -ne 2 ]; then
    93         [ -z "$verbose" ] || log_msg_fail "policy count";
    94         return 1
    95     fi
    96     egrep "CRIT.*POLICY \[ReadOnly\] C-------TS.*${BASE}/c/x" $LOGFILE >/dev/null 2>&1
    97     if [ $? -ne 0 ]; then
    98         [ -z "$verbose" ] || log_msg_fail "${BASE}/c/x";
    99         return 1
    100     fi
    101     egrep "CRIT.*POLICY \[ReadOnly\] -----M--T-.*${BASE}/a/y" $LOGFILE >/dev/null 2>&1
    102     if [ $? -ne 0 ]; then
    103         [ -z "$verbose" ] || log_msg_fail "${BASE}/a/y";
    104         return 1
    105     fi
    106     CDIRS="a a/a a/b a/c c b a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c";
    107     NDIRS="";
    108     test_dirs;
    109     return $?
    11048}
    11149
     
    811749run_init ()
    812750{
    813     rm -f test_log_valgrind
    814 
    815     ${VALGRIND} ./samhain -t init -p none 2>>test_log_valgrind
     751    ./samhain -t init -p none
    816752
    817753    if test x$? = x0; then
     
    825761run_check ()
    826762{
    827     ${VALGRIND} ./samhain -t check -p none -l debug 2>>test_log_valgrind
     763    ./samhain -t check -p none -l debug
    828764
    829765    if test x$? = x0; then
     
    842778run_update ()
    843779{
    844     ${VALGRIND} ./samhain -t update -p none -l debug 2>>test_log_valgrind
     780    ./samhain -t update -p none -l debug
    845781
    846782    if test x$? = x0; then
     
    856792    rm -rf $LOGFILE
    857793
    858     ${VALGRIND} ./samhain -t check -p none -l debug 2>>test_log_valgrind
     794    ./samhain -t check -p none -l debug
    859795
    860796    if test x$? = x0; then
     
    865801            return 1
    866802        fi
    867         #
    868         # wtmp may not be readable
    869         #
    870         tmp=`./samhain -j -L $LOGFILE | grep ERR | grep -v wtmp | wc -l`
     803        tmp=`./samhain -j -L $LOGFILE | grep ERR | wc -l`
    871804        if [ $tmp -ne 0 ]; then
    872             [ -z "$verbose" ] || log_msg_fail "errors during check";
    873             return 1
    874         fi
    875         #
    876         [ -z "$VALGRIND" ] || {
    877             tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
    878             if [ $tmp -ne 0 ]; then
    879                 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
    880                 cat test_log_valgrind
    881                 return 1;
    882             fi;
    883         }
     805            [ -z "$verbose" ] || log_msg_fail "update not successful(?)";
     806            return 1
     807        fi
    884808        #
    885809        [ -z "$verbose" ] || log_msg_ok    "check(2)...";
     
    892816prep_testdata ()
    893817{
    894     if test -d "$BASE"; then
    895         if [ -d "${BASE}" ]; then
    896             chmod -R 0700 "${BASE}" || {
    897                 [ -z "$quiet" ] &&   log_msg_fail "chmod -R 0700 ${BASE}";
    898                 return 1;
    899             }
    900         fi
    901     fi
     818    chmod -R 0700 "${BASE}" || {
     819        [ -z "$quiet" ] &&   log_msg_fail "chmod -R 0700 ${BASE}";
     820        return 1;
     821    }
    902822
    903823    rm -rf "${BASE}" || {
     
    952872        if test x$? = x0; then
    953873                [ -z "$verbose" ] ||     log_msg_ok "configure...";
    954                 $MAKE  >/dev/null 2>>test_log
     874                $MAKE  > /dev/null
    955875                if test x$? = x0; then
    956876                    [ -z "$verbose" ] || log_msg_ok "make...";
  • /trunk/test/testrun_1a.sh

    r30 r20  
    11#! /bin/sh
    2 
    3 #
    4 # Copyright Rainer Wichmann (2006)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    212
    223BUILDOPTS="--quiet $TRUST --enable-debug --enable-xml-log --enable-micro-stealth=137 --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file"
  • /trunk/test/testrun_1b.sh

    r30 r20  
    11#! /bin/sh
    22
    3 #
    4 # Copyright Rainer Wichmann (2006)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    213
    224MAXTEST=2; export MAXTEST
     
    3315        #
    3416        if test -r "Makefile"; then
    35                 $MAKE distclean >/dev/null >&1
     17                $MAKE distclean >/dev/null
    3618        fi
    3719        #
     
    4224        if test x$? = x0; then
    4325                [ -z "$verbose" ] ||     log_msg_ok "configure...";
    44                 $MAKE  > /dev/null 2>&1
     26                $MAKE  > /dev/null
    4527                if test x$? = x0; then
    4628                    [ -z "$verbose" ] || log_msg_ok "make...";
  • /trunk/test/testrun_2.sh

    r30 r20  
    11#! /bin/sh
    2 
    3 #
    4 # Copyright Rainer Wichmann (2006)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    212
    223LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
    234RCFILE="$PW_DIR/testrc_2";  export RCFILE
    24 HTML="$PW_DIR/yule.html";  export HTML
    255
    266
     
    3212            echo;
    3313        }
    34 
    35         rm -f test_log_valgrind
    36 
    37         ${VALGRIND} ./yule.2 -l info -p none >/dev/null 2>>test_log_valgrind &
    38         PROC_Y2=$!
    39         sleep 5
    40 
    41         [ -z "$verbose" ] || {
    42             echo;
    43             echo "${S}Start Server #2${E}: ./yule.2 -l info -p none &";
    44             echo;
    45         }
    46 
    47         ${VALGRIND} ./yule -l info -p none -e info --bind-address=127.0.0.1 \
    48             --server-port=49778 >/dev/null 2>>test_log_valgrind &
     14        ./yule -l info -p none >/dev/null 2>&1 &
    4915        PROC_Y=$!
    5016        sleep 5
     
    5622        }
    5723
    58         ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
     24        ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>&1
    5925        if test x$? = x0; then
    6026            [ -z "$verbose" ] || log_msg_ok    "samhain.new -t check";
     
    6228            [ -z "$quiet" ]   && log_msg_fail  "samhain.new -t check";
    6329            kill $PROC_Y
    64             kill $PROC_Y2
    6530            return 1
    6631        fi
    6732
    6833        kill $PROC_Y
    69         kill $PROC_Y2
    70         sleep 5
    71 
    72         # cp ${LOGFILE}  triple_test
    73         # cp ${LOGFILE}2 triple_test_2
    74 
    75         egrep "START(>|\").*Yule(>|\")" ${LOGFILE}2 >/dev/null 2>&1
    76         if [ $? -ne 0 ]; then
    77             [ -z "$verbose" ] || log_msg_fail "Server #2 start";
    78             return 1
    79         fi
    80         egrep "remote_host.*Checking.*/bin" ${LOGFILE}2 >/dev/null 2>&1
    81         if [ $? -ne 0 ]; then
    82             [ -z "$verbose" ] || log_msg_fail "Client file check (relayed)";
    83             return 1
    84         fi
    85         egrep "remote_host.*EXIT.*Samhain" ${LOGFILE}2 >/dev/null 2>&1
    86         if [ $? -ne 0 ]; then
    87             [ -z "$verbose" ] || log_msg_fail "Client exit (relayed)";
    88             return 1
    89         fi
    90         egrep "EXIT.*Yule.*SIGTERM" ${LOGFILE}2 >/dev/null 2>&1
    91         if [ $? -ne 0 ]; then
    92             [ -z "$verbose" ] || log_msg_fail "Server #2 exit";
    93             return 1
    94         fi
    95 
     34        sleep 5
    9635
    9736        egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
     
    12059            return 1
    12160        fi
    122 
    123         [ -z "$VALGRIND" ] || {
    124             tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
    125             if [ $tmp -ne 0 ]; then
    126                 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
    127                 cat test_log_valgrind
    128                 return 1;
    129             fi;
    130         }
     61       
    13162
    13263        return 0
     
    13869        REPLACEMENT="UseSeparateLogs=yes"
    13970        ex $RCFILE <<EOF
    140 %s/$ORIGINAL/$REPLACEMENT/g
    141 wq
     71:%s/$ORIGINAL/$REPLACEMENT/g
     72:wq
    14273EOF
    14374# :%s is the "ex" substitution command.
     
    15081
    15182        rm -f $LOGFILE
    152         rm -f test_log_valgrind
    153 
    154         ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
     83
     84        ./yule -l info -p none >/dev/null 2>&1 &
    15585        PROC_Y=$!
    15686        sleep 5
     
    16292        }
    16393
    164         ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
     94        ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>&1
    16595        if test x$? = x0; then
    16696            [ -z "$verbose" ] || log_msg_ok    "samhain.new -t check";
     
    182112            CLIENTLOG="${LOGFILE}.${remhost}"
    183113        else
    184             tail -n 1 ${SCRIPTDIR}/test.sh >/dev/null 2>&1
    185             if [ $? -eq 0 ]; then
    186                 CLIENTLOG=`ls -1 ${LOGFILE}.* 2>/dev/null | tail -n 1`
    187             else
    188                 CLIENTLOG=`ls -1 ${LOGFILE}.* 2>/dev/null | tail -1`
    189             fi
     114            CLIENTLOG=`ls -1 ${LOGFILE}.* | tail -n 1`
    190115        fi
    191116
     
    215140            return 1
    216141        fi
    217 
    218         [ -z "$VALGRIND" ] || {
    219             tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
    220             if [ $tmp -ne 0 ]; then
    221                 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
    222                 cat test_log_valgrind
    223                 return 1;
    224             fi;
    225         }
    226142       
    227143        rm -f ${LOGFILE}.${remhost}
     
    240156        REPLACEMENT_4="SetClientTimeLimit=20"
    241157        ex $RCFILE <<EOF
    242 %s/${ORIGINAL_1}/${REPLACEMENT_1}/g
    243 %s/${ORIGINAL_2}/${REPLACEMENT_2}/g
    244 %s/${ORIGINAL_3}/${REPLACEMENT_3}/g
    245 %s/${ORIGINAL_4}/${REPLACEMENT_4}/g
    246 wq
     158:%s/${ORIGINAL_1}/${REPLACEMENT_1}/g
     159:%s/${ORIGINAL_2}/${REPLACEMENT_2}/g
     160:%s/${ORIGINAL_3}/${REPLACEMENT_3}/g
     161:%s/${ORIGINAL_4}/${REPLACEMENT_4}/g
     162:wq
    247163EOF
    248164# :%s is the "ex" substitution command.
     
    255171
    256172        rm -f $LOGFILE
    257         rm -f test_log_valgrind
    258 
    259         ${VALGRIND} ./yule -p none -e none >/dev/null 2>>test_log_valgrind &
     173
     174        ./yule -p none >/dev/null 2>&1 &
    260175        PROC_Y=$!
    261176        sleep 5
     
    267182        }
    268183
    269         ${VALGRIND} ./samhain.new -t check -p none -l none --forever --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind &
     184        ./samhain.new -t check -p none -l none --forever --bind-address=127.0.0.1 >/dev/null 2>&1 &
    270185        if test x$? = x0; then
    271186            PROC_S=$!
     
    316231            return 1
    317232        fi
    318 
    319         [ -z "$VALGRIND" ] || {
    320             tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
    321             if [ $tmp -ne 0 ]; then
    322                 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
    323                 cat test_log_valgrind
    324                 return 1;
    325             fi;
    326         }
    327233       
    328         rm -f ${LOGFILE}
     234        rm -f ${LOGFILE}.${remhost}
    329235        return 0
    330236}
    331 
    332 do_test_4 () {
    333 
    334         # don't know what is supported on the test platform, so
    335         # prepare for both (password and socket credential)
    336 
    337         # 'id -u' is posix
    338         me=`id -u`
    339 
    340         ORIGINAL_1="SetSocketAllowUid=0"
    341         REPLACEMENT_1="SetSocketAllowUid=$me"
    342         ex $RCFILE <<EOF
    343 %s/${ORIGINAL_1}/${REPLACEMENT_1}/g
    344 wq
    345 EOF
    346 
    347         [ -z "$verbose" ] || {
    348             echo;
    349             echo "${S}Start Server${E}: ./yule -l info -p none &";
    350             echo;
    351         }
    352 
    353         rm -f $LOGFILE
    354         rm -f test_log_valgrind
    355 
    356         ${VALGRIND} ./yule -l info -p none -e none \
    357             >/dev/null 2>>test_log_valgrind &
    358         PROC_Y=$!
    359         sleep 5
    360 
    361         [ -z "$verbose" ] || {
    362             echo;
    363             echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
    364             echo;
    365         }
    366 
    367         $MAKE yulectl >/dev/null
    368         if [ $? -ne 0 ]; then
    369             [ -z "$verbose" ] || log_msg_fail "make yulectl";
    370             kill $PROC_Y
    371             return 1
    372         fi
    373 
    374 
    375         ./yulectl -v -c RELOAD foobar1 >test_log_yulectl 2>/dev/null
    376 
    377         if [ $? -ne 0 ]; then
    378             YULECTL_PASSWORD=samhain; export YULECTL_PASSWORD
    379             ./yulectl -v -c RELOAD foobar1 >test_log_yulectl
    380             if [ $? -ne 0 ]; then
    381                 kill ${PROC_Y}
    382                 [ -z "$verbose" ] || log_msg_fail "yulectl";
    383                 return 1
    384             fi
    385         fi
    386 
    387         ./yulectl -v -c RELOAD foobar2 >test_yulectl_log
    388 
    389         if [ $? -ne 0 ]; then
    390             kill ${PROC_Y}
    391             [ -z "$verbose" ] || log_msg_fail "yulectl";
    392             return 1
    393         fi
    394 
    395         ./yulectl -v -c RELOAD foobar3 >test_log_yulectl
    396 
    397         if [ $? -ne 0 ]; then
    398             kill ${PROC_Y}
    399             [ -z "$verbose" ] || log_msg_fail "yulectl";
    400             return 1
    401         fi
    402 
    403         ./yulectl -v -c LISTALL dummy >test_log_yulectl
    404 
    405         if [ $? -ne 0 ]; then
    406             kill ${PROC_Y}
    407             [ -z "$verbose" ] || log_msg_fail "yulectl";
    408             return 1
    409         fi
    410 
    411         tmp=`cat test_log_yulectl | grep RELOAD | wc -l`
    412         if [ $tmp -ne 3 ]; then
    413             kill ${PROC_Y}
    414             [ -z "$verbose" ] || log_msg_fail "command confirmation";
    415             return 1
    416         fi
    417 
    418         ./yulectl -v -c CANCEL foobar3 >test_log_yulectl
    419 
    420         if [ $? -ne 0 ]; then
    421             kill ${PROC_Y}
    422             [ -z "$verbose" ] || log_msg_fail "yulectl";
    423             return 1
    424         fi
    425 
    426         ./yulectl -v -c LISTALL dummy >test_log_yulectl
    427 
    428         if [ $? -ne 0 ]; then
    429             kill ${PROC_Y}
    430             [ -z "$verbose" ] || log_msg_fail "yulectl";
    431             return 1
    432         fi
    433 
    434         tmp=`cat test_log_yulectl | grep RELOAD | wc -l`
    435         if [ $tmp -ne 2 ]; then
    436             kill ${PROC_Y}
    437             [ -z "$verbose" ] || log_msg_fail "command confirmation";
    438             return 1
    439         fi
    440 
    441         kill ${PROC_Y}
    442         sleep 2
    443         kill -9 ${PROC_Y} >/dev/null 2>&1
    444 
    445         [ -z "$VALGRIND" ] || {
    446             tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
    447             if [ $tmp -ne 0 ]; then
    448                 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
    449                 cat test_log_valgrind
    450                 return 1;
    451             fi;
    452         }
    453        
    454         return 0
    455 }
    456 
    457 do_test_5 () {
    458 
    459         [ -z "$verbose" ] || {
    460             echo;
    461             echo "${S}Start Server${E}: ./yule -l info -p none &";
    462             echo;
    463         }
    464 
    465 ( cat <<EOF
    466 <!-- head -->
    467 <html><head><title>test</title></head>
    468 <body>
    469 Current time: %T <br>
    470 <table>
    471 <!-- ehead -->
    472 EOF
    473 ) >head.html
    474 
    475 ( cat <<EOF
    476 <!-- foot -->
    477 </table>
    478 </body>
    479 <!-- efoot -->
    480 EOF
    481 ) >foot.html
    482 
    483 ( cat <<EOF
    484 <!-- entry -->
    485 <tr>
    486   <td>%H</td>
    487   <td>%S</td>
    488   <td>%T</td>
    489 </tr>
    490 <!-- eentry -->
    491 EOF
    492 ) >entry.html
    493 
    494         ${VALGRIND} ./yule -l info -p none -e none \
    495             >/dev/null 2>>test_log_valgrind &
    496         PROC_Y=$!
    497         sleep 5
    498 
    499         egrep '<!-- head -->' $HTML >/dev/null 2>&1
    500         if [ $? -ne 0 ]; then
    501             # rm -f head.html; rm -f foot.html; rm -f entry.html;
    502             kill $PROC_Y
    503             [ -z "$verbose" ] || log_msg_fail "head.html (1)";
    504             return 1
    505         fi
    506 
    507         egrep '<!-- foot -->' $HTML >/dev/null 2>&1
    508         if [ $? -ne 0 ]; then
    509             rm -f head.html; rm -f foot.html; rm -f entry.html;
    510             kill $PROC_Y
    511             [ -z "$verbose" ] || log_msg_fail "foot.html (1)";
    512             return 1
    513         fi
    514 
    515         [ -z "$verbose" ] || {
    516             echo;
    517             echo "${S}Start Client${E}: ./samhain.new -l none -p none -e info -t check";
    518             echo;
    519         }
    520 
    521         ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
    522         if test x$? = x0; then
    523             [ -z "$verbose" ] || log_msg_ok    "samhain.new -t check";
    524         else
    525             kill $PROC_Y
    526             [ -z "$quiet" ]   && log_msg_fail  "samhain.new -t check";
    527             return 1
    528         fi
    529 
    530         kill $PROC_Y
    531         sleep 5
    532 
    533         # rm -f head.html; rm -f foot.html; rm -f entry.html;
    534 
    535         egrep "START(>|\").*Yule(>|\")" $LOGFILE >/dev/null 2>&1
    536         if [ $? -ne 0 ]; then
    537             [ -z "$verbose" ] || log_msg_fail "Server start";
    538             return 1
    539         fi
    540         egrep "NEW CLIENT" $LOGFILE >/dev/null 2>&1
    541         if [ $? -ne 0 ]; then
    542             [ -z "$verbose" ] || log_msg_fail "Client connect";
    543             return 1
    544         fi
    545         egrep "remote_host.*Checking.*/bin" $LOGFILE >/dev/null 2>&1
    546         if [ $? -ne 0 ]; then
    547             [ -z "$verbose" ] || log_msg_fail "Client file check";
    548             return 1
    549         fi
    550         egrep "remote_host.*EXIT.*Samhain" $LOGFILE >/dev/null 2>&1
    551         if [ $? -ne 0 ]; then
    552             [ -z "$verbose" ] || log_msg_fail "Client exit";
    553             return 1
    554         fi
    555         egrep "EXIT.*Yule.*SIGTERM" $LOGFILE >/dev/null 2>&1
    556         if [ $? -ne 0 ]; then
    557             [ -z "$verbose" ] || log_msg_fail "Server exit";
    558             return 1
    559         fi
    560 
    561         egrep '<!-- head -->' $HTML >/dev/null 2>&1
    562         if [ $? -ne 0 ]; then
    563             [ -z "$verbose" ] || log_msg_fail "head.html";
    564             return 1
    565         fi
    566         egrep '<!-- ehead -->' $HTML >/dev/null 2>&1
    567         if [ $? -ne 0 ]; then
    568             [ -z "$verbose" ] || log_msg_fail "end head.html";
    569             return 1
    570         fi
    571 
    572         egrep '<!-- entry -->' $HTML >/dev/null 2>&1
    573         if [ $? -ne 0 ]; then
    574             [ -z "$verbose" ] || log_msg_fail "entry.html";
    575             return 1
    576         fi
    577         egrep '<!-- eentry -->' $HTML >/dev/null 2>&1
    578         if [ $? -ne 0 ]; then
    579             [ -z "$verbose" ] || log_msg_fail "end entry.html";
    580             return 1
    581         fi
    582 
    583         egrep '<!-- foot -->' $HTML >/dev/null 2>&1
    584         if [ $? -ne 0 ]; then
    585             [ -z "$verbose" ] || log_msg_fail "foot.html";
    586             return 1
    587         fi
    588         egrep '<!-- efoot -->' $HTML >/dev/null 2>&1
    589         if [ $? -ne 0 ]; then
    590             [ -z "$verbose" ] || log_msg_fail "end foot.html";
    591             return 1
    592         fi
    593 
    594         [ -z "$VALGRIND" ] || {
    595             tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
    596             if [ $tmp -ne 0 ]; then
    597                 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
    598                 cat test_log_valgrind
    599                 return 1;
    600             fi;
    601         }
    602 
    603         return 0
    604 }
    605 
    606237
    607238testrun2_internal ()
     
    637268        fi
    638269
    639         # save binary and build server2
     270        # save binary and build server
    640271        #
    641272        cp samhain samhain.build || return 1
    642         $MAKE clean >/dev/null || return 1
    643 
    644         ${TOP_SRCDIR}/configure --quiet  $TRUST --enable-debug --enable-network=server  --enable-xml-log --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=${RCFILE}2  --with-log-file=${LOGFILE}2 --with-pid-file=$PW_DIR/.samhain_lock2 --with-html-file=${HTML}2 --with-state-dir=$PW_DIR --enable-encrypt=2 --with-port=49778
     273        make clean >/dev/null || return 1
     274
     275        ${TOP_SRCDIR}/configure --quiet  $TRUST --enable-debug --enable-network=server  --enable-xml-log --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE  --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --enable-identity=rainer --enable-encrypt=2
    645276        #
    646277        if test x$? = x0; then
     
    659290        fi
    660291
    661         # save binary and build server
    662         #
    663         cp yule yule.2 || return 1
    664         $MAKE clean >/dev/null || return 1
    665 
    666         ${TOP_SRCDIR}/configure --quiet  $TRUST --enable-debug --enable-network=server  --enable-xml-log --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE  --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-html-file=$HTML --with-state-dir=$PW_DIR --enable-encrypt=2
    667         #
    668         if test x$? = x0; then
    669                 [ -z "$verbose" ] ||     log_msg_ok "configure...";
    670                 $MAKE  > /dev/null 2>>test_log
    671                 if test x$? = x0; then
    672                     [ -z "$verbose" ] || log_msg_ok "make...";
    673                 else
    674                     [ -z "$quiet" ] &&   log_msg_fail "make...";
    675                     return 1
    676                 fi
    677 
    678         else
    679                 [ -z "$quiet" ] &&       log_msg_fail "configure...";
    680                 return 1
    681         fi
    682 
    683292
    684293        #####################################################################
     
    721330        mv samhain.build.new  samhain.new || return 1
    722331
    723         # Set in server
    724 
    725         ./samhain_setpwd yule new $SHPW >/dev/null
    726 
    727         if test x$? = x0; then
    728             [ -z "$verbose" ] || log_msg_ok    "./samhain_setpwd yule new $SHPW";
    729         else
    730             [ -z "$quiet" ]   && log_msg_fail  "./samhain_setpwd yule new $SHPW";
    731             return 1
    732         fi
    733 
    734         mv yule.new yule || return 1
    735 
    736         #
    737 
    738         rm -f ./.samhain_log*
    739         rm -f ./.samhain_lock*
    740 
    741         SHCLT=`./yule -P $SHPW`
     332        rm -f ./.samhain_log.*
     333        rm -f ./.samhain_lock
     334
     335        SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%`
    742336
    743337        if test x$? = x0; then
     
    748342        fi
    749343
    750         SHCLT1=`echo "${SHCLT}"  | sed s%HOSTNAME%${SH_LOCALHOST}%`
    751         AHOST=`find_hostname`
    752         SHCLT2=`echo "${SHCLT}"  | sed s%HOSTNAME%${AHOST}%`
    753        
    754 
    755         echo $SHCLT1 >> testrc_2
    756         echo $SHCLT2 >> testrc_2
    757         cp testrc_2 testrc_22
     344        echo $SHCLT >> testrc_2
    758345
    759346        do_test_1
     
    766353        do_test_2
    767354        if [ $? -eq 0 ]; then
    768             [ -z "$quiet" ] && log_ok   2 ${MAXTEST} "Client logging, separate logfiles";
    769         else
    770             [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Client logging, separate logfiles";
     355            [ -z "$quiet" ] && log_ok   2 ${MAXTEST} "Client logging, seperate logfiles";
     356        else
     357            [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "Client logging, seperate logfiles";
    771358        fi
    772359
     
    778365        fi
    779366
    780         do_test_4
    781         if [ $? -eq 0 ]; then
    782             [ -z "$quiet" ] && log_ok   4 ${MAXTEST} "Server command socket";
    783         else
    784             [ -z "$quiet" ] && log_fail 4 ${MAXTEST} "Server command socket";
    785         fi
    786 
    787         do_test_5
    788         if [ $? -eq 0 ]; then
    789             [ -z "$quiet" ] && log_ok   5 ${MAXTEST} "Server status file";
    790         else
    791             [ -z "$quiet" ] && log_fail 5 ${MAXTEST} "Server status file";
    792         fi
    793 
    794367        return $?
    795368}
    796369
    797 MAXTEST=5; export MAXTEST
     370MAXTEST=3; export MAXTEST
    798371
    799372testrun2 ()
  • /trunk/test/testrun_2a.sh

    r30 r20  
    11#! /bin/sh
    2 
    3 #
    4 # Copyright Rainer Wichmann (2006)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    212
    223LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
     
    256SERVER_BUILDOPTS="--quiet  $TRUST  --enable-network=server --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=${SH_LOCALHOST}  --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock"; export SERVER_BUILDOPTS
    267
    27 CLIENT_BUILDOPTS="--quiet  $TRUST --enable-debug --enable-network=client --enable-srp --prefix=$PW_DIR --with-tmp-dir=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$RCFILE --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=localhost  --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS
     8CLIENT_BUILDOPTS="--quiet  $TRUST --enable-debug --enable-network=client --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$RCFILE --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=localhost  --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS
    289
    2910do_test_1_a () {
     
    3415            echo;
    3516        }
    36         rm -f test_log_valgrind
    37 
    38         ${VALGRIND} ./yule -l info -p none >/dev/null 2>>test_log_valgrind &
     17        ./yule -l info -p none >/dev/null 2>&1 &
    3918        PROC_Y=$!
    4019        sleep 5
     
    4625        }
    4726
    48         ${VALGRIND} ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>>test_log_valgrind
     27        ./samhain.new -t check -p none -l none -e info --bind-address=127.0.0.1 >/dev/null 2>&1
    4928        if test x$? = x0; then
    5029            [ -z "$verbose" ] || log_msg_ok    "samhain.new -t check";
     
    8463        fi
    8564       
    86         [ -z "$VALGRIND" ] || {
    87             tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
    88             if [ $tmp -ne 0 ]; then
    89                 [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
    90                 cat test_log_valgrind
    91                 return 1;
    92             fi;
    93         }
    9465
    9566        return 0
     
    131102        #
    132103        cp samhain samhain.build || return 1
    133         $MAKE clean >/dev/null || return 1
     104        make clean >/dev/null || return 1
    134105
    135106        ${TOP_SRCDIR}/configure ${SERVER_BUILDOPTS}
     
    159130        rm -f ./rc.${SH_LOCALHOST}
    160131        rm -f ./file.${SH_LOCALHOST}
    161         rm -f  "./rc.${ALTHOST}"
    162         rm -f  "./file.${ALTHOST}"
    163132
    164133        cp ${SCRIPTDIR}/testrc_2.in testrc_2
     
    197166        rm -f ./.samhain_lock
    198167
    199         SHCLT=`./yule -P $SHPW`
     168        SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%`
    200169
    201170        if test x$? = x0; then
     
    206175        fi
    207176
    208         SHCLT1=`echo "${SHCLT}"  | sed s%HOSTNAME%${SH_LOCALHOST}%`
    209         AHOST=`find_hostname`
    210         SHCLT2=`echo "${SHCLT}"  | sed s%HOSTNAME%${AHOST}%`
    211        
    212 
    213         echo $SHCLT1 >> testrc_2
    214         echo $SHCLT2 >> testrc_2
    215 
     177        echo $SHCLT >> testrc_2
    216178
    217179        cp    ./testrc_2       ./rc.${SH_LOCALHOST}
     
    224186}
    225187
    226 MAXTEST=5; export MAXTEST
     188MAXTEST=1; export MAXTEST
    227189
    228190testrun2a ()
     
    237199    #
    238200    testrun2a_internal
     201    #
    239202    do_test_1_a
    240203    if [ $? -eq 0 ]; then
     
    242205    else
    243206        [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client download+logging";
    244     fi
    245     #
    246     SERVER_BUILDOPTS_ORIG="${SERVER_BUILDOPTS}"
    247     CLIENT_BUILDOPTS_ORIG="${CLIENT_BUILDOPTS}"
    248     #
    249     SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --disable-srp"
    250     CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --disable-srp"
    251     #
    252     testrun2a_internal
    253     do_test_1_a
    254     if [ $? -eq 0 ]; then
    255         [ -z "$quiet" ] && log_ok   2 ${MAXTEST} "SRP disabled";
    256     else
    257         [ -z "$quiet" ] && log_fail 2 ${MAXTEST} "SRP disabled";
    258     fi
    259     #
    260     SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --disable-encrypt"
    261     CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --disable-encrypt"
    262     #
    263     testrun2a_internal
    264     do_test_1_a
    265     if [ $? -eq 0 ]; then
    266         [ -z "$quiet" ] && log_ok   3 ${MAXTEST} "Encryption disabled";
    267     else
    268         [ -z "$quiet" ] && log_fail 3 ${MAXTEST} "Encryption disabled";
    269     fi
    270     #
    271     SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --enable-encrypt=1"
    272     CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --enable-encrypt=1"
    273     #
    274     testrun2a_internal
    275     do_test_1_a
    276     if [ $? -eq 0 ]; then
    277         [ -z "$quiet" ] && log_ok   4 ${MAXTEST} "Encryption (v1)";
    278     else
    279         [ -z "$quiet" ] && log_fail 4 ${MAXTEST} "Encryption (v1)";
    280     fi
    281     #
    282     SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG}"
    283     CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --enable-encrypt=1"
    284     #
    285     testrun2a_internal
    286     do_test_1_a
    287     if [ $? -eq 0 ]; then
    288         [ -z "$quiet" ] && log_ok   5 ${MAXTEST} "Encryption backward compat";
    289     else
    290         [ -z "$quiet" ] && log_fail 5 ${MAXTEST} "Encryption backward compat";
    291207    fi
    292208    #
  • /trunk/test/testrun_2b.sh

    r30 r20  
    11#! /bin/sh
    2 
    3 #
    4 # Copyright Rainer Wichmann (2006)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    212
    223LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
     
    267SERVER_BUILDOPTS="--quiet  $TRUST  --enable-network=server --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=${SH_LOCALHOST}  --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock"; export SERVER_BUILDOPTS
    278
    28 CLIENT_BUILDOPTS="--quiet  $TRUST --enable-micro-stealth=137 --enable-debug --enable-network=client --enable-srp --prefix=$PW_DIR --with-tmp-dir=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER${RCFILE_C} --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=localhost  --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS
     9CLIENT_BUILDOPTS="--quiet  $TRUST --enable-micro-stealth=137 --enable-debug --enable-network=client --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER${RCFILE_C} --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=localhost  --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS
    2910
    3011testrun2b_internal ()
     
    8061
    8162    cp samhain samhain.build || return 1
    82     $MAKE clean >/dev/null || return 1
     63    make clean >/dev/null || return 1
    8364   
    8465    ${TOP_SRCDIR}/configure ${SERVER_BUILDOPTS}
     
    144125    rm -f ./.samhain_lock
    145126   
    146     SHCLT=`./yule -P $SHPW`
     127    SHCLT=`./yule -P $SHPW | sed s%HOSTNAME%${SH_LOCALHOST}%`
    147128   
    148129    if test x$? = x0; then
     
    153134    fi
    154135   
    155     SHCLT1=`echo "${SHCLT}"  | sed s%HOSTNAME%${SH_LOCALHOST}%`
    156     AHOST=`find_hostname`
    157     SHCLT2=`echo "${SHCLT}"  | sed s%HOSTNAME%${AHOST}%`
    158        
    159 
    160     echo $SHCLT1 >> testrc_2
    161     echo $SHCLT2 >> testrc_2
    162 
     136    echo $SHCLT >> testrc_2
    163137   
    164138    cp    "${RCFILE_C}"              ./rc.${SH_LOCALHOST}
     
    166140
    167141    ALTHOST=`find_hostname`
    168     cp    "${RCFILE_C}"          "./rc.${ALTHOST}"
     142    cp    ./testrc_2       "./rc.${ALTHOST}"
    169143    cp    ./file.${SH_LOCALHOST} "./file.${ALTHOST}" 2>/dev/null
    170144}
     
    192166   
    193167            testrun2b_internal "$GPG"
    194 
    195             SAVE_VALGRIND="${VALGRIND}"; VALGRIND=''; export VALGRIND
     168   
    196169            do_test_1_a
    197             VALGRIND="${SAVE_VALGRIND}"; export VALGRIND
    198170            if [ $? -eq 0 ]; then
    199171                [ -z "$quiet" ] && log_ok   1 ${MAXTEST} "Client download+logging w/gpg";
  • /trunk/test/testrun_2c.sh

    r30 r20  
    11#! /bin/sh
    2 
    3 #
    4 # Copyright Rainer Wichmann (2006)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    212
    223SERVER_BUILDOPTS="--quiet  $TRUST --enable-xml-log --enable-debug --enable-network=server --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=${SH_LOCALHOST}  --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-database=mysql"; export SERVER_BUILDOPTS
    234
    24 CLIENT_BUILDOPTS="--quiet  $TRUST --prefix=$PW_DIR --with-tmp-dir=$PW_DIR --localstatedir=$PW_DIR --enable-network=client --disable-mail --disable-external-scripts --enable-login-watch --enable-xml-log --enable-db-reload --with-logserver=localhost --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS
     5CLIENT_BUILDOPTS="--quiet  $TRUST --prefix=$PW_DIR --localstatedir=$PW_DIR --enable-network=client --disable-mail --disable-external-scripts --enable-login-watch --enable-xml-log --enable-db-reload --with-logserver=localhost --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS
    256
    267check_mysql_log () {
     
    9273    REPLACEMENT="DatabaseSeverity=info"
    9374    ex $RCFILE <<EOF
    94 %s/$ORIGINAL/$REPLACEMENT/g
    95 wq
     75:%s/$ORIGINAL/$REPLACEMENT/g
     76:wq
    9677EOF
    9778    #
  • /trunk/test/testrun_2d.sh

    r30 r20  
    11#! /bin/sh
    2 
    3 #
    4 # Copyright Rainer Wichmann (2006)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    212
    223SERVER_BUILDOPTS="--quiet  $TRUST --enable-xml-log --enable-debug --enable-network=server --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=${SH_LOCALHOST}  --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-database=postgresql"; export SERVER_BUILDOPTS
    234
    24 CLIENT_BUILDOPTS="--quiet  $TRUST --prefix=$PW_DIR --with-tmp-dir=$PW_DIR --localstatedir=$PW_DIR --enable-network=client --disable-mail --disable-external-scripts --enable-login-watch --enable-xml-log --enable-db-reload --with-logserver=localhost --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS
     5CLIENT_BUILDOPTS="--quiet  $TRUST --prefix=$PW_DIR --localstatedir=$PW_DIR --enable-network=client --disable-mail --disable-external-scripts --enable-login-watch --enable-xml-log --enable-db-reload --with-logserver=localhost --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock"; export CLIENT_BUILDOPTS
    256
    267check_psql_log () {
     
    9475    REPLACEMENT="DatabaseSeverity=info"
    9576    ex $RCFILE <<EOF
    96 %s/$ORIGINAL/$REPLACEMENT/g
    97 wq
     77:%s/$ORIGINAL/$REPLACEMENT/g
     78:wq
    9879EOF
    9980    #
    10081    do_test_1_a
    101     #
    10282    if [ $? -ne 0 ]; then
    10383        [ -z "$quiet" ] && log_fail 1 ${MAXTEST} "Client/server w/postgresql";
  • /trunk/test/testtimesrv.sh

    r30 r20  
    11#! /bin/sh
    2 
    3 #
    4 # Copyright Rainer Wichmann (2006)
    5 #
    6 # License Information:
    7 # This program is free software; you can redistribute it and/or modify
    8 # it under the terms of the GNU General Public License as published by
    9 # the Free Software Foundation; either version 2 of the License, or
    10 # (at your option) any later version.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 # GNU General Public License for more details.
    16 #
    17 # You should have received a copy of the GNU General Public License
    18 # along with this program; if not, write to the Free Software
    19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 #
    212
    223RCFILE="$PW_DIR/testrc_1.dyn";  export RCFILE
     
    3011prep_testdata ()
    3112{
    32     if test -d "$BASE"; then
    33         chmod -R 0700 "${BASE}" || {
    34             [ -z "$quiet" ] &&   log_msg_fail "chmod -R 0700 ${BASE}";
    35             return 1;
    36         }
    37     fi
     13    chmod -R 0700 "${BASE}" || {
     14        [ -z "$quiet" ] &&   log_msg_fail "chmod -R 0700 ${BASE}";
     15        return 1;
     16    }
    3817
    3918    rm -rf "${BASE}" || {
     
    142121        # standalone compilation
    143122        #
    144         [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent${E}"; echo; }
     123        [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent w/timeserver${E}"; echo; }
    145124        #
    146125        if test -r "Makefile"; then
     
    152131        if test x$? = x0; then
    153132                [ -z "$verbose" ] ||     log_msg_ok "configure...";
    154                 $MAKE  > /dev/null 2>>test_log
     133                $MAKE  > /dev/null
    155134                if test x$? = x0; then
    156135                    [ -z "$verbose" ] || log_msg_ok "make...";
  • /trunk/yulerc.template

    r30 r20  
    165165#####################################################
    166166
     167[Misc]
     168
     169## whether to become a daemon process
     170## (this is not honoured on database initialisation)
     171#
     172# Daemon = no
     173Daemon = yes
     174
     175
    167176
    168177[Misc]
     
    174183# SetLoopTime = 60
    175184SetLoopTime = 600
    176 
    177 ## Normally, client messages are regarded as data within a
    178 ## server message of fixed severity. The following two
    179 ## options cause the server to use the original severity/class
    180 ## of client messages for logging.
    181 #
    182 # UseClientSeverity = False
    183 # UseClientClass    = False
    184185
    185186## The maximum time between client messages (seconds)
Note: See TracChangeset for help on using the changeset viewer.