Changeset 20


Ignore:
Timestamp:
Feb 13, 2006, 11:54:42 PM (19 years ago)
Author:
rainer
Message:

Enable command-line parsing for prelude, and make prelude regression test safer.

Location:
trunk
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/samhain.h

    r19 r20  
    252252extern long int eintr__result;
    253253
     254extern int     sh_argc_store;
     255extern char ** sh_argv_store;
     256
    254257#include "sh_calls.h"
    255258
  • trunk/include/sh_calls.h

    r1 r20  
    5353                         struct sigaction *oldact);
    5454
    55 int      sh_calls_set_bind_addr (char *);
     55int      sh_calls_set_bind_addr (const char *);
    5656long int retry_connect(char * file, int line,
    5757                       int fd, struct sockaddr *serv_addr, int addrlen);
  • trunk/include/sh_error.h

    r1 r20  
    9191
    9292
    93 int sh_error_verify (char * s);
    94 int sh_error_logverify_mod (char * s); /* just list, don't verify */
    95 int sh_error_logverify (char * s);
     93int sh_error_verify (const char * s);
     94int sh_error_logverify_mod (const char * s); /* just list, don't verify */
     95int sh_error_logverify (const char * s);
    9696
    9797void sh_error_dbg_switch(void);
     
    124124/* set level for error logging
    125125 */
    126 int sh_error_setlog(char * str_s);
     126int sh_error_setlog(const char * str_s);
    127127
    128128/* set severity levels
     
    132132/* set priorities
    133133 */
    134 int sh_error_set_level(char * str_s, int *facility);
     134int sh_error_set_level(const char * str_s, int *facility);
    135135
    136136/* set level for TCP export
    137137 */
    138 int sh_error_setexport(char *  str_s);
     138int sh_error_setexport(const char *  str_s);
    139139
    140140/* set level for syslog
    141141 */
    142 int sh_error_set_syslog (char * flag_s);
     142int sh_error_set_syslog (const char * flag_s);
    143143
    144144/* set level for printing
    145145 */
    146 int sh_error_setprint(char *  flag_s);
     146int sh_error_setprint(const char *  flag_s);
    147147
    148148/* set severity for external
    149149 */
    150 int sh_error_set_external (char * str_s);
     150int sh_error_set_external (const char * str_s);
    151151
    152152/* set severity for external
    153153 */
    154 int sh_error_set_database (char * str_s);
     154int sh_error_set_database (const char * str_s);
    155155
    156156/* set severity for external
    157157 */
    158 int sh_error_set_prelude (char * str_s);
     158int sh_error_set_prelude (const char * str_s);
    159159
    160160
    161161/* set level for mailing
    162162 */
    163 int sh_error_setseverity (char * flag);
     163int sh_error_setseverity (const char * flag);
    164164
    165165/* set debug level
  • trunk/include/sh_files.h

    r1 r20  
    5959/* set maximum recursion level
    6060 */
    61 int sh_files_setrecursion (char * flag_s);
     61int sh_files_setrecursion (const char * flag_s);
    6262
    6363/* select a directory stack 2=Two, else One (standard)
  • trunk/include/sh_forward.h

    r1 r20  
    2222
    2323#ifndef SH_STANDALONE
    24 int sh_forward_set_strip (char * str);
     24int sh_forward_set_strip (const char * str);
    2525
    2626#endif
     
    2828/* generate a random password
    2929 */
    30 int sh_forward_create_password (char * dummy);
     30int sh_forward_create_password (const char * dummy);
    3131
    3232/* set time limit
     
    4040/* create client entry for given password
    4141 */
    42 int sh_forward_make_client (char * str);
     42int sh_forward_make_client (const char * str);
    4343
    4444#ifdef SH_WITH_SERVER
  • trunk/include/sh_hash.h

    r1 r20  
    3838/* write database to stdout
    3939 */
    40 int sh_hash_pushdata_stdout (char * str);
     40int sh_hash_pushdata_stdout (const char * str);
    4141
    4242/* version string for database
     
    4646/* List database content
    4747 */
    48 int sh_hash_list_db (char * db_file);
     48int sh_hash_list_db (const char * db_file);
    4949
    5050/* List database content with full detail
    5151 */
    52 int set_full_detail (char * c);
     52int set_full_detail (const char * c);
    5353
    5454/* List database content with full detail, comma delimited
    5555 */
    56 int set_list_delimited (char * c);
     56int set_list_delimited (const char * c);
    5757
    5858/* Read the database from disk.
  • trunk/include/sh_mail.h

    r1 r20  
    3838/* test mailbox
    3939 */
    40 int sh_mail_sigverify (char * s);
     40int sh_mail_sigverify (const char * s);
    4141
    4242/* maximum number of mail attempts
  • trunk/include/sh_tiger.h

    r19 r20  
    1717/* the checksum function
    1818 */
    19 /*@owned@*/ char * sh_tiger_hash (char * filename, TigerType what,
     19/*@owned@*/ char * sh_tiger_hash (const char * filename, TigerType what,
    2020                                  UINT64 Length);
    2121
     
    3737/* GnuPG-like format
    3838 */
    39 /*@owned@*/ char * sh_tiger_hash_gpg (char * filename, TigerType what,
     39/*@owned@*/ char * sh_tiger_hash_gpg (const char * filename, TigerType what,
    4040                                      UINT64 Length);
    4141#endif
  • trunk/include/sh_unix.h

    r19 r20  
    144144/* chroot directory
    145145 */
    146 int sh_unix_set_chroot(char * str);
     146int sh_unix_set_chroot(const char * str);
    147147
    148148/* whether to use localtime for file timesatams in logs
     
    233233/* deamon mode
    234234 */
    235 int sh_unix_setdeamon  (char * dummy);
    236 int sh_unix_setnodeamon(char * dummy);
     235int sh_unix_setdeamon  (const char * dummy);
     236int sh_unix_setnodeamon(const char * dummy);
    237237
    238238/* Test whether file exists
  • trunk/include/sh_utils.h

    r1 r20  
    7474/* eval boolean input
    7575 */
    76 int sh_util_flagval(char * c, int * fval);
     76int sh_util_flagval(const char * c, int * fval);
    7777
    7878/* ask if a file should be updated (returns S_TRUE/S_FALSE)
    7979 */
    8080int sh_util_ask_update(char * path);
    81 int sh_util_set_interactive(char * str);
     81int sh_util_set_interactive(const char * str);
    8282
    8383/* don't log output files
     
    9595/* change verifier
    9696 */
    97 int sh_util_set_newkey (char * str);
     97int sh_util_set_newkey (const char * str);
    9898
    9999/* server mode
    100100 */
    101 int sh_util_setserver (char * dummy);
     101int sh_util_setserver (const char * dummy);
    102102
    103103/* a simple compressor
     
    116116/* set timer for main loop
    117117 */
    118 int sh_util_setlooptime (char * str);
     118int sh_util_setlooptime (const char * str);
    119119
    120120/* whether init or check the database
    121121 */
    122 int  sh_util_setchecksum (char * str);
     122int  sh_util_setchecksum (const char * str);
    123123
    124124/* compare an in_string against a regular expression regex_str
  • trunk/include/slib.h

    r11 r20  
    297297  /* Open for writing.
    298298   */
    299   SL_TICKET  sl_open_write       (char * fname, int priviledge_mode);
     299  SL_TICKET  sl_open_write       (const char * fname, int priviledge_mode);
    300300
    301301  /* Open for reading.
    302302   */
    303   SL_TICKET  sl_open_read        (char * fname, int priviledge_mode);
     303  SL_TICKET  sl_open_read        (const char * fname, int priviledge_mode);
    304304
    305305  /* Open for reading w/minimum checking.
    306306   */
    307   SL_TICKET  sl_open_fastread    (char * fname, int priviledge_mode);
     307  SL_TICKET  sl_open_fastread    (const char * fname, int priviledge_mode);
    308308
    309309  /* Open for read and write.
    310310   */
    311   SL_TICKET  sl_open_rdwr        (char * fname, int priviledge_mode);
     311  SL_TICKET  sl_open_rdwr        (const char * fname, int priviledge_mode);
    312312
    313313  /* Open for read and write, fail if file exists.
    314314   */
    315   SL_TICKET sl_open_safe_rdwr    (char * fname, int priv);
     315  SL_TICKET sl_open_safe_rdwr    (const char * fname, int priv);
    316316
    317317  /* Open for write, truncate.
    318318   */
    319   SL_TICKET  sl_open_write_trunc (char * fname, int priviledge_mode);
     319  SL_TICKET  sl_open_write_trunc (const char * fname, int priviledge_mode);
    320320
    321321  /* Open for read and write, truncate.
    322322   */
    323   SL_TICKET  sl_open_rdwr_trunc  (char * fname, int priviledge_mode);
     323  SL_TICKET  sl_open_rdwr_trunc  (const char * fname, int priviledge_mode);
    324324
    325325  /* Close file.
     
    394394  char * sl_trust_errfile(void);
    395395
     396  /* Overflow tests
     397   */
     398  int sl_ok_muli (int a, int b);
     399  int sl_ok_divi (int a, int b);
     400  int sl_ok_addi (int a, int b);
     401  int sl_ok_subi (int a, int b);
    396402
    397403#ifdef  __cplusplus
     
    500506void sl_trace_in   (char * str, char * file, int line);
    501507void sl_trace_out  (char * str, char * file, int line);
    502 int  sl_trace_file (char * str);
    503 int  sl_trace_use  (char * str);
     508int  sl_trace_file (const char * str);
     509int  sl_trace_use  (const char * str);
    504510
    505511
  • trunk/src/samhain.c

    r19 r20  
    12621262
    12631263#if !defined(SH_STEALTH_NOCL)
     1264  sh_argc_store = argc;
     1265  sh_argv_store = argv;
    12641266  (void) sh_getopt_get (argc, argv);
    12651267#else
     
    12831285            }
    12841286          } while (my_argc < 32);
     1287
     1288          sh_argc_store = my_argc;
     1289          sh_argv_store = my_argv;
     1290
    12851291          (void) sh_getopt_get (my_argc, my_argv);
    12861292          SH_FREE (command_line);
  • trunk/src/sh_calls.c

    r3 r20  
    136136static int        use_bind_addr = 0;
    137137
    138 int sh_calls_set_bind_addr (char * str)
     138int sh_calls_set_bind_addr (const char * str)
    139139{
    140140  static int reject = 0;
  • trunk/src/sh_err_log.c

    r19 r20  
    116116static int just_list = S_FALSE;
    117117
    118 int sh_error_logverify_mod (char * s)
     118int sh_error_logverify_mod (const char * s)
    119119{
    120120  just_list = S_TRUE;
     
    125125}
    126126
    127 int sh_error_logverify (char * s)
     127int sh_error_logverify (const char * s)
    128128{
    129129  SL_TICKET fd;
  • trunk/src/sh_error.c

    r11 r20  
    115115 *********************************************/
    116116
    117 int sh_error_verify (char * s)
     117int sh_error_verify (const char * s)
    118118{
    119119  char * foo;
     
    504504}
    505505
    506 int sh_error_set_level(char * str_in, int * facility)
     506int sh_error_set_level(const char * str_in, int * facility)
    507507{
    508508  register int  i, j, f = BAD;
    509509
    510510  int  old_facility;
    511   char * str_s = str_in;
     511  const char * str_s = str_in;
    512512
    513513  SL_ENTER(_("sh_error_set_level"));
     
    636636/* set severity for TCP export
    637637 */
    638 int sh_error_setexport(char *  str_s)
     638int sh_error_setexport(const char *  str_s)
    639639{
    640640  static int reject = 0;
     
    653653extern void dlog_set_active(int flag);
    654654
    655 int sh_error_setprint(char *  str_s)
     655int sh_error_setprint(const char *  str_s)
    656656{
    657657  static int reject = 0;
     
    676676/* set level for error logging
    677677 */
    678 int sh_error_setlog(char * str_s)
     678int sh_error_setlog(const char * str_s)
    679679{
    680680  static int reject = 0;
     
    691691/* set severity for syslog
    692692 */
    693 int sh_error_set_syslog (char * str_s)
     693int sh_error_set_syslog (const char * str_s)
    694694{
    695695  static int reject = 0;
     
    706706/* set severity for external
    707707 */
    708 int sh_error_set_external (char * str_s)
     708int sh_error_set_external (const char * str_s)
    709709{
    710710  static int reject = 0;
     
    722722/* set severity for database
    723723 */
    724 int sh_error_set_database (char * str_s)
     724int sh_error_set_database (const char * str_s)
    725725{
    726726  static int reject = 0;
     
    738738/* set severity for prelude
    739739 */
    740 int sh_error_set_prelude (char * str_s)
     740int sh_error_set_prelude (const char * str_s)
    741741{
    742742  static int reject = 0;
     
    784784/* set severity for mailing
    785785 */
    786 int sh_error_setseverity (char * str_s)
     786int sh_error_setseverity (const char * str_s)
    787787{
    788788  static int reject = 0;
  • trunk/src/sh_files.c

    r19 r20  
    168168/* set default recursion level
    169169 */
    170 int sh_files_setrecursion (char * flag_s)
     170int sh_files_setrecursion (const char * flag_s)
    171171{
    172172  long flag = 0;
  • trunk/src/sh_forward.c

    r19 r20  
    202202static int StripDomain = S_TRUE;
    203203
    204 int sh_forward_set_strip (char * str)
     204int sh_forward_set_strip (const char * str)
    205205{
    206206  static int fromcl = 0;
     
    17201720#ifndef USE_SRP_PROTOCOL
    17211721
    1722 int sh_forward_make_client (char * str)
     1722int sh_forward_make_client (const char * str)
    17231723{
    17241724  /* char *          safer; */
     
    17671767#else
    17681768
    1769 int sh_forward_make_client (char * str)
     1769int sh_forward_make_client (const char * str)
    17701770{
    17711771  char * foo_v;
     
    18221822
    18231823
    1824 int sh_forward_create_password (char * dummy)
     1824int sh_forward_create_password (const char * dummy)
    18251825{
    18261826  UINT32   val[2];
  • trunk/src/sh_getopt.c

    r1 r20  
    4040#endif
    4141
    42 extern int      sh_calls_set_bind_addr (char *);
     42extern int      sh_calls_set_bind_addr (const char *);
    4343
    4444#undef  FIL__
     
    5656  char * usage;
    5757  int          hasArg;
    58   int (*func)(char * opt);
     58  int (*func)(const char * opt);
    5959} opttable_t;
    6060
    6161/*@noreturn@*/
    62 static int sh_getopt_usage (char * dummy);
     62static int sh_getopt_usage (const char * dummy);
    6363#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
    64 static int sh_getopt_forever (char * dummy);
    65 #endif
    66 static int sh_getopt_copyright (char * dummy);
     64static int sh_getopt_forever (const char * dummy);
     65#endif
     66static int sh_getopt_copyright (const char * dummy);
    6767
    6868static opttable_t op_table[] = {
     
    258258    HAS_ARG_NO,
    259259    sh_getopt_usage },
     260#if defined(HAVE_LIBPRELUDE) && defined(HAVE_LIBPRELUDE_9)
     261  /* need to skip over these */
     262  { N_("prelude"), 
     263    '-',
     264    N_("Prelude generic options"), 
     265    HAS_ARG_NO,
     266    NULL },
     267  { N_("profile"), 
     268    '-',
     269    N_("Profile to use for this analyzer"), 
     270    HAS_ARG_YES,
     271    NULL },
     272  { N_("heartbeat-interval"), 
     273    '-',
     274    N_("Number of seconds between two heartbeats"), 
     275    HAS_ARG_YES,
     276    NULL },
     277  { N_("server-addr"), 
     278    '-',
     279    N_("Address where this sensor should report to"), 
     280    HAS_ARG_YES,
     281    NULL },
     282  { N_("analyzer-name"), 
     283    '-',
     284    N_("Name for this analyzer"), 
     285    HAS_ARG_YES,
     286    NULL },
     287#endif
    260288  /* last entry -- required !! -- */
    261289  { NULL,
     
    266294};
    267295
    268 static int sh_getopt_copyright (char * dummy)
     296static int sh_getopt_copyright (const char * dummy)
    269297{
    270298  fprintf (stdout,
     
    331359
    332360/*@noreturn@*/
    333 static int sh_getopt_usage (char * dummy)
     361static int sh_getopt_usage (const char * dummy)
    334362{
    335363  int  i;
     
    413441
    414442#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
    415 static int sh_getopt_forever (char * dummy)
     443static int sh_getopt_forever (const char * dummy)
    416444{
    417445  dummy = (void *) dummy;
     
    489517                              /* call function with argument */
    490518                              --argc; ++argv;
    491                               if (0 != (* op_table[i].func )(argv[1]))
     519                              if (NULL != op_table[i].func &&
     520                                  0 != (* op_table[i].func )(argv[1]))
    492521                                fprintf (stderr,
    493522                                         _("Error processing option -%c"),
     
    498527                      else
    499528                        {
    500                           if (0 != (* op_table[i].func )(NULL))
     529                          if (NULL != op_table[i].func &&
     530                              0 != (* op_table[i].func )(NULL))
    501531                            fprintf (stderr,
    502532                                     _("Error processing option -%c"),
     
    540570                      if ( (theequal = strchr(argv[1], '=')) == NULL)
    541571                        {
    542                           fprintf (stderr, _("Error: missing argument\n"));
    543                           /* argument required, but no avail */
    544                           (void) sh_getopt_usage(_("fail"));
     572                          if (argc < 3)
     573                            {
     574                              /* argument required, but no avail
     575                               */
     576                              fprintf (stderr, _("Error: missing argument\n"));
     577                              (void) sh_getopt_usage(_("fail"));
     578                            }
     579                          else
     580                            {
     581                              /* call function with argument */
     582                              --argc; ++argv;
     583                              if (NULL != op_table[i].func &&
     584                                  0 != (* op_table[i].func )(argv[1]))
     585                                fprintf (stderr,
     586                                         _("Error processing option -%s"),
     587                                         op_table[i].longopt);
     588                              break;
     589                            }
    545590                        }
    546591                      else
     
    550595                              ++theequal;
    551596                              /* call function with argument */
    552                               if (0 != (* op_table[i].func )(theequal))
     597                              if (NULL != op_table[i].func &&
     598                                  0 != (* op_table[i].func )(theequal))
    553599                                fprintf (stderr,
    554600                                         _("Error processing option -%s"),
     
    566612                  else
    567613                    {
    568                       if (0 != (* op_table[i].func )(NULL))
     614                      if (NULL != op_table[i].func &&
     615                          0 != (* op_table[i].func )(NULL))
    569616                        fprintf (stderr,
    570617                                 _("Error processing option -%s"),
  • trunk/src/sh_hash.c

    r19 r20  
    759759 *
    760760 ******************************************************************/
    761 int sh_hash_setdataent (SL_TICKET fd, char * line, int size, char * file)
     761int sh_hash_setdataent (SL_TICKET fd, char * line, int size, const char * file)
    762762{
    763763  long i;
     
    12611261static char * sh_db_version_string = NULL;
    12621262
    1263 int sh_hash_pushdata_stdout (char * str)
     1263int sh_hash_pushdata_stdout (const char * str)
    12641264{
    12651265  if (!str)
     
    31273127static int ListWithDelimiter = S_FALSE;
    31283128
    3129 int set_full_detail (char * c)
     3129int set_full_detail (const char * c)
    31303130{
    31313131  ListFullDetail = S_TRUE;
     
    31373137}
    31383138 
    3139 int set_list_delimited (char * c)
     3139int set_list_delimited (const char * c)
    31403140{
    31413141  ListFullDetail = S_TRUE;
     
    32593259}
    32603260
    3261 int sh_hash_list_db (char * db_file)
     3261int sh_hash_list_db (const char * db_file)
    32623262{
    32633263  sh_file_t * p;
  • trunk/src/sh_mail.c

    r1 r20  
    9393static mail_trail_type * mail_trail = NULL;
    9494
    95 int sh_mail_sigverify (char * s)
     95int sh_mail_sigverify (const char * s)
    9696{
    9797  SL_TICKET  fd;
  • trunk/src/sh_prelude.c

    r15 r20  
    5555#include <pwd.h>
    5656#include <grp.h>
     57
     58int     sh_argc_store;
     59char ** sh_argv_store;
    5760
    5861#if defined(HAVE_LIBPRELUDE) && defined(HAVE_LIBPRELUDE_9)
     
    933936        idmef_analyzer_t *analyzer;
    934937        prelude_client_flags_t flags;
     938#ifdef SH_NOFAILOVER
     939        prelude_connection_pool_t *pool;
     940        prelude_connection_pool_flags_t conn_flags;
     941#endif
    935942
    936943        if (ready_for_init == 0)
     
    941948
    942949        prelude_thread_init(NULL);
    943         prelude_init(NULL, NULL);
     950        prelude_init(&sh_argc_store, sh_argv_store);
    944951
    945952        ret = prelude_client_new(&client, profile ? profile : _("samhain"));
     
    968975        prelude_string_set_dup(str, IDMEF_ANALYZER_VERSION);
    969976       
     977#ifdef SH_NOFAILOVER
     978        pool = prelude_client_get_connection_pool(client);
     979        conn_flags = prelude_connection_pool_get_flags(pool);
     980
     981        conn_flags &= ~PRELUDE_CONNECTION_POOL_FLAGS_FAILOVER;
     982        prelude_connection_pool_set_flags(pool, conn_flags);
     983#endif
     984
    970985        ret = prelude_client_start(client);
    971986        if ( ret < 0 ) {
  • trunk/src/sh_readconf.c

    r1 r20  
    731731#endif
    732732
     733/* Yes, this isn't very elegant ;)
     734 */
     735#if defined(WITH_EXTERNAL)
     736int sh_error_set_external_wrap (char * str) {
     737  return sh_error_set_external ((const char *) str);
     738}
     739#endif
     740#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
     741int sh_files_setrecursion_wrap (char * str) {
     742  return sh_files_setrecursion ((const char *) str);
     743}
     744int sh_util_setchecksum_wrap (char * str) {
     745  return sh_util_setchecksum ((const char *) str);
     746}
     747#endif
     748int sh_util_setlooptime_wrap (char * str) {
     749  return sh_util_setlooptime ((const char *) str);
     750}
     751#ifdef SH_WITH_MAIL
     752int sh_error_setseverity_wrap (char * str) {
     753  return sh_error_setseverity ((const char *) str);
     754}
     755#endif
     756int sh_calls_set_bind_addr_wrap (char * str) {
     757  return sh_calls_set_bind_addr ((const char *) str);
     758}
     759int sh_unix_setdeamon_wrap (char * str) {
     760  return sh_unix_setdeamon ((const char *) str);
     761}
     762int sh_error_setprint_wrap (char * str) {
     763  return sh_error_setprint ((const char *) str);
     764}
     765int sh_error_setlog_wrap (char * str) {
     766  return sh_error_setlog ((const char *) str);
     767}
     768int sh_error_set_syslog_wrap (char * str) {
     769  return sh_error_set_syslog ((const char *) str);
     770}
     771#ifdef HAVE_LIBPRELUDE
     772int sh_error_set_prelude_wrap (char * str) {
     773  return sh_error_set_prelude ((const char *) str);
     774}
     775#endif
     776#ifdef SH_WITH_CLIENT
     777int sh_error_setexport_wrap (char * str) {
     778  return sh_error_setexport ((const char *) str);
     779}
     780#endif
     781#ifdef SH_WITH_SERVER
     782int sh_forward_set_strip_wrap (char * str) {
     783  return sh_forward_set_strip ((const char *) str);
     784}
     785int sh_unix_set_chroot_wrap (char * str) {
     786  return sh_unix_set_chroot ((const char *) str);
     787}
     788#endif
     789#if defined(WITH_DATABASE)
     790int sh_error_set_database_wrap (char * str) {
     791  return sh_error_set_database ((const char *) str);
     792}
     793#endif
     794 
    733795cfg_options ext_table[] = {
    734796#if defined(WITH_EXTERNAL)
     
    756818    sh_ext_add_or },
    757819  { N_("externalseverity"),SH_SECTION_LOG,      SH_SECTION_EXTERNAL, 
    758     sh_error_set_external },
     820    sh_error_set_external_wrap },
    759821  { N_("externalclass"),   SH_SECTION_LOG,      SH_SECTION_EXTERNAL, 
    760822    sh_error_external_mask },
     
    840902    sh_util_obscure_ok },
    841903  { N_("setrecursionlevel"),  SH_SECTION_MISC,   SH_SECTION_NONE,
    842     sh_files_setrecursion },
     904    sh_files_setrecursion_wrap },
    843905  { N_("checksumtest"),       SH_SECTION_MISC,   SH_SECTION_NONE,
    844     sh_util_setchecksum },
     906    sh_util_setchecksum_wrap },
    845907  { N_("reportonlyonce"),     SH_SECTION_MISC,   SH_SECTION_NONE,
    846908    sh_files_reportonce },
     
    915977    sh_socket_password },
    916978  { N_("setstripdomain"),      SH_SECTION_SRV,  SH_SECTION_MISC,
    917     sh_forward_set_strip },
     979    sh_forward_set_strip_wrap },
    918980  { N_("useseparatelogs"),     SH_SECTION_SRV,  SH_SECTION_MISC,
    919981    set_flag_sep_log },
    920982  { N_("setchrootdir"),        SH_SECTION_SRV,  SH_SECTION_MISC,
    921     sh_unix_set_chroot },
     983    sh_unix_set_chroot_wrap },
    922984  { N_("setclienttimelimit"),  SH_SECTION_SRV,  SH_SECTION_MISC,
    923985    sh_forward_set_time_limit },
     
    9401002#ifdef SH_WITH_CLIENT
    9411003  { N_("exportseverity"),      SH_SECTION_LOG,  SH_SECTION_NONE,
    942     sh_error_setexport },
     1004    sh_error_setexport_wrap },
    9431005  { N_("exportclass"),         SH_SECTION_LOG,  SH_SECTION_NONE,
    9441006    sh_error_export_mask },
     
    9491011    sh_readconf_setFiletime },
    9501012  { N_("setlooptime"),     SH_SECTION_MISC,  SH_SECTION_NONE,
    951     sh_util_setlooptime },
     1013    sh_util_setlooptime_wrap },
    9521014
    9531015#ifdef SH_WITH_MAIL
    9541016  { N_("mailseverity"),      SH_SECTION_LOG,   SH_SECTION_NONE,
    955     sh_error_setseverity },
     1017    sh_error_setseverity_wrap },
    9561018  { N_("mailclass"),         SH_SECTION_LOG,   SH_SECTION_NONE,
    9571019    sh_error_mail_mask },
     
    9781040#endif
    9791041  { N_("setbindaddress"),    SH_SECTION_MISC,  SH_SECTION_NONE,
    980     sh_calls_set_bind_addr },
     1042    sh_calls_set_bind_addr_wrap },
    9811043  { N_("daemon"),            SH_SECTION_MISC,  SH_SECTION_NONE,
    982     sh_unix_setdeamon },
     1044    sh_unix_setdeamon_wrap },
    9831045  { N_("samhainpath"),       SH_SECTION_MISC,  SH_SECTION_NONE,
    9841046    sh_unix_self_hash },
     
    9891051
    9901052  { N_("printseverity"),     SH_SECTION_LOG,   SH_SECTION_NONE,
    991     sh_error_setprint },
     1053    sh_error_setprint_wrap },
    9921054  { N_("printclass"),        SH_SECTION_LOG,   SH_SECTION_NONE,
    9931055    sh_error_print_mask },
    9941056
    9951057  { N_("logseverity"),       SH_SECTION_LOG,   SH_SECTION_NONE,
    996     sh_error_setlog },
     1058    sh_error_setlog_wrap },
    9971059  { N_("logclass"),          SH_SECTION_LOG,   SH_SECTION_NONE,
    9981060    sh_error_log_mask },
    9991061
    10001062  { N_("syslogseverity"),    SH_SECTION_LOG,   SH_SECTION_NONE,
    1001     sh_error_set_syslog },
     1063    sh_error_set_syslog_wrap },
    10021064  { N_("syslogclass"),       SH_SECTION_LOG,   SH_SECTION_NONE,
    10031065    sh_error_syslog_mask },
    10041066#ifdef HAVE_LIBPRELUDE
    10051067  { N_("preludeseverity"),   SH_SECTION_LOG,   SH_SECTION_NONE,
    1006     sh_error_set_prelude },
     1068    sh_error_set_prelude_wrap },
    10071069  { N_("preludeclass"),      SH_SECTION_LOG,   SH_SECTION_NONE,
    10081070    sh_error_prelude_mask },
  • trunk/src/sh_tiger0.c

    r19 r20  
    103103#if defined(TIGER_64_BIT)
    104104static
    105 word64 * sh_tiger_hash_val (char * filename, TigerType what,
     105word64 * sh_tiger_hash_val (const char * filename, TigerType what,
    106106                            UINT64 Length, int timeout)
    107107#else
    108108static
    109 sh_word32 * sh_tiger_hash_val (char * filename, TigerType what,
     109sh_word32 * sh_tiger_hash_val (const char * filename, TigerType what,
    110110                               UINT64 Length, int timeout)
    111111#endif
     
    14181418}
    14191419
    1420 static char * sh_tiger_hash_internal (char * filename, TigerType what,
     1420static char * sh_tiger_hash_internal (const char * filename, TigerType what,
    14211421                                      UINT64 Length, int timeout);
    14221422
    1423 char * sh_tiger_hash (char * filename, TigerType what,
     1423char * sh_tiger_hash (const char * filename, TigerType what,
    14241424                      UINT64 Length)
    14251425{
     
    14441444 * -------   end new ---------  */
    14451445 
    1446 static char * sh_tiger_hash_internal (char * filename, TigerType what,
     1446static char * sh_tiger_hash_internal (const char * filename, TigerType what,
    14471447                                      UINT64 Length, int timeout)
    14481448{
     
    14901490}
    14911491
    1492 char * sh_tiger_hash_gpg (char * filename, TigerType what,
     1492char * sh_tiger_hash_gpg (const char * filename, TigerType what,
    14931493                          UINT64 Length)
    14941494{
  • trunk/src/sh_unix.c

    r19 r20  
    16011601char * chroot_dir = NULL;
    16021602
    1603 int sh_unix_set_chroot(char * str)
     1603int sh_unix_set_chroot(const char * str)
    16041604{
    16051605  size_t len;
     
    16521652static int block_setdeamon = 0;
    16531653
    1654 int sh_unix_setdeamon(char * dummy)
     1654int sh_unix_setdeamon(const char * dummy)
    16551655{
    16561656  int    res = 0;
     
    16751675#endif
    16761676
    1677 int sh_unix_setnodeamon(char * dummy)
     1677int sh_unix_setnodeamon(const char * dummy)
    16781678{
    16791679  int    res = 0;
  • trunk/src/sh_utils.c

    r13 r20  
    5151UINT32 ErrFlag[2];
    5252
    53 int sh_util_flagval(char * c, int * fval)
     53int sh_util_flagval(const char * c, int * fval)
    5454{
    5555  SL_ENTER(_("sh_util_flagval"));
     
    101101static int sh_ask_update = S_FALSE;
    102102
    103 int sh_util_set_interactive(char * str)
    104 {
    105   if (str == NULL)
    106     sh_ask_update = S_TRUE;
    107   else
    108     sh_ask_update = S_TRUE;
     103int sh_util_set_interactive(const char * str)
     104{
     105  (void) str;
     106
     107  sh_ask_update = S_TRUE;
    109108
    110109  sh_unix_setnodeamon(NULL);
     
    950949static void copy_four (unsigned char * dest, UINT32 in);
    951950
    952 int sh_util_set_newkey (char * new)
     951int sh_util_set_newkey (const char * new_in)
    953952{
    954953  size_t i, j = 0;
     
    964963  long ii, k = 0;
    965964  UINT32    * h1;
     965  char * new;
    966966
    967967  if (0 != sl_is_suid())
     
    973973    }
    974974       
    975   if (new == NULL || new[0] == '\0')
     975  if (new_in == NULL || new_in[0] == '\0')
    976976    {
    977977      fprintf(stderr,
     
    981981      return -1;
    982982    }
     983
     984  if (NULL == (new = malloc(strlen(new_in) + 1)))
     985    goto bail_mem;
     986  sl_strncpy(new, new_in, strlen(new_in) + 1);
     987
    983988  key = new;
    984989  len = strlen(new);
     
    11581163/* server mode
    11591164 */
    1160 int sh_util_setserver (char * dummy)
     1165int sh_util_setserver (const char * dummy)
    11611166{
    11621167  SL_ENTER(_("sh_util_setserver"));
    11631168
    1164   if (dummy)
    1165     sh.flag.isserver = GOOD;
    1166   else
    1167     sh.flag.isserver = GOOD;
     1169  (void) dummy;
     1170  sh.flag.isserver = GOOD;
    11681171  SL_RETURN((0),_("sh_util_setserver"));
    11691172}
    11701173
    11711174
    1172 int sh_util_setlooptime (char * str)
     1175int sh_util_setlooptime (const char * str)
    11731176{
    11741177  int i = atoi (str);
     
    11871190
    11881191#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
    1189 int  sh_util_setchecksum (char * str)
     1192int  sh_util_setchecksum (const char * str)
    11901193{
    11911194  static int reject = 0;
  • trunk/src/slib.c

    r12 r20  
    66#include <stdarg.h>
    77#include <string.h>
    8 
     8#include <limits.h>
    99
    1010#include <unistd.h>
     
    9898static FILE * trace_fp     = NULL;
    9999
    100 int  sl_trace_use (char * dummy)
     100int  sl_trace_use (const char * dummy)
    101101{
    102102  if (dummy)
     
    107107}
    108108
    109 int  sl_trace_file (char * str)
     109int  sl_trace_file (const char * str)
    110110{
    111111  if (!str)
     
    16381638
    16391639static
    1640 int sl_open_file (char *filename, int mode, int priv)
     1640int sl_open_file (const char *filename, int mode, int priv)
    16411641{
    16421642  struct stat   lbuf;
     
    18481848
    18491849static
    1850 int check_fname_priv (char * fname, int priv)
     1850int check_fname_priv (const char * fname, int priv)
    18511851{
    18521852  SL_ENTER(_("check_fname_priv"));
     
    18581858}
    18591859 
    1860 SL_TICKET sl_open_write (char * fname, int priv)
     1860SL_TICKET sl_open_write (const char * fname, int priv)
    18611861{
    18621862  long status;
     
    18701870}
    18711871
    1872 SL_TICKET sl_open_read (char * fname, int priv)
     1872SL_TICKET sl_open_read (const char * fname, int priv)
    18731873{
    18741874  long status;
     
    18871887}
    18881888
    1889 SL_TICKET sl_open_fastread (char * fname, int priv)
     1889SL_TICKET sl_open_fastread (const char * fname, int priv)
    18901890{
    18911891  long status;
     
    18991899}
    19001900
    1901 SL_TICKET sl_open_rdwr (char * fname, int priv)
     1901SL_TICKET sl_open_rdwr (const char * fname, int priv)
    19021902{
    19031903  long status;
     
    19111911}
    19121912
    1913 SL_TICKET sl_open_safe_rdwr (char * fname, int priv)
     1913SL_TICKET sl_open_safe_rdwr (const char * fname, int priv)
    19141914{
    19151915  long status;
     
    19231923}
    19241924
    1925 SL_TICKET sl_open_write_trunc (char * fname, int priv)
     1925SL_TICKET sl_open_write_trunc (const char * fname, int priv)
    19261926{
    19271927  long status;
     
    19351935}
    19361936
    1937 SL_TICKET sl_open_rdwr_trunc (char * fname, int priv)
     1937SL_TICKET sl_open_rdwr_trunc (const char * fname, int priv)
    19381938{
    19391939  long status;
     
    24902490}
    24912491
    2492 
     2492/* ----------------------------------------------------------------
     2493 *
     2494 *    Overflow tests
     2495 *
     2496 * ---------------------------------------------------------------- */
     2497
     2498int sl_ok_muli (int a, int b) /* a*b */
     2499{
     2500  if (a >= (INT_MIN / b) && a <= (INT_MAX / b))
     2501    return SL_TRUE; /* no overflow */
     2502  return SL_FALSE;
     2503}
     2504
     2505int sl_ok_divi (int a, int b) /* a/b */
     2506{
     2507  (void) a;
     2508  if (b != 0)
     2509    return SL_TRUE; /* no overflow */
     2510  return SL_FALSE;
     2511}
     2512
     2513int sl_ok_addi (int a, int b) /* a+b */
     2514{
     2515  if (a >= 0 && b >= 0)
     2516    {
     2517      if (a <= (INT_MAX - b))
     2518        return SL_TRUE; /* no overflow */
     2519      else
     2520        return SL_FALSE;
     2521    }
     2522  else if (a < 0 && b < 0)
     2523    {
     2524      if (a >= (INT_MIN - b))
     2525        return SL_TRUE; /* no overflow */
     2526      else
     2527        return SL_FALSE;
     2528    }
     2529  return SL_TRUE;
     2530}
     2531
     2532int sl_ok_subi (int a, int b) /* a-b */
     2533{
     2534  if (a >= 0 && b < 0)
     2535    {
     2536      if (a <= (INT_MAX + b))
     2537        return SL_TRUE; /* no overflow */
     2538      else
     2539        return SL_FALSE;
     2540    }
     2541  else if (a < 0 && b >= 0)
     2542    {
     2543      if (a >= (INT_MIN + b))
     2544        return SL_TRUE; /* no overflow */
     2545      else
     2546        return SL_FALSE;
     2547    }
     2548  return SL_TRUE;
     2549}
  • trunk/test/testrun_1b.sh

    r19 r20  
    102102    rm -f $PW_DIR/test_log_prelude
    103103
    104     ( "$PM" --textmod -l $PW_DIR/test_log_prelude >/dev/null 2>&1 )&
     104    "$PM" --textmod -l $PW_DIR/test_log_prelude --listen 127.0.0.1:5500 >/dev/null 2>&1 &
    105105    PID=$!
    106106
    107     ./samhain -t check -p none -l info --set-prelude-severity=info >/dev/null
     107    sleep 5
     108
     109    ./samhain -t check -p none -l info --set-prelude-severity=info --prelude --server-addr 127.0.0.1:5500 >/dev/null
    108110   
    109111    if test x$? = x0; then
     
    166168            else
    167169                BUILDOPTS="--quiet $TRUST --enable-debug --with-prelude --with-gpg=${GPG} --with-checksum=no --enable-micro-stealth=137 --enable-login-watch --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"
    168                 testrun1b_internal "${BUILDOPTS}"
     170                testrun1b_internal "${BUILDOPTS} CFLAGS=-DSH_NOFAILOVER=1"
    169171                do_test_1b_2
    170172                if [ $? -eq 0 ]; then
Note: See TracChangeset for help on using the changeset viewer.