Changeset 564 for trunk


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

Fix for ticket #452 (reproducible database generation).

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/config.h.in

    r550 r564  
    770770/* Define if you have SA_SIGINFO */
    771771#undef HAVE_SA_SIGINFO
     772
     773/* Define to 1 if you have the `scandir' function. */
     774#undef HAVE_SCANDIR
    772775
    773776/* Define to 1 if you have the <sched.h> header file. */
  • trunk/configure.ac

    r560 r564  
    1212dnl start
    1313dnl
    14 AM_INIT_AUTOMAKE(samhain, 4.4.3)
     14AM_INIT_AUTOMAKE(samhain, 4.4.4)
    1515AC_DEFINE([SAMHAIN], 1, [Application is samhain])
    1616AC_CANONICAL_HOST
     
    391391        strerror_r getgrgid_r getpwnam_r getpwuid_r \
    392392        gmtime_r localtime_r rand_r readdir_r strtok_r \
    393         mincore posix_fadvise inotify_init1
     393        mincore posix_fadvise inotify_init1 scandir
    394394)
    395395AC_CHECK_FUNC(statfs, AC_DEFINE(HAVE_STATFS) statfs="yes",  statfs="no")
     
    11401140# this is from the snort configure.in
    11411141#
    1142 AC_DEFUN(FAIL_MESSAGE,[
     1142AC_DEFUN([FAIL_MESSAGE],[
    11431143   echo
    11441144   echo
  • trunk/docs/Changelog

    r562 r564  
    33        * fix bug with signify-openbsd in client/server setup (reported
    44        by Sdoba)
     5        * patch by K. Hacene for reproducible database generation
     6        * fix recognition of invalid compiler options in configure.ac
    57
    684.4.3:
  • trunk/src/sh_dbIO.c

    r560 r564  
    15121512        }
    15131513    }
    1514          
    1515   if (!buf) {
    1516     memset(&p, 0, sizeof(sh_filestore_t));
    1517   }
     1514
     1515  /* unconditionally initialize the structure */
     1516  memset(&p, 0, sizeof(sh_filestore_t));
    15181517
    15191518  if (buf != NULL)
  • trunk/src/sh_files.c

    r543 r564  
    2020#include "config_xor.h"
    2121
    22 #if defined(HAVE_PTHREAD_MUTEX_RECURSIVE)
     22#if defined(HAVE_PTHREAD_MUTEX_RECURSIVE) && defined(HAVE_DIRENT_H) && defined(HAVE_SCANDIR)
     23
     24/* Linux */
     25#if defined(__linux__)
     26#define _XOPEN_SOURCE 700
     27#define SH_USE_SCANDIR 1
     28
     29/* FreeBSD */
     30#elif defined(__FreeBSD__)
     31
     32#if __FreeBSD__ >= 8
     33#define __XSI_VISIBLE 700
     34#define SH_USE_SCANDIR 1
     35#endif
     36
     37/* OpenBSD */
     38#elif defined(__OpenBSD__)
     39#define __POSIX_VISIBLE 200809
     40#define SH_USE_SCANDIR 1
     41
     42#elif defined(__NetBSD__)
     43#define _NETBSD_SOURCE
     44#define SH_USE_SCANDIR 1
     45
     46/* other os */
     47#else
     48#define _XOPEN_SOURCE 500
     49
     50#endif
     51
     52#elif defined(HAVE_PTHREAD_MUTEX_RECURSIVE)
    2353#define _XOPEN_SOURCE 500
    2454#endif
     
    3666#include <sys/types.h>
    3767#include <unistd.h>
    38 #include <sys/types.h>
    3968#include <sys/stat.h>
    4069#include <fcntl.h>
     
    20812110  DIR *           thisDir = NULL;
    20822111  struct dirent * thisEntry;
     2112#if defined(SH_USE_SCANDIR)
     2113  struct dirent **entryList;
     2114  int             entry;
     2115#endif
    20832116  int             status;
    20842117  int             dummy = S_FALSE;
     
    22672300  dirlist_orig = NULL;
    22682301
     2302#if defined(SH_USE_SCANDIR)
     2303  entry = scandir(iname, &entryList, 0, alphasort);
     2304  while(entry > 0) { /* scandir() may return -1 on error! */
     2305      entry--;
     2306      thisEntry = entryList[entry];
     2307#else
    22692308  do {
    22702309      thisEntry = readdir (thisDir);
     2310#endif
    22712311      if (thisEntry != NULL)
    22722312        {
     
    22842324          dirlist = addto_sh_dirlist (thisEntry, dirlist);
    22852325        }
    2286   } while (thisEntry != NULL);
    2287 
     2326  }
     2327#if !defined(SH_USE_SCANDIR) 
     2328  while (thisEntry != NULL);
     2329#endif
     2330 
    22882331  SH_MUTEX_UNLOCK(mutex_readdir);
    22892332
Note: See TracChangeset for help on using the changeset viewer.