close Warning: Can't synchronize with repository "(default)" (The repository directory has changed, you should resynchronize the repository with: trac-admin $ENV repository resync '(default)'). Look in the Trac log for more information.

Changeset 169


Ignore:
Timestamp:
Apr 13, 2008, 9:59:55 PM (19 years ago)
Author:
katerina
Message:

Fixes for tickes #93 to #104 (yes, big commit, bad, bad,...).

Location:
trunk
Files:
2 added
34 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile.in

    r168 r169  
    16981698sh_portcheck.o: $(srcsrc)/sh_portcheck.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_mem.h $(srcinc)/sh_calls.h $(srcinc)/sh_utils.h $(srcinc)/sh_modules.h $(srcinc)/sh_static.h $(srcinc)/sh_pthread.h $(srcinc)/CuTest.h
    16991699sh_pthread.o: $(srcsrc)/sh_pthread.c Makefile config_xor.h $(srcinc)/sh_pthread.h $(srcinc)/sh_calls.h $(srcinc)/sh_modules.h
    1700 sh_string.o: $(srcsrc)/sh_string.c Makefile $(srcinc)/sh_string.h $(srcinc)/sh_mem.h $(srcinc)/CuTest.h
     1700sh_string.o: $(srcsrc)/sh_string.c Makefile config_xor.h $(srcinc)/sh_string.h $(srcinc)/sh_mem.h $(srcinc)/CuTest.h
  • trunk/aclocal.m4

    r168 r169  
    19141914        CPPFLAGS="$ZLIB_OLD_CPPFLAGS"
    19151915        AC_MSG_RESULT(failed)
    1916         AC_MSG_ERROR([zlib not found in ZLIB_HOME, /usr/local, or /usr])
     1916        AC_MSG_WARN([zlib not found in ZLIB_HOME, /usr/local, or /usr])
    19171917fi
    19181918
  • trunk/configure.ac

    r168 r169  
    1313dnl start
    1414dnl
    15 AM_INIT_AUTOMAKE(samhain, 2.4.3)
     15AM_INIT_AUTOMAKE(samhain, 2.4.4)
    1616AC_CANONICAL_HOST
    1717
    … …  
    100100       
    101101        *openbsd*)
     102        AC_DEFINE([HOST_IS_OPENBSD], 1, [Define if host OS is OPENBSD])
    102103        selectconfig=freebsd
    103104        AC_MSG_RESULT(none)
    … …  
    589590$PS ax >/dev/null 2>&1
    590591if test $? -eq 0; then
     592   case "$host_os" in
     593   *openbsd*)
     594   one=`$PS akx | wc -l`
     595   ;;
     596   *)
    591597   one=`$PS ax | wc -l`
     598   ;;
     599   esac
    592600else
    593601   one=0
    … …  
    601609if test $one -ge $two
    602610then
    603     PSARG="ax"
     611   case "$host_os" in
     612   *openbsd*)
     613        PSARG="akx"
     614        ;;
     615   *)
     616        PSARG="ax"
     617        ;;
     618   esac
    604619else
    605     PSARG="-e"
     620        PSARG="-e"
    606621fi
    607622AC_DEFINE_UNQUOTED([PSARG], _("$PSARG"), [Argument for ps])
    … …  
    21462161        [
    21472162        if test "x${cross_compiling}" = xyes; then
    2148                 :
     2163                my_tmp_dir="$withval"
     2164                AC_DEFINE_UNQUOTED(SH_TMPDIR, _("${my_tmp_dir}") )
    21492165        else
    21502166                if test -d "${withval}"; then
    … …  
    21522168                        AC_DEFINE_UNQUOTED(SH_TMPDIR, _("${my_tmp_dir}") )
    21532169                else
    2154                         AC_MSG_ERROR([--with-tmp-dir: tmp directory ${withval} does not exist])
     2170                        my_tmp_dir="$withval"
     2171                        AC_DEFINE_UNQUOTED(SH_TMPDIR, _("${my_tmp_dir}") )
     2172                        AC_MSG_WARN([--with-tmp-dir: tmp directory ${withval} does not exist])
    21552173                fi
    21562174        fi
  • trunk/depend.dep

    r168 r169  
    6363sh_pthread.o: $(srcsrc)/sh_pthread.c Makefile config_xor.h $(srcinc)/sh_pthread.h $(srcinc)/sh_calls.h $(srcinc)/sh_modules.h
    6464kern_head.o: $(srcsrc)/kern_head.c Makefile config.h $(srcinc)/kern_head.h $(srcinc)/kern_head.h
    65 sh_string.o: $(srcsrc)/sh_string.c Makefile $(srcinc)/sh_string.h $(srcinc)/sh_mem.h $(srcinc)/CuTest.h
     65sh_string.o: $(srcsrc)/sh_string.c Makefile config_xor.h $(srcinc)/sh_string.h $(srcinc)/sh_mem.h $(srcinc)/CuTest.h
  • trunk/depend.sum

    r168 r169  
    1 2783424603
     13805394239
  • trunk/docs/Changelog

    r167 r169  
    112.4.4:
    2         * fill content if MODI_TXT, base64 encode and add as link_path
    3           in sh_unix.c; add to report in sh_hash.c; needs listing option
     2        * configure.ac: warn, but accept nonexistent tmp dir
     3          (Problem reported by Brian)
     4        * sh_unix.c: undef P_ALL, P_PID, P_PGID before including
     5          sys/wait.h (compile problem reported by Reputation)
     6        * syslog function tested ok with Syslog Fuzzer v0.1
     7          by Jaime Blasco (c) 2008
     8        * slib.c: call fflush when writing trace to file
     9        * sh_readconf.c: don't set OnlyStderr to false if gpg (problem
     10          reported by Irene Reed)
     11        * fix unconditional removal of pid file in atexit handler (bug
     12          reported by Brian)
     13        * fix invalid free() in sh_unix_checksum_size()
     14        * sh_processcheck.c: workaround for stupid OpenBSD bug (returns
     15          ENODEV instead of EAGAIN, because fgetc does
     16          fcntl(0,F_SETFL,O_NONBLOCK) [ENODEV] internally), problem
     17          reported by Roman R.
     18        * fix buf that cause incomplete reporting of modified symlink if
     19          symlink has changed and both old and new paths are >48 bytes
     20        * fix bug that prevented mount check from running in one-shot mode
     21        * enable mount check for openbsd
     22        * fix processcheck default options and test script for openbsd
     23        * option --list-file to list content of file (if saved)
     24        * sh_tools.c: use strcasecmp in reverse lookup since DNS is case
     25          insensitive (bug reported by Phil)
     26        * fill content if MODI_TXT, zlib compress, base64 encode and add
     27          as link_path in sh_unix.c; add to report in sh_hash.c
    428        * testsuite: add test for gpg fingerprint option
    529        * sh_extern.c: add 'CloseCommand' for syntactic sugar,
    630          add in testsuite
    731
    8 2.4.3a:
    9         * fix compile error cause by open() with O_CREAT and no third argument
     322.4.3a (12-02-2008):
     33        * fix compile error caused by open() with O_CREAT and no third argument
    1034          (reported by J.-S. Eon)
    1135
    12 2.4.3:
     362.4.3 (31-01-2008):
    1337        * sh_kern.c: don't require asm/segment.h for kernel check module
    1438        * use global var with pid of initial thread instead of getpid(),
  • trunk/docs/TODO

    r134 r169  
    11
    22
    3 check thread_safe sh_entropy
    4 check thread_safe rng
    5 
    6 
     3check reported problem with rpmbuild (samhain_setpwd)
  • trunk/include/sh_cat.h

    r78 r169  
    142142
    143143#ifdef SH_USE_PORTCHECK
    144  MSG_PORT_REPORT,
     144 MSG_PORT_MISS,
     145 MSG_PORT_NEW,
     146 MSG_PORT_RESTART,
     147 MSG_PORT_NEWPORT,
    145148#endif
    146149
  • trunk/include/sh_extern.h

    r164 r169  
    1010  char   *  envv[32];
    1111  char      checksum[KEY_LEN + 1];
    12 
     12#if 0
    1313  uid_t     trusted_users[32];
     14#endif
    1415  uid_t     run_user_uid;
    1516  gid_t     run_user_gid;
  • trunk/include/sh_hash.h

    r115 r169  
    4747 */
    4848int sh_hash_list_db (const char * db_file);
     49
     50/* List database content for a single file
     51 */
     52int set_list_file (const char * c);
    4953
    5054/* List database content with full detail
  • trunk/include/sh_unix.h

    r167 r169  
    9191#define MODI_PREL (1 << 13)
    9292/* get content     */
    93 #define MODI_TXT (1 << 14)
     93#define MODI_TXT ((1 << 14)|MODI_CHK)
    9494
    9595#define SH_TXT_MAX 9200
  • trunk/include/slib.h

    r167 r169  
    213213
    214214  /*
     215   * robust strcasecmp replacement
     216   */
     217  int sl_strcasecmp(const char * one, const char * two);
     218
     219  /*
    215220   * robust strlen replacement
    216221   */
  • trunk/man/samhain.8

    r76 r169  
    262262[\-a | \-\-full\-detail]
    263263List all informations for each file, not only those you would get
    264 with ls \-l.
     264with ls \-l. Must precede the \-d option.
    265265.TP
    266266[\-\-delimited]
    267267List all informations for each file, in a comma-separated format.
     268Must precede the \-d option.
     269.TP
     270.RI [\-\-list\-file= file ]
     271List the literal content of the given file as stored in the database.
     272Content is not stored by default, must be enabled in the runtime
     273configuration file. Must precede the \-d option.
    268274
    269275.SS "OPTIONS TO VERIFY AN AUDIT TRAIL"
  • trunk/man/samhainrc.5

    r119 r169  
    648648.BI RedefReadOnly= +/-XXX,+/-YYY,...
    649649Add or subtract tests XXX from the ReadOnly policy.
    650 Tests are: CHK (checksum), LNK (link),
     650Tests are: CHK (checksum), TXT (store literal content), LNK (link),
    651651HLN (hardlink), INO (inode), USR (user), GRP (group), MTM (mtime),
    652652ATM (atime), CTM (ctime), SIZ (size), RDEV (device numbers)
  • trunk/src/cutest_slib.c

    r21 r169  
    2424}
    2525
     26void Test_sl_strcasecmp (CuTest *tc) {
     27  char one[64], two[64];
     28  int  res;
    2629
     30  strcpy(one, "foo");
     31  strcpy(two, "foo");
     32  res = sl_strcasecmp(one, two);
     33  CuAssertIntEquals(tc, 0, res);
     34
     35  strcpy(one, "fo");
     36  strcpy(two, "foo");
     37  res = sl_strcasecmp(one, two);
     38  CuAssertIntEquals(tc, -1, res);
     39
     40  strcpy(one, "foo");
     41  strcpy(two, "fo");
     42  res = sl_strcasecmp(one, two);
     43  CuAssertIntEquals(tc, 1, res);
     44
     45  strcpy(one, "1234");
     46  strcpy(two, "2345");
     47  res = sl_strcasecmp(one, two);
     48  CuAssertIntEquals(tc, -1, res);
     49
     50  strcpy(one, "234");
     51  strcpy(two, "123");
     52  res = sl_strcasecmp(one, two);
     53  CuAssertIntEquals(tc, 1, res);
     54
     55  strcpy(one, "");
     56  strcpy(two, "123");
     57  res = sl_strcasecmp(one, two);
     58  CuAssertIntEquals(tc, -1, res);
     59
     60  strcpy(one, "234");
     61  strcpy(two, "");
     62  res = sl_strcasecmp(one, two);
     63  CuAssertIntEquals(tc, 1, res);
     64
     65  strcpy(one, "");
     66  strcpy(two, "");
     67  res = sl_strcasecmp(one, two);
     68  CuAssertTrue(tc, res == 0);
     69
     70#ifndef SL_FAIL_ON_ERROR
     71  res = sl_strcasecmp(NULL, two);
     72  CuAssertIntEquals(tc, -1, res);
     73
     74  res = sl_strcasecmp(one, NULL);
     75  CuAssertIntEquals(tc, 1, res);
     76
     77  res = sl_strcasecmp(NULL, NULL);
     78  CuAssertTrue(tc, res != 0);
     79#endif
     80}
  • trunk/src/samhain.c

    r162 r169  
    775775   */
    776776  (void) sh_unix_rm_lock_file (sh.srvlog.name);
    777   (void) sh_unix_rm_pid_file ();
     777  if (sh.flag.isdaemon == S_TRUE)
     778    (void) sh_unix_rm_pid_file ();
    778779  if (skey != NULL)
    779780    memset (skey, (int) '\0', sizeof(sh_key_t));
  • trunk/src/sh_calls.c

    r137 r169  
    341341#endif
    342342
    343   SL_ENTER(_("retry_fcntl"));
     343  SL_ENTER(_("retry_msleep"));
    344344
    345345  errno  = 0;
  • trunk/src/sh_cat.c

    r144 r169  
    134134
    135135#ifdef SH_USE_PORTCHECK
    136   { MSG_PORT_REPORT, SH_ERR_SEVERE,  EVENT, N_("msg=\"%s\"")},
     136  { MSG_PORT_MISS,   SH_ERR_SEVERE,  EVENT, N_("msg=\"POLICY [ServiceMissing] %s\"")},
     137  { MSG_PORT_NEW,    SH_ERR_SEVERE,  EVENT, N_("msg=\"POLICY [ServiceNew] %s\"")},
     138  { MSG_PORT_RESTART,SH_ERR_SEVERE,  EVENT, N_("msg=\"POLICY [ServiceRestarted] %s\"")},
     139  { MSG_PORT_NEWPORT,SH_ERR_SEVERE,  EVENT, N_("msg=\"POLICY [ServicePortSwitch] %s\"")},
    137140#endif
    138141
    … …  
    449452
    450453#ifdef SH_USE_PORTCHECK
    451   { MSG_PORT_REPORT, SH_ERR_SEVERE,  EVENT, N_("msg=<%s>")},
     454  { MSG_PORT_MISS,   SH_ERR_SEVERE,  EVENT, N_("msg=<POLICY [ServiceMissing] %s>")},
     455  { MSG_PORT_NEW,    SH_ERR_SEVERE,  EVENT, N_("msg=<POLICY [ServiceNew] %s>")},
     456  { MSG_PORT_RESTART,SH_ERR_SEVERE,  EVENT, N_("msg=<POLICY [ServiceRestarted] %s>")},
     457  { MSG_PORT_NEWPORT,SH_ERR_SEVERE,  EVENT, N_("msg=<POLICY [ServicePortSwitch] %s>")},
    452458#endif
    453459
  • trunk/src/sh_extern.c

    r164 r169  
    143143   * --  check whether path is trustworthy
    144144   */
     145  status = sl_trustfile(task->command, NULL, NULL);
     146#if 0
    145147  if ((uid_t) -1 != task->trusted_users[0])
    146148    {
    147149      status = sl_trustfile(task->command, task->trusted_users, NULL);
    148150    }
     151#endif
    149152
    150153  PDBG_OPEN;
    … …  
    647650      tas->argv[i]          = NULL;
    648651      tas->envv[i]          = NULL;
     652#if 0
    649653      tas->trusted_users[i] = (uid_t) -1;
     654#endif
    650655    }
    651656
    … …  
    826831
    827832  (void) sl_get_euid(&ff_euid);
     833#if 0
    828834  ext_com->tas.trusted_users[0] = (uid_t) 0;
    829835  ext_com->tas.trusted_users[1] = (uid_t) (ff_euid);
     836#endif
    830837
    831838  /* ------------------------------------------------- */
  • trunk/src/sh_getopt.c

    r161 r169  
    225225    HAS_ARG_NO,
    226226    sh_getopt_forever},
     227  { N_("list-file"), 
     228    '-',
     229    N_("Modify -d to list content of a single file"), 
     230    HAS_ARG_YES,
     231    set_list_file},
    227232  { N_("full-detail"), 
    228233    'a',
    … …  
    417422#if defined(SL_DEBUG)
    418423  if (num > 0) fputc ('\n', stdout);
    419   fputs (_(" debug build"), stdout); ++num;
     424  fputs (_(" debug build (don't use for production)"), stdout); ++num;
    420425#endif
    421426#if defined(SCREW_IT_UP)
    … …  
    433438
    434439#if defined(SH_WITH_CLIENT) || defined(SH_STANDALONE)
     440#if defined(HAVE_LIBZ)
     441  if (num > 0) fputc ('\n', stdout);
     442  fputs (_(" optionally store full text for files"), stdout); ++num;
     443#endif
    435444#if defined(USE_XATTR)
    436445  if (num > 0) fputc ('\n', stdout);
  • trunk/src/sh_hash.c

    r167 r169  
    24972497  sl_strlcat(msg, tmp, SH_BUFSIZE);
    24982498
    2499   if (theFile->c_mode[0] == 'l' || theFile->link_path != NULL)
     2499  if (theFile->c_mode[0] == 'l' ||
     2500      (theFile->link_path != NULL && theFile->link_path[0] != '-'))
    25002501    {
    25012502      tmp_lnk     = sh_util_safe_name(theFile->link_path);
    … …  
    26632664  sl_strlcat(msg, tmp, SH_BUFSIZE);
    26642665
    2665   if (theFile->c_mode[0] == 'l' || theFile->link_path != NULL)
     2666  if (theFile->c_mode[0] == 'l' ||
     2667      (theFile->link_path != NULL && theFile->link_path[0] != '-'))
    26662668    {
    26672669      tmp_lnk     = sh_util_safe_name(theFile->link_path);
    … …  
    27392741  char timstr2m[32];
    27402742  char linkHash[KEY_LEN+1];
     2743  char * linkComp;
    27412744  int  maxcomp;
    27422745
    … …  
    28692872  if (p->theFile.c_mode[0] == 'l')
    28702873    {
    2871       if (sl_strlen(theFile->link_path) >= MAX_PATH_STORE)
    2872         {
    2873           sl_strlcpy(linkHash,
    2874                      sh_tiger_hash(theFile->link_path,
    2875                                    TIGER_DATA,
    2876                                    sl_strlen(theFile->link_path),
    2877                                    hashbuf, sizeof(hashbuf)),
    2878                      MAX_PATH_STORE+1);
    2879           maxcomp = MAX_PATH_STORE;
    2880         }
    2881       else
    2882         {
    2883           sl_strlcpy(linkHash, theFile->link_path, KEY_LEN + 1);
    2884           maxcomp = KEY_LEN;
    2885         }
    2886      
    2887 
    2888       if ( sl_strncmp (linkHash, p->linkpath, maxcomp) != 0 &&
    2889            (theFile->check_mask & MODI_LNK) != 0)
    2890         {
     2874      if (!(theFile->link_path) &&
     2875          (theFile->check_mask & MODI_LNK) != 0)
     2876        {
     2877          linkComp = NULL;
    28912878          modi_mask |= MODI_LNK;
    28922879          change_code[1] = 'L';
    28932880          TPT ((0, FIL__, __LINE__, _("mod=<link>")));
    2894         }
     2881        }
     2882      else
     2883        {
     2884          if (sl_strlen(theFile->link_path) >= MAX_PATH_STORE)
     2885            {
     2886              sl_strlcpy(linkHash,
     2887                         sh_tiger_hash(theFile->link_path,
     2888                                       TIGER_DATA,
     2889                                       sl_strlen(theFile->link_path),
     2890                                       hashbuf, sizeof(hashbuf)),
     2891                         MAX_PATH_STORE+1);
     2892              linkComp = linkHash;
     2893              maxcomp  = KEY_LEN;
     2894            }
     2895          else
     2896            {
     2897              linkComp = theFile->link_path;
     2898              maxcomp  = MAX_PATH_STORE;
     2899            }
     2900         
     2901          if ( sl_strncmp (linkComp, p->linkpath, maxcomp) != 0 &&
     2902               (theFile->check_mask & MODI_LNK) != 0)
     2903            {
     2904              modi_mask |= MODI_LNK;
     2905              change_code[1] = 'L';
     2906              TPT ((0, FIL__, __LINE__, _("mod=<link>")));
     2907            }
     2908        }
    28952909    }
    28962910
    … …  
    33493363            }
    33503364#endif
    3351         }
    3352 
    3353 
    3354       if ((modi_mask & MODI_LNK) != 0 && theFile->c_mode[0] == 'l')
    3355         {
    3356           tmp_lnk     = sh_util_safe_name(theFile->link_path);
    3357           tmp_lnk_old = sh_util_safe_name(p->linkpath);
     3365          /* FIXME is this correct? */
     3366          if (theFile->c_mode[0] != 'l' && theFile->link_path &&
     3367              strlen(theFile->link_path) > 2)
     3368            modi_mask |= MODI_LNK;
     3369        }
     3370
     3371
     3372      if ((modi_mask & MODI_LNK) != 0 /* && theFile->c_mode[0] == 'l' */)
     3373        {
     3374          if (theFile->link_path)
     3375            tmp_lnk     = sh_util_safe_name(theFile->link_path);
     3376          else
     3377            tmp_lnk     = sh_util_strdup("-");
     3378          if (p->linkpath)
     3379            tmp_lnk_old = sh_util_safe_name(p->linkpath);
     3380          else
     3381            tmp_lnk_old = sh_util_strdup("-");
    33583382#ifdef SH_USE_XML
    33593383          sl_snprintf(tmp, SH_BUFSIZE, _("link_old=\"%s\" link_new=\"%s\" "),
    … …  
    35993623#endif
    36003624
    3601 static int ListFullDetail = S_FALSE;
     3625static int ListFullDetail    = S_FALSE;
    36023626static int ListWithDelimiter = S_FALSE;
     3627static char * ListFile       = NULL;
     3628
     3629int set_list_file (const char * c)
     3630{
     3631  ListFile = sh_util_strdup(c);
     3632  return 0;
     3633}
    36033634
    36043635int set_full_detail (const char * c)
    … …  
    38583889}
    38593890
     3891#ifdef HAVE_LIBZ
     3892#include <zlib.h>
     3893#endif   
     3894
     3895int sh_hash_printcontent(char * linkpath)
     3896{
     3897#ifdef HAVE_LIBZ
     3898  unsigned char * decoded;
     3899  unsigned char * decompressed = NULL;
     3900  size_t dlen;
     3901  unsigned long clen;
     3902  unsigned long clen_o;
     3903  int    res;
     3904
     3905  if (linkpath && *linkpath != '-')
     3906    {
     3907      dlen = sh_util_base64_dec_alloc (&decoded,
     3908                                       (unsigned char *)linkpath,
     3909                                       strlen(linkpath));
     3910      clen = dlen * 2 + 1;
     3911      do {
     3912        if (decompressed)
     3913          SH_FREE(decompressed);
     3914        clen += dlen; clen_o = clen;
     3915        decompressed = SH_ALLOC(clen);
     3916        res = uncompress(decompressed, &clen, decoded, dlen);
     3917        if (res == Z_MEM_ERROR)
     3918          { fprintf(stderr, _("Error: Not enough memory\n")); return -1; }
     3919        if (res == Z_DATA_ERROR)
     3920          { fprintf(stderr, _("Error: Data corrupt or incomplete\n")); return -1; }
     3921      } while (res == Z_BUF_ERROR || clen == clen_o);
     3922      decompressed[clen] = '\0';
     3923      fputs( (char*) decompressed, stdout);
     3924      return 0;
     3925    }
     3926#else
     3927  (void) linkpath;
     3928#endif
     3929  fprintf(stderr, _("Error: No data available\n"));
     3930  return -1;
     3931}
     3932
    38603933int sh_hash_list_db (const char * db_file)
    38613934{
    … …  
    38633936  SL_TICKET fd;
    38643937  char * line;
     3938  int  flag = 0;
    38653939
    38663940  if (!db_file)
    … …  
    39003974    {
    39013975      p = sh_hash_getdataent (fd, line, MAX_PATH_STORE);
    3902       if ((p != NULL) && (p->fullpath[0] != 'K'))
    3903         {
    3904           if (ListFullDetail == S_FALSE)
    3905             sh_hash_list_db_entry (p);
     3976      if ((p != NULL) && (p->fullpath[0] == '/'))
     3977        {
     3978          if (!ListFile)
     3979            {
     3980              flag = 1;
     3981              if (ListFullDetail == S_FALSE)
     3982                sh_hash_list_db_entry (p);
     3983              else
     3984                sh_hash_list_db_entry_full_detail (p);
     3985            }
    39063986          else
    3907             sh_hash_list_db_entry_full_detail (p);
     3987            {
     3988              if (0 != sl_strcmp(ListFile, p->fullpath))
     3989                {
     3990                  continue;
     3991                }
     3992              flag = 1;
     3993              if ('l' != p->theFile.c_mode[0])
     3994                {
     3995                  if (sh_hash_printcontent(p->linkpath) < 0)
     3996                    {
     3997                      _exit(EXIT_FAILURE);
     3998                      return -1;
     3999                    }
     4000                }
     4001              else
     4002                {
     4003                  fprintf(stderr, _("File is a link\n"));
     4004                  _exit(EXIT_FAILURE);
     4005                  return -1;
     4006                }
     4007              break;
     4008            }
    39084009        }
    39094010      else if (p == NULL)
    … …  
    39194020  fflush(NULL);
    39204021
     4022  if (flag == 0)
     4023    {
     4024      fprintf(stderr, _("No file found\n"));
     4025      _exit(EXIT_FAILURE);
     4026    }
    39214027  _exit(EXIT_SUCCESS);
    39224028  return 0;
  • trunk/src/sh_mounts.c

    r149 r169  
    180180  }
    181181
    182   lastcheck = time(NULL);
    183 
    184182  SL_RETURN(0, _("sh_mounts_init"));
    185183}
    … …  
    197195    SL_RETURN(-1, _("sh_mounts_timer"));
    198196  }
    199   
     197 
    200198  SL_RETURN(0, _("sh_mounts_timer"));
    201199}
    … …  
    400398
    401399/* FreeBSD includes */
    402 #ifdef HOST_IS_FREEBSD
     400#if defined(HOST_IS_FREEBSD) || defined(HOST_IS_OPENBSD)
    403401#include <sys/param.h>
    404402#include <sys/ucred.h>
    … …  
    577575#endif
    578576
    579 #if defined(HOST_IS_FREEBSD)
     577#if defined(HOST_IS_FREEBSD) || defined(HOST_IS_OPENBSD)
    580578
    581579/* FreeBSD returns flags instead of strings as mount options, so we'll convert
    … …  
    595593                {"local",       MNT_LOCAL},
    596594                {"quota",       MNT_QUOTA},
     595#ifdef MNT_NOATIME
     596                {"noatime",     MNT_NOATIME},
     597#endif
    597598                {"bound",       -1}
    598599        };
    … …  
    665666        list = m;
    666667
    667 /* The FreeBSD way */
    668 #ifdef HOST_IS_FREEBSD
     668/* The Open/FreeBSD way */
     669#if defined(HOST_IS_FREEBSD) || defined(HOST_IS_OPENBSD)
    669670{
    670671        struct statfs *fsp;
  • trunk/src/sh_portcheck.c

    r162 r169  
    384384          if (ptr->flag != SH_PORT_OPT && ptr->flag != SH_PORT_IGN)
    385385            {
    386               snprintf (errbuf, sizeof(errbuf), _("POLICY [ServiceMissing] port %s:%d/%s (%s)"),
     386              snprintf (errbuf, sizeof(errbuf), _("port: %s:%d/%s (%s)"),
    387387                        ptr->interface, ptr->port, SH_PROTO_STR(proto),
    388388                        ptr->service ? ptr->service : check_services(ptr->port, proto));
    … …  
    395395                  SH_MUTEX_LOCK(mutex_thread_nolog);
    396396                  sh_error_handle(sh_portchk_severity, FIL__, __LINE__, 0,
    397                                   MSG_PORT_REPORT, errbuf);
     397                                  MSG_PORT_MISS, errbuf);
    398398                  SH_MUTEX_UNLOCK(mutex_thread_nolog);
    399399                }
    … …  
    497497      if (!portent)
    498498        {
    499           snprintf (errbuf, sizeof(errbuf), _("POLICY [ServiceNew] port %s:%d/%s (%s)"),
     499          snprintf (errbuf, sizeof(errbuf), _("port: %s:%d/%s (%s)"),
    500500                    inet_ntoa(haddr), port, SH_PROTO_STR(proto), service);
    501501#ifdef TEST_ONLY
    … …  
    505505          SH_MUTEX_LOCK(mutex_thread_nolog);
    506506          sh_error_handle(sh_portchk_severity, FIL__, __LINE__, 0,
    507                           MSG_PORT_REPORT, errbuf);
     507                          MSG_PORT_NEW, errbuf);
    508508          SH_MUTEX_UNLOCK(mutex_thread_nolog);
    509509#endif
    … …  
    515515      else if (portent->status == SH_PORT_MISS && portent->flag != SH_PORT_IGN)
    516516        {
    517           snprintf (errbuf, sizeof(errbuf), _("POLICY [ServiceRestarted] port %s:%d/%s to %d/%s (%s)"),
    518                     inet_ntoa(haddr), portent->port, SH_PROTO_STR(proto), port, SH_PROTO_STR(proto), service);
     517          snprintf (errbuf, sizeof(errbuf), _("port: %s:%d/%s (%s), was %d/%s"),
     518                    inet_ntoa(haddr), port, SH_PROTO_STR(proto), service, portent->port, SH_PROTO_STR(proto));
    519519#ifdef TEST_ONLY
    520520          fprintf(stderr, _("service: %s\n"), errbuf);
    … …  
    522522          SH_MUTEX_LOCK(mutex_thread_nolog);
    523523          sh_error_handle(sh_portchk_severity, FIL__, __LINE__, 0,
    524                           MSG_PORT_REPORT, errbuf);
     524                          MSG_PORT_RESTART, errbuf);
    525525          SH_MUTEX_UNLOCK(mutex_thread_nolog);
    526526#endif
    … …  
    530530      else if (port != portent->port && (-1) != portent->port)
    531531        {
    532           snprintf (errbuf, sizeof(errbuf), _("POLICY [ServicePortSwitch] port %s:%d/%s to %d/%s (%s)"),
    533                     inet_ntoa(haddr), portent->port, SH_PROTO_STR(proto), port, SH_PROTO_STR(proto), service);
     532          snprintf (errbuf, sizeof(errbuf), _("port: %s:%d/%s (%s), was %d/%s"),
     533                    inet_ntoa(haddr), port, SH_PROTO_STR(proto), service, portent->port, SH_PROTO_STR(proto));
    534534#ifdef TEST_ONLY
    535535          fprintf(stderr, _("service: %s\n"), errbuf);
    … …  
    537537          SH_MUTEX_LOCK(mutex_thread_nolog);
    538538          sh_error_handle(sh_portchk_severity, FIL__, __LINE__, 0,
    539                           MSG_PORT_REPORT, errbuf);
     539                          MSG_PORT_NEWPORT, errbuf);
    540540          SH_MUTEX_UNLOCK(mutex_thread_nolog);
    541541#endif
    … …  
    552552      if (!portent)
    553553        {
    554           snprintf (errbuf, sizeof(errbuf), _("POLICY [ServiceNew] port %s:%d/%s (%s)"),
     554          snprintf (errbuf, sizeof(errbuf), _("port: %s:%d/%s (%s)"),
    555555                    inet_ntoa(haddr), port, SH_PROTO_STR(proto), check_services(port, proto));
    556556#ifdef TEST_ONLY
    … …  
    560560          SH_MUTEX_LOCK(mutex_thread_nolog);
    561561          sh_error_handle(sh_portchk_severity, FIL__, __LINE__, 0,
    562                           MSG_PORT_REPORT, errbuf);
     562                          MSG_PORT_NEW, errbuf);
    563563          SH_MUTEX_UNLOCK(mutex_thread_nolog);
    564564#endif
    … …  
    570570      else if (portent->status == SH_PORT_MISS && portent->flag != SH_PORT_IGN)
    571571        {
    572           snprintf (errbuf, sizeof(errbuf), _("POLICY [ServiceRestarted] port %s:%d/%s (%s)"),
     572          snprintf (errbuf, sizeof(errbuf), _("port: %s:%d/%s (%s)"),
    573573                    inet_ntoa(haddr), port, SH_PROTO_STR(proto), check_services(port, proto));
    574574#ifdef TEST_ONLY
    … …  
    577577          SH_MUTEX_LOCK(mutex_thread_nolog);
    578578          sh_error_handle(sh_portchk_severity, FIL__, __LINE__, 0,
    579                           MSG_PORT_REPORT, errbuf);
     579                          MSG_PORT_RESTART, errbuf);
    580580          SH_MUTEX_UNLOCK(mutex_thread_nolog);
    581581#endif
  • trunk/src/sh_prelude.c

    r131 r169  
    8585#define SH_NEED_PWD_GRP 1
    8686#include "sh_static.h"
    87 
     87char * sh_util_strdup (const char * str) SH_GNUC_MALLOC;
    8888/*
    8989 * When SH_USE_XML is set, value are formated using name="value".
    … …  
    651651#endif
    652652
     653#ifdef SH_USE_PORTCHECK
     654                { MSG_PORT_MISS, N_("Service closed"), IDMEF_IMPACT_TYPE_OTHER },
     655                { MSG_PORT_NEW, N_("Service opened"), IDMEF_IMPACT_TYPE_OTHER },
     656                { MSG_PORT_RESTART, N_("Service restarted"), IDMEF_IMPACT_TYPE_OTHER },
     657                { MSG_PORT_NEWPORT, N_("Service restarted"), IDMEF_IMPACT_TYPE_OTHER },
     658#endif
     659
    653660#ifdef SH_USE_SUIDCHK
    654661                { MSG_SUID_POLICY, N_("SUID/SGID File Detected"), IDMEF_IMPACT_TYPE_FILE },
    … …  
    684691
    685692
     693#ifdef SH_USE_PORTCHECK
     694static int get_service_info(char *msg, idmef_alert_t *alert)
     695{
     696        int ret;
     697        long port;
     698        char *ptr, *new, *tmp, *ip, *srv, *end;
     699        prelude_string_t *str;
     700        idmef_address_t *address;
     701        idmef_node_t *node;
     702        idmef_service_t *service;
     703        idmef_source_t *source = idmef_alert_get_next_source(alert, NULL);
     704
     705        new = sh_util_strdup(msg);
     706 
     707        ptr = strstr(new, _("port: "));
     708        if ( ! ptr ) {
     709                sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
     710                                _("malformed Samhain port check message"), _("get_service_info"));
     711                SH_FREE( new );
     712                return -1;
     713        }
     714
     715        ptr += 6; /* skip 'port: ', position on first byte of interface */
     716        tmp = strchr(ptr, ':');
     717        if ( ! tmp ) {
     718                sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
     719                                _("malformed Samhain port check message (no port)"), _("get_service_info"));
     720                SH_FREE( new );
     721                return -1;
     722        }
     723        *tmp = '\0';
     724
     725        ip = strdup(ptr);
     726        if ( ip ) {
     727                if ( ! source ) {
     728                        ret = idmef_alert_new_source(alert, &source, IDMEF_LIST_APPEND);
     729                        if ( ret < 0 ) {
     730                                free(ip);
     731                                SH_FREE( new );
     732                                return ret;
     733                        }
     734                }
     735
     736                ret = idmef_source_new_node(source, &node);
     737                if ( ret < 0 ) {
     738                        free(ip);
     739                        SH_FREE( new );
     740                        return ret;
     741                }
     742               
     743                ret = idmef_node_new_address(node, &address, IDMEF_LIST_APPEND);
     744                if ( ret < 0 ) {
     745                        free(ip);
     746                        SH_FREE( new );
     747                        return ret;
     748                }
     749               
     750                ret = idmef_address_new_address(address, &str);
     751                if ( ret < 0 ) {
     752                        free(ip);
     753                        SH_FREE( new );
     754                        return ret;
     755                }
     756               
     757                prelude_string_set_nodup(str, ip);
     758        }
     759
     760        ptr = tmp;
     761        ++ptr;
     762        tmp = strchr(ptr, '/');
     763        if ( ! tmp ) {
     764                sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
     765                                _("malformed Samhain port check message (no protocol)"), _("get_service_info"));
     766                SH_FREE( new );
     767                return -1;
     768        }
     769        *tmp = '\0';
     770
     771        port = strtol(ptr, &end, 0);
     772        if ( *ptr && *end == '\0' && port >= 0 && port < 65536) {
     773
     774                if ( ! source ) {
     775                        ret = idmef_alert_new_source(alert, &source, IDMEF_LIST_APPEND);
     776                        if ( ret < 0 ) {
     777                                free(srv);
     778                                SH_FREE( new );
     779                                return ret;
     780                        }
     781                }
     782
     783                ret = idmef_source_new_service(source, &service);
     784                if ( ret < 0 ) {
     785                        free(srv);
     786                        SH_FREE( new );
     787                        return ret;
     788                }
     789
     790                idmef_service_set_port(service, port);
     791        }
     792
     793        ptr = tmp;
     794        ++ptr;
     795        ptr = strchr(ptr, '(');
     796        if ( ! ptr ) {
     797                sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
     798                                _("malformed Samhain port check message (no service)"), _("get_service_info"));
     799                SH_FREE( new );
     800                return -1;
     801        }
     802        ++ptr;
     803        tmp = strchr(ptr, ')');
     804        if ( ! tmp ) {
     805                sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
     806                                _("malformed Samhain port check message (service not closed)"), _("get_service_info"));
     807                SH_FREE( new );
     808                return -1;
     809        }
     810        *tmp = '\0';
     811
     812        srv = strdup(ptr);
     813        if ( srv ) {
     814                if ( ! source ) {
     815                        ret = idmef_alert_new_source(alert, &source, IDMEF_LIST_APPEND);
     816                        if ( ret < 0 ) {
     817                                free(srv);
     818                                SH_FREE( new );
     819                                return ret;
     820                        }
     821                }
     822
     823                if ( ! service ) {
     824                        ret = idmef_source_new_service(source, &service);
     825                        if ( ret < 0 ) {
     826                                free(srv);
     827                                SH_FREE( new );
     828                                return ret;
     829                        }
     830                }
     831
     832                ret = idmef_service_new_ident(service, &str);
     833                if ( ret < 0 ) {
     834                        free(srv);
     835                        SH_FREE( new );
     836                        return ret;
     837                }
     838               
     839                prelude_string_set_nodup(str, srv);
     840        }
     841
     842        SH_FREE( new );
     843
     844        return 0;
     845}
     846#endif
    686847
    687848static int get_login_info(char *msg, idmef_alert_t *alert)
    … …  
    9021063                goto err;
    9031064       
     1065#ifdef SH_USE_PORTCHECK
     1066        if (msgid == MSG_PORT_MISS || msgid == MSG_PORT_NEW || msgid == MSG_PORT_RESTART || msgid == MSG_PORT_NEWPORT) {
     1067                ret = get_service_info(message, alert);
     1068                if ( ret < 0 )
     1069                        goto err;
     1070        }
     1071#endif
     1072   
    9041073        map_policy_to_class(message, msgid, impact, str);
    9051074
  • trunk/src/sh_processcheck.c

    r144 r169  
    837837          else if (errno == EAGAIN)
    838838            {
     839              clearerr(in);
    839840              continue;
    840841            }
     842#ifdef HOST_IS_OPENBSD
     843          else if (errno == ENODEV)
     844            {
     845              clearerr(in);
     846              continue;
     847            }
     848#endif
    841849          else
    842850            {
    … …  
    10491057  size_t i, j;
    10501058  char  tests[512];
     1059  int   retval;
    10511060
    10521061  pid_t this_pid;
    … …  
    10601069      SH_MUTEX_LOCK(mutex_thread_nolog);
    10611070      sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
    1062                       _("Internal error: NULL argument"),
     1071                      _("Internal error: NULL argument, switching off"),
    10631072                      _("sh_process_check_int"));
    10641073      SH_MUTEX_UNLOCK(mutex_thread_nolog);
    … …  
    10671076
    10681077  SH_MUTEX_LOCK(mutex_thread_nolog);
    1069   sh_processes_runps (res, NULL, 0, SH_PR_PS, 0);
     1078  retval = sh_processes_runps (res, NULL, 0, SH_PR_PS, 0);
    10701079  SH_MUTEX_UNLOCK(mutex_thread_nolog);
    10711080  for (i = sh_prochk_minpid; i != sh_prochk_maxpid; ++i)
    … …  
    10751084    }
    10761085  SH_MUTEX_LOCK(mutex_thread_nolog);
    1077   sh_processes_runps (res, NULL, 0, SH_PR_PS2, 0);
     1086  retval += sh_processes_runps (res, NULL, 0, SH_PR_PS2, 0);
    10781087  SH_MUTEX_UNLOCK(mutex_thread_nolog);
     1088
     1089  if (retval != 0)
     1090    {
     1091      SH_MUTEX_LOCK(mutex_thread_nolog);
     1092      sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
     1093                      _("Failed to run ps, switching off"),
     1094                      _("sh_process_check_int"));
     1095      SH_MUTEX_UNLOCK(mutex_thread_nolog);
     1096      SL_RETURN ((-1), _("sh_process_check_int"));
     1097    }
    10791098
    10801099  /* Evaluate results
  • trunk/src/sh_readconf.c

    r164 r169  
    573573   */
    574574  sl_rewind (fd);
    575   sh_error_only_stderr (S_FALSE);
    576575  if (0 != sh_gpg_check_sign (fd, 0, 1))
    577576    aud_exit (FIL__, __LINE__, EXIT_FAILURE);
  • trunk/src/sh_tools.c

    r161 r169  
    582582                      *errnum = 0;
    583583                      if (sl_strlen(host_entry->h_name) == 0 ||
    584                           (*errnum = sl_strcmp(host_name,host_entry->h_name)) != 0)
     584                          (*errnum = sl_strcasecmp(host_name,host_entry->h_name)) != 0)
    585585                        {
    586586                          if (*errnum)
    … …  
    16631663        SH_FREE (file);
    16641664        SH_FREE(my_tmp_dir);
     1665        sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, status, MSG_E_SUBGEN,
     1666                        _("Error (lstat) while opening temporary file"), _("open_tmp"));
    16651667        TPT(( 0, FIL__, __LINE__, _("msg=<Unexpected error %d>\n"), error));
    16661668        SL_RETURN((-1), _("open_tmp"));
  • trunk/src/sh_unix.c

    r167 r169  
    4343#include <fcntl.h>
    4444#include <unistd.h>
     45/* need to undef these, since the #define's may be picked up from
     46 * linux/wait.h, and will clash with a typedef in sys/wait.h
     47 */
     48#undef P_ALL
     49#undef P_PID
     50#undef P_PGID
    4551#include <sys/wait.h>
    4652
    … …  
    29932999              someval *= 1000;  /* milliseconds in a second */
    29943000              sometime = (unsigned long) someval;
    2995               /* fprintf(stderr, "FIXME PAUSE %ld\n", sometime); */
    29963001              retry_msleep(0, sometime);
    29973002            }
    … …  
    29993004            {
    30003005              sometime = (unsigned long) someval;
    3001               /* fprintf(stderr, "FIXME PAUSE %ld sec\n", sometime); */
    30023006              retry_msleep (sometime, 0);
    30033007            }
    … …  
    30373041
    30383042  SL_ENTER(_("sh_unix_checksum_size"));
     3043
     3044  tmpFile.link_path = NULL;
    30393045
    30403046  if (sh.flag.checkSum != SH_CHECK_INIT)
    … …  
    32563262}
    32573263#endif
    3258    
     3264
     3265#ifdef HAVE_LIBZ
     3266#include <zlib.h>
     3267#endif   
    32593268
    32603269int sh_unix_getinfo (int level, char * filename, file_type * theFile,
    … …  
    34023411              UINT64 length_nolim = TIGER_NOLIM;
    34033412
    3404               if ((theFile->check_mask & MODI_TXT) != 0 && fbuf.st_size < SH_TXT_MAX)
     3413              if ((theFile->check_mask & MODI_TXT) != 0 && fbuf.st_size < (10 * SH_TXT_MAX))
    34053414                {
    34063415                  sl_init_content (rval_open, fbuf.st_size);
    … …  
    34153424
    34163425              content = sl_get_content(rval_open);
     3426              content = sh_string_copy(content);
    34173427
    34183428              if ((theFile->check_mask & MODI_SGROW) != 0)
    … …  
    34543464              UINT64 length_nolim = TIGER_NOLIM;
    34553465
    3456               if ((theFile->check_mask & MODI_TXT) != 0 && fbuf.st_size < SH_TXT_MAX)
     3466              if ((theFile->check_mask & MODI_TXT) != 0 && fbuf.st_size < (10 * SH_TXT_MAX))
    34573467                {
    34583468                  sl_init_content (rval_open, fbuf.st_size);
    … …  
    34673477
    34683478              content = sl_get_content(rval_open);
     3479              content = sh_string_copy(content);
    34693480
    34703481              if ((theFile->check_mask & MODI_SGROW) != 0)
    … …  
    37593770      if (content)
    37603771        {
    3761           sh_util_base64_enc_alloc (&(theFile->link_path),
    3762                                     sh_string_str(content),
    3763                                     sh_string_len(content));
     3772#ifdef HAVE_LIBZ
     3773          unsigned long   clen = compressBound(sh_string_len(content));
     3774          unsigned char * compressed = SH_ALLOC(clen);
     3775          if (Z_OK == compress(compressed, &clen,
     3776                               (unsigned char *) sh_string_str(content),
     3777                               sh_string_len(content)))
     3778              {
     3779                if (clen < SH_TXT_MAX)
     3780                  {
     3781                    sh_util_base64_enc_alloc (&(theFile->link_path),
     3782                                              (char *) compressed, clen);
     3783                  }
     3784                else
     3785                  {
     3786                    char tmsg[128];
     3787                    char * tpath = sh_util_safe_name (theFile->fullpath);
     3788                    sl_snprintf(tmsg, sizeof(tmsg),
     3789                                _("compressed file too large (%lu bytes)"),
     3790                                clen);
     3791                    sh_error_handle (SH_ERR_WARN, FIL__, __LINE__, -1,
     3792                                     MSG_E_SUBGPATH, tmsg,
     3793                                     _("sh_unix_getinfo"), tpath);
     3794                    SH_FREE(tpath);
     3795                  }
     3796              }
     3797          SH_FREE(compressed);
     3798#endif
     3799          sh_string_destroy(&content);
    37643800        }
    37653801    }
    … …  
    37703806#endif
    37713807
    3772 int sh_unix_unlock (char * lockfile, char * flag);
    3773 int sh_unix_lock   (char * lockfile, char * flag);
     3808int sh_unix_unlock(char * lockfile, char * flag)
     3809{
     3810  int         error = 0;
     3811 
     3812  SL_ENTER(_("sh_unix_unlock"));
     3813
     3814  if (sh.flag.isdaemon == S_FALSE && flag == NULL)
     3815    SL_RETURN((0),_("sh_unix_unlock"));
     3816
     3817  /* --- Logfile is not locked to us. ---
     3818   */
     3819  if (sh.flag.islocked == BAD && flag != NULL)
     3820    SL_RETURN((-1),_("sh_unix_unlock"));
     3821
     3822  /* --- Check whether the directory is secure. ---
     3823   */
     3824  if (0 != tf_trust_check (lockfile, SL_YESPRIV))
     3825    SL_RETURN((-1),_("sh_unix_unlock"));
     3826
     3827  /* --- Delete the lock file. ---
     3828   */
     3829  error = retry_aud_unlink (FIL__, __LINE__, lockfile);
     3830 
     3831  if (error == 0)
     3832    {
     3833      if (flag != NULL)
     3834        sh.flag.islocked = BAD; /* not locked anymore */
     3835    }
     3836  else if (flag != NULL)
     3837    {
     3838      char errbuf[SH_ERRBUF_SIZE];
     3839      error = errno;
     3840      sh_error_handle ((-1), FIL__, __LINE__, error, MSG_E_UNLNK,
     3841                       sh_error_message(error, errbuf, sizeof(errbuf)),
     3842                       lockfile);
     3843      SL_RETURN((-1),_("sh_unix_unlock"));
     3844    }
     3845  SL_RETURN((0),_("sh_unix_unlock"));
     3846}
     3847
     3848int sh_unix_lock (char * lockfile, char * flag)
     3849{
     3850  int filed;
     3851  int errnum;
     3852  char myPid[64];
     3853  SL_TICKET  fd;
     3854  extern int get_the_fd (SL_TICKET ticket);
     3855
     3856  SL_ENTER(_("sh_unix_lock"));
     3857
     3858  sprintf (myPid, "%ld\n", (long) sh.pid);             /* known to fit  */
     3859
     3860  fd = sl_open_safe_rdwr (lockfile, SL_YESPRIV);       /* fails if file exists */
     3861
     3862  if (!SL_ISERROR(fd))
     3863    {
     3864      errnum = sl_write (fd, myPid, sl_strlen(myPid));
     3865      filed = get_the_fd(fd);
     3866      fchmod (filed, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
     3867      sl_close (fd);
     3868
     3869      if (!SL_ISERROR(errnum))
     3870        {
     3871          if (flag != NULL)
     3872            sh.flag.islocked = GOOD;
     3873          SL_RETURN((0),_("sh_unix_lock"));
     3874        }
     3875    }
     3876
     3877  TPT((0, FIL__, __LINE__, _("msg=<open pid file failed>\n")));
     3878  if (flag != NULL)
     3879    sh.flag.islocked       = BAD;
     3880  SL_RETURN((-1),_("sh_unix_lock"));
     3881
     3882  /* notreached */
     3883}
     3884
    37743885
    37753886/* check whether file is locked
    … …  
    39644075}
    39654076
    3966 int sh_unix_unlock(char * lockfile, char * flag)
    3967 {
    3968   int         error = 0;
    3969  
    3970   SL_ENTER(_("sh_unix_unlock"));
    3971 
    3972   /* --- Logfile is not locked to us. ---
    3973    */
    3974   if (sh.flag.islocked == BAD && flag != NULL)
    3975     SL_RETURN((-1),_("sh_unix_unlock"));
    3976 
    3977   /* --- Check whether the directory is secure. ---
    3978    */
    3979   if (0 != tf_trust_check (lockfile, SL_YESPRIV))
    3980     SL_RETURN((-1),_("sh_unix_unlock"));
    3981 
    3982   /* --- Delete the lock file. ---
    3983    */
    3984   error = retry_aud_unlink (FIL__, __LINE__, lockfile);
    3985  
    3986   if (error == 0)
    3987     {
    3988       if (flag != NULL)
    3989         sh.flag.islocked = BAD; /* not locked anymore */
    3990     }
    3991   else if (flag != NULL)
    3992     {
    3993       char errbuf[SH_ERRBUF_SIZE];
    3994       error = errno;
    3995       sh_error_handle ((-1), FIL__, __LINE__, error, MSG_E_UNLNK,
    3996                        sh_error_message(error, errbuf, sizeof(errbuf)),
    3997                        lockfile);
    3998       SL_RETURN((-1),_("sh_unix_unlock"));
    3999     }
    4000   SL_RETURN((0),_("sh_unix_unlock"));
    4001 }
    4002 
    40034077/* rm lock for filename
    40044078 */
    … …  
    40294103{
    40304104  return sh_unix_unlock(sh.srvlog.alt, NULL);
    4031 }
    4032 
    4033 int sh_unix_lock (char * lockfile, char * flag)
    4034 {
    4035   int filed;
    4036   int errnum;
    4037   char myPid[64];
    4038   SL_TICKET  fd;
    4039   extern int get_the_fd (SL_TICKET ticket);
    4040 
    4041   SL_ENTER(_("sh_unix_lock"));
    4042 
    4043   sprintf (myPid, "%ld\n", (long) sh.pid);             /* known to fit  */
    4044 
    4045   fd = sl_open_safe_rdwr (lockfile, SL_YESPRIV);       /* fails if file exists */
    4046 
    4047   if (!SL_ISERROR(fd))
    4048     {
    4049       errnum = sl_write (fd, myPid, sl_strlen(myPid));
    4050       filed = get_the_fd(fd);
    4051       fchmod (filed, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
    4052       sl_close (fd);
    4053 
    4054       if (!SL_ISERROR(errnum))
    4055         {
    4056           if (flag != NULL)
    4057             sh.flag.islocked = GOOD;
    4058           SL_RETURN((0),_("sh_unix_lock"));
    4059         }
    4060     }
    4061 
    4062   TPT((0, FIL__, __LINE__, _("msg=<open pid file failed>\n")));
    4063   if (flag != NULL)
    4064     sh.flag.islocked       = BAD;
    4065   SL_RETURN((-1),_("sh_unix_lock"));
    4066 
    4067   /* notreached */
    40684105}
    40694106
  • trunk/src/slib.c

    r167 r169  
    108108int  sl_trace_use (const char * dummy)
    109109{
    110   if (dummy)
    111     slib_do_trace = 1;
    112   else
    113     slib_do_trace = 1;
     110  (void) dummy;
     111  slib_do_trace = 1;
    114112  return 0;
    115113}
    … …  
    156154          fprintf(trace_fp, "[%2d] %s \t - File %c%s%c at line %d\n",
    157155                 trace_level, str, 0x22, file, 0x22, line);
     156          fflush(trace_fp);
    158157        }
    159158      else
    … …  
    191190          fprintf(trace_fp, _("[%2d] %s \t - File %c%s%c at line %d\n"),
    192191                 trace_level, str, 0x22, file, 0x22, line);
     192          fflush(trace_fp);
    193193        }
    194194      else
    … …  
    10071007}
    10081008
     1009#include <ctype.h>
     1010int sl_strcasecmp(const char * one, const char * two)
     1011{
     1012#ifdef SL_FAIL_ON_ERROR
     1013  SL_REQUIRE (one != NULL, _("one != NULL"));
     1014  SL_REQUIRE (two != NULL, _("two != NULL"));
     1015#endif
     1016
     1017  if (one && two)
     1018    {
     1019      do {
     1020        if (*one && *two)
     1021          {
     1022            if (tolower(*one) == tolower(*two))
     1023              {
     1024                ++one; ++two;
     1025              }
     1026            else if (tolower(*one) < tolower(*two))
     1027              return -1;
     1028            else
     1029              return 1;
     1030          }
     1031        else if (*one == '\0' && *two == '\0')
     1032          return 0;
     1033        else if (*one == '\0')
     1034          return -1;
     1035        else
     1036          return 1;
     1037      } while (1 == 1);
     1038    }
     1039  else if (one == NULL && two != NULL)
     1040    return -1;
     1041  else if (one != NULL && two == NULL)
     1042    return 1;
     1043  else
     1044    return -7; /* default to not equal */
     1045}
    10091046
    10101047int sl_strcmp(const char * a, const char * b)
    … …  
    10221059    return (1);
    10231060  else
    1024     return (-7); /* arbitrary */
     1061    return (-7); /* default to not equal */
    10251062}
    10261063
    … …  
    10401077    return (1);
    10411078  else
    1042     return (-7); /* arbitrary */
     1079    return (-7); /* default to not equal */
    10431080}
    10441081
    … …  
    22322269                  if (is_nonblocking == SL_FALSE)
    22332270                      retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
     2271                  TPT(( 0, FIL__, __LINE__, _("msg=<read error>")));
    22342272                  return (SL_EREAD);
    22352273                }
    … …  
    22472285          if (is_nonblocking == SL_FALSE)
    22482286              retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
     2287          TPT(( 0, FIL__, __LINE__, _("msg=<timeout>")));
    22492288          return (SL_TIMEOUT);
    22502289        }
    … …  
    22532292          if (is_nonblocking == SL_FALSE)
    22542293              retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
     2294          TPT(( 0, FIL__, __LINE__, _("msg=<timeout>")));
    22552295          return (SL_EREAD);
    22562296        }
    … …  
    22602300          if (is_nonblocking == SL_FALSE)
    22612301              retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
     2302          TPT(( 0, FIL__, __LINE__, _("msg=<terminated>")));
    22622303          return (SL_EREAD);
    22632304        }
    … …  
    22702311          if (is_nonblocking == SL_FALSE)
    22712312              retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
     2313          TPT(( 0, FIL__, __LINE__, _("msg=<timeout>")));
    22722314          return (SL_TIMEOUT);
    22732315        }
    … …  
    22822324                     int timeout, int is_nonblocking)
    22832325{
    2284   int    fd;
     2326  int    fd, retval;
    22852327 
     2328  SL_ENTER(_("sl_read_timeout"));
     2329
    22862330  if (buf_in == NULL || SL_ISERROR(fd = get_the_fd(ticket)))
    22872331    {
    … …  
    22892333        {
    22902334          TPT(( 0, FIL__, __LINE__, _("msg=<null buffer>")));
    2291           return (SL_ENULL);
     2335          SL_IRETURN((SL_ENULL), _("sl_read_timeout"));
    22922336        }
    22932337      if (SL_ISERROR(fd = get_the_fd(ticket)))
    22942338        {
    22952339          TPT(( 0, FIL__, __LINE__, _("msg=<ticket error> errno=<%d>"), fd));
    2296           return (fd);
     2340          SL_IRETURN((fd),  _("sl_read_timeout"));
    22972341        }
    22982342    }
    22992343
    2300   return sl_read_timeout_fd (fd, buf_in, count, timeout, is_nonblocking);
     2344  retval = sl_read_timeout_fd (fd, buf_in, count, timeout, is_nonblocking);
     2345  SL_IRETURN((retval), _("sl_read_timeout"));
    23012346}
    23022347
    … …  
    23102355  char * buf;
    23112356
     2357  SL_ENTER(_("sl_read"));
     2358
    23122359  if (count < 1)
    23132360    {
    23142361      TPT(( 0, FIL__, __LINE__, _("msg=<range error>")));
    2315       return(SL_ERANGE);
     2362      SL_IRETURN((SL_ERANGE), _("sl_read"));
    23162363    }
    23172364  if (buf_in == NULL)
    23182365    {
    23192366      TPT(( 0, FIL__, __LINE__, _("msg=<null buffer>")));
    2320       return (SL_ENULL);
     2367      SL_IRETURN((SL_ENULL), _("sl_read"));
    23212368    }
    23222369
    … …  
    23242371    {
    23252372      TPT(( 0, FIL__, __LINE__, _("msg=<ticket error> errno=<%d>"), fd));
    2326       return (fd);
     2373      SL_IRETURN((fd), _("sl_read"));
    23272374    }
    23282375
    … …  
    23452392    {
    23462393      TPT(( 0, FIL__, __LINE__, _("msg=<read error> errno=<%d>\n"), errno));
    2347       return (SL_EREAD);
    2348     }
    2349   return (bytes);
     2394      SL_IRETURN((SL_EREAD), _("sl_read"));
     2395    }
     2396  SL_IRETURN((bytes), _("sl_read"));
    23502397}
    23512398
    … …  
    23572404  char * buf;
    23582405
     2406  SL_ENTER(_("sl_read_fast"));
     2407
    23592408  if (count < 1)
    23602409    {
    23612410      TPT(( 0, FIL__, __LINE__, _("msg=<range error>")));
    2362       return(SL_ERANGE);
     2411      SL_IRETURN((SL_ERANGE), _("sl_read_fast"));
    23632412    }
    23642413  if (buf_in == NULL)
    23652414    {
    23662415      TPT(( 0, FIL__, __LINE__, _("msg=<null buffer>")));
    2367       return (SL_ENULL);
     2416      SL_IRETURN((SL_ENULL), _("sl_read_fast"));
    23682417    }
    23692418
    … …  
    23712420    {
    23722421      TPT(( 0, FIL__, __LINE__, _("msg=<ticket error> errno=<%d>"), fd));
    2373       return (fd);
     2422      SL_IRETURN((fd), _("sl_read_fast"));
    23742423    }
    23752424
    … …  
    23812430      if (byteread >= 0)
    23822431        {
    2383           return (byteread);
     2432          SL_IRETURN((byteread), _("sl_read_fast"));
    23842433        } 
    23852434    } while ( byteread == -1 && (errno == EINTR || errno == EAGAIN));
    … …  
    23892438    {
    23902439      TPT(( 0, FIL__, __LINE__, _("msg=<read error> errno=<%d>\n"), errno));
    2391       return (SL_EREAD);
    2392     }
    2393   return (0);
     2440      SL_IRETURN((SL_EREAD), _("sl_read_fast"));
     2441    }
     2442  SL_IRETURN((0), _("sl_read_fast"));
    23942443}
    23952444
  • trunk/test/testrun_1.sh

    r138 r169  
    4141testrun1_setup=0
    4242
    43 MAXTEST=13; export MAXTEST
     43MAXTEST=15; export MAXTEST
    4444
    4545test_dirs () {
    … …  
    6565        fi
    6666    done
     67}
     68
     69
     70TESTPOLICY_15="
     71[Misc]
     72DigestAlgo=SHA1
     73RedefReadOnly = +TXT
     74[ReadOnly]
     75dir=${BASE}
     76"
     77mod_testdata_15 () {
     78    mod_testdata_1
     79}
     80chk_testdata_15 () {
     81    chk_testdata_1
     82}
     83
     84TESTPOLICY_14="
     85[Misc]
     86DigestAlgo=MD5
     87RedefReadOnly = +TXT
     88[ReadOnly]
     89dir=${BASE}
     90"
     91mod_testdata_14 () {
     92    mod_testdata_1
     93}
     94chk_testdata_14 () {
     95    chk_testdata_1
    6796}
    6897
    … …  
    455484mod_testdata_5 () {
    456485    mod_testdata_4
    457     echo "This is a xxxx file"  > "${BASE}/a/a/b/x"    # GrowingLogFiles
    458     echo "This is a test file" > "${BASE}/a/a/b/y"     # GrowingLogFiles
    459     echo "This is a xxxx file bad" > "${BASE}/a/a/b/z" # GrowingLogFiles
     486    echo "1 This is a xxxx file" > "${BASE}/a/a/b/x"     # GrowingLogFiles
     487    echo "1 This is a test file" > "${BASE}/a/a/b/y"     # GrowingLogFiles
     488    echo "2 This is a test file" >> "${BASE}/a/a/b/y"    # GrowingLogFiles
     489    echo "1 This is a xxxx file bad" > "${BASE}/a/a/b/z" # GrowingLogFiles
     490    echo "2 This is a xxxx file bad" >>"${BASE}/a/a/b/z" # GrowingLogFiles
     491    echo "3 This is a xxxx file bad" >>"${BASE}/a/a/b/z" # GrowingLogFiles
    460492}
    461493
    … …  
    716748"
    717749mod_testdata_2 () {
    718     mod_testdata_1;
     750    # mod_testdata_1;
     751    one_sec_sleep
     752    touch "${BASE}/a/a/x"
     753    chmod 0555 "${BASE}/a/a/y"
     754    mv "${BASE}/a/b/y" "${BASE}/a/b/yy";
     755    echo "1 This is a test file" >  "${BASE}/a/b/y";
     756    echo "2 This is a test file" >> "${BASE}/a/b/y";
     757    echo "4 This is a test file" >> "${BASE}/a/b/z";
     758    rm "${BASE}/a/b/yy"; # mv/rm to force new inode
     759    rm "${BASE}/a/b/l_y";
     760    ln -s "${BASE}/a/b/x" "${BASE}/a/b/l_y";
     761    echo "foobar" > "${BASE}/a/c/y"
    719762    rm "${BASE}/a/a/c/y"
    720763    echo "foobar" > "${BASE}/a/a/c/foo"
    … …  
    762805    fi
    763806    tmp=`grep CRIT $LOGFILE | wc -l`
    764     if [ $tmp -ne 8 ]; then
     807    if [ $tmp -ne 10 ]; then
    765808        [ -z "$verbose" ] || log_msg_fail "policy count";
    766809        return 1
    … …  
    769812
    770813TESTPOLICY_1="
     814[Misc]
     815RedefReadOnly = +TXT
    771816[ReadOnly]
    772817dir=${BASE}
    … …  
    777822    touch "${BASE}/a/a/x"
    778823    chmod 0555 "${BASE}/a/a/y"
    779     mv "${BASE}/a/b/y"  "${BASE}/a/b/yy"; echo "This is a test file" > "${BASE}/a/b/y"; rm "${BASE}/a/b/yy"
     824    mv "${BASE}/a/b/y" "${BASE}/a/b/yy";
     825    echo "1 This is a test file" >  "${BASE}/a/b/y";
     826    echo "2 This is a test file" >> "${BASE}/a/b/y";
     827    echo "4 This is a test file" >> "${BASE}/a/b/z";
     828    rm "${BASE}/a/b/yy"; # mv/rm to force new inode
     829    rm "${BASE}/a/b/l_y";
     830    ln -s "${BASE}/a/b/x" "${BASE}/a/b/l_y";
    780831    echo "foobar" > "${BASE}/a/c/y"
     832    #
     833    mv "${BASE}/b/x" "${BASE}/b/xx"; # mv/rm to force new inode
     834    mkdir "${BASE}/b/x"
     835    rm "${BASE}/b/xx";
     836    #
     837    mv "${BASE}/b/y" "${BASE}/b/yy"; # mv/rm to force new inode
     838    ln -s  "${BASE}/b/z" "${BASE}/b/y"
     839    rm "${BASE}/b/yy";
     840    #
     841    rm "${BASE}/b/l_x";  echo "1 This is a test file" >  "${BASE}/b/l_x";
    781842}
    782843
    … …  
    792853        if [ $tmp -ne 1 ]; then
    793854            [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff} (multiple)";
     855            return 1
    794856        fi
    795857        #
    … …  
    797859            egrep "Checksum.*${BASE}/${ff}/${gg}" $LOGFILE >/dev/null 2>&1
    798860            if [ $? -ne 0 ]; then
    799                 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/${gg} (checking)";
    800                 return 1
     861                if [ "${BASE}/${ff}" != "${BASE}/b" ]; then
     862                    [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/${gg} (checksum)";
     863                    return 1
     864                fi
    801865            fi
    802866            tmp=`egrep "Checksum.*${BASE}/${ff}/${gg}" $LOGFILE 2>/dev/null | wc -l`
    803867            if [ $tmp -ne 1 ]; then
    804                 [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/${gg} (multiple)";
     868                if [ "${BASE}/${ff}" != "${BASE}/b" ]; then
     869                    [ -z "$verbose" ] || log_msg_fail "${BASE}/${ff}/${gg} (multiple)";
     870                    return 1
     871                fi
    805872            fi
    806873        done
    807874    done
     875    #
     876    #
     877    #
     878    egrep "CRIT.*POLICY \[ReadOnly\] ----H---T-.*${BASE}/b" $LOGFILE >/dev/null 2>&1
     879    if [ $? -ne 0 ]; then
     880        [ -z "$verbose" ] || log_msg_fail "${BASE}/b";
     881        return 1
     882    fi
     883    egrep "CRIT.*POLICY \[ReadOnly\] CL-I-M--TS.*${BASE}/b/y" $LOGFILE >/dev/null 2>&1
     884    if [ $? -ne 0 ]; then
     885        [ -z "$verbose" ] || log_msg_fail "${BASE}/b/y";
     886        return 1
     887    fi
     888    egrep "CRIT.*POLICY \[ReadOnly\] CL---M--TS.*${BASE}/b/l_x" $LOGFILE >/dev/null 2>&1
     889    if [ $? -ne 0 ]; then
     890        [ -z "$verbose" ] || log_msg_fail "${BASE}/b/l_x";
     891        return 1
     892    fi
     893    egrep "CRIT.*POLICY \[ReadOnly\] C--IHM--TS.*${BASE}/b/x" $LOGFILE >/dev/null 2>&1
     894    if [ $? -ne 0 ]; then
     895        [ -z "$verbose" ] || log_msg_fail "${BASE}/b/x";
     896        return 1
     897    fi
     898    #
     899    #
     900    #
    808901    egrep "CRIT.*POLICY \[ReadOnly\] --------T-.*${BASE}/a/a/x" $LOGFILE >/dev/null 2>&1
    809902    if [ $? -ne 0 ]; then
    … …  
    821914        return 1
    822915    fi
     916    egrep "CRIT.*POLICY \[ReadOnly\] -L-I----T-.*${BASE}/a/b/l_y" $LOGFILE >/dev/null 2>&1
     917    if [ $? -ne 0 ]; then
     918        [ -z "$verbose" ] || log_msg_fail "${BASE}/a/b/l_y";
     919        return 1
     920    fi
    823921    egrep "CRIT.*POLICY \[ReadOnly\] --------T-.*${BASE}/a/b" $LOGFILE >/dev/null 2>&1
    824922    if [ $? -ne 0 ]; then
    … …  
    826924        return 1
    827925    fi
     926    egrep "CRIT.*POLICY \[ReadOnly\] C-------TS.*${BASE}/a/b/z" $LOGFILE >/dev/null 2>&1
     927    if [ $? -ne 0 ]; then
     928        [ -z "$verbose" ] || log_msg_fail "${BASE}/a/b/z";
     929        return 1
     930    fi
    828931    egrep "CRIT.*POLICY \[ReadOnly\] C-------TS.*${BASE}/a/c/y" $LOGFILE >/dev/null 2>&1
    829932    if [ $? -ne 0 ]; then
    … …  
    832935    fi
    833936    tmp=`grep CRIT $LOGFILE | wc -l`
    834     if [ $tmp -ne 5 ]; then
     937    if [ $tmp -ne 11 ]; then
    835938        [ -z "$verbose" ] || log_msg_fail "policy count";
    836939        return 1
    837940    fi
     941    for ff in x y z; do
     942        ./samhain --list-file "${BASE}/a/a/${ff}" -d "$PW_DIR/.samhain_file" > "$PW_DIR/.samhain_tmp"
     943        diff "$PW_DIR/.samhain_tmp" "${BASE}/a/a/${ff}" >/dev/null
     944        if [ $? -ne 0 ]; then
     945            [ -z "$verbose" ] || log_msg_fail "diff $PW_DIR/.samhain_tmp ${BASE}/a/a/${ff}"
     946            return 1
     947        fi
     948    done
     949
    838950    return 0
    839951}
    … …  
    10281140        chmod 0755 "${BASE}/${ff}"
    10291141        for gg in $TFILES; do
    1030             echo "This is a test file" > "${BASE}/${ff}/${gg}"
     1142            echo "1 This is a test file" > "${BASE}/${ff}/${gg}"
    10311143            chmod 0644 "${BASE}/${ff}/${gg}"
     1144            ln -s "${BASE}/${ff}/${gg}" "${BASE}/${ff}/l_${gg}"
    10321145        done
     1146        echo "2 This is a test file" >> "${BASE}/${ff}/y"
     1147        echo "2 This is a test file" >> "${BASE}/${ff}/z"
     1148        echo "3 This is a test file" >> "${BASE}/${ff}/z"
    10331149    done
    10341150}
  • trunk/test/testrun_1b.sh

    r163 r169  
    2020#
    2121
    22 MAXTEST=5; export MAXTEST
     22MAXTEST=6; export MAXTEST
    2323LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
    2424RCFILE="$PW_DIR/testrc_1.dyn";  export RCFILE
    … …  
    136136
    137137        mv $PW_DIR/.samhain_file.asc $PW_DIR/.samhain_file
     138}
     139
     140testrun1b_nogpg ()
     141{
     142        BUILDOPTS="$1"
     143        #
     144        # test standalone compilation
     145        #
     146        [ -z "$verbose" ] || { echo; echo "${S}Building standalone agent${E}"; echo; }
     147        #
     148        if test -r "Makefile"; then
     149                $MAKE distclean >/dev/null >&1
     150        fi
     151
     152        ${TOP_SRCDIR}/configure ${BUILDOPTS} 2>/dev/null
     153        #
     154        #
     155        if test x$? = x0; then
     156                [ -z "$verbose" ] ||     log_msg_ok "configure...";
     157                $MAKE  > /dev/null 2>&1
     158                if test x$? = x0; then
     159                    [ -z "$verbose" ] || log_msg_ok "make...";
     160                else
     161                    [ -z "$quiet" ] &&   log_msg_fail "make...";
     162                    return 1
     163                fi
     164
     165        else
     166                [ -z "$quiet" ] &&       log_msg_fail "configure...";
     167                return 1
     168        fi
     169
     170        rm -f ./.samhain_file
     171        rm -f ./.samhain_log
     172        rm -f ./.samhain_lock
     173
     174        cp "${SCRIPTDIR}/testrc_1" "${RCFILE}"
     175
     176        ./samhain -t init -p none -l info
     177
     178        if test x$? = x0; then
     179            [ -z "$verbose" ] || log_msg_ok    "init...";
     180        else
     181            [ -z "$quiet" ]   && log_msg_fail  "init...";
     182            return 1
     183        fi
     184
    138185}
    139186
    … …  
    316363                fi
    317364            fi
     365
     366            #
     367            # -------------  sixth test -------------
     368            #
     369            if test -f /usr/local/lib/libprelude.so
     370            then
     371                    LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
     372                    export LD_LIBRARY_PATH
     373            fi
     374            #
     375            PM=`find_path prelude-manager`
     376            if [ -z "$PM" ]; then
     377                log_skip 6 $MAXTEST 'prelude-manager not found in $PATH'
     378            elif [ -z "$doall" ]; then
     379                log_skip 6 $MAXTEST 'logging to prelude (or use --really-all)'
     380            else
     381                BUILDOPTS="--quiet $TRUST --with-prelude --enable-login-watch --enable-mounts-check --enable-process-check --enable-port-check --enable-suidcheck --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE  --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file"
     382                testrun1b_nogpg "${BUILDOPTS} CFLAGS=-DSH_NOFAILOVER=1"
     383                do_test_1b_2
     384                if [ $? -eq 0 ]; then
     385                    log_ok   6 $MAXTEST 'logging to prelude'
     386                else
     387                    log_fail 6 $MAXTEST 'logging to prelude'
     388                fi
     389            fi
     390
    318391        fi
    319392    fi
  • trunk/test/testrun_1d.sh

    r85 r169  
    197197proc_psarg ()
    198198{
    199     OS=`uname -o`
     199    OS=`uname -s`
    200200    case $OS in
    201201        *Linux*|*linux*)
    202202            PSARG="-eT";;
     203        *OpenBSD*)
     204            PSARG="akx";;
    203205        *)
    204206            PS=`proc_pspath`
Note: See TracChangeset for help on using the changeset viewer.