Changeset 481 for trunk/include


Ignore:
Timestamp:
Jul 18, 2015, 5:06:52 PM (9 years ago)
Author:
katerina
Message:

Enhancements and fixes for tickets #374, #375, #376, #377, #378, and #379.

Location:
trunk/include
Files:
7 added
4 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/rijndael-alg-fst.h

    r230 r481  
    1 /*
    2  * rijndael-alg-fst.h   v2.3   April '2000
     1/*      $NetBSD: rijndael-alg-fst.h,v 1.4 2005/12/11 12:20:52 christos Exp $    */
     2/*      $KAME: rijndael-alg-fst.h,v 1.5 2003/07/15 10:47:16 itojun Exp $        */
     3/**
     4 * rijndael-alg-fst.h
    35 *
    4  * Optimised ANSI C code
     6 * @version 3.0 (December 2000)
    57 *
     8 * Optimised ANSI C code for the Rijndael cipher (now AES)
     9 *
     10 * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
     11 * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
     12 * @author Paulo Barreto <paulo.barreto@terra.com.br>
     13 *
     14 * This code is hereby placed in the public domain.
     15 *
     16 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
     17 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
     20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    627 */
    7 
    8 /*@-fixedformalarray@*/
    9 
    1028#ifndef __RIJNDAEL_ALG_FST_H
    1129#define __RIJNDAEL_ALG_FST_H
    1230
    13 #define MAXKC                   (256/32)
    14 #define MAXROUNDS               14
    15 
    16 /* USUAL_TYPES */
    17 #ifndef USUAL_TYPES
    18 #define USUAL_TYPES
    19 typedef unsigned char   byte;
    20 typedef unsigned char   word8; 
    21 typedef unsigned short  word16;
    22 typedef unsigned int    word32;
    23 #endif
     31#define RIJNDAEL_MAXKC  (256/32)
     32#define RIJNDAEL_MAXKB  (256/8)
     33#define RIJNDAEL_MAXNR  14
    2434
    2535#ifdef SH_ENCRYPT
    2636
    27 int rijndaelKeySched(word8 k[MAXKC][4], word8 rk[MAXROUNDS+1][4][4], int ROUNDS);
    28 
    29 int rijndaelKeyEncToDec(word8 W[MAXROUNDS+1][4][4], int ROUNDS);
    30 
    31 int rijndaelEncrypt(word8 a[16], word8 b[16], word8 rk[MAXROUNDS+1][4][4], int ROUNDS);
    32 
    33 
    34 int rijndaelDecrypt(word8 a[16], word8 b[16], word8 rk[MAXROUNDS+1][4][4], int ROUNDS);
    35 
    36 #ifdef INTERMEDIATE_VALUE_KAT
    37 int rijndaelEncryptRound(word8 a[4][4], word8 rk[MAXROUNDS+1][4][4], int ROUNDS, int rounds);
    38 int rijndaelDecryptRound(word8 a[4][4], word8 rk[MAXROUNDS+1][4][4], int ROUNDS, int rounds);
    39 #endif
     37int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
     38int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
     39void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]);
     40void rijndaelDecrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 ct[16], u8 pt[16]);
    4041
    4142/* SH_ENCRYPT */
    4243#endif
    43 
    44 /* __RIJNDAEL_ALG_FST_H */
    45 #endif
    46 
     44#endif /* __RIJNDAEL_ALG_FST_H */
  • trunk/include/rijndael-api-fst.h

    r230 r481  
    1 /*
    2  * rijndael-api-fst.h   v2.3   April '2000
     1/*      $NetBSD: rijndael-api-fst.h,v 1.8 2007/01/21 23:00:08 cbiere Exp $      */
     2
     3/**
     4 * rijndael-api-fst.h
    35 *
    4  * Optimised ANSI C code
     6 * @version 2.9 (December 2000)
    57 *
     8 * Optimised ANSI C code for the Rijndael cipher (now AES)
     9 *
     10 * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
     11 * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
     12 * @author Paulo Barreto <paulo.barreto@terra.com.br>
     13 *
     14 * This code is hereby placed in the public domain.
     15 *
     16 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
     17 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
     20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 *
     28 * Acknowledgements:
     29 *
     30 * We are deeply indebted to the following people for their bug reports,
     31 * fixes, and improvement suggestions to this implementation. Though we
     32 * tried to list all contributions, we apologise in advance for any
     33 * missing reference.
     34 *
     35 * Andrew Bales <Andrew.Bales@Honeywell.com>
     36 * Markus Friedl <markus.friedl@informatik.uni-erlangen.de>
     37 * John Skodon <skodonj@webquill.com>
    638 */
    739
     
    941#define __RIJNDAEL_API_FST_H
    1042
     43/* Blocksize: 16 * 8 = 128; 128 * 1 = 128 */
     44#define     B_SIZ    16
     45#define     BNUM      1
     46
     47
     48#if defined(UINT32)
     49typedef unsigned char u8;
     50typedef UINT32 u32;
     51#else
     52
     53typedef unsigned char u8;
     54#if defined(HAVE_INT_32)
     55typedef unsigned int u32;
     56#elif defined(HAVE_LONG_32)
     57typedef unsigned long u32;
     58#elif defined(HAVE_SHORT_32)
     59typedef unsigned short u32;
     60#else
     61#error "No 32 bit integer type found"
     62#endif
     63
     64#endif
     65
    1166#include "rijndael-alg-fst.h"
    1267
    13 /*  Defines:
    14     Add any additional defines you need
    15 */
    16 
    17 #define     BNUM                  1
    18 #define     B_SIZ                 16
    19 #define     STRICT_ALIGN          1 /*  For safety          */
    20 
    21 
     68/*  Generic Defines  */
    2269#define     DIR_ENCRYPT           0 /*  Are we encrpyting?  */
    2370#define     DIR_DECRYPT           1 /*  Are we decrpyting?  */
     
    3380#define     BITSPERBLOCK        128 /* Default number of bits in a cipher block */
    3481
    35 /*  Error Codes - CHANGE POSSIBLE: inclusion of additional error codes  */
    36 
     82/*  Error Codes  */
    3783#define     BAD_KEY_DIR          -1 /*  Key direction is invalid, e.g., unknown value */
    3884#define     BAD_KEY_MAT          -2 /*  Key material not of correct length */
     
    4591#define     BAD_OTHER            -9 /*  Unknown error */
    4692
    47 /*  CHANGE POSSIBLE:  inclusion of algorithm specific defines  */
    48 #define     MAX_KEY_SIZE         64 /* # of ASCII char's needed to represent a key */
    49 #define     MAX_IV_SIZE          16 /* # bytes needed to represent an IV  */
     93/*  Algorithm-specific Defines  */
     94#define     RIJNDAEL_MAX_KEY_SIZE         64 /* # of ASCII char's needed to represent a key */
     95#define     RIJNDAEL_MAX_IV_SIZE          16 /* # bytes needed to represent an IV  */
    5096
    5197#ifdef SH_ENCRYPT
    5298
    53 /*  Typedefs:
     99/*  Typedefs  */
    54100
    55         Typedef'ed data storage elements.  Add any algorithm specific
    56 parameters at the bottom of the structs as appropriate.
    57 */
    58 
    59 typedef unsigned char   RIJ_BYTE;
     101typedef unsigned char   BYTE;
    60102
    61103/*  The structure for key information */
    62104typedef struct {
    63     RIJ_BYTE  direction;                /* Key used for encrypting or decrypting? */
    64     int   keyLen;                   /* Length of the key  */
    65     char  keyMaterial[MAX_KEY_SIZE+1];  /* Raw key data in ASCII, e.g., user input or KAT values */
    66         /*  The following parameters are algorithm dependent, replace or add as necessary  */
    67         int   ROUNDS;                   /* key-length-dependent number of rounds */
    68     int   blockLen;                 /* block length */
    69     word8 keySched[MAXROUNDS+1][4][4];  /* key schedule         */
     105  u32   rk[4*(RIJNDAEL_MAXNR + 1)];        /* key schedule */
     106  u32   ek[4*(RIJNDAEL_MAXNR + 1)];        /* CFB1 key schedule (encryption only) */
     107  BYTE  direction;                /* Key used for encrypting or decrypting? */
     108  int   keyLen;                   /* Length of the key  */
     109  char  keyMaterial[RIJNDAEL_MAX_KEY_SIZE+1];  /* Raw key data in ASCII, e.g., user input or KAT values */
     110  int   Nr;                       /* key-length-dependent number of rounds */
    70111} keyInstance;
    71112
    72113/*  The structure for cipher information */
    73114typedef struct {                    /* changed order of the components */
    74     RIJ_BYTE  mode;                     /* MODE_ECB, MODE_CBC, or MODE_CFB1 */
    75     RIJ_BYTE  IV[MAX_IV_SIZE];          /* A possible Initialization Vector for ciphering */
    76         /*  Add any algorithm specific parameters needed here  */
    77     int   blockLen;                 /* Sample: Handles non-128 bit block sizes (if available) */
     115    u32  IV[RIJNDAEL_MAX_IV_SIZE / sizeof(u32)];
     116                        /* A possible Initialization Vector for ciphering */
     117    BYTE  mode;                     /* MODE_ECB, MODE_CBC, or MODE_CFB1 */
    78118} cipherInstance;
    79119
    80120/*  Function prototypes  */
    81 /*  CHANGED: nothing
    82         TODO: implement the following extensions to setup 192-bit and 256-bit block lengths:
    83         makeKeyEx():    parameter blockLen added
    84                         -- this parameter is absolutely necessary if you want to
    85                         setup the round keys in a variable block length setting
    86             cipherInitEx(): parameter blockLen added (for obvious reasons)             
    87  */
    88121
    89 int makeKey(keyInstance *key, RIJ_BYTE direction, int keyLen, char *keyMaterial);
     122int rijndael_makeKey(keyInstance *, BYTE, int, const char *);
    90123
    91 int cipherInit(cipherInstance *cipher, RIJ_BYTE mode, char *IV);
     124int rijndael_cipherInit(cipherInstance *, BYTE, const char *);
    92125
    93 int blockEncrypt(cipherInstance *cipher, keyInstance *key,
    94                  RIJ_BYTE *input, int inputLen, RIJ_BYTE *outBuffer);
     126int rijndael_blockEncrypt(cipherInstance *, keyInstance *, const BYTE *, int, BYTE *);
    95127
    96 int blockDecrypt(cipherInstance *cipher, keyInstance *key,
    97                  RIJ_BYTE *input, int inputLen, RIJ_BYTE *outBuffer);
    98 #ifdef INTERMEDIATE_VALUE_KAT
    99 int cipherUpdateRounds(cipherInstance *cipher, keyInstance *key,
    100                        RIJ_BYTE *input, int inputLen, RIJ_BYTE *outBuffer, int rounds);
    101 #endif
     128int rijndael_padEncrypt(cipherInstance *, keyInstance *, const BYTE *, int, BYTE *);
     129
     130int rijndael_blockDecrypt(cipherInstance *, keyInstance *, const BYTE *, int, BYTE *);
     131
     132int rijndael_padDecrypt(cipherInstance *, keyInstance *, const BYTE *, int, BYTE *);
    102133
    103134/* SH_ENCRYPT */
    104135#endif
    105 
    106 /*  __RIJNDAEL_API_FST_H */
    107 #endif
     136#endif /* __RIJNDAEL_API_FST_H */
  • trunk/include/samhain.h

    r459 r481  
    2828#endif
    2929
     30#if defined(__GNUC__) && (__GNUC__ >= 4)
     31#define SH_GNUC_SENTINEL __attribute__((__sentinel__))
     32#else
     33#define SH_GNUC_SENTINEL
     34#endif
     35
     36#if defined(__GNUC__) && (__GNUC__ >= 3)
     37#undef  SH_GNUC_PURE
     38#define SH_GNUC_PURE     __attribute__((pure))
     39#undef  SH_GNUC_CONST
     40#define SH_GNUC_CONST    __attribute__((const))
     41#undef  SH_GNUC_NORETURN
     42#define SH_GNUC_NORETURN __attribute__((noreturn))
     43#undef  SH_GNUC_MALLOC
     44#define SH_GNUC_MALLOC   __attribute__((malloc))
     45#else
     46#undef  SH_GNUC_PURE
     47#define SH_GNUC_PURE
     48#undef  SH_GNUC_CONST
     49#define SH_GNUC_CONST
     50#undef  SH_GNUC_NORETURN
     51#define SH_GNUC_NORETURN
     52#undef  SH_GNUC_MALLOC
     53#define SH_GNUC_MALLOC
     54#endif
     55
    3056/**************************************************
    3157 *
     
    5783
    5884/* end IPv6 */
    59 
    60 #define REPLACE_OLD
    6185
    6286/* Standard buffer sizes.
     
    101125#define PW_LEN     8
    102126
    103 #undef  GOOD
    104 #define GOOD  1
    105 #undef  BAD
    106 #define BAD   0
    107 #undef  ON
    108 #define ON    1
    109 #undef  OFF
    110 #define OFF   0
    111127#undef  S_TRUE
    112128#define S_TRUE    1
    113129#undef  S_FALSE
    114130#define S_FALSE   0
     131
     132#undef  GOOD
     133#define GOOD  S_TRUE
     134#undef  BAD
     135#define BAD   S_FALSE
     136
     137
     138#ifdef HAVE_INTTYPES_H
     139#include <inttypes.h>
     140#endif
     141#ifdef HAVE_STDINT_H
     142#include <stdint.h>
     143#endif
     144
     145#if !defined(HAVE_UINT16_T)
     146#define UINT16 unsigned short
     147#else
     148#define UINT16 uint16_t
     149#endif
     150
     151#if !defined(HAVE_UINT32_T)
    115152
    116153/* An unsigned integer guaranteed to be 32 bit.
     
    129166#endif
    130167
    131 #ifdef HAVE_INTTYPES_H
    132 #include <inttypes.h>
    133 #endif
    134 #ifdef HAVE_STDINT_H
    135 #include <stdint.h>
    136 #endif
    137 
    138 #if !defined(HAVE_UINT16_T)
    139 #define UINT16 unsigned short
    140 #else
    141 #define UINT16 uint16_t
     168#else
     169#define UINT32 uint32_t
     170#define SINT32 int32_t
     171
    142172#endif
    143173
     
    305335  int    client_severity;          /* TRUE if client severity used    */
    306336  int    client_class;             /* TRUE if client class used       */
     337  int    hidefile;                 /* TRUE if file not shown in log   */
     338  int    inotify;                  /* Flags for inotify               */
    307339  int    audit;
    308340  unsigned long aud_mask;
    309   int    hidefile;                 /* TRUE if file not shown in log   */
    310   int    inotify;                  /* Flags for inotify               */
    311341} sh_sh_flag;
    312342
     
    347377  /*@null@*//*@out@*/ char   * timezone;
    348378
     379  int delayload;
     380
    349381#ifdef SCREW_IT_UP
    350382  int sigtrap_max_duration;
    351383#endif
    352384
     385  char * outpath;
    353386} sh_struct;
    354387
     
    365398extern volatile  int      sig_termfast;           /* SIGTERM */
    366399extern volatile  int      sig_force_check;        /* SIGTTOU */
     400extern volatile  int      sh_load_delta_flag;
    367401
    368402extern long int eintr__result;
     
    420454#endif
    421455
    422 #if defined(__GNUC__) && (__GNUC__ >= 4)
    423 #define SH_GNUC_SENTINEL __attribute__((__sentinel__))
    424 #else
    425 #define SH_GNUC_SENTINEL
    426 #endif
    427 
    428 #if defined(__GNUC__) && (__GNUC__ >= 3)
    429 #undef  SH_GNUC_PURE
    430 #define SH_GNUC_PURE     __attribute__((pure))
    431 #undef  SH_GNUC_CONST
    432 #define SH_GNUC_CONST    __attribute__((const))
    433 #undef  SH_GNUC_NORETURN
    434 #define SH_GNUC_NORETURN __attribute__((noreturn))
    435 #undef  SH_GNUC_MALLOC
    436 #define SH_GNUC_MALLOC   __attribute__((malloc))
    437 #else
    438 #undef  SH_GNUC_PURE
    439 #define SH_GNUC_PURE
    440 #undef  SH_GNUC_CONST
    441 #define SH_GNUC_CONST
    442 #undef  SH_GNUC_NORETURN
    443 #define SH_GNUC_NORETURN
    444 #undef  SH_GNUC_MALLOC
    445 #define SH_GNUC_MALLOC
    446 #endif
    447456
    448457
     
    481490#ifdef USE_SUID
    482491#define MLOCK(a, b) \
    483       if ((skey != NULL) && skey->mlock_failed == SL_FALSE){ \
     492      if ((skey != NULL) && skey->mlock_failed == S_FALSE){ \
    484493        (void) sl_set_suid(); \
    485         if (sh_unix_mlock(FIL__, __LINE__, a, b) < 0) skey->mlock_failed = SL_TRUE; \
     494        if (sh_unix_mlock(FIL__, __LINE__, a, b) < 0) skey->mlock_failed = S_TRUE; \
    486495        (void) sl_unset_suid(); }
    487496#else
    488497#define MLOCK(a, b) \
    489       if ((skey != NULL) && skey->mlock_failed == SL_FALSE){ \
    490         if (sh_unix_mlock(FIL__, __LINE__, a, b) < 0) skey->mlock_failed = SL_TRUE; }
     498      if ((skey != NULL) && skey->mlock_failed == S_FALSE){ \
     499        if (sh_unix_mlock(FIL__, __LINE__, a, b) < 0) skey->mlock_failed = S_TRUE; }
    491500#endif
    492501#else
     
    498507#ifdef USE_SUID
    499508#define MUNLOCK(a, b) \
    500       if ((skey != NULL) && skey->mlock_failed == SL_FALSE){ \
     509      if ((skey != NULL) && skey->mlock_failed == S_FALSE){ \
    501510        (void) sl_set_suid(); \
    502511        (void) sh_unix_munlock( a, b );\
     
    504513#else
    505514#define MUNLOCK(a, b) \
    506       if ((skey != NULL) && skey->mlock_failed == SL_FALSE){ \
     515      if ((skey != NULL) && skey->mlock_failed == S_FALSE){ \
    507516        (void) sh_unix_munlock( a, b ); }
    508517#endif
  • trunk/include/sh_calls.h

    r317 r481  
    3030
    3131/*@-fixedformalarray@*/
     32
     33#include "config_xor.h"
     34#if defined(__GNUC__) && (__GNUC__ >= 3)
     35#undef  SH_GNUC_NORETURN
     36#define SH_GNUC_NORETURN __attribute__((noreturn))
     37#else
     38#undef  SH_GNUC_NORETURN
     39#define SH_GNUC_NORETURN
     40#endif
     41
    3242
    3343/* Set aud functions
     
    8393                             int * o_noatime);
    8494/*@noreturn@*/
    85 void     aud_exit   (const char * file, int line, int fd);
     95void     aud_exit   (const char * file, int line, int fd) SH_GNUC_NORETURN;
    8696/*@noreturn@*/
    87 void     aud__exit  (const char * file, int line, int fd);
     97void     aud__exit  (const char * file, int line, int fd) SH_GNUC_NORETURN;
    8898pid_t    aud_fork   (const char * file, int line);
    8999int      aud_pipe   (const char * file, int line, int modus[2]);
  • trunk/include/sh_cat.h

    r294 r481  
    7575 MSG_CHECK_0,     
    7676 MSG_CHECK_1,     
     77 MSG_CHECK_2,     
    7778 MSG_STAMP,       
    7879                 
     
    8081 MSG_D_DSTART,   
    8182 MSG_D_FAIL,     
    82 
     83 MSG_D_DELTAOK,
     84 MSG_D_DELTAFAIL,
    8385
    8486#ifndef HAVE_URANDOM
     
    98100 MSG_SUID_QREPORT,
    99101 MSG_SUID_ERROR,
    100 #endif
    101 
    102 #ifdef SH_USE_KERN
    103  /* FreeBSD */
    104  MSG_KERN_POLICY,   
    105  MSG_KERN_POL_CO,
    106 
    107  /* Linux */
    108  MSG_KERN_SYSCALL,
    109  MSG_KERN_PROC,
    110  MSG_KERN_IDT,
    111  MSG_KERN_GATE,
    112102#endif
    113103
  • trunk/include/sh_error.h

    r410 r481  
    178178int sh_error_setdebug (char * debug_s);
    179179
    180 /* error messages
    181  */
    182 /*@owned@*/char * sh_error_message (int tellme, char * str, size_t len);
    183 
    184180/* switch on/off log to file temporarily
    185181 */
     
    198194void reset_count_dev_console(void);
    199195
     196/* close the message queue [no-op if !defined(WITH_MESSAGE_QUEUE)]
     197 */
     198void close_ipc (void);
     199
    200200#ifdef WITH_MESSAGE_QUEUE
    201 /* close the message queue
    202  */
    203 void close_ipc (void);
    204 
    205201/* enable message queue
    206202 */
  • trunk/include/sh_error_min.h

    r272 r481  
    3535int sh_error_convert_level (const char * str_s);
    3636
     37/* error messages
     38 */
     39char * sh_error_message (int tellme, char * str, size_t len);
     40
    3741#endif
  • trunk/include/sh_extern.h

    r415 r481  
    4242 *    executes shell command
    4343 */
    44 int sh_ext_popen_init (sh_tas_t * task, char * command, char * argv0, ...) SH_GNUC_SENTINEL;
     44int sh_ext_popen_init (sh_tas_t * task, const char * command, char * argv0, ...) SH_GNUC_SENTINEL;
    4545
    4646/*
     
    5252 * -- Execute command, return first line of output
    5353 */
    54 char * sh_ext_popen_str (char * command);
     54char * sh_ext_popen_str (const char * command);
    5555
    5656/*
  • trunk/include/sh_fifo.h

    r272 r481  
    3333} SH_FIFO;
    3434
     35#define SH_FIFO_INITIALIZER { NULL, NULL, 0 }
     36
    3537/*****************************************************
    3638 *
     
    4244 *
    4345 */
    44 #define fifo_init(fifo_p) { fifo_p->fifo_cts = 0; fifo_p->head_ptr = NULL; \
    45  fifo_p->tail_ptr = NULL; }
     46#define fifo_init(fifo_p) { (fifo_p)->fifo_cts = 0; (fifo_p)->head_ptr = NULL; \
     47    (fifo_p)->tail_ptr = NULL; }
    4648
    4749
     
    5052 * Returns: -1 if the list is full, 0 on success
    5153 */
    52 int push_list (SH_FIFO * fifo, char * indat, int in_i, const char * in_str);
     54int push_list (SH_FIFO * fifo, const char * indat, int in_i, const char * in_str);
     55#define sh_fifo_push(a, b) push_list((a), (b), 0, NULL)
    5356
    5457/* Push an item on the tail of the list.
     
    5659 * Returns: -1 if the list is full, 0 on success
    5760 */
    58 int push_tail_list (SH_FIFO * fifo, char * indat, int in_i, const char * in_str);
     61int push_tail_list (SH_FIFO * fifo, const char * indat, int in_i, const char * in_str);
     62#define sh_fifo_push_tail(a, b) push_tail_list((a), (b), 0, NULL)
    5963
    6064/* pop an item from the tail of the list
     
    6468 */
    6569char * pop_list (SH_FIFO * fifo);
     70#define sh_fifo_pop(a) pop_list((a))
    6671
     72/* ----  Special functions -------------------------------------------------*/
    6773
     74/* This is for eMail where different recipients may be eligible for         *
     75 * different subsets of messages. We need to delete all that were sent      *
     76 * to all intended recipients, and keep all with at least one failure.      */
     77
     78/* Iterate over list and check for each if it is valid for 'tag';
     79 * i.e. (item->s_extra == tag). If yes, add to the returned string.
     80 * If (okNull == False) then item->s_xtra must be defined
     81 */
    6882sh_string * tag_list (SH_FIFO * fifo, char * tag,
    6983                      int(*check)(int, const char*, const char*, const void*),
    7084                      const void * info, int okNull);
     85
     86/* Flag all tagged as candidate to keep */
    7187void rollback_list (SH_FIFO * fifo);
     88/* Flag all tagged as candidate to delete */
    7289void mark_list (SH_FIFO * fifo);
     90/* Remove all flags */
    7391void reset_list (SH_FIFO * fifo);
     92/* Delete all marked for delete that are not flagged for keep */
    7493int commit_list (SH_FIFO * fifo);
    7594
  • trunk/include/sh_files.h

    r457 r481  
    3131};
    3232
     33/* Fix the check flags
     34 */
     35void sh_files_fixup_mask (int class, unsigned long * check_flags);
     36
     37/* Dequote a filename in the config file
     38 */
     39char * sh_files_parse_input(const char * str_s, size_t * len);
     40
    3341/* Check whether a file is in the config
    3442 */
     
    233241int sh_files_redef_allignore(const char * str);
    234242
    235 ShFileType sh_files_filecheck (int class, unsigned long check_mask,
     243ShFileType sh_files_filecheck (int class, unsigned long check_flags,
    236244                               const char * dirName,
    237245                               const char * infileName,
     
    239247                               int rsrcflag);
    240248
    241 int sh_files_checkdir (int iclass, unsigned long check_mask,
     249int sh_files_checkdir (int iclass, unsigned long check_flags,
    242250                       int idepth, char * iname,
    243251                       char * relativeName);
    244252
    245253int sh_files_search_file(char * name, int * class,
    246                          unsigned long *check_mask, int * reported);
     254                         unsigned long *check_flags, int * reported);
    247255int sh_files_search_dir(char * name, int * class,
    248                         unsigned long *check_mask, int *reported,
     256                        unsigned long *check_flags, int *reported,
    249257                        int * rdepth);
    250258void sh_files_set_file_reported(const char * name);
  • trunk/include/sh_gpg.h

    r347 r481  
    2323#define SH_GPG_H
    2424
     25#define SIG_CONF 1
     26#define SIG_DATA 2
     27
    2528/* Top level function to verify file.
    2629 */
     
    3033 * and/or database cannot be verified; otherwise returns 0
    3134 */
    32 int sh_gpg_check_sign (long file_1, long file_2, int what);
     35int sh_gpg_check_sign (long file, int what);
    3336
    3437/* log successful startup
  • trunk/include/sh_hash.h

    r458 r481  
    2828#include "sh_error.h"
    2929
     30/* the report_checkflags flag
     31 */
     32int get_report_checkflags();
     33
     34/* whether to report checkflags
     35 */
     36int set_report_checkflags(const char * c);
     37
    3038/* convert to policy string
    3139 */
     
    4048int hashreport_missing( char *fullpath, int level);
    4149
     50/* remove internal db record for a file (checks for some flags).
     51 */
     52void sh_hash_remove (const char * path);
     53
    4254/* remove internal db record for a file
    4355 */
    44 void sh_hash_remove (const char * path);
    45 
    46 /* write database to stdout
    47  */
    48 int sh_hash_pushdata_stdout (const char * str);
    49 
    50 /* version string for database
    51  */
    52 int sh_hash_version_string(const char * str);
     56void sh_hash_remove_unconditional (const char * path);
     57
     58/* Insert a "null" record in-memory (representing a missing file).
     59 */
     60void sh_hash_insert_null(char * str);
     61
     62#ifdef SH_DBIO_INT_H
     63/* Check for "null" record
     64 */
     65int sh_hash_is_null_record(sh_filestore_t * theFile);
     66#endif
    5367
    5468/* Dont report on ctm/mtm change for directories
     
    5670int sh_hash_loosedircheck(const char * str);
    5771
    58 /* List database content
    59  */
    60 int sh_hash_list_db (const char * db_file);
    61 
    6272/* List database content for a single file
    6373 */
    6474int set_list_file (const char * c);
    6575
     76/* Set the path of that file
     77 */
     78char * get_list_file();
     79
    6680/* List database content with full detail
    6781 */
     
    7589 */
    7690void sh_hash_init (void);
     91
     92/* Check init status
     93 */
     94int sh_hash_get_initialized();
     95
     96/* Read the database from disk and fill sh.data.hash with checksum.
     97 */
     98void sh_hash_init_and_checksum();
     99
     100/* Set status to 'database is read in'.
     101 */
     102void sh_hash_set_initialized();
    77103
    78104/* Check whether a file is present in the database.
  • trunk/include/sh_html.h

    r1 r481  
    5353  int                     encf_flag;
    5454  int                     ency_flag;
     55  int                     ivst_flag;
    5556  int                     status_now;
    5657  int                     status_arr[CLT_MAX];
  • trunk/include/sh_inotify.h

    r373 r481  
    3232
    3333int sh_inotify_add_watch(char * filename, sh_watches * watches, int  * errnum,
    34                          int class, unsigned long check_mask, int type, int rdepth);
     34                         int class, unsigned long check_flags, int type, int rdepth);
    3535
    3636int sh_inotify_add_watch_later(const char * filename, sh_watches * watches,
    3737                               int  * errnum,
    38                                int class, unsigned long check_mask,
     38                               int class, unsigned long check_flags,
    3939                               int type, int rdepth);
    4040
    4141char * sh_inotify_pop_dormant(sh_watches * watches, int * class,
    42                               unsigned long * check_mask, int * type, int * rdepth);
     42                              unsigned long * check_flags, int * type, int * rdepth);
    4343
    4444void sh_inotify_purge_dormant(sh_watches * watches);
     
    4747
    4848char * sh_inotify_search_item(sh_watches * watches, int watch,
    49                               int * class, unsigned long * check_mask,
     49                              int * class, unsigned long * check_flags,
    5050                              int * type, int * rdepth);
    5151ssize_t sh_inotify_read(char * buffer, size_t count);
  • trunk/include/sh_prelink.h

    r102 r481  
    66 * alert_timeout: timeout for read
    77 */
    8 int sh_prelink_run (char * path, char * file_hash, int alert_timeout);
     8int sh_prelink_run (char * path, char * file_hash, int alert_timeout, unsigned long mask);
    99
    1010/* return S_TRUE if ELF file, S_FALSE otherwise
  • trunk/include/sh_socket.h

    r200 r481  
    88
    99#if defined (SH_WITH_CLIENT)
    10 void sh_socket_server_cmd(const char * srvcmd);
     10char * sh_socket_get_uuid(int * errflag, unsigned int * count, time_t * last);
     11int    sh_socket_store_uuid(const char * cmd);
     12int    sh_socket_return_uuid(const char * uuid, unsigned int count, time_t last);
     13void   sh_socket_server_cmd(const char * srvcmd);
     14int    set_delta_retry_interval(const char * str);
     15int    set_delta_retry_count(const char * str);
    1116#endif
    1217
  • trunk/include/sh_tiger.h

    r170 r481  
    4444int sh_tiger_get_hashtype (void);
    4545
     46/* set the hash fuction in use in the mask
     47 */
     48void sh_tiger_get_mask_hashtype(unsigned long * mask);
     49
     50
     51/* reset the hash function to the one in the mask
     52 */
     53void sh_tiger_set_hashtype_mask(unsigned long mask);
     54
    4655/* GnuPG-like format, returns allocated memory
    4756 */
  • trunk/include/sh_tools.h

    r295 r481  
    88 */
    99#define SH_PROTO_SRP (1 << 0)
     10#define SH_PROTO_IVA (1 << 1)
    1011#define SH_PROTO_MSG (1 << 2)
    1112#define SH_PROTO_BIG (1 << 3)
    1213#define SH_PROTO_END (1 << 4)
    13 #define SH_PROTO_ENC (1 << 5)
     14#define SH_PROTO_EN1 (1 << 5)
    1415#define SH_PROTO_EN2 (1 << 6)
     16#define SH_PROTO_ENC (SH_PROTO_EN1|SH_PROTO_EN2)
    1517#define SH_MASK_ENC (SH_PROTO_ENC|SH_PROTO_EN2)
    1618
     
    4446#if defined (SH_WITH_SERVER)
    4547
     48unsigned char sh_tools_probe_store(unsigned char protocol, int * probe_flag);
     49
    4650int get_open_max (void);
    4751
    48 void put_header (/*@out@*/unsigned char * head, int protocol,
     52void put_header (/*@out@*/unsigned char * head, const int protocol,
    4953                 unsigned long * length, char * u);
    5054
     
    5963/* returns allocated buffer
    6064 */
    61 char * get_client_conf_file (char * peer, unsigned long * length);
     65char * get_client_conf_file (const char * peer, unsigned long * length);
    6266
    6367/* returns allocated buffer
    6468 */
    65 char * get_client_data_file (char * peer, unsigned long * length);
     69char * get_client_data_file (const char * peer, unsigned long * length);
    6670
     71/* returns allocated buffer
     72 */
     73char * get_client_uuid_file (const char * peer, unsigned long * length, const char * uuid);
    6774#endif
     75
    6876
    6977unsigned long read_port (int sockfd, char *buf, unsigned long nbytes,
     
    7280
    7381#if defined (SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
     82
     83void sh_tools_probe_reset();
    7484
    7585unsigned long write_port (int sockfd, char *buf, unsigned long nbytes,
  • trunk/include/sh_trace.h

    r1 r481  
    99#define ASSERT(expr, expr1) \
    1010      if (!(expr)) \
    11          fprintf(stderr, \
     11        { \
     12         fprintf(stderr,            \
    1213                 SDG_AERRO, \
    13                  FIL__, __LINE__, expr1 );
     14                 FIL__, __LINE__, expr1 ); \
     15          abort(); \
     16        }
    1417
    1518
  • trunk/include/sh_unix.h

    r425 r481  
    6868/* inode        */
    6969#define MODI_INO (1 << 2)
     70
    7071/* user         */
    7172#define MODI_USR (1 << 3)
     
    7475/* mtime        */
    7576#define MODI_MTM (1 << 5)
     77
    7678/* ctime        */
    7779#define MODI_CTM (1 << 6)
     
    8082/* size         */
    8183#define MODI_SIZ (1 << 8)
     84
    8285/* file mode    */
    8386#define MODI_MOD (1 << 9)
     
    8689/* device type   */
    8790#define MODI_RDEV (1 << 11)
     91
    8892/* size may grow   */
    8993#define MODI_SGROW (1 << 12)
    9094/* use prelink     */
    9195#define MODI_PREL (1 << 13)
    92 
    9396/* get content     */
    9497#define MODI_TXT ((1 << 14)|MODI_CHK)
     
    98101#define MODI_AUDIT (1 << 15)
    99102#define MODI_AUDIT_ENABLED(a) (((a)&(1 << 15))!=0)
    100 
    101 #define MODI_INIT 0xDA000000UL
    102 #define MODI_INITIALIZED(a) (((a) & 0xFF000000UL) == MODI_INIT)
     103/* do not check  */
     104#define MODI_NOCHECK (1 << 16)
     105/* do not check  */
     106#define MODI_ALLIGNORE (1 << 17)
     107
     108#define MODI_TIGER192  0x01000000UL
     109#define MODI_SHA1      0x02000000UL
     110#define MODI_MD5       0x03000000UL
     111#define MODI_SHA256    0x04000000UL
     112#define MODI_HASHTYPE  0x0F000000UL
     113
     114#define MODI_INIT 0xD0000000UL
     115#define MODI_INITIALIZED(a) (((a) & 0xF0000000UL) == MODI_INIT)
     116
     117#define MODI_SET(a, b) ((a) |= (b))
     118#define MODI_CLEAR(a, b) ((a) &= ~(b))
     119#define MODI_ISSET(a, b) (((a) & (b)) != 0)
    103120
    104121#define SH_TXT_MAX 9200
     
    128145
    129146typedef struct file_struct {
    130   unsigned long    check_mask;
     147  unsigned long    check_flags;
    131148  int              file_reported;
    132149  char             fullpath[PATH_MAX];
     
    314331 */
    315332int sh_check_rotated_log (const char * path, 
    316                           UINT64 old_size, UINT64 old_inode, const char * old_hash);
     333                          UINT64 old_size, UINT64 old_inode, const char * old_hash, unsigned long mask);
    317334
    318335/* obtain file info
  • trunk/include/slib.h

    r428 r481  
    6060 * TRUE, FALSE
    6161 */
    62 #define SL_TRUE  1
    63 #define SL_FALSE 0
     62#if !defined(S_TRUE)
     63#define S_TRUE  1
     64#define S_FALSE 0
     65#endif
    6466
    6567#define SH_GRBUF_SIZE   4096
Note: See TracChangeset for help on using the changeset viewer.