Changeset 412


Ignore:
Timestamp:
Sep 1, 2012, 4:25:30 PM (12 years ago)
Author:
katerina
Message:

Enhancements for ticket #312 (logrotate) and #313 (--enable-suid).

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile.in

    r378 r412  
    610610                if test -f $(srcdir)/stealth_template.jpg; then \
    611611                        cp $(srcdir)/stealth_template.jpg . ; \
     612                fi; \
     613        fi
     614        @if test -d /etc/logrotate.d; then \
     615                if test ! -f /etc/logrotate.d/@install_name@; then \
     616                        cp $(srcdir)/scripts/logrotate /etc/logrotate.d/@install_name@; \
     617                else \
     618                        echo "/etc/logrotate.d/@install_name@ exists, not overwriting"; \
    612619                fi; \
    613620        fi
     
    16331640samhain.startIRIX samhain.startMACOSX
    16341641
    1635 SCRIPTFILES=redhat_i386.client.spec check_samhain.pl samhainadmin.pl
     1642SCRIPTFILES=redhat_i386.client.spec check_samhain.pl samhainadmin.pl logrotate \
     1643yuleadmin.pl samhain.ebuild samhain.ebuild-light samhain.spec
    16361644
    16371645distdir: distfilecheck
    16381646        -rm -f $(top_srcdir)/init/*~
     1647        -rm -f $(top_srcdir)/sql_init/*~
    16391648        -rm -f $(top_srcdir)/dsys/*~
    16401649        -rm -f $(top_srcdir)/docs/*~
  • trunk/aclocal.m4

    r378 r412  
    409409x_libraries=NONE
    410410DESTDIR=
    411 SH_ENABLE_OPTS="ssp db-reload xml-log message-queue login-watch process-check port-check mounts-check logfile-monitor userfiles debug ptrace static network udp nocl stealth micro-stealth install-name identity khide suidcheck base largefile mail external-scripts encrypt srp dnmalloc ipv6 shellexpand"
     411SH_ENABLE_OPTS="ssp db-reload xml-log message-queue login-watch process-check port-check mounts-check logfile-monitor userfiles debug ptrace static network udp nocl stealth micro-stealth install-name identity khide suidcheck base largefile mail external-scripts encrypt srp dnmalloc ipv6 shellexpand suid"
    412412SH_WITH_OPTS="prelude libprelude-prefix database libwrap cflags libs console altconsole timeserver alttimeserver rnd egd-socket port logserver altlogserver kcheck gpg keyid checksum fp recipient sender trusted tmp-dir config-file log-file pid-file state-dir data-file html-file"
    413413
  • trunk/configure.ac

    r405 r412  
    805805        ],
    806806        [AC_DEFINE(SH_WITH_MAIL)]
     807)
     808
     809AC_ARG_ENABLE(suid,
     810        [  --enable-suid                allow suid],
     811        [
     812        if test "x${enable_suid}" = xyes; then
     813                AC_DEFINE(SH_ALLOW_SUID, [1], [Define if you want to allow suid execution for samhain])
     814        fi
     815        ]
    807816)
    808817
     
    27592768rules.deb-light
    27602769hp_ux.psf
     2770scripts/logrotate
    27612771scripts/samhain.spec
    27622772scripts/redhat_i386.client.spec
  • trunk/include/samhain.h

    r411 r412  
    458458
    459459#if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK)
     460#ifdef USE_SUID
    460461#define MLOCK(a, b) \
    461462      if ((skey != NULL) && skey->mlock_failed == SL_FALSE){ \
    462463        (void) sl_set_suid(); \
    463464        if (sh_unix_mlock(FIL__, __LINE__, a, b) < 0) skey->mlock_failed = SL_TRUE; \
    464         (void) sl_unset_suid(); }
     465        (void) sl_unset_suid(); }
     466#else
     467#define MLOCK(a, b) \
     468      if ((skey != NULL) && skey->mlock_failed == SL_FALSE){ \
     469        if (sh_unix_mlock(FIL__, __LINE__, a, b) < 0) skey->mlock_failed = SL_TRUE; }
     470#endif
    465471#else
    466472#define MLOCK(a, b) \
     
    469475
    470476#if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK)
     477#ifdef USE_SUID
    471478#define MUNLOCK(a, b) \
    472479      if ((skey != NULL) && skey->mlock_failed == SL_FALSE){ \
    473480        (void) sl_set_suid(); \
    474481        (void) sh_unix_munlock( a, b );\
    475         (void) sl_unset_suid(); }
     482        (void) sl_unset_suid(); }
     483#else
     484#define MUNLOCK(a, b) \
     485      if ((skey != NULL) && skey->mlock_failed == SL_FALSE){ \
     486        (void) sh_unix_munlock( a, b ); }
     487#endif
    476488#else
    477489#define MUNLOCK(a, b) \
  • trunk/include/slib.h

    r272 r412  
    3939
    4040*****************/
     41
    4142
    4243/* --------------------------------------------------------------
  • trunk/samhain-install.sh.in

    r203 r412  
    12641264        fi
    12651265
     1266       
     1267        if test -d /etc/logrotate.d; then
     1268            if test -f /etc/logrotate.d/@install_name@; then
     1269                test -z "$verbose" || echo $ECHO_N "  rm -f /etc/logrotate.d/@install_name@ ... $ECHO_C"
     1270                rm -f /etc/logrotate.d/@install_name@;
     1271                if test x$? = x0; then
     1272                     test -z "$verbose" || echo "${ECHO_T}done"
     1273                else
     1274                    test -z "$verbose" || echo "${ECHO_T}failed"
     1275                fi
     1276            fi
     1277        fi
     1278
    12661279        if test x"$force" = "xyes"
    12671280        then
  • trunk/samhain.spec.in

    r390 r412  
    196196%attr(644,root,root) @mandir@/man5/@install_name@*
    197197%attr(644,root,root) @mandir@/man8/@install_name@*
     198%attr(644,root,root) /etc/logrotate.d/@install_name@
    198199%config(noreplace) @myrpmconffile@
    199200
  • trunk/scripts/check_samhain.pl.in

    r310 r412  
    44#   by the samhain file integrity checker.
    55#
    6 # Copyright Rainer Wichmann (2004)
     6# Copyright Rainer Wichmann (2004, 2012)
    77#
    88# License Information:
     
    2828use Getopt::Long;
    2929use vars qw($PROGNAME $SAMHAIN $opt_V $opt_h $opt_v $verbose $opt_w $opt_c $opt_t $status $msg $state $retval);
    30 use lib  "utils.pm";
     30use lib  "/usr/local/nagios/libexec" ;
    3131use utils qw(%ERRORS &print_revision);
    3232
     
    4949# -----------------------------------------------------------------[ Global ]--
    5050
    51 $PROGNAME = "check_samhain";
     51$PROGNAME = "check_@install_name@";
    5252$SAMHAIN = "@sbindir@/@install_name@";
    5353
     
    9999    $state = $ERRORS{'WARNING'};
    100100} else {
    101     $msg = "CRITICAL: $status policy violations (threshold w=$opt_w)";
     101    $msg = "CRITICAL: $status policy violations (threshold c=$opt_c)";
    102102    $state = $ERRORS{'CRITICAL'};
    103103}
     
    143143   
    144144    if ($opt_V) {
    145         print_revision($PROGNAME,'$Revision: 1.0 $ ');
     145        print_revision($PROGNAME,'$Revision: 1.1 $ ');
    146146        exit $ERRORS{'OK'};
    147147    }
     
    182182
    183183sub print_help () {
    184     print_revision($PROGNAME, '$Revision: 1.0 $');
    185     print "Copyright (c) 2004 Rainer Wichmann
     184    print_revision($PROGNAME, '1.1');
     185    print "Copyright (c) 2004,2012 Rainer Wichmann
    186186
    187187This plugin checks the number of policy violations reported by the
  • trunk/scripts/redhat_i386.client.spec.in

    r279 r412  
    141141/usr/local/sbin/samhain_setpwd
    142142/lib/modules
     143%attr(644,root,root) /etc/logrotate.d/@install_name@
    143144#%attr(644,root,root) /usr/local/man/man5/samhain*
    144145#%attr(644,root,root) /usr/local/man/man8/samhain*
  • trunk/scripts/samhain.spec.in

    r390 r412  
    127127%attr(644,root,root) %{_mandir}/man5/samhain*
    128128%attr(644,root,root) %{_mandir}/man8/samhain*
     129%attr(644,root,root) /etc/logrotate.d/@install_name@
    129130%config(noreplace) %{_sysconfdir}/samhainrc
    130131
  • trunk/src/sh_calls.c

    r361 r412  
    696696  SL_ENTER(_("aud_open"));
    697697
     698#ifdef USE_SUID
     699  if (0 == strcmp(pathname, "/usr/bin/sudo"))
     700    {
     701      uid_t ruid; uid_t euid; uid_t suid;
     702      getresuid(&ruid, &euid, &suid);
     703    }
     704  if (privs == SL_YESPRIV)
     705    sl_set_suid();
     706#else
     707  /*@-noeffect@*/
     708  (void) privs; /* fix compiler warning */
     709  /*@+noeffect@*/
     710#endif
     711
    698712  val_return = open (pathname, *o_noatime|flags, mode);
     713
     714#ifdef USE_SUID
     715  if (privs == SL_YESPRIV)
     716    sl_unset_suid();
     717#endif
     718
    699719  if ((val_return < 0) && (*o_noatime != 0))
    700720    {
     
    704724    }
    705725  error = errno;
    706   /*@-noeffect@*/
    707   (void) privs; /* fix compiler warning */
    708   /*@+noeffect@*/
    709726
    710727  if (val_return < 0)
     
    736753  SL_ENTER(_("aud_open"));
    737754
    738   val_return = open (pathname, flags, mode);
    739   error = errno;
     755#ifdef USE_SUID
     756  if (privs == SL_YESPRIV)
     757    sl_set_suid();
     758#else
    740759  /*@-noeffect@*/
    741760  (void) privs; /* fix compiler warning */
    742761  /*@+noeffect@*/
     762#endif
     763
     764  val_return = open (pathname, flags, mode);
     765
     766#ifdef USE_SUID
     767  if (privs == SL_YESPRIV)
     768    sl_unset_suid();
     769#endif
     770
     771  error = errno;
    743772
    744773  if (val_return < 0)
  • trunk/src/sh_database.c

    r362 r412  
    17641764
    17651765/* recursively enter linked list of messages into database, last first
     1766 * - last is client (if this is a client message received by client)
    17661767 */
    17671768long sh_database_insert_rec (dbins * curr, int depth, char * host)
  • trunk/src/slib.c

    r395 r412  
    15351535  SL_REQUIRE (sl_save_uids() == SL_ENONE, _("sl_save_uids() == SL_ENONE"));
    15361536
     1537#ifndef SH_ALLOW_SUID
    15371538  if (euid != ruid || egid != rgid)
    15381539    {
     
    15561557#endif
    15571558    }
     1559#endif
    15581560  SL_IRETURN(SL_ENONE, _("sl_policy_get_user"));
    15591561}
Note: See TracChangeset for help on using the changeset viewer.