Changeset 562 for trunk


Ignore:
Timestamp:
Jun 29, 2021, 10:23:44 PM (3 years ago)
Author:
katerina
Message:

Fix for ticket #450 (compiler warnings) and fixes for tests.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/Changelog

    r560 r562  
     14.4.4:
     2        * fix more gcc 10 compiler warnings
     3        * fix bug with signify-openbsd in client/server setup (reported
     4        by Sdoba)
     5
    164.4.3:
    27        * allow console logging to a unix domain socket
  • trunk/src/dnmalloc.c

    r520 r562  
    165165 *   HAVE_SYS_PARAM_H Define to #include <sys/param.h> (for pagesize)
    166166 *
    167  *   HAVE_MALLOC_H    Define to #include <malloc.h> (for struct mallinfo)
     167 *   HAVE_MALLOC_H    Define to #include <malloc.h> (for struct mallinfo2)
    168168 *
    169169 *   HAVE_FCNTL_H     Define to #include <fcntl.h>
     
    531531#define vALLOc      public_vALLOc
    532532#define pVALLOc     public_pVALLOc
    533 #define mALLINFo    public_mALLINFo
     533#define mALLINFo2   public_mALLINFo2
    534534#define mALLOPt     public_mALLOPt
    535535#define mTRIm       public_mTRIm
     
    547547#define public_vALLOc    dlvalloc
    548548#define public_pVALLOc   dlpvalloc
    549 #define public_mALLINFo  dlmallinfo
     549#define public_mALLINFo2 dlmallinfo2
    550550#define public_mALLOPt   dlmallopt
    551551#define public_mTRIm     dlmalloc_trim
     
    561561#define public_vALLOc    valloc
    562562#define public_pVALLOc   pvalloc
    563 #define public_mALLINFo  mallinfo
     563#define public_mALLINFo2 mallinfo2
    564564#define public_mALLOPt   mallopt
    565565#define public_mTRIm     malloc_trim
     
    791791
    792792/*
    793   This version of malloc supports the standard SVID/XPG mallinfo
     793  This version of malloc supports the standard SVID/XPG mallinfo2
    794794  routine that returns a struct containing usage properties and
    795795  statistics. It should work on any SVID/XPG compliant system that has
    796   a /usr/include/malloc.h defining struct mallinfo. (If you'd like to
     796  a /usr/include/malloc.h defining struct mallinfo2. (If you'd like to
    797797  install such a thing yourself, cut out the preliminary declarations
    798798  as described above and below and save them in a malloc.h file. But
    799799  there's no compelling reason to bother to do this.)
    800800
    801   The main declaration needed is the mallinfo struct that is returned
    802   (by-copy) by mallinfo().  The SVID/XPG malloinfo struct contains a
     801  The main declaration needed is the mallinfo2 struct that is returned
     802  (by-copy) by mallinfo2().  The SVID/XPG malloinfo2 struct contains a
    803803  bunch of fields that are not even meaningful in this version of
    804   malloc.  These fields are are instead filled by mallinfo() with
     804  malloc.  These fields are are instead filled by mallinfo2() with
    805805  other numbers that might be of interest.
    806806
    807807  HAVE_MALLOC_H should be set if you have a
    808808  /usr/include/malloc.h file that includes a declaration of struct
    809   mallinfo.  If so, it is included; else an SVID2/XPG2 compliant
     809  mallinfo2.  If so, it is included; else an SVID2/XPG2 compliant
    810810  version is declared below.  These must be precisely the same for
    811   mallinfo() to work.  The original SVID version of this struct,
    812   defined on most systems with mallinfo, declares all fields as
    813   ints. But some others define as unsigned long. If your system
     811  mallinfo2() to work.  The original SVID version of this struct,
     812  defined on most systems with mallinfo2, declares all fields as
     813  size_2. But some others define as unsigned long. If your system
    814814  defines the fields using a type of different width than listed here,
    815815  you must #include your system version and #define
     
    826826#else
    827827
    828 /* SVID2/XPG mallinfo structure */
    829 
    830 struct mallinfo {
    831   int arena;    /* non-mmapped space allocated from system */
    832   int ordblks;  /* number of free chunks */
    833   int smblks;   /* number of fastbin blocks */
    834   int hblks;    /* number of mmapped regions */
    835   int hblkhd;   /* space in mmapped regions */
    836   int usmblks;  /* maximum total allocated space */
    837   int fsmblks;  /* space available in freed fastbin blocks */
    838   int uordblks; /* total allocated space */
    839   int fordblks; /* total free space */
    840   int keepcost; /* top-most, releasable (via malloc_trim) space */
     828/* SVID2/XPG mallinfo2 structure */
     829
     830struct mallinfo2 {
     831  size_t arena;    /* non-mmapped space allocated from system */
     832  size_t ordblks;  /* number of free chunks */
     833  size_t smblks;   /* number of fastbin blocks */
     834  size_t hblks;    /* number of mmapped regions */
     835  size_t hblkhd;   /* space in mmapped regions */
     836  size_t usmblks;  /* maximum total allocated space */
     837  size_t fsmblks;  /* space available in freed fastbin blocks */
     838  size_t uordblks; /* total allocated space */
     839  size_t fordblks; /* total free space */
     840  size_t keepcost; /* top-most, releasable (via malloc_trim) space */
    841841};
    842842
     
    10081008
    10091009/*
    1010   mallinfo()
     1010  mallinfo2()
    10111011  Returns (by copy) a struct containing various summary statistics:
    10121012
     
    10311031*/
    10321032#if __STD_C
    1033 struct mallinfo public_mALLINFo(void);
    1034 #else
    1035 struct mallinfo public_mALLINFo();
     1033struct mallinfo2 public_mALLINFo2(void);
     1034#else
     1035struct mallinfo2 public_mALLINFo2();
    10361036#endif
    10371037
     
    11151115
    11161116  malloc_stats prints only the most commonly interesting statistics.
    1117   More information can be obtained by calling mallinfo.
     1117  More information can be obtained by calling mallinfo2.
    11181118
    11191119*/
     
    13661366static void     mSTATs();
    13671367static int      mALLOPt(int, int);
    1368 static struct mallinfo mALLINFo(void);
     1368static struct mallinfo2 mALLINFo2(void);
    13691369#else
    13701370static Void_t*  mALLOc();
     
    13801380static void     mSTATs();
    13811381static int      mALLOPt();
    1382 static struct mallinfo mALLINFo();
     1382static struct mallinfo2 mALLINFo2();
    13831383#endif
    13841384
     
    16871687}
    16881688
    1689 struct mallinfo public_mALLINFo() {
    1690   struct mallinfo m;
     1689struct mallinfo2 public_mALLINFo2() {
     1690  struct mallinfo2 m;
    16911691  if (MALLOC_PREACTION == 0) {
    1692     m = mALLINFo();
     1692    m = mALLINFo2();
    16931693    (void) MALLOC_POSTACTION;
    16941694    return m;
    16951695  } else {
    1696     struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
     1696    struct mallinfo2 nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    16971697    return nm;
    16981698  }
     
    52935293*/
    52945294
    5295 DL_STATIC struct mallinfo mALLINFo()
     5295DL_STATIC struct mallinfo2 mALLINFo2()
    52965296{
    52975297  mstate av = get_malloc_state();
    5298   static struct mallinfo mi;
     5298  static struct mallinfo2 mi;
    52995299  unsigned int i;
    53005300  mbinptr b;
     
    53615361DL_STATIC void mSTATs()
    53625362{
    5363   struct mallinfo mi = mALLINFo();
     5363  struct mallinfo2 mi = mALLINFo2();
    53645364
    53655365  fprintf(stderr, "hashtable = %10lu MB\n",
  • trunk/src/sh_login_track.c

    r541 r562  
    402402  while(u)
    403403    {
    404       if (0 == strcmp(user, u->user))
     404      if (0 == sl_strcmp(user, u->user))
    405405        {
    406406          return u;
     
    839839  else
    840840    {
    841       q = strchr(host, '.');
     841      char * tmp = sh_util_strdup(host);
     842      q = strchr(tmp, '.');
    842843      if (q && *q)
    843844        {
    844845          ++q;
    845846          p = sh_util_strdup(q);
     847          SH_FREE(tmp);
    846848        }
    847849      else
    848850        {
    849           p = sh_util_strdup(host);
     851          p = tmp;
    850852        }
    851853    }
  • trunk/src/sh_tools.c

    r550 r562  
    13861386}
    13871387
     1388#ifdef SH_ENCRYPT
    13881389static int probe_ok(int flag)
    13891390{
     
    13931394  return S_FALSE;
    13941395}
     1396#endif
    13951397
    13961398static unsigned char probe_header_set(unsigned char protocol)
     
    14441446}
    14451447
     1448#ifdef SH_ENCRYPT
    14461449static int probe_ok(int flag)
    14471450{
     
    14501453  return S_FALSE;
    14511454}
     1455#endif
     1456
    14521457#endif
    14531458
  • trunk/src/t-test0.c

    r541 r562  
    390390                actions = RANDOM(&ld, ACTIONS_MAX);
    391391#if USE_MALLOC && MALLOC_DEBUG
    392                 if(actions < 2) { mallinfo(); }
     392                if(actions < 2) { mallinfo2(); }
    393393#endif
    394394                for(j=0; j<actions; j++) {
  • trunk/src/t-test1.c

    r481 r562  
    499499                actions = RANDOM(&ld, ACTIONS_MAX);
    500500#if USE_MALLOC && MALLOC_DEBUG
    501                 if(actions < 2) { mallinfo(); }
     501                if(actions < 2) { mallinfo2(); }
    502502#endif
    503503                for(j=0; j<actions; j++) {
  • trunk/src/yulectl.c

    r481 r562  
    4848#endif
    4949
     50#define SH_PW_SIZE 15
     51
    5052static int    sock     = -1;
    51 static char   password[15] = "";
     53static char   password[SH_PW_SIZE] = "";
    5254static int    verbose = 0;
    5355
     
    123125static char * safe_copy(char * to, const char * from, size_t size)
    124126{
    125   if (to && from)
    126     {
    127       strncpy (to, from, size);
    128       if (size > 0)
    129         to[size-1] = '\0';
    130       else
    131         *to = '\0';
     127  if (to && from && (size > 0))
     128    {
     129      strncpy (to, from, size-1);
     130      to[size-1] = '\0';
    132131    }
    133132  return to;
     
    144143   */
    145144  name.sun_family = AF_UNIX;
    146   strncpy (name.sun_path, serversock, sizeof(name.sun_path) - 1);
     145  memcpy(name.sun_path, serversock, sizeof(name.sun_path));
     146  name.sun_path[sizeof(name.sun_path)-1] = '\0';
     147  if (strlen(serversock) > strlen(name.sun_path))
     148    {
     149      perror (_("ERROR: socket path too long"));
     150      return -1;
     151    }
    147152  size = (offsetof (struct sockaddr_un, sun_path)
    148153          + strlen (name.sun_path) + 1);
     
    401406   */
    402407  pw = getenv(_("YULECTL_PASSWORD"));
    403   if (pw && strlen(pw) < 15)
     408  if (pw && strlen(pw) < SH_PW_SIZE)
    404409    {
    405410      strcpy(password, pw);
     
    413418    return -1;
    414419
    415   if ( (strlen(home) + strlen(_("/.yulectl_cred")) + 1) > 4096)
     420  if ( (strlen(home) + strlen(_("/.yulectl_cred")) + 1) > sizeof(home))
    416421    {
    417422      fprintf (stderr, "%s", _("ERROR: path for $HOME is too long.\n"));
     
    451456  (void) rtrim(message2);
    452457
    453   if (strlen(message2) > 14)
     458  if (strlen(message2) > (SH_PW_SIZE -1))
    454459    {
    455460      fprintf (stderr, "%s",
  • trunk/test/testrun_1b.sh

    r539 r562  
    239239do_test_1b_2 () {
    240240
    241     rm -f $PW_DIR/test_log_prelude
    242 
    243     [ -z "$verbose" ] || { echo " starting prelude-manager.."; echo " ($PM --textmod -l $PW_DIR/test_log_prelude --listen 127.0.0.1:5500 >/dev/null 2>&1 &)"; }
    244     "$PM" --textmod -l $PW_DIR/test_log_prelude --listen 127.0.0.1:5500 >/dev/null 2>&1 &
    245     PID=$!
    246 
    247     five_sec_sleep
     241    #rm -f $PW_DIR/test_log_prelude
     242    test_log_prelude="/var/log/prelude/prelude-text.log"
     243    echo -n >"${test_log_prelude}"
     244   
     245    #[ -z "$verbose" ] || { echo " starting prelude-manager.."; echo " ($PM --textmod -l $PW_DIR/test_log_prelude --listen 127.0.0.1:5500 >/dev/null 2>&1 &)"; }
     246    #"$PM" --textmod -l $PW_DIR/test_log_prelude --listen 127.0.0.1:5500 >/dev/null 2>&1 &
     247    #PID=$!
     248
     249    #five_sec_sleep
    248250
    249251    ./samhain -t check -p none -l info --set-prelude-severity=info --prelude --server-addr 127.0.0.1:5500 >/dev/null
     
    259261    else
    260262        [ -z "$quiet" ]   && log_msg_fail  "check...";
    261         kill $PID
     263        #kill $PID
    262264        return 1
    263265    fi
    264266    #
    265     tmp=`egrep 'File original:.*name=etc.*path=/etc' test_log_prelude 2>/dev/null | wc -l`
     267    tmp=`egrep 'File original:.*name=etc.*path=/etc' ${test_log_prelude} 2>/dev/null | wc -l`
    266268    if [ $tmp -lt 1 ]; then
    267269        [ -z "$verbose" ] || log_msg_fail "/etc";
    268         kill $PID
    269         return 1
    270     fi
    271     tmp=`egrep 'Classification text: Checking' test_log_prelude 2>/dev/null | wc -l`
     270        #kill $PID
     271        return 1
     272    fi
     273    tmp=`egrep 'Classification text: Checking' ${test_log_prelude} 2>/dev/null | wc -l`
    272274    if [ $tmp -lt 1 ]; then
    273275        [ -z "$verbose" ] || log_msg_fail "checking";
    274         kill $PID
     276        #kill $PID
    275277        return 1
    276278    fi
    277279    #
    278280    if test "x$2" = "xmodrc"; then
    279         tmp=`egrep 'Classification text: Service opened' test_log_prelude 2>/dev/null | wc -l`
     281        tmp=`egrep 'Classification text: Service opened' ${test_log_prelude} 2>/dev/null | wc -l`
    280282        if [ $tmp -lt 1 ]; then
    281283            [ -z "$verbose" ] || log_msg_fail "service";
    282             kill $PID
    283             return 1
    284         fi
    285         tmp=`egrep 'Service: port=5500' test_log_prelude 2>/dev/null | wc -l`
     284            #kill $PID
     285            return 1
     286        fi
     287        tmp=`egrep 'Service: port=5500' ${test_log_prelude} 2>/dev/null | wc -l`
    286288        if [ $tmp -lt 1 ]; then
    287289            [ -z "$verbose" ] || log_msg_fail "port 5500";
    288             kill $PID
     290            #kill $PID
    289291            return 1
    290292        fi
    291293    fi
    292294    #
    293     kill $PID
     295    #kill $PID
    294296    return 0
    295297}
  • trunk/test/testrun_1e.sh

    r468 r562  
    2525MAXTEST=5; export MAXTEST
    2626
     27test_log_prelude="/var/log/prelude/prelude-text.log"; export test_log_prelude
     28
    2729PORTPOLICY_5="
    2830[ReadOnly]
     
    4244        log_skip 5 $MAXTEST 'logging to prelude (or use --really-all)'
    4345    else
    44         tmp=`egrep 'Service: port=5500 .unknown. protocol=tcp' test_log_prelude 2>/dev/null | wc -l`
     46        tmp=`egrep 'Service: port=5500 .unknown. protocol=tcp' ${test_log_prelude} 2>/dev/null | wc -l`
    4547        if [ $tmp -lt 1 ]; then
    4648            [ -z "$verbose" ] || log_msg_fail "port 5500";
     
    187189run_check_prelude()
    188190{
     191    echo -n >"${test_log_prelude}"
     192
    189193    ./samhain -t check -p none -l info --set-prelude-severity=info --prelude --server-addr 127.0.0.1:5500 >/dev/null
    190194 
     
    322326                  #
    323327                  #
    324                   [ -z "$verbose" ] || { echo " starting prelude-manager.."; echo " ($PM --textmod -l $PW_DIR/test_log_prelude --listen 127.0.0.1:5500 >/dev/null 2>&1 &)"; }
    325                   "$PM" --textmod -l $PW_DIR/test_log_prelude --listen 127.0.0.1:5500 >/dev/null 2>&1 &
    326                   PRELUDEPID=$!
     328                  #[ -z "$verbose" ] || { echo " starting prelude-manager.."; echo " ($PM --textmod -l $PW_DIR/test_log_prelude --listen 127.0.0.1:5500 >/dev/null 2>&1 &)"; }
     329                  #"$PM" --textmod -l $PW_DIR/test_log_prelude --listen 127.0.0.1:5500 >/dev/null 2>&1 &
     330                  #PRELUDEPID=$!
    327331                  #
    328332                  #
  • trunk/test/testrun_2d.sh

    r481 r562  
    3838    # PGPASSWORD=samhain; export PGPASSWORD
    3939    create_pgpass
    40     psql -o test_log_db -U samhain -d samhain -c "SELECT * FROM log WHERE entry_status = 'NEW' and log_time > '${DATE}';"
     40    psql -h localhost -o test_log_db -U samhain -d samhain -c "SELECT * FROM log WHERE entry_status = 'NEW' and log_time > '${DATE}';"
    4141    #
    4242    egrep "START.*Yule" test_log_db >/dev/null 2>&1
    4343    if [ $? -ne 0 ]; then
    44         [ -z "$verbose" ] || log_msg_fail "Server start (psql)";
     44        [ -z "$verbose" ] || log_msg_fail "Server start (psql) DATE ${DATE}";
    4545        return 1
    4646    fi
     
    8888        # PGPASSWORD="samhain"; export PGPASSWORD
    8989        create_pgpass
    90         TEST=`psql -U samhain -d samhain -c "SELECT * FROM log LIMIT 1;" 2>/dev/null`
     90        TEST=`psql -h localhost -U samhain -d samhain -c "SELECT * FROM log LIMIT 1;" 2>/dev/null`
    9191        if [ $? -ne 0 -o -z "$TEST" ]; then
    9292            log_skip 1 $MAXTEST "psql not default setup"
     
    112112    ORIGINAL="DatabaseSeverity=none"
    113113    REPLACEMENT="DatabaseSeverity=info"
     114    ex -s $RCFILE <<EOF
     115%s/$ORIGINAL/$REPLACEMENT/g
     116wq
     117EOF
     118    #
     119    ORIGINAL="# setdbname=samhain"
     120    REPLACEMENT="setdbhost=127.0.0.1"
    114121    ex -s $RCFILE <<EOF
    115122%s/$ORIGINAL/$REPLACEMENT/g
Note: See TracChangeset for help on using the changeset viewer.