Changeset 59


Ignore:
Timestamp:
Aug 31, 2006, 9:25:02 PM (20 years ago)
Author:
rainer
Message:

Fix for exit status if database load fails; fix for problem with GrowingLogFiles if signed database is used; better support for *BSD init script installation.

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r57 r59  
    1313dnl start
    1414dnl
    15 AM_INIT_AUTOMAKE(samhain, 2.2.3)
     15AM_INIT_AUTOMAKE(samhain, 2.2.4)
    1616AC_CANONICAL_HOST
    1717
  • trunk/docs/Changelog

    r58 r59  
    112.2.4:
     2        * fixed sh_unix.c: bug in database init if GrowingLogFiles used
     3          with signed database (reported by Timothy Stotts)
     4        * bug in manual fixed (incorrect documentation of --enable-user,
     5          noticed by M. Brown)
     6        * rc.subr compatible init script for FreeBSD/NetBSD
    27        * improve routine to find rpm after build
    38        * add netbsd rc file from Brian Seklecki (taken from pkgsrc-wip)
    … …  
    510        * fix bug with SuidExclude (files in directory were still checked)
    611
    7 2.2.3:
     122.2.3 (31-07-2006):
    813        * fix samhainadmin.pl: check for gpg-agent running if use-agent is set
    914          (ticket #28 by anonymous)
  • trunk/init/samhain.startFreeBSD.in

    r1 r59  
    1 #! /bin/sh -
     1#!/bin/sh
     2
     3# PROVIDE: @install_name@
     4# REQUIRE: LOGIN
     5# KEYWORD: shutdown
     6
     7. /etc/rc.subr
     8
     9name="@install_name@"
     10rcvar=`set_rcvar`
     11
     12pidfile="@mylockfile@"
     13
     14# there are no required_files in general,
     15# as they might be downloaded from the server
    216#
    3 #    initialization/shutdown script for @install_name@ package
     17# required_files="@myconffile@ @mydatafile@"
    418
    5 prefix="@prefix@"
    6 exec_prefix="@exec_prefix@"
     19extra_commands="reload"
     20stop_postcmd="remove_stale_files"
    721
    8 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    9 DAEMON=@sbindir@/@install_name@
    10 NAME=@install_name@
    11 pidfile=@mylockfile@
     22command="@sbindir@/@install_name@"
    1223
    13 test -f $DAEMON || exit 0
    14 
    15 safe_pidof () {
    16     pidval=0
    17     if [ -f $pidfile ] ; then
    18        pidval=`cat $pidfile | awk '{ print $1 }'`
    19        echo "${pidval}" | grep ['[^0123456789]'] >/dev/null 2>&1 && pidval=0
    20     fi
    21     echo $pidval
    22     if [ x"$pidval" = x0 ] ; then
    23         return 1
    24     else
    25         return 0
    26     fi
     24is_set()
     25{
     26    eval "[ -n \"\${$1+X}\" ]"
    2727}
    2828
    29 log_stat_msg () {
    30 case "$1" in
    31         0)
    32         echo "Service $NAME: Running";
    33         break;
    34         ;;
    35         1)
    36         echo "Service $NAME: Stopped and @mylockfile@ pid file exists";
    37         break;
    38         ;;
    39         3)
    40         echo "Service $NAME: Stopped";
    41         break;
    42         ;;
    43         *)
    44         echo "Service $NAME: Status unknown";
    45         break;
    46         ;;
    47 esac
     29remove_stale_files()
     30{
     31    if test -f @mylockfile@; then
     32        /bin/rm -f @mylockfile@
     33    fi
     34    /bin/rm -f @mylockdir@/${name}.sock
    4835}
    4936
    50 case "$1" in
    51   start)
    52         #
    53         # Remove a stale lockfile, if found
    54         #
    55         if test -f @mylockfile@; then
    56             rm -f @mylockfile@
    57         fi
    58         /bin/rm -f @mylockdir@/${NAME}.sock
    59         $DAEMON -D && echo -n " $NAME"
    60         ;;
    61   stop)
    62         PID=`safe_pidof`
    63         if test "x$PID" != x0
    64         then
    65                 kill $PID && echo -n " $NAME"
    66         fi
    67         ;;
    68   reload|force-reload)
    69         PID=`safe_pidof`
    70         if test "x$PID" != x0
    71         then
    72                 echo " Reloading $NAME configuration file."
    73                 kill -s HUP $PID && echo -n " $NAME"
    74         else
    75                 echo " Cannot determine PID of process $NAME."
    76                 exit 1
    77         fi
    78         ;;
    79   restart)
    80         $0 stop
    81         sleep 3
    82         $0 start
    83         ;;
    84     status)
    85         $DAEMON  status
    86         ERRNUM=$?
    87         log_stat_msg ${ERRNUM}
    88         exit ${ERRNUM}
    89         ;;
    90   *)
    91         echo " Usage: $0 {start|stop|restart|reload|force-reload}" >&2
    92         exit 1
    93         ;;
    94 esac
     37load_rc_config "$name"
    9538
     39if ! is_set ${rcvar}; then
     40    eval "${rcvar}=YES"
     41fi
     42
     43run_rc_command "$1"
     44
  • trunk/init/samhain.startLinux.in

    r1 r59  
    6363fi
    6464
    65 function debian_end ()
     65debian_end()
    6666{
    6767        if [ $RETVAL -eq 0 ];
    … …  
    103103
    104104# echo OK in green if is success, FAILED in red is failed
    105 function generic_end ()
     105generic_end()
    106106{
    107107        if [ $RETVAL -eq 0 ];
  • trunk/init/samhain.startSolaris.in

    r1 r59  
    99
    1010
    11 log_stat_msg () {
     11log_stat_msg() {
    1212case "$1" in
    1313        0)
  • trunk/samhain-install.sh.in

    r1 r59  
    672672       realname="$user"
    673673       case "$platform" in
    674            FreeBSD/* | NetBSD/* )
     674           FreeBSD/* | NetBSD/* | OpenBSD/* )
    675675              file=/etc/master.passwd
    676676              entry="${user}:*:${uid}:${gid}::0:0:${realname}:${home}:${shell}"
    … …  
    785785        ;;
    786786
     787    OpenBSD/*)
     788        test -z "$verbose" || echo "  OpenBSD system detected"
     789        grep '^## begin @install_name@' /etc/rc.local >/dev/null 2>&1
     790        if [ $? -eq 0 ]; then
     791            RCLOCALTMP=`mktemp /etc/rc.local.XXXXXXXXXX` || exit 1
     792            sed "/^## begin @install_name@/,/^## end @install_name@/d" /etc/rc.local >$RCLOCALTMP || exit 1
     793            cat $RCLOCALTMP >/etc/rc.local || exit 1
     794            rm -f $RCLOCALTMP || exit 1
     795            if test x"$act" = xuboot; then
     796                echo "  uninstalling from /etc/rc.local completed"
     797            fi
     798        fi
     799        if test x"$act" = xboot; then
     800            echo "## begin @install_name@"          >>/etc/rc.local || exit 1
     801            echo "if [ -x @sbindir@/@install_name@ ]; then" >>/etc/rc.local || exit 1
     802            echo "  @sbindir@/@install_name@ start" >>/etc/rc.local || exit 1
     803            echo "fi"                               >>/etc/rc.local || exit 1
     804            echo "## end @install_name@"            >>/etc/rc.local || exit 1
     805            echo "  installing to /etc/rc.local completed"
     806        fi
     807        exit 0
     808        ;;
     809
     810    NetBSD/*)
     811        test -z "$verbose" || echo "  NetBSD system detected"
     812        if test -f /etc/rc.subr; then
     813            DVER="FreeBSD"
     814            rc_main=${DESTDIR}/etc/rc.d
     815            rc_dirz=
     816            rc_inst="chmod 755 /etc/rc.d/@install_name@"
     817            rc_uinst="rm -f /etc/rc.d/@install_name@"
     818        else
     819            echo "${0}: unsupported platform ${platform} (too old)"
     820            exit 1
     821        fi
     822        ;;
     823
    787824    FreeBSD/* )
    788         DVER="FreeBSD"
    789825        test -z "$verbose" || echo "  FreeBSD system detected"
    790         rc_main=${DESTDIR}/usr/local/etc/rc.d
    791         rc_dirz=
    792         rc_inst="mv /usr/local/etc/rc.d/@install_name@ /usr/local/etc/rc.d/@install_name@.sh &&  chmod 755 /usr/local/etc/rc.d/@install_name@.sh"
    793         rc_uinst="rm -f /usr/local/etc/rc.d/@install_name@.sh; echo You may want to remove ${rc_main} from local_startup in /etc/rc.conf; echo if it is empty"
     826        if test -f /etc/rc.subr; then
     827            DVER="FreeBSD"
     828            rc_main=${DESTDIR}/etc/rc.d
     829            rc_dirz=
     830            rc_inst="chmod 755 /etc/rc.d/@install_name@"
     831            rc_uinst="rm -f /etc/rc.d/@install_name@"
     832        else
     833            DVER="Solaris"
     834            rc_main=${DESTDIR}/usr/local/etc/rc.d
     835            rc_dirz=
     836            rc_inst="mv /usr/local/etc/rc.d/@install_name@ /usr/local/etc/rc.d/@install_name@.sh && chmod 755 /usr/local/etc/rc.d/@install_name@.sh"
     837            rc_uinst="rm -f /usr/local/etc/rc.d/@install_name@.sh"
     838        fi
    794839        if test x"$act" = xboot
    795840        then
    … …  
    797842                test x"$act" = xboot && mkdir ${rc_main}
    798843            fi
     844            if test "x$DVER" = "xSolaris"; then
    799845            (   . /etc/defaults/rc.conf
    800846                . /etc/rc.conf
    … …  
    814860                fi
    815861            )
    816        fi
     862            fi
     863        fi
    817864        ;;
     865
    818866    SunOS/5.* )
    819867        DVER="Solaris"
     868        DVER_REAL="Solaris"
    820869        test -z "$verbose" || echo "  Solaris system detected"
    821870        rc_dirz=
    … …  
    824873        rc_uinst="rm -f ${DESTDIR}/etc/init.d/@install_name@; rm -f ${DESTDIR}/etc/rc0.d/K10@install_name@; rm -f ${DESTDIR}/etc/rc1.d/K10@install_name@; rm -f ${DESTDIR}/etc/rc3.d/S99@install_name@"
    825874        ;;
     875
    826876    Linux/*)
    827877        rlv="2 3 4 5"
    … …  
    10051055                    ${mkinstalldirs} ${rc_main}
    10061056                    #
    1007                     if test x"$DVER" = xSolaris; then
     1057                    if test x"${DVER_REAL}" = xSolaris; then
    10081058                        ${mkinstalldirs} ${DESTDIR}/etc/rc0.d
    10091059                        ${mkinstalldirs} ${DESTDIR}/etc/rc1.d
  • trunk/samhainrc.freebsd

    r14 r59  
    177177#
    178178
    179 [ReadOnly]
    180 file = /var
    181 
    182179[Attributes]
    183180
  • trunk/samhainrc.netbsd

    r56 r59  
    774774
    775775
    776 ## The digest/checksum/hash algorithm
    777 #
    778 DigestAlgo = MD5
     776## The digest/checksum/hash algorithm (default: TIGER192; others: MD5, SHA1)
     777#
     778# DigestAlgo = TIGER192
    779779
    780780
  • trunk/src/samhain.c

    r52 r59  
    652652  sh_files_delfilestack ();
    653653  sh_hash_hashdelete();
     654  sh_files_hle_reg (NULL);
    654655#endif
    655656#if defined(SH_WITH_SERVER)
    … …  
    13691370    }
    13701371
    1371   /* initialize signal handling etc
    1372    */
    13731372  if (sh.flag.isdaemon == S_TRUE)
    13741373    sh_error_only_stderr (BAD);
    13751374
     1375  /* --- load database; checksum of database
     1376   */
     1377#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
     1378  TPT((0, FIL__, __LINE__, _("msg=<Get checksum of the database.>\n")))
     1379  if (sh.flag.checkSum == SH_CHECK_CHECK)
     1380    {
     1381      if (0 != sl_strcmp(file_path('D', 'R'), _("REQ_FROM_SERVER")))
     1382        {
     1383          (void) sl_strlcpy(sh.data.hash,
     1384                            sh_tiger_hash (file_path('D', 'R'),
     1385                                           TIGER_FILE, 0),
     1386                            KEY_LEN+1);
     1387        }
     1388
     1389      /* this eventually fetches the file from server to get checksum
     1390       */
     1391      sh_hash_init ();
     1392    }
     1393#endif
     1394
     1395  /* --- initialize signal handling etc.; fork daemon
     1396   */
    13761397  if (sh_unix_init(sh.flag.isdaemon) == -1)
    13771398    {
    … …  
    14091430#if defined(INET_SYSLOG) && defined(SH_WITH_SERVER)
    14101431  create_syslog_socket (S_FALSE);
    1411 #endif
    1412 
    1413 
    1414   /* checksum of database
    1415    */
    1416 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
    1417   TPT((0, FIL__, __LINE__, _("msg=<Get checksum of the database.>\n")))
    1418   if (sh.flag.checkSum == SH_CHECK_CHECK)
    1419     {
    1420       if (0 == sl_strcmp(file_path('D', 'R'), _("REQ_FROM_SERVER")))
    1421         {
    1422           /* fetch the file from server to get checksum
    1423            */
    1424           sh_hash_init ();
    1425           /* sh_hash_hashdelete (); */
    1426         }
    1427       else
    1428         {
    1429           (void) sl_strlcpy(sh.data.hash,
    1430                             sh_tiger_hash (file_path('D', 'R'),
    1431                                            TIGER_FILE, 0),
    1432                             KEY_LEN+1);
    1433         }
    1434     }
    14351432#endif
    14361433
  • trunk/src/sh_unix.c

    r52 r59  
    28432843  SL_ENTER(_("sh_unix_checksum_size"));
    28442844
    2845   /* lookup file in database */
    2846   status = sh_hash_get_it (filename, &tmpFile);
    2847   if (status != 0) {
    2848     goto out;
    2849   }
     2845  if (sh.flag.checkSum != SH_CHECK_INIT)
     2846    {
     2847      /* lookup file in database */
     2848      status = sh_hash_get_it (filename, &tmpFile);
     2849      if (status != 0) {
     2850        goto out;
     2851      }
     2852    }
     2853  else
     2854    {
     2855      tmpFile.size = fbuf->st_size;
     2856    }
    28502857
    28512858  /* if last < current get checksum */
    … …  
    28532860    {
    28542861      sl_strlcpy(fileHash,
    2855                 sh_tiger_generic_hash (filename, TIGER_FD, tmpFile.size,
    2856                                        alert_timeout),
    2857                 KEY_LEN+1);
     2862                 sh_tiger_generic_hash (filename, TIGER_FD, tmpFile.size,
     2863                                        alert_timeout),
     2864                 KEY_LEN+1);
    28582865
    28592866      /* return */
Note: See TracChangeset for help on using the changeset viewer.