[1] | 1 | /* SAMHAIN file system integrity testing */
|
---|
| 2 | /* Copyright (C) 1999 Rainer Wichmann */
|
---|
| 3 | /* */
|
---|
| 4 | /* This program is free software; you can redistribute it */
|
---|
| 5 | /* and/or modify */
|
---|
| 6 | /* it under the terms of the GNU General Public License as */
|
---|
| 7 | /* published by */
|
---|
| 8 | /* the Free Software Foundation; either version 2 of the License, or */
|
---|
| 9 | /* (at your option) any later version. */
|
---|
| 10 | /* */
|
---|
| 11 | /* This program is distributed in the hope that it will be useful, */
|
---|
| 12 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
---|
| 13 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
---|
| 14 | /* GNU General Public License for more details. */
|
---|
| 15 | /* */
|
---|
| 16 | /* You should have received a copy of the GNU General Public License */
|
---|
| 17 | /* along with this program; if not, write to the Free Software */
|
---|
| 18 | /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
---|
| 19 |
|
---|
| 20 | #ifndef SAMHAIN_H
|
---|
| 21 | #define SAMHAIN_H
|
---|
| 22 |
|
---|
| 23 | #include <sys/types.h>
|
---|
| 24 | #include "slib.h"
|
---|
| 25 |
|
---|
| 26 | #ifdef SH_ENCRYPT
|
---|
| 27 | #include "rijndael-api-fst.h"
|
---|
| 28 | #endif
|
---|
| 29 |
|
---|
| 30 | /**************************************************
|
---|
| 31 | *
|
---|
| 32 | * STANDARD DEFINES
|
---|
| 33 | *
|
---|
| 34 | **************************************************/
|
---|
| 35 |
|
---|
| 36 | #define REPLACE_OLD
|
---|
| 37 |
|
---|
| 38 | /* Standard buffer sizes.
|
---|
| 39 | */
|
---|
| 40 | #define SH_MINIBUF 64
|
---|
| 41 | #define SH_BUFSIZE 1024
|
---|
| 42 | #define SH_MAXBUF 4096
|
---|
| 43 | #define SH_PATHBUF 256
|
---|
[170] | 44 | #define SH_MSG_BUF 64512
|
---|
[1] | 45 |
|
---|
[132] | 46 | #define SH_ERRBUF_SIZE 64
|
---|
[131] | 47 |
|
---|
[170] | 48 | /* MAX_PATH_STORE must be >= KEY_LEN
|
---|
| 49 | */
|
---|
| 50 | #define MAX_PATH_STORE 12287
|
---|
| 51 |
|
---|
[1] | 52 | /* Sizes for arrays (user, group, timestamp).
|
---|
| 53 | */
|
---|
[40] | 54 | #define SOCKPASS_MAX 14
|
---|
[149] | 55 | #define USER_MAX 20
|
---|
| 56 | #define GROUP_MAX 20
|
---|
| 57 | #define TIM_MAX 32
|
---|
[1] | 58 |
|
---|
[149] | 59 | #define CMODE_SIZE 11
|
---|
[40] | 60 |
|
---|
[149] | 61 | #define ATTRBUF_SIZE 16
|
---|
| 62 | #define ATTRBUF_USED 12
|
---|
| 63 |
|
---|
[1] | 64 | /* The number of bytes in a key,
|
---|
| 65 | * the number of chars in its hex repesentation,
|
---|
| 66 | * and the block size of the hash algorithm.
|
---|
| 67 | */
|
---|
| 68 | #define KEY_BYT 24
|
---|
| 69 | #define KEY_LEN 48
|
---|
| 70 | #define KEY_BLOCK 24
|
---|
[133] | 71 | #define KEYBUF_SIZE (KEY_LEN+1)
|
---|
[1] | 72 |
|
---|
| 73 | /* The length of the compiled-in password.
|
---|
| 74 | */
|
---|
| 75 | #define PW_LEN 8
|
---|
| 76 |
|
---|
| 77 | #undef GOOD
|
---|
| 78 | #define GOOD 1
|
---|
| 79 | #undef BAD
|
---|
| 80 | #define BAD 0
|
---|
| 81 | #undef ON
|
---|
| 82 | #define ON 1
|
---|
| 83 | #undef OFF
|
---|
| 84 | #define OFF 0
|
---|
| 85 | #undef S_TRUE
|
---|
| 86 | #define S_TRUE 1
|
---|
| 87 | #undef S_FALSE
|
---|
| 88 | #define S_FALSE 0
|
---|
| 89 |
|
---|
| 90 | /* An unsigned integer guaranteed to be 32 bit.
|
---|
| 91 | */
|
---|
| 92 | #if defined(HAVE_INT_32)
|
---|
| 93 | #define UINT32 unsigned int
|
---|
| 94 | #define SINT32 int
|
---|
| 95 | #elif defined(HAVE_LONG_32)
|
---|
| 96 | #define UINT32 unsigned long
|
---|
| 97 | #define SINT32 long
|
---|
| 98 | #elif defined(HAVE_SHORT_32)
|
---|
| 99 | #define UINT32 unsigned short
|
---|
| 100 | #define SINT32 short
|
---|
| 101 | #endif
|
---|
| 102 |
|
---|
| 103 | #ifdef HAVE_INTTYPES_H
|
---|
| 104 | #include <inttypes.h>
|
---|
[156] | 105 | #endif
|
---|
[1] | 106 | #ifdef HAVE_STDINT_H
|
---|
| 107 | #include <stdint.h>
|
---|
| 108 | #endif
|
---|
| 109 |
|
---|
[156] | 110 | #if !defined(HAVE_UINT64_T)
|
---|
[1] | 111 |
|
---|
| 112 | #ifdef HAVE_LONG_LONG_64
|
---|
| 113 | #define UINT64 unsigned long long
|
---|
| 114 | #else
|
---|
| 115 | #ifdef HAVE_LONG_64
|
---|
| 116 | #define UINT64 unsigned long
|
---|
| 117 | #else
|
---|
[156] | 118 | #error "no 64bit type found"
|
---|
[1] | 119 | #endif
|
---|
| 120 | #endif
|
---|
| 121 |
|
---|
| 122 | #else
|
---|
| 123 | #define UINT64 uint64_t
|
---|
| 124 | #endif
|
---|
| 125 |
|
---|
| 126 |
|
---|
| 127 |
|
---|
| 128 | #define UBYTE unsigned char
|
---|
| 129 |
|
---|
| 130 |
|
---|
| 131 | enum {
|
---|
| 132 | SH_CHECK_NONE = 0,
|
---|
| 133 | SH_CHECK_INIT = 1,
|
---|
| 134 | SH_CHECK_CHECK = 2
|
---|
| 135 | };
|
---|
| 136 |
|
---|
[143] | 137 | #define SH_MOD_THREAD 1
|
---|
| 138 | #define SH_MOD_ACTIVE 0
|
---|
| 139 | #define SH_MOD_FAILED -1
|
---|
[207] | 140 | #define SH_MOD_OFFSET 10
|
---|
[156] | 141 |
|
---|
[114] | 142 | /* Flags for file status
|
---|
| 143 | */
|
---|
| 144 | #define SH_FFLAG_ALLIGNORE (1<<0)
|
---|
| 145 | #define SH_FFLAG_VISITED (1<<1)
|
---|
| 146 | #define SH_FFLAG_CHECKED (1<<3)
|
---|
| 147 | #define SH_FFLAG_REPORTED (1<<3)
|
---|
[115] | 148 | #define SH_FFLAG_SUIDCHK (1<<4)
|
---|
[93] | 149 |
|
---|
[114] | 150 | #define SH_FFLAG_ALLIGNORE_SET(a) (((a) & SH_FFLAG_ALLIGNORE) != 0)
|
---|
| 151 | #define SET_SH_FFLAG_ALLIGNORE(a) ((a) |= SH_FFLAG_ALLIGNORE)
|
---|
| 152 | #define CLEAR_SH_FFLAG_ALLIGNORE(a) ((a) &= ~SH_FFLAG_ALLIGNORE)
|
---|
| 153 |
|
---|
| 154 | #define SH_FFLAG_VISITED_SET(a) (((a) & SH_FFLAG_VISITED) != 0)
|
---|
| 155 | #define SET_SH_FFLAG_VISITED(a) ((a) |= SH_FFLAG_VISITED)
|
---|
| 156 | #define CLEAR_SH_FFLAG_VISITED(a) ((a) &= ~SH_FFLAG_VISITED)
|
---|
| 157 |
|
---|
| 158 | #define SH_FFLAG_CHECKED_SET(a) (((a) & SH_FFLAG_VISITED) != 0)
|
---|
| 159 | #define SET_SH_FFLAG_CHECKED(a) ((a) |= SH_FFLAG_VISITED)
|
---|
| 160 | #define CLEAR_SH_FFLAG_CHECKED(a) ((a) &= ~SH_FFLAG_VISITED)
|
---|
| 161 |
|
---|
| 162 | #define SH_FFLAG_REPORTED_SET(a) (((a) & SH_FFLAG_REPORTED) != 0)
|
---|
| 163 | #define SET_SH_FFLAG_REPORTED(a) ((a) |= SH_FFLAG_REPORTED)
|
---|
| 164 | #define CLEAR_SH_FFLAG_REPORTED(a) ((a) &= ~SH_FFLAG_REPORTED)
|
---|
| 165 |
|
---|
[115] | 166 | #define SH_FFLAG_SUIDCHK_SET(a) (((a) & SH_FFLAG_SUIDCHK) != 0)
|
---|
| 167 | #define SET_SH_FFLAG_SUIDCHK(a) ((a) |= SH_FFLAG_SUIDCHK)
|
---|
| 168 | #define CLEAR_SH_FFLAG_SUIDCHK(a) ((a) &= ~SH_FFLAG_SUIDCHK)
|
---|
[114] | 169 |
|
---|
| 170 |
|
---|
[1] | 171 | /**************************************************
|
---|
| 172 | *
|
---|
| 173 | * TYPEDEFS
|
---|
| 174 | *
|
---|
| 175 | **************************************************/
|
---|
| 176 |
|
---|
| 177 | enum {
|
---|
| 178 | SH_LEVEL_READONLY = 1,
|
---|
| 179 | SH_LEVEL_LOGFILES = 2,
|
---|
| 180 | SH_LEVEL_LOGGROW = 3,
|
---|
| 181 | SH_LEVEL_NOIGNORE = 4,
|
---|
| 182 | SH_LEVEL_ALLIGNORE = 5,
|
---|
| 183 | SH_LEVEL_ATTRIBUTES = 6,
|
---|
| 184 | SH_LEVEL_USER0 = 7,
|
---|
| 185 | SH_LEVEL_USER1 = 8,
|
---|
[27] | 186 | SH_LEVEL_USER2 = 9,
|
---|
| 187 | SH_LEVEL_USER3 = 10,
|
---|
| 188 | SH_LEVEL_USER4 = 11,
|
---|
| 189 | SH_LEVEL_PRELINK = 12
|
---|
[1] | 190 | };
|
---|
| 191 |
|
---|
| 192 | typedef struct {
|
---|
| 193 | time_t alarm_interval;
|
---|
| 194 | time_t alarm_last;
|
---|
| 195 | } sh_timer_t;
|
---|
| 196 |
|
---|
| 197 | typedef struct {
|
---|
| 198 | char path[SH_PATHBUF];
|
---|
| 199 | char hash[KEY_LEN+1];
|
---|
| 200 | } sh_sh_df;
|
---|
| 201 |
|
---|
| 202 | typedef struct {
|
---|
| 203 | char user[USER_MAX];
|
---|
| 204 | char group[GROUP_MAX];
|
---|
| 205 | char home[SH_PATHBUF];
|
---|
| 206 | uid_t uid;
|
---|
| 207 | gid_t gid;
|
---|
| 208 | } sh_sh_user;
|
---|
| 209 |
|
---|
| 210 | typedef struct {
|
---|
| 211 | char name[SH_PATHBUF]; /* local hostname */
|
---|
| 212 | char system[SH_MINIBUF]; /* system */
|
---|
| 213 | char release[SH_MINIBUF]; /* release */
|
---|
| 214 | char machine[SH_MINIBUF]; /* machine */
|
---|
| 215 | } sh_sh_local;
|
---|
| 216 |
|
---|
| 217 | typedef struct {
|
---|
| 218 | char name[SH_PATHBUF];
|
---|
| 219 | char alt[SH_PATHBUF];
|
---|
| 220 | } sh_sh_remote;
|
---|
| 221 |
|
---|
| 222 | typedef struct {
|
---|
| 223 | unsigned long bytes_hashed; /* bytes last check */
|
---|
| 224 | unsigned long bytes_speed; /* bytes/sec last check */
|
---|
| 225 | unsigned long mail_success; /* mails sent */
|
---|
| 226 | unsigned long mail_failed; /* mails not sent */
|
---|
| 227 | time_t time_start; /* start last check */
|
---|
| 228 | time_t time_check; /* time last check */
|
---|
| 229 | unsigned long dirs_checked; /* #dirs last check */
|
---|
| 230 | unsigned long files_checked; /* #files last check */
|
---|
| 231 | } sh_sh_stat;
|
---|
| 232 |
|
---|
| 233 | typedef struct {
|
---|
| 234 | int exit; /* exit value */
|
---|
| 235 | int checkSum; /* whether to init/check checksums */
|
---|
| 236 | int update; /* update db */
|
---|
| 237 | int opts; /* reading cl options */
|
---|
[256] | 238 | int started; /* finished with startup stuff */
|
---|
[1] | 239 | int isdaemon; /* daemon or not */
|
---|
| 240 | int loop; /* go in loop even if not daemon */
|
---|
| 241 | int nice; /* desired nicety */
|
---|
| 242 | int isserver; /* server or not */
|
---|
| 243 | int islocked; /* BAD if logfile not locked */
|
---|
| 244 | int smsg; /* GOOD if end message sent */
|
---|
| 245 | int log_start; /* TRUE if new audit trail */
|
---|
| 246 | int reportonce; /* TRUE if bad files only once rep.*/
|
---|
| 247 | int fulldetail; /* TRUE if full details requested */
|
---|
| 248 | int client_severity; /* TRUE if client severity used */
|
---|
| 249 | int client_class; /* TRUE if client class used */
|
---|
| 250 | int audit;
|
---|
| 251 | unsigned long aud_mask;
|
---|
| 252 | int hidefile; /* TRUE if file not reveled in log */
|
---|
| 253 | } sh_sh_flag;
|
---|
| 254 |
|
---|
| 255 | typedef struct {
|
---|
| 256 |
|
---|
| 257 | char prg_name[8];
|
---|
[162] | 258 |
|
---|
| 259 | UINT64 pid;
|
---|
[1] | 260 |
|
---|
| 261 | sh_sh_df exec;
|
---|
| 262 | sh_sh_df conf;
|
---|
| 263 | sh_sh_df data;
|
---|
| 264 |
|
---|
| 265 | sh_sh_user real;
|
---|
| 266 | sh_sh_user effective;
|
---|
| 267 | sh_sh_user run;
|
---|
| 268 |
|
---|
| 269 | sh_sh_local host;
|
---|
| 270 |
|
---|
| 271 | sh_sh_remote srvtime;
|
---|
| 272 | sh_sh_remote srvmail;
|
---|
| 273 | sh_sh_remote srvexport;
|
---|
| 274 | sh_sh_remote srvcons;
|
---|
| 275 | sh_sh_remote srvlog;
|
---|
| 276 |
|
---|
| 277 | sh_sh_stat statistics;
|
---|
| 278 | sh_sh_flag flag;
|
---|
| 279 |
|
---|
| 280 | #ifdef SH_STEALTH
|
---|
| 281 | unsigned long off_data;
|
---|
| 282 | #endif
|
---|
| 283 |
|
---|
| 284 | sh_timer_t mailNum;
|
---|
| 285 | sh_timer_t mailTime;
|
---|
| 286 | sh_timer_t fileCheck;
|
---|
| 287 |
|
---|
| 288 | int looptime; /* timing for main loop */
|
---|
| 289 | /*@null@*//*@out@*/ char * timezone;
|
---|
| 290 | } sh_struct;
|
---|
| 291 |
|
---|
| 292 |
|
---|
| 293 | extern volatile int sig_raised;
|
---|
| 294 | extern volatile int sig_urgent;
|
---|
| 295 | extern volatile int sig_debug_switch; /* SIGUSR1 */
|
---|
| 296 | extern volatile int sig_suspend_switch; /* SIGUSR2 */
|
---|
[143] | 297 | extern volatile int sh_global_suspend_flag;
|
---|
[1] | 298 | extern volatile int sig_fresh_trail; /* SIGIOT */
|
---|
[143] | 299 | extern volatile int sh_thread_pause_flag;
|
---|
[1] | 300 | extern volatile int sig_config_read_again; /* SIGHUP */
|
---|
| 301 | extern volatile int sig_terminate; /* SIGQUIT */
|
---|
| 302 | extern volatile int sig_termfast; /* SIGTERM */
|
---|
| 303 | extern volatile int sig_force_check; /* SIGTTOU */
|
---|
| 304 |
|
---|
| 305 | extern long int eintr__result;
|
---|
| 306 |
|
---|
[20] | 307 | extern int sh_argc_store;
|
---|
| 308 | extern char ** sh_argv_store;
|
---|
| 309 |
|
---|
[1] | 310 | #include "sh_calls.h"
|
---|
| 311 |
|
---|
| 312 |
|
---|
| 313 | typedef struct {
|
---|
[40] | 314 | char sh_sockpass[2*SOCKPASS_MAX+2];
|
---|
[1] | 315 | char sigkey_old[KEY_LEN+1];
|
---|
| 316 | char sigkey_new[KEY_LEN+1];
|
---|
| 317 | char mailkey_old[KEY_LEN+1];
|
---|
| 318 | char mailkey_new[KEY_LEN+1];
|
---|
| 319 | char crypt[KEY_LEN+1];
|
---|
| 320 | char session[KEY_LEN+1];
|
---|
| 321 | char vernam[KEY_LEN+1];
|
---|
| 322 | int mlock_failed;
|
---|
| 323 |
|
---|
| 324 | char pw[PW_LEN];
|
---|
| 325 |
|
---|
| 326 | char poolv[KEY_BYT];
|
---|
| 327 | int poolc;
|
---|
| 328 |
|
---|
| 329 | int rngI;
|
---|
| 330 | UINT32 rng0[3];
|
---|
| 331 | UINT32 rng1[3];
|
---|
| 332 | UINT32 rng2[3];
|
---|
| 333 |
|
---|
[156] | 334 | UINT32 res_vec[6];
|
---|
| 335 |
|
---|
[1] | 336 | UINT32 ErrFlag[2];
|
---|
| 337 |
|
---|
| 338 | #ifdef SH_ENCRYPT
|
---|
| 339 | /*@out@*/ keyInstance keyInstE;
|
---|
| 340 | /*@out@*/ keyInstance keyInstD;
|
---|
| 341 | #endif
|
---|
| 342 | } sh_key_t;
|
---|
| 343 |
|
---|
| 344 | extern sh_struct sh;
|
---|
| 345 | /*@null@*/ extern sh_key_t *skey;
|
---|
| 346 |
|
---|
[22] | 347 | /**************************************************
|
---|
| 348 | *
|
---|
| 349 | * macros
|
---|
| 350 | *
|
---|
| 351 | **************************************************/
|
---|
[1] | 352 |
|
---|
[76] | 353 | #if defined(__GNUC__) && (__GNUC__ >= 4)
|
---|
[149] | 354 | #define SH_GNUC_SENTINEL __attribute__((__sentinel__))
|
---|
[76] | 355 | #else
|
---|
[149] | 356 | #define SH_GNUC_SENTINEL
|
---|
[76] | 357 | #endif
|
---|
| 358 |
|
---|
[149] | 359 | #if defined(__GNUC__) && (__GNUC__ >= 3)
|
---|
| 360 | #undef SH_GNUC_PURE
|
---|
| 361 | #define SH_GNUC_PURE __attribute__((pure))
|
---|
| 362 | #undef SH_GNUC_CONST
|
---|
| 363 | #define SH_GNUC_CONST __attribute__((const))
|
---|
| 364 | #undef SH_GNUC_NORETURN
|
---|
| 365 | #define SH_GNUC_NORETURN __attribute__((noreturn))
|
---|
| 366 | #undef SH_GNUC_MALLOC
|
---|
| 367 | #define SH_GNUC_MALLOC __attribute__((malloc))
|
---|
| 368 | #else
|
---|
| 369 | #undef SH_GNUC_PURE
|
---|
| 370 | #define SH_GNUC_PURE
|
---|
| 371 | #undef SH_GNUC_CONST
|
---|
| 372 | #define SH_GNUC_CONST
|
---|
| 373 | #undef SH_GNUC_NORETURN
|
---|
| 374 | #define SH_GNUC_NORETURN
|
---|
| 375 | #undef SH_GNUC_MALLOC
|
---|
| 376 | #define SH_GNUC_MALLOC
|
---|
| 377 | #endif
|
---|
| 378 |
|
---|
| 379 |
|
---|
[76] | 380 | /* The semantics of the built-in are that it is expected that expr == const
|
---|
| 381 | * for __builtin_expect ((expr), const)
|
---|
| 382 | */
|
---|
| 383 | #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
|
---|
| 384 | #define SH_LIKELY(expr) (__builtin_expect((expr), 1))
|
---|
| 385 | #define SH_UNLIKELY(expr) (__builtin_expect((expr), 0))
|
---|
| 386 | #else
|
---|
| 387 | #define SH_LIKELY(expr) (expr)
|
---|
| 388 | #define SH_UNLIKELY(expr) (expr)
|
---|
| 389 | #endif
|
---|
| 390 |
|
---|
[22] | 391 | /* signal-safe log function
|
---|
| 392 | */
|
---|
[170] | 393 | int safe_logger (int thesignal, int method, char * details);
|
---|
| 394 | void safe_fatal (const char * details, const char *f, int l);
|
---|
[22] | 395 |
|
---|
[25] | 396 | #define SH_VALIDATE_EQ(a,b) \
|
---|
[22] | 397 | do { \
|
---|
[34] | 398 | if ((a) != (b)) safe_fatal(#a " != " #b, FIL__, __LINE__);\
|
---|
[22] | 399 | } while (0)
|
---|
| 400 |
|
---|
[25] | 401 | #define SH_VALIDATE_NE(a,b) \
|
---|
| 402 | do { \
|
---|
[34] | 403 | if ((a) == (b)) safe_fatal(#a " == " #b, FIL__, __LINE__);\
|
---|
[25] | 404 | } while (0)
|
---|
[22] | 405 |
|
---|
[68] | 406 | #define SH_VALIDATE_GE(a,b) \
|
---|
| 407 | do { \
|
---|
| 408 | if ((a) < (b)) safe_fatal(#a " < " #b, FIL__, __LINE__);\
|
---|
| 409 | } while (0)
|
---|
| 410 |
|
---|
[1] | 411 | #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK)
|
---|
| 412 | #define MLOCK(a, b) \
|
---|
| 413 | if ((skey != NULL) && skey->mlock_failed == SL_FALSE){ \
|
---|
| 414 | (void) sl_set_suid(); \
|
---|
[19] | 415 | if (sh_unix_mlock(FIL__, __LINE__, a, b) < 0) skey->mlock_failed = SL_TRUE; \
|
---|
[1] | 416 | (void) sl_unset_suid(); }
|
---|
| 417 | #else
|
---|
| 418 | #define MLOCK(a, b) \
|
---|
| 419 | ;
|
---|
| 420 | #endif
|
---|
| 421 |
|
---|
| 422 | #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK)
|
---|
| 423 | #define MUNLOCK(a, b) \
|
---|
| 424 | if ((skey != NULL) && skey->mlock_failed == SL_FALSE){ \
|
---|
| 425 | (void) sl_set_suid(); \
|
---|
| 426 | (void) sh_unix_munlock( a, b );\
|
---|
| 427 | (void) sl_unset_suid(); }
|
---|
| 428 | #else
|
---|
| 429 | #define MUNLOCK(a, b) \
|
---|
| 430 | ;
|
---|
| 431 | #endif
|
---|
| 432 |
|
---|
| 433 | #ifdef SH_STEALTH
|
---|
| 434 | void sh_do_encode (char * str, int len);
|
---|
| 435 | #define sh_do_decode sh_do_encode
|
---|
| 436 | #endif
|
---|
| 437 |
|
---|
| 438 | /* #if defined(SCREW_IT_UP)
|
---|
| 439 | * extern volatile int sh_not_traced;
|
---|
| 440 | * inline int sh_sigtrap_prepare();
|
---|
| 441 | * inline int sh_derr();
|
---|
| 442 | * #endif
|
---|
| 443 | */
|
---|
| 444 |
|
---|
| 445 | #if defined(SCREW_IT_UP) && (defined(__FreeBSD__) || defined(__linux__)) && defined(__i386__)
|
---|
| 446 | #define BREAKEXIT(expr) \
|
---|
| 447 | do { \
|
---|
| 448 | int ixi; \
|
---|
| 449 | for (ixi = 0; ixi < 8; ++ixi) { \
|
---|
| 450 | if ((*(volatile unsigned *)((unsigned) expr + ixi) & 0xff) == 0xcc) \
|
---|
| 451 | _exit(EXIT_FAILURE); \
|
---|
| 452 | } \
|
---|
| 453 | } \
|
---|
| 454 | while (1 == 0)
|
---|
| 455 | #else
|
---|
| 456 | #define BREAKEXIT(expr)
|
---|
| 457 | #endif
|
---|
| 458 |
|
---|
| 459 |
|
---|
| 460 |
|
---|
| 461 | #include "sh_cat.h"
|
---|
| 462 | #include "sh_trace.h"
|
---|
| 463 | #include "sh_mem.h"
|
---|
| 464 |
|
---|
| 465 | #endif
|
---|
| 466 |
|
---|
| 467 | /* CRIT: */
|
---|
| 468 | /* NEW_CLIENT <client> */
|
---|
| 469 | /* BAD_CLIENT <client> -- <details> */
|
---|
| 470 | /* ERR_CLIENT <client> -- <details> */
|
---|
| 471 |
|
---|
| 472 | /* ALERT: */
|
---|
| 473 | /* LOG_KEY samhain|yule <key> */
|
---|
| 474 | /* STARTUP samhain|yule -- user <username> */
|
---|
| 475 | /* EXIT samhain|yule */
|
---|
| 476 | /* GOODSIG <file> <user> */
|
---|
| 477 | /* FP_KEY <fingerprint> */
|
---|
| 478 | /* GOODSIG_DAT <file> <user> */
|
---|
| 479 | /* FP_KEY_DAT <fingerprint> */
|
---|
| 480 | /* TIGER_CFG <file> <checksum> */
|
---|
| 481 | /* TIGER_DAT <file> <checksum> */
|
---|
| 482 |
|
---|
| 483 | /* PANIC -- <details> */
|
---|
| 484 | /* ERROR -- <details> */
|
---|
| 485 |
|
---|
| 486 | /* Policy */
|
---|
| 487 | /* POLICY <code> <file> */
|
---|
| 488 | /* <code> = MISSING || ADDED || NOT_A_DIRECTORY || <policy> */
|
---|
| 489 |
|
---|
| 490 |
|
---|
| 491 |
|
---|