source: trunk/src/samhain.c@ 304

Last change on this file since 304 was 294, checked in by katerina, 14 years ago

Tikets #213 and #214 (Use auditd to determine who changed a file, Windows registry check).

File size: 50.6 KB
Line 
1/* SAMHAIN file system integrity testing */
2/* Copyright (C) 1999, 2000 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#include "config_xor.h"
21
22
23#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
26#include <unistd.h>
27#include <fcntl.h>
28
29/* samhainctl */
30#include <sys/types.h>
31#include <sys/stat.h>
32#include <sys/wait.h>
33#include <signal.h>
34#include <errno.h>
35
36
37#if TIME_WITH_SYS_TIME
38#include <sys/time.h>
39#include <time.h>
40#else
41#if HAVE_SYS_TIME_H
42#include <sys/time.h>
43#else
44#include <time.h>
45#endif
46#endif
47
48#ifdef HAVE_MEMORY_H
49#include <memory.h>
50#endif
51
52#ifdef HAVE_SETPRIORITY
53#include <sys/resource.h>
54#endif
55
56#ifndef HAVE_LSTAT
57#define lstat stat
58#endif
59
60/* for FLT_EPSILON
61 */
62#include <float.h>
63
64#include "samhain.h"
65#include "sh_pthread.h"
66#include "sh_files.h"
67#include "sh_utils.h"
68#include "sh_error.h"
69#include "sh_unix.h"
70#include "sh_getopt.h"
71#include "sh_readconf.h"
72#include "sh_hash.h"
73
74#include "sh_nmail.h"
75
76#include "sh_tiger.h"
77#include "sh_gpg.h"
78#include "sh_mem.h"
79#include "sh_forward.h"
80#include "sh_tools.h"
81#include "sh_hash.h"
82#if defined(WITH_EXTERNAL)
83#include "sh_extern.h"
84#endif
85#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
86#include "sh_modules.h"
87#include "sh_ignore.h"
88#include "sh_prelink.h"
89#endif
90
91#undef FIL__
92#define FIL__ _("samhain.c")
93
94
95/**************************************************
96 *
97 * Needed to compile the key into the code.
98 *
99 **************************************************/
100
101extern UINT32 ErrFlag[2];
102#include "sh_MK.h"
103
104/**************************************************
105 *
106 * Variables for signal handling.
107 *
108 **************************************************/
109
110volatile int sig_raised;
111volatile int sig_urgent;
112volatile int sig_debug_switch; /* SIGUSR1 */
113volatile int sig_suspend_switch; /* SIGUSR2 */
114volatile int sh_global_suspend_flag;
115volatile int sig_fresh_trail; /* SIGIOT */
116volatile int sh_thread_pause_flag = S_FALSE;
117volatile int sig_config_read_again; /* SIGHUP */
118volatile int sig_terminate; /* SIGQUIT */
119volatile int sig_termfast; /* SIGTERM */
120volatile int sig_force_check; /* SIGTTOU */
121long int eintr__result;
122char sh_sig_msg[SH_MINIBUF];
123
124
125#ifdef SH_STEALTH
126/**************************************************
127 *
128 * The following set of functions is required for
129 * the 'stealth' mode.
130 *
131 **************************************************/
132
133#ifndef SH_MAX_GLOBS
134#define SH_MAX_GLOBS 16
135#endif
136
137#ifndef GLOB_LEN
138#define GLOB_LEN 511
139#endif
140
141#ifdef HAVE_PTHREAD
142struct gt {
143 size_t g_count;
144 char * g_glob;
145};
146
147pthread_key_t g_key;
148
149int sh_g_thread()
150{
151 struct gt * ptr = malloc(sizeof(struct gt));
152 if (!ptr)
153 return -1;
154 ptr->g_count = 0;
155 ptr->g_glob = calloc(1, SH_MAX_GLOBS * (GLOB_LEN+1));
156 if (!(ptr->g_glob))
157 return -1;
158 return pthread_setspecific(g_key, ptr);
159}
160
161void sh_g_destroy(void * data)
162{
163 struct gt * ptr = (struct gt *) data;
164 free(ptr->g_glob);
165 free(ptr);
166 return;
167}
168
169void sh_g_init(void)
170{
171#if !defined(USE_SYSTEM_MALLOC) && defined(USE_MALLOC_LOCK)
172 extern int dnmalloc_pthread_init(void);
173 dnmalloc_pthread_init();
174#endif
175
176 if (0 != pthread_key_create(&g_key, sh_g_destroy))
177 {
178 perror("1");
179 exit(EXIT_FAILURE);
180 }
181
182 if (0 != sh_g_thread())
183 {
184 perror("2");
185 exit(EXIT_FAILURE);
186 }
187 return;
188}
189#define SH_G_INIT sh_g_init()
190#else
191#define SH_G_INIT ((void)0)
192#endif
193
194char * globber(const char * str)
195{
196 size_t i;
197 size_t j;
198
199#ifndef HAVE_PTHREAD
200 static size_t count = 0;
201 static char glob[SH_MAX_GLOBS * (GLOB_LEN+1)];
202#else
203 struct gt * ptr = pthread_getspecific(g_key);
204 size_t count;
205 char * glob;
206
207 if (ptr) {
208 count = ptr->g_count;
209 glob = ptr->g_glob;
210 } else {
211 return NULL;
212 }
213#endif
214
215 if (str != NULL)
216 j = strlen(str);
217 else
218 return NULL;
219
220 ASSERT((j <= GLOB_LEN), _("j <= GLOB_LEN"))
221
222 if (j > GLOB_LEN)
223 j = GLOB_LEN;
224
225 /* Overwrap the buffer.
226 */
227 if ( (count + j) >= (SH_MAX_GLOBS * (GLOB_LEN+1)))
228 {
229 count = 0;
230 }
231
232 for (i = 0; i < j; ++i)
233 {
234 if (str[i] != '\n' && str[i] != '\t' && str[i] != '\r' && str[i] != '"')
235 glob[count + i] = str[i] ^ XOR_CODE;
236 else
237 glob[count + i] = str[i];
238 }
239 glob[count + j] = '\0';
240
241 i = count;
242#ifdef HAVE_PTHREAD
243 ptr->g_count = count + j + 1;
244#else
245 count = count + j + 1;
246#endif
247 return &glob[i];
248}
249
250void sh_do_encode (char * str, int len)
251{
252 register int i;
253
254 /* this is a symmetric operation
255 */
256 for (i = 0; i < len; ++i)
257 {
258 str[i] = str[i] ^ XOR_CODE;
259 }
260 return;
261}
262
263#else
264/* not stealth */
265#define SH_G_INIT ((void)0)
266#endif
267
268/**************************************************
269 *
270 * Global variables.
271 *
272 **************************************************/
273
274sh_struct sh;
275/*@null@*/ sh_key_t * skey = NULL;
276
277extern unsigned char TcpFlag[8][PW_LEN+1];
278
279/**************************************************
280 *
281 * Initializing.
282 *
283 **************************************************/
284
285static int is_samhainctl_init = S_FALSE;
286
287static
288void sh_init (void)
289{
290 unsigned char * dez = NULL;
291 int i;
292#if defined(SH_WITH_MAIL)
293 char * p;
294 char q[SH_PATHBUF];
295#endif
296
297 SL_ENTER(_("sh_init"));
298
299#ifdef MKA_09
300 ErrFlag[0] |= (1 << 8);
301#endif
302#ifdef MKA_10
303 ErrFlag[0] |= (1 << 9);
304#endif
305#ifdef MKA_11
306 ErrFlag[0] |= (1 << 10);
307#endif
308#ifdef MKA_12
309 ErrFlag[0] |= (1 << 11);
310#endif
311#ifdef MKA_13
312 ErrFlag[0] |= (1 << 12);
313#endif
314#ifdef MKA_14
315 ErrFlag[0] |= (1 << 13);
316#endif
317#ifdef MKA_15
318 ErrFlag[0] |= (1 << 14);
319#endif
320#ifdef MKA_16
321 ErrFlag[0] |= (1 << 15);
322#endif
323
324 /* Signal handling.
325 */
326 sig_raised = 0;
327 sig_config_read_again = 0; /* SIGHUP */
328 sig_debug_switch = 0; /* SIGUSR1 */
329 sig_suspend_switch = 0; /* SIGUSR2 */
330 sh_global_suspend_flag = 0; /* SIGUSR2 */
331 sig_fresh_trail = 0; /* SIGIOT */
332 sig_terminate = 0; /* SIGQUIT */
333 sig_termfast = 0; /* SIGTERM */
334 sig_force_check = 0; /* SIGTTOU */
335 strcpy ( sh_sig_msg, _("None"));
336
337#ifdef MKB_01
338 ErrFlag[1] |= (1 << 0);
339#endif
340#ifdef MKB_02
341 ErrFlag[1] |= (1 << 1);
342#endif
343#ifdef MKB_03
344 ErrFlag[1] |= (1 << 2);
345#endif
346#ifdef MKB_04
347 ErrFlag[1] |= (1 << 3);
348#endif
349#ifdef MKB_05
350 ErrFlag[1] |= (1 << 4);
351#endif
352#ifdef MKB_06
353 ErrFlag[1] |= (1 << 5);
354#endif
355#ifdef MKB_07
356 ErrFlag[1] |= (1 << 6);
357#endif
358#ifdef MKB_08
359 ErrFlag[1] |= (1 << 7);
360#endif
361
362#if defined(SH_WITH_SERVER) && !defined(SH_WITH_CLIENT)
363 strncpy(sh.prg_name, _("Yule"), 8);
364 sh.prg_name[4] = '\0';
365#else
366 strncpy(sh.prg_name, _("Samhain"), 8);
367 sh.prg_name[7] = '\0';
368#endif
369
370 sh.pid = (UINT64) getpid();
371
372 /* The flags.
373 */
374 if (is_samhainctl_init == S_FALSE)
375 sh.flag.checkSum = SH_CHECK_NONE;
376 sh.flag.update = S_FALSE;
377 sh.flag.opts = S_FALSE;
378 sh.flag.started = S_FALSE;
379 if (is_samhainctl_init == S_FALSE)
380 sh.flag.isdaemon = S_FALSE;
381 sh.flag.isserver = S_FALSE;
382 sh.flag.islocked = S_FALSE;
383 sh.flag.smsg = S_FALSE;
384 sh.flag.log_start = S_TRUE;
385 sh.flag.reportonce = S_TRUE;
386 sh.flag.fulldetail = S_FALSE;
387 sh.flag.audit = S_FALSE;
388 sh.flag.nice = 0;
389 sh.flag.aud_mask = 0xFFFFFFFFUL;
390 sh.flag.client_severity = S_FALSE;
391 sh.flag.client_class = S_FALSE;
392 sh.flag.hidefile = S_FALSE;
393 sh.flag.loop = S_FALSE;
394
395#ifdef MKB_09
396 ErrFlag[1] |= (1 << 8);
397#endif
398#ifdef MKB_10
399 ErrFlag[1] |= (1 << 9);
400#endif
401#ifdef MKB_11
402 ErrFlag[1] |= (1 << 10);
403#endif
404#ifdef MKB_12
405 ErrFlag[1] |= (1 << 11);
406#endif
407#ifdef MKB_13
408 ErrFlag[1] |= (1 << 12);
409#endif
410#ifdef MKB_14
411 ErrFlag[1] |= (1 << 13);
412#endif
413#ifdef MKB_15
414 ErrFlag[1] |= (1 << 14);
415#endif
416#ifdef MKB_16
417 ErrFlag[1] |= (1 << 15);
418#endif
419
420 /* The stats.
421 */
422 sh.statistics.bytes_speed = 0;
423 sh.statistics.bytes_hashed = 0;
424 sh.statistics.mail_success = 0;
425 sh.statistics.mail_failed = 0;
426 sh.statistics.time_start = time(NULL);
427 sh.statistics.time_check = (time_t) 0;
428
429#ifdef MKC_01
430 ErrFlag[0] |= (1 << 16);
431#endif
432#ifdef MKC_02
433 ErrFlag[0] |= (1 << 17);
434#endif
435#ifdef MKC_03
436 ErrFlag[0] |= (1 << 18);
437#endif
438#ifdef MKC_04
439 ErrFlag[0] |= (1 << 19);
440#endif
441#ifdef MKC_05
442 ErrFlag[0] |= (1 << 20);
443#endif
444#ifdef MKC_06
445 ErrFlag[0] |= (1 << 21);
446#endif
447#ifdef MKC_07
448 ErrFlag[0] |= (1 << 22);
449#endif
450#ifdef MKC_08
451 ErrFlag[0] |= (1 << 23);
452#endif
453
454
455 /* The local host.
456 */
457 (void) sl_strlcpy (sh.host.name, _("localhost"), SH_MINIBUF);
458 sh.host.system[0] = '\0'; /* flawfinder: ignore *//* ff bug */
459 sh.host.release[0] = '\0';
460 sh.host.machine[0] = '\0';
461
462#ifdef MKC_09
463 ErrFlag[0] |= (1 << 24);
464#endif
465#ifdef MKC_10
466 ErrFlag[0] |= (1 << 25);
467#endif
468#ifdef MKC_11
469 ErrFlag[0] |= (1 << 26);
470#endif
471#ifdef MKC_12
472 ErrFlag[0] |= (1 << 27);
473#endif
474#ifdef MKC_13
475 ErrFlag[0] |= (1 << 28);
476#endif
477#ifdef MKC_14
478 ErrFlag[0] |= (1 << 29);
479#endif
480#ifdef MKC_15
481 ErrFlag[0] |= (1 << 30);
482#endif
483#ifdef MKC_16
484 ErrFlag[0] |= (1UL << 31);
485#endif
486
487 /* The paths.
488 */
489 (void) sl_strlcpy (sh.conf.path, DEFAULT_CONFIGFILE, SH_PATHBUF);
490 sh.conf.hash[0] = '\0';
491 (void) sl_strlcpy (sh.data.path, DEFAULT_DATA_FILE, SH_PATHBUF);
492 sh.data.hash[0] = '\0';
493 sh.exec.path[0] = '\0';
494 sh.exec.hash[0] = '\0';
495
496#ifdef MKD_01
497 ErrFlag[1] |= (1 << 16);
498#endif
499#ifdef MKD_02
500 ErrFlag[1] |= (1 << 17);
501#endif
502#ifdef MKD_03
503 ErrFlag[1] |= (1 << 18);
504#endif
505#ifdef MKD_04
506 ErrFlag[1] |= (1 << 19);
507#endif
508#ifdef MKD_05
509 ErrFlag[1] |= (1 << 20);
510#endif
511#ifdef MKD_06
512 ErrFlag[1] |= (1 << 21);
513#endif
514#ifdef MKD_07
515 ErrFlag[1] |= (1 << 22);
516#endif
517#ifdef MKD_08
518 ErrFlag[1] |= (1 << 23);
519#endif
520
521 /* The addresses.
522 */
523#if defined(SH_WITH_MAIL)
524 if (0 != strcmp (DEFAULT_MAILADDRESS, _("NULL")))
525 {
526#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
527 char * saveptr;
528 (void) sl_strncpy(q, DEFAULT_MAILADDRESS, SH_PATHBUF);
529 p = strtok_r (q, ", \t", &saveptr);
530 if (p)
531 {
532 (void) sh_nmail_add_compiled_recipient (p);
533 while (NULL != (p = strtok_r (NULL, ", \t", &saveptr)))
534 (void) sh_nmail_add_compiled_recipient (p);
535 }
536#else
537 (void) sl_strncpy(q, DEFAULT_MAILADDRESS, SH_PATHBUF);
538 p = strtok (q, ", \t");
539 if (p)
540 {
541 (void) sh_nmail_add_compiled_recipient (p);
542 while (NULL != (p = strtok (NULL, ", \t")))
543 (void) sh_nmail_add_compiled_recipient (p);
544 }
545#endif
546 }
547#endif
548
549 if (0 == strcmp (ALT_TIMESERVER, _("NULL")))
550 sh.srvtime.alt[0] = '\0';
551 else
552 (void) sl_strlcpy (sh.srvtime.alt, ALT_TIMESERVER, SH_PATHBUF);
553 if (0 == strcmp (DEFAULT_TIMESERVER, _("NULL")))
554 sh.srvtime.name[0] = '\0';
555 else
556 (void) sl_strlcpy (sh.srvtime.name, DEFAULT_TIMESERVER, SH_PATHBUF);
557
558
559 if (0 == strcmp (ALT_LOGSERVER, _("NULL")))
560 sh.srvexport.alt[0] = '\0';
561 else
562 (void) sl_strlcpy (sh.srvexport.alt, ALT_LOGSERVER, SH_PATHBUF);
563 if (0 == strcmp (DEFAULT_LOGSERVER, _("NULL")))
564 sh.srvexport.name[0] = '\0';
565 else
566 (void) sl_strlcpy (sh.srvexport.name, DEFAULT_LOGSERVER, SH_PATHBUF);
567
568
569 if (0 == strcmp (DEFAULT_ERRLOCK, _("NULL")))
570 sh.srvlog.alt[0] = '\0';
571 else
572 (void) sl_strlcpy (sh.srvlog.alt, DEFAULT_ERRLOCK, SH_PATHBUF);
573 if (0 == strcmp (DEFAULT_ERRFILE, _("NULL")))
574 sh.srvlog.name[0] = '\0';
575 else
576 (void) sl_strlcpy (sh.srvlog.name, DEFAULT_ERRFILE, SH_PATHBUF);
577
578 if (0 == strcmp (ALT_CONSOLE, _("NULL")))
579 sh.srvcons.alt[0] = '\0';
580 else
581 (void) sl_strlcpy (sh.srvcons.alt, ALT_CONSOLE, SH_PATHBUF);
582#ifndef DEFAULT_CONSOLE
583 (void) sl_strlcpy (sh.srvcons.name, _("/dev/console"), SH_PATHBUF);
584#else
585 if (0 == strcmp (DEFAULT_CONSOLE, _("NULL")))
586 (void) sl_strlcpy (sh.srvcons.name, _("/dev/console"), SH_PATHBUF);
587 else
588 (void) sl_strlcpy (sh.srvcons.name, DEFAULT_CONSOLE, SH_PATHBUF);
589#endif
590
591#ifdef MKD_09
592 ErrFlag[1] |= (1 << 24);
593#endif
594#ifdef MKD_10
595 ErrFlag[1] |= (1 << 25);
596#endif
597#ifdef MKD_11
598 ErrFlag[1] |= (1 << 26);
599#endif
600#ifdef MKD_12
601 ErrFlag[1] |= (1 << 27);
602#endif
603#ifdef MKD_13
604 ErrFlag[1] |= (1 << 28);
605#endif
606#ifdef MKD_14
607 ErrFlag[1] |= (1 << 29);
608#endif
609#ifdef MKD_15
610 ErrFlag[1] |= (1 << 30);
611#endif
612#ifdef MKD_16
613 ErrFlag[1] |= (1UL << 31);
614#endif
615
616
617 /* The timers.
618 */
619 sh.fileCheck.alarm_last = 0;
620 sh.fileCheck.alarm_interval = 600; /* ten minutes */
621
622 sh.mailTime.alarm_last = 0;
623 sh.mailTime.alarm_interval = 86400;
624
625 sh.mailNum.alarm_last = 0;
626 sh.mailNum.alarm_interval = 10;
627
628 sh.looptime = 60;
629
630 /* The struct to hold privileged information.
631 */
632 skey = (sh_key_t *) malloc (sizeof(sh_key_t));
633 if (skey != NULL)
634 {
635
636 skey->mlock_failed = SL_FALSE;
637 skey->rngI = BAD;
638 /* properly initialized later
639 */
640 skey->rng0[0] = 0x03; skey->rng0[1] = 0x09; skey->rng0[2] = 0x17;
641 skey->rng1[0] = 0x03; skey->rng1[1] = 0x09; skey->rng1[2] = 0x17;
642 skey->rng2[0] = 0x03; skey->rng2[1] = 0x09; skey->rng2[2] = 0x17;
643
644 for (i = 0; i < KEY_BYT; ++i)
645 skey->poolv[i] = '\0';
646
647 skey->poolc = 0;
648
649 skey->ErrFlag[0] = ErrFlag[0];
650 ErrFlag[0] = 0;
651 skey->ErrFlag[1] = ErrFlag[1];
652 ErrFlag[1] = 0;
653
654 dez = &(TcpFlag[POS_TF-1][0]);
655 for (i = 0; i < PW_LEN; ++i)
656 {
657 skey->pw[i] = (char) (*dez);
658 (*dez) = '\0';
659 ++dez;
660 }
661
662 skey->sh_sockpass[0] = '\0';
663 skey->sigkey_old[0] = '\0';
664 skey->sigkey_new[0] = '\0';
665 skey->mailkey_old[0] = '\0';
666 skey->mailkey_new[0] = '\0';
667 skey->crypt[0] = '\0'; /* flawfinder: ignore *//* ff bug */
668 skey->session[0] = '\0';
669 skey->vernam[0] = '\0';
670 }
671 else
672 {
673 perror(_("sh_init"));
674 _exit (EXIT_FAILURE);
675 }
676
677 sh_unix_memlock();
678 SL_RET0(_("sh_init"));
679}
680
681
682#if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK)
683#include <sys/mman.h>
684#endif
685
686#if defined(SH_USE_XML)
687extern int sh_log_file (char * message, char * inet_peer);
688#endif
689
690/*******************************************************
691 *
692 * Exit Handler
693 *
694 *******************************************************/
695static void exit_handler(void)
696{
697 /* --- Clean up modules, if any. ---
698 */
699#if defined(SH_WITH_CLIENT) || defined(SH_STANDALONE)
700 int modnum;
701#endif
702#if defined(SH_WITH_SERVER)
703 extern int sh_socket_remove (void);
704#endif
705
706 SL_ENTER(_("exit_handler"));
707
708#if defined(SH_WITH_SERVER)
709 sh_socket_remove ();
710#endif
711
712#if defined(SH_WITH_CLIENT) || defined(SH_STANDALONE)
713 for (modnum = 0; modList[modnum].name != NULL; ++modnum)
714 {
715 if (modList[modnum].initval == SH_MOD_ACTIVE)
716 (void) modList[modnum].mod_cleanup();
717 }
718#ifdef HAVE_PTHREAD
719 sh_pthread_cancel_all();
720#endif
721#endif
722
723 /* --- Push out all pending messages. ---
724 */
725#if defined(SH_WITH_MAIL)
726 if (sh.mailNum.alarm_last > 0)
727 {
728 (void) sh_nmail_flush ();
729 }
730#endif
731
732 /* --- Write the server stat. ---
733 */
734#if defined(SH_WITH_SERVER)
735 sh_forward_html_write();
736#endif
737
738 /* --- Clean up memory to check for problems. ---
739 */
740#ifdef MEM_DEBUG
741#if defined(SH_WITH_CLIENT) || defined(SH_STANDALONE)
742 sh_files_deldirstack ();
743 sh_files_delfilestack ();
744 sh_files_delglobstack ();
745 sh_hash_hashdelete();
746 sh_files_hle_reg (NULL);
747 /*
748 * Only flush on exit if running as deamon.
749 * Otherwise we couldn't run another instance
750 * while the deamon is running (would leave the
751 * deamon with flushed ruleset).
752 */
753 if (sh.flag.isdaemon == S_TRUE)
754 {
755 sh_audit_delete_all ();
756 }
757#endif
758#if defined(SH_WITH_SERVER)
759 sh_forward_free_all ();
760#endif
761#if defined(SH_WITH_MAIL)
762 sh_nmail_free();
763#endif
764 delete_cache();
765 sh_userid_destroy ();
766 sh_mem_stat();
767#endif
768
769#ifdef MEM_DEBUG
770 sh_unix_count_mlock();
771#endif
772
773 /* --- Checksum of executable. ---
774 */
775 (void) sh_unix_self_check();
776
777
778 /* --- Exit Message. ---
779 */
780 sh_error_handle ((-1), FIL__, __LINE__, sh.flag.exit, MSG_EXIT_NORMAL,
781 sh.prg_name, sh_sig_msg);
782#ifdef SH_USE_XML
783 (void) sh_log_file (NULL, NULL);
784#endif
785
786
787 /* --- Restrict error logging to stderr. ---
788 */
789#ifdef WITH_MESSAGE_QUEUE
790 close_ipc ();
791#endif
792 sh_error_only_stderr (S_TRUE);
793
794
795 /* --- Remove lock, delete critical information. ---
796 */
797 (void) sh_unix_rm_lock_file (sh.srvlog.name);
798 if (sh.flag.isdaemon == S_TRUE)
799 (void) sh_unix_rm_pid_file ();
800 if (skey != NULL)
801 memset (skey, (int) '\0', sizeof(sh_key_t));
802
803 /* --- Exit. ---
804 */
805 SL_RET0(_("exit_handler"));
806}
807
808/***********************************************************
809 *
810 */
811#ifndef SIGHUP
812#define SIGHUP 1
813#endif
814#ifndef SIGTERM
815#define SIGTERM 15
816#endif
817#ifndef SIGKILL
818#define SIGKILL 9
819#endif
820
821#if defined(__linux__) || defined(sun) || defined(__sun) || defined(__sun__)
822#include <dirent.h>
823static pid_t * procdirSamhain (void)
824{
825 pid_t * pidlist;
826 struct dirent * d;
827 DIR * dp;
828 long ino;
829 struct stat buf;
830 int i;
831 pid_t pid, mypid = getpid();
832 char * tail;
833 char exef[128];
834
835 if (0 != stat(SH_INSTALL_PATH, &buf))
836 {
837 return NULL;
838 }
839
840 ino = (long) buf.st_ino;
841
842 if (NULL == (dp = opendir(_("/proc"))))
843 {
844 return NULL;
845 }
846
847 SH_MUTEX_LOCK(mutex_readdir);
848
849 pidlist = malloc(sizeof(pid_t) * 65535);
850 if (!pidlist)
851 goto unlock_and_out;
852
853 for (i = 0; i < 65535; ++i) pidlist[i] = 0;
854
855 i = 0;
856 while (NULL != (d = readdir(dp)) && i < 65535)
857 {
858 if (0 != strcmp(d->d_name, ".") && 0 != strcmp(d->d_name, ".."))
859 {
860 errno = 0;
861 pid = (pid_t) strtol (d->d_name, &tail, 0);
862 if (*tail != '\0' || errno != 0)
863 continue;
864 if (pid == mypid)
865 continue;
866#if defined(__linux__)
867 sprintf(exef, _("/proc/%d/exe"), (int) pid); /* known to fit */
868#else
869 sprintf(exef, _("/proc/%d/object/a.out"), /* known to fit */
870 (int) pid);
871#endif
872 if (0 == stat(exef, &buf) && ino == (long) buf.st_ino)
873 { pidlist[i] = (pid_t) pid; ++i; }
874 }
875 }
876
877 unlock_and_out:
878 ;
879 SH_MUTEX_UNLOCK(mutex_readdir);
880
881 closedir(dp);
882 return pidlist;
883}
884#else
885static pid_t * procdirSamhain (void)
886{
887 return NULL;
888}
889#endif
890
891static int killprocSamhain (pid_t pid)
892{
893 int i;
894
895 /* fprintf(stderr, "Killing %d\n", pid); */
896 if (pid > 0 && 0 == kill (pid, SIGTERM))
897 {
898 for (i = 0; i < 16; ++i)
899 {
900 (void) retry_msleep(1, 0);
901 if (0 != kill (pid, 0) && errno == ESRCH)
902 return (0);
903 }
904
905 (void) kill (pid, SIGKILL);
906 return (0);
907 }
908 if (pid > 0)
909 {
910 if (errno == ESRCH)
911 return 7;
912 if (errno == EPERM)
913 return 4;
914 return 1;
915 }
916 else
917 return (7);
918}
919
920static pid_t pidofSamhain (int flag)
921{
922 FILE * fp;
923 char line[256];
924 char * tail;
925 char * p;
926 pid_t pid;
927 long inpid;
928 struct stat buf;
929
930 fp = fopen (DEFAULT_ERRLOCK, "r");
931
932 if (!fp)
933 { if (errno != ENOENT) perror(_("fopen")); return 0; }
934 if (NULL == fgets(line, sizeof(line), fp))
935 { perror(_("fgets")); (void) sl_fclose(FIL__, __LINE__, fp); return 0; }
936 (void) sl_fclose(FIL__, __LINE__, fp);
937 p = line;
938 while (*p == ' ' || *p == '\f' || *p == '\n' ||
939 *p == '\r' || *p == '\t' || *p == '\v')
940 ++p;
941 errno = 0;
942 inpid = strtol (p, &tail, 0);
943 if (p == tail || errno != 0)
944 { perror(_("strtol")); return 0; }
945
946 pid = (pid_t) inpid;
947 if (inpid != (long) pid)
948 { perror(_("strtol")); return 0; }
949
950 /* remove stale pid file
951 */
952 if (flag == 1 && pid > 0 && 0 != kill(pid, 0) && errno == ESRCH)
953 {
954 if /*@-unrecog@*/ (0 == lstat (DEFAULT_ERRLOCK, &buf))/*@+unrecog@*/
955 {
956 if /*@-usedef@*/(S_ISREG(buf.st_mode))/*@+usedef@*/
957 {
958 (void) unlink(DEFAULT_ERRLOCK);
959 }
960 }
961 else
962 {
963 perror(_("lstat")); return 0;
964 }
965 pid = 0;
966 }
967 return pid;
968}
969
970/* 1: start 2:stop 3:reload 4:status
971 */
972/*@-exitarg@*/
973static int samhainctl(int ctl, int * argc, char * argv[])
974{
975 char * fullpath;
976 pid_t pid;
977 int status;
978 int res;
979 pid_t respid;
980 int times;
981 char * argp[32];
982 pid_t * pidlist;
983 int i;
984
985
986 fullpath = strdup (SH_INSTALL_PATH);
987 if (fullpath == NULL)
988 { perror(_("strdup")); exit (1); }
989
990 argp[0] = strdup (SH_INSTALL_PATH);
991 if (argp[0] == NULL)
992 { perror(_("strdup")); exit (1); }
993
994 for (times = 1; times < 32; ++times) argp[times] = NULL;
995
996 res = (*argc > 32) ? 32 : *argc;
997
998 for (times = 2; times < res; ++times)
999 {
1000 argp[times-1] = strdup (argv[times]);
1001 if (argp[times-1] == NULL)
1002 { perror(_("strdup")); exit (1); }
1003 }
1004
1005 if (ctl == 1)
1006 {
1007 pid = pidofSamhain(1);
1008
1009 if (pid != 0 && 0 == kill (pid, 0)) /* already started */
1010 exit (0);
1011
1012 pid = fork();
1013 switch (pid) {
1014 case ((pid_t) -1):
1015 perror(_("fork"));
1016 exit (1);
1017 case 0:
1018 if (0 != sl_close_fd (FIL__, __LINE__, 0))
1019 {
1020 _exit(4);
1021 }
1022 (void) execv(fullpath, argp); /* flawfinder: ignore *//* wtf? */
1023 if (errno == EPERM)
1024 _exit(4);
1025 else if (errno == ENOENT)
1026 _exit(5);
1027 _exit (1);
1028 default:
1029 times = 0;
1030 while (times < 300) {
1031 respid = waitpid(pid, &status, WNOHANG|WUNTRACED);
1032 if ((pid_t)-1 == respid)
1033 {
1034 perror(_("waitpid"));
1035 exit (1);
1036 }
1037 else if (pid == respid)
1038 {
1039#ifndef USE_UNO
1040 if (0 != WIFEXITED(status))
1041 {
1042 res = WEXITSTATUS(status);
1043 exit (res == 0 ? 0 : res );
1044 }
1045 else
1046 exit (1);
1047#else
1048 exit (1);
1049#endif
1050 }
1051 ++times;
1052 (void) retry_msleep(1, 0);
1053 }
1054 exit (0); /* assume that it runs ok */
1055 }
1056 }
1057
1058 pid = pidofSamhain(0);
1059
1060 if (ctl == 2) /* stop */
1061 {
1062 pidlist = procdirSamhain ();
1063 if (pid == 0 && NULL == pidlist) /* pid file not found */
1064 {
1065 free(fullpath);
1066 return (0);
1067 }
1068
1069 status = 0;
1070 if (pid != 0)
1071 status = killprocSamhain(pid);
1072 if (pidlist != NULL)
1073 {
1074 i = 0;
1075 while (i < 65535 && pidlist[i] != 0)
1076 {
1077 if (pidlist[i] != pid)
1078 status = killprocSamhain(pidlist[i]);
1079 ++i;
1080 }
1081 }
1082 free(fullpath);
1083 if (status == 7)
1084 return 0;
1085 else
1086 return status;
1087 }
1088
1089 if (ctl == 3) /* reload */
1090 {
1091 if (pid == 0)
1092 exit (7);
1093 if (0 == kill (pid, SIGHUP))
1094 exit (0);
1095 else
1096 {
1097 if (errno == EPERM)
1098 exit (4);
1099 if (errno == ESRCH)
1100 exit (7);
1101 exit (1);
1102 }
1103 }
1104
1105 if (ctl == 4) /* status */
1106 {
1107 if (pid == 0)
1108 exit (3);
1109 if (0 == kill (pid, 0))
1110 exit (0);
1111 else
1112 {
1113 if (errno == EPERM)
1114 exit (4);
1115 if (errno == ESRCH)
1116 exit (1);
1117 }
1118 }
1119 free(fullpath); /* silence smatch false positive */
1120 exit (1); /* no exit handler installed yet */
1121 /*@notreached@*/
1122 return (0);
1123}
1124/*@+exitarg@*/
1125
1126#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
1127#include "sh_schedule.h"
1128static sh_schedule_t * FileSchedOne = NULL;
1129static sh_schedule_t * FileSchedTwo = NULL;
1130
1131/* free a linked list of schedules
1132 */
1133static sh_schedule_t * free_sched (sh_schedule_t * isched)
1134{
1135 sh_schedule_t * current = isched;
1136 sh_schedule_t * next = NULL;
1137
1138 while (current != NULL)
1139 {
1140 next = current->next;
1141 SH_FREE(current);
1142 current = next;
1143 }
1144 return NULL;
1145}
1146
1147/* Add a new schedule to the linked list of schedules
1148 */
1149static sh_schedule_t * sh_set_schedule_int (const char * str,
1150 sh_schedule_t * FileSchedIn,
1151 /*@out@*/ int * status)
1152{
1153 sh_schedule_t * FileSched;
1154
1155 SL_ENTER(_("sh_set_schedule_int"));
1156
1157 if (0 == sl_strncmp(str, _("NULL"), 4))
1158 {
1159 (void) free_sched(FileSchedIn);
1160 FileSchedIn = NULL;
1161 *status = 0;
1162 return 0;
1163 }
1164
1165 FileSched = SH_ALLOC(sizeof(sh_schedule_t));
1166 *status = create_sched(str, FileSched);
1167 if (*status != 0)
1168 {
1169 SH_FREE(FileSched);
1170 FileSched = NULL;
1171 SL_RETURN(FileSchedIn , _("sh_set_schedule_int"));
1172 }
1173 FileSched->next = FileSchedIn;
1174 SL_RETURN(FileSched , _("sh_set_schedule_int"));
1175}
1176
1177/* Add a new schedule to the linked list FileSchedOne
1178 */
1179int sh_set_schedule_one (const char * str)
1180{
1181 int status;
1182 FileSchedOne = sh_set_schedule_int (str, FileSchedOne, &status);
1183 return status;
1184}
1185
1186/* Add a new schedule to the linked list FileSchedTwo
1187 */
1188int sh_set_schedule_two (const char * str)
1189{
1190 int status;
1191 FileSchedTwo = sh_set_schedule_int (str, FileSchedTwo, &status);
1192 return status;
1193}
1194
1195#endif
1196
1197/*******************************************************
1198 *
1199 * Main program
1200 *
1201 *******************************************************/
1202#if !defined(SH_CUTEST)
1203int main(int argc, char * argv[])
1204#else
1205int undef_main(int argc, char * argv[])
1206#endif
1207{
1208#if defined(INET_SYSLOG)
1209 extern int create_syslog_socket (int flag);
1210#endif
1211#if defined(SH_WITH_SERVER)
1212 extern int sh_create_tcp_socket(void);
1213#endif
1214
1215#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
1216 int modnum;
1217 time_t runtim;
1218 float st_1, st_2;
1219 int status;
1220 volatile long cct = 0; /* main loop iterations */
1221
1222 volatile int flag_check_1 = 0;
1223 volatile int flag_check_2 = 0;
1224
1225 int check_done = 0;
1226#endif
1227
1228 volatile time_t told;
1229 volatile time_t tcurrent;
1230 size_t tzlen;
1231 char * tzptr;
1232 int res;
1233
1234#if defined (SH_STEALTH_NOCL)
1235 char command_line[256];
1236 int my_argc = 0;
1237 char * my_argv[32];
1238#endif
1239
1240#if !defined(USE_SYSTEM_MALLOC)
1241 typedef void assert_handler_tp(const char * error, const char *file, int line);
1242 extern assert_handler_tp *dnmalloc_set_handler(assert_handler_tp *new);
1243 (void) dnmalloc_set_handler(safe_fatal);
1244#endif
1245
1246 SH_G_INIT; /* Must precede any use of _() */
1247
1248 SL_ENTER(_("main"));
1249
1250 /* --- Close all but first three file descriptors. ---
1251 */
1252 sh_unix_closeall(3, -1, SL_FALSE); /* at program start */
1253
1254
1255 if (argc >= 2 && 0 != getuid() &&
1256 (0 == strcmp(argv[1], _("start")) ||
1257 0 == strcmp(argv[1], _("stop")) ||
1258 0 == strcmp(argv[1], _("reload")) ||
1259 0 == strcmp(argv[1], _("force-reload")) ||
1260 0 == strcmp(argv[1], _("status")) ||
1261 0 == strcmp(argv[1], _("restart"))))
1262 {
1263 return 4;
1264 }
1265
1266 if (argc >= 2 && 0 == getuid())
1267 {
1268 /* return codes:
1269 * 0 Success
1270 * 1 Can not send signal / start program
1271 * 2 Pid file does not exist
1272 */
1273 if (0 == strcmp(argv[1], _("start")))
1274 {
1275 (void) samhainctl (1, &argc, argv); /* does not return */
1276 }
1277 else if (0 == strcmp(argv[1], _("stop")))
1278 return (samhainctl (2, &argc, argv));
1279 else if (0 == strcmp(argv[1], _("reload")))
1280 (void) samhainctl (3, &argc, argv); /* does not return */
1281 else if (0 == strcmp(argv[1], _("force-reload")))
1282 (void) samhainctl (3, &argc, argv); /* does not return */
1283 else if (0 == strcmp(argv[1], _("status")))
1284 (void) samhainctl (4, &argc, argv); /* does not return */
1285 else if (0 == strcmp(argv[1], _("restart")))
1286 {
1287 res = samhainctl (2, &argc, argv);
1288 if (res == 0 || res == 7)
1289 {
1290 (void) samhainctl (1, &argc, argv); /* does not return */
1291 }
1292 else
1293 return (res);
1294 }
1295 }
1296
1297 /* if fd 0 is closed, presume that we want to be daemon and
1298 * run in check mode
1299 */
1300 if ((-1) == retry_fcntl(FIL__, __LINE__, 0, F_GETFL, 0) &&
1301 errno == EBADF)
1302 {
1303 sh.flag.opts = S_TRUE;
1304 (void) sh_unix_setdeamon(NULL);
1305#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
1306 sh.flag.checkSum = SH_CHECK_CHECK;
1307 /* (void) sh_util_setchecksum(_("check")); */
1308#endif
1309 is_samhainctl_init = S_TRUE;
1310 sh.flag.opts = S_FALSE;
1311 }
1312
1313
1314 /* --- Install the exit handler. ---
1315 */
1316 (void) atexit(exit_handler);
1317
1318 /* --- Zero the mailer key, and fill it. ---
1319 */
1320 memset (ErrFlag, 0, 2*sizeof(UINT32));
1321
1322#ifdef MKA_01
1323 ErrFlag[0] |= (1 << 0);
1324#endif
1325#ifdef MKA_02
1326 ErrFlag[0] |= (1 << 1);
1327#endif
1328#ifdef MKA_03
1329 ErrFlag[0] |= (1 << 2);
1330#endif
1331#ifdef MKA_04
1332 ErrFlag[0] |= (1 << 3);
1333#endif
1334#ifdef MKA_05
1335 ErrFlag[0] |= (1 << 4);
1336#endif
1337#ifdef MKA_06
1338 ErrFlag[0] |= (1 << 5);
1339#endif
1340#ifdef MKA_07
1341 ErrFlag[0] |= (1 << 6);
1342#endif
1343#ifdef MKA_08
1344 ErrFlag[0] |= (1 << 7);
1345#endif
1346
1347#if defined(SCREW_IT_UP)
1348 BREAKEXIT(sh_sigtrap_prepare);
1349 (void) sh_sigtrap_prepare();
1350#endif
1351
1352 /* Save the timezone.
1353 */
1354 if (NULL != (tzptr = getenv("TZ"))) /* flawfinder: ignore */
1355 {
1356 tzlen = strlen(tzptr);
1357 if (tzlen < 1024)
1358 {
1359 sh.timezone = malloc (tzlen + 1);
1360 if (sh.timezone != NULL)
1361 (void) sl_strlcpy (sh.timezone, tzptr, tzlen + 1);
1362 }
1363 else
1364 sh.timezone = NULL;
1365 }
1366 else
1367 sh.timezone = NULL;
1368
1369
1370 /* -------- INIT --------
1371 */
1372
1373 /* Restrict error logging to stderr.
1374 */
1375 sh_error_only_stderr (S_TRUE);
1376
1377 BREAKEXIT(sh_derr);
1378 (void) sh_derr();
1379
1380 /* Check that first three descriptors are open.
1381 */
1382 if ( retry_fcntl(FIL__, __LINE__, 0, F_GETFL, 0) == (-1))
1383 (void) aud_open(FIL__, __LINE__, SL_NOPRIV, _("/dev/null"), O_RDWR, 0);
1384 if ( retry_fcntl(FIL__, __LINE__, 1, F_GETFL, 0) == (-1))
1385 (void) aud_open(FIL__, __LINE__, SL_NOPRIV, _("/dev/null"), O_RDWR, 1);
1386 if ( retry_fcntl(FIL__, __LINE__, 2, F_GETFL, 0) == (-1))
1387 (void) aud_open(FIL__, __LINE__, SL_NOPRIV, _("/dev/null"), O_RDWR, 2);
1388
1389 /* --- Set default values. ---
1390 */
1391 BREAKEXIT(sh_init);
1392 sh_init (); /* we are still privileged here, so we can mlock skey */
1393#if (defined (SH_WITH_SERVER) && !defined (SH_WITH_CLIENT))
1394 sh.flag.isserver = S_TRUE;
1395#endif
1396
1397 /* --- Get local hostname. ---
1398 */
1399 BREAKEXIT(sh_unix_localhost);
1400 sh_unix_localhost();
1401
1402 /* --- Read the command line. ---
1403 */
1404 sh.flag.opts = S_TRUE;
1405
1406#if !defined(SH_STEALTH_NOCL)
1407 sh_argc_store = argc;
1408 sh_argv_store = argv;
1409 (void) sh_getopt_get (argc, argv);
1410#else
1411 if (argc > 1 && argv[1] != NULL &&
1412 strlen(argv[1]) > 0 && strlen(NOCL_CODE) > 0)
1413 {
1414 if ( 0 == strcmp(argv[1], NOCL_CODE) )
1415 {
1416#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
1417 char * saveptr;
1418#endif
1419 my_argv[0] = argv[0]; ++my_argc;
1420 command_line[0] = '\0';
1421 if (NULL != fgets (command_line, sizeof(command_line), stdin))
1422 command_line[sizeof(command_line)-1] = '\0';
1423
1424 do {
1425#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
1426 my_argv[my_argc] =
1427 strtok_r( (my_argc == 1) ? command_line : NULL, " \n", &saveptr);
1428#else
1429 my_argv[my_argc] =
1430 strtok( (my_argc == 1) ? command_line : NULL, " \n");
1431#endif
1432 if (my_argv[my_argc] != NULL) {
1433 ++my_argc;
1434 } else {
1435 break;
1436 }
1437 } while (my_argc < 32);
1438
1439 sh_argc_store = my_argc;
1440 sh_argv_store = my_argv;
1441
1442 (void) sh_getopt_get (my_argc, my_argv);
1443 }
1444 else
1445 {
1446 /* discard command line */
1447 /* _exit(EXIT_FAILURE) */ ;
1448 }
1449 }
1450#endif
1451 sh.flag.opts = S_FALSE;
1452
1453
1454 /* --- Get user info. ---
1455 */
1456 TPT((0, FIL__, __LINE__, _("msg=<Get user name.>\n")))
1457 if (0 != sh_unix_getUser ())
1458 {
1459 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EXIT_ABORT1,
1460 sh.prg_name);
1461 aud_exit(FIL__, __LINE__, EXIT_FAILURE);
1462 }
1463
1464
1465 /* *****************************
1466 *
1467 * Read the configuration file.
1468 *
1469 * *****************************/
1470
1471 TPT((0, FIL__, __LINE__, _("msg=<Read the configuration file.>\n")))
1472 BREAKEXIT(sh_readconf_read);
1473 (void) sh_readconf_read ();
1474
1475#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
1476 if (sh.flag.checkSum == SH_CHECK_NONE)
1477 {
1478 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
1479 _("No action specified: init, update, or check"),
1480 _("main"));
1481 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EXIT_ABORT1,
1482 sh.prg_name);
1483 aud_exit (FIL__, __LINE__, EXIT_FAILURE);
1484 }
1485#endif
1486
1487 /* do not append to database if run SUID
1488 */
1489 if ((sh.flag.checkSum == SH_CHECK_INIT) && (0 != sl_is_suid()))
1490 {
1491 (void) dlog(1, FIL__, __LINE__,
1492 _("Cannot initialize database when running with SUID credentials.\nYou need to run this with the user ID %d.\nYour current user ID is %d."),
1493 (int) geteuid(), (int) sh.real.uid);
1494 sh_error_handle ((-1), FIL__, __LINE__, EACCES, MSG_ACCESS,
1495 (long) sh.real.uid, sh.data.path);
1496 aud_exit(FIL__, __LINE__, EXIT_FAILURE);
1497 }
1498
1499 /* avoid daemon mode for initialization
1500 */
1501 if (sh.flag.checkSum == SH_CHECK_INIT)
1502 {
1503 sh.flag.isdaemon = S_FALSE;
1504 sh.flag.loop = S_FALSE;
1505 }
1506
1507 /* --- load database; checksum of database
1508 */
1509#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
1510 TPT((0, FIL__, __LINE__, _("msg=<Get checksum of the database.>\n")))
1511 if (sh.flag.checkSum == SH_CHECK_CHECK)
1512 {
1513 if (0 != sl_strcmp(file_path('D', 'R'), _("REQ_FROM_SERVER")))
1514 {
1515 char hashbuf[KEYBUF_SIZE];
1516 (void) sl_strlcpy(sh.data.hash,
1517 sh_tiger_hash (file_path('D', 'R'),
1518 TIGER_FILE, TIGER_NOLIM,
1519 hashbuf, sizeof(hashbuf)),
1520 KEY_LEN+1);
1521 }
1522
1523 /* this eventually fetches the file from server to get checksum
1524 */
1525 sh_hash_init ();
1526 }
1527#endif
1528
1529 /* --- initialize signal handling etc.; fork daemon
1530 */
1531 if (sh_unix_init(sh.flag.isdaemon) == -1)
1532 {
1533 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EXIT_ABORT1,
1534 sh.prg_name);
1535 aud_exit(FIL__, __LINE__, EXIT_FAILURE);
1536 }
1537
1538 /* --- drop privileges eventually ---
1539 */
1540#if defined(SH_WITH_SERVER)
1541 sh_create_tcp_socket ();
1542#if defined(INET_SYSLOG)
1543 create_syslog_socket (S_TRUE);
1544#endif
1545 SL_REQUIRE(sl_policy_get_real(DEFAULT_IDENT) == SL_ENONE,
1546 _("sl_policy_get_real(DEFAULT_IDENT) == SL_ENONE"));
1547#else
1548 SL_REQUIRE(sl_policy_get_user(DEFAULT_IDENT) == SL_ENONE,
1549 _("sl_policy_get_user(DEFAULT_IDENT) == SL_ENONE"));
1550#endif
1551
1552 /* --- Get user info (again). ---
1553 */
1554 TPT((0, FIL__, __LINE__, _("msg=<Get user name.>\n")))
1555 if (0 != sh_unix_getUser ())
1556 {
1557 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EXIT_ABORT1,
1558 sh.prg_name);
1559 aud_exit(FIL__, __LINE__, EXIT_FAILURE);
1560 }
1561
1562 /* --- now check whether we really wanted it; if not, close ---
1563 */
1564#if defined(INET_SYSLOG) && defined(SH_WITH_SERVER)
1565 create_syslog_socket (S_FALSE);
1566#endif
1567
1568
1569 /* --- Enable full error logging ---
1570 */
1571 sh_error_only_stderr (S_FALSE);
1572
1573 sh.flag.started = S_TRUE;
1574
1575 /****************************************************
1576 *
1577 * SERVER
1578 *
1579 ****************************************************/
1580
1581#if defined(SH_WITH_SERVER) && !defined(SH_WITH_CLIENT)
1582
1583#if (defined(WITH_GPG) || defined(WITH_PGP))
1584 /* log startup */
1585 sh_gpg_log_startup ();
1586#else
1587 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_START_1H,
1588 sh.prg_name, (long) sh.real.uid,
1589 (sh.flag.hidefile == S_TRUE) ?
1590 _("(hidden)") : file_path('C','R'),
1591 sh.conf.hash);
1592#endif
1593
1594#else
1595
1596 /****************************************************
1597 *
1598 * CLIENT/STANDALONE
1599 *
1600 ****************************************************/
1601
1602 BREAKEXIT(sh_error_handle);
1603
1604 if (sh.flag.checkSum == SH_CHECK_CHECK)
1605 {
1606#if (defined(WITH_GPG) || defined(WITH_PGP))
1607 /* log startup */
1608 sh_gpg_log_startup ();
1609#else
1610 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_START_2H,
1611 sh.prg_name, (long) sh.real.uid,
1612 (sh.flag.hidefile == S_TRUE) ? _("(hidden)") : file_path('C', 'R'), sh.conf.hash,
1613 (sh.flag.hidefile == S_TRUE) ? _("(hidden)") : file_path('D', 'R'), sh.data.hash);
1614#endif
1615 }
1616 else
1617 {
1618#if (defined(WITH_GPG) || defined(WITH_PGP))
1619 /* log startup */
1620 sh_gpg_log_startup ();
1621#else
1622 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_START_1H,
1623 sh.prg_name, (long) sh.real.uid,
1624 (sh.flag.hidefile == S_TRUE) ? _("(hidden)") : file_path('C', 'R'), sh.conf.hash);
1625#endif
1626 }
1627#endif
1628
1629
1630 if ((skey == NULL) || (skey->mlock_failed == SL_TRUE))
1631 sh_error_handle ((-1), FIL__, __LINE__, EPERM, MSG_MLOCK);
1632
1633 /* timer
1634 */
1635 tcurrent = time (NULL);
1636 told = tcurrent;
1637 sh.mailTime.alarm_last = told;
1638
1639
1640 /****************************************************
1641 *
1642 * SERVER
1643 *
1644 ****************************************************/
1645
1646#if defined(SH_WITH_SERVER)
1647 TPT((0, FIL__, __LINE__, _("msg=<Start server.>\n")))
1648
1649#if defined (SH_WITH_CLIENT)
1650 if (sh.flag.isserver == S_TRUE)
1651 {
1652 sh_receive();
1653 TPT((0, FIL__, __LINE__, _("msg=<End server.>\n")))
1654 aud_exit (FIL__, __LINE__, EXIT_SUCCESS);
1655 }
1656#else
1657 sh_receive();
1658 TPT((0, FIL__, __LINE__, _("msg=<End server.>\n")))
1659 aud_exit (FIL__, __LINE__, EXIT_SUCCESS);
1660#endif
1661
1662#endif
1663
1664 /****************************************************
1665 *
1666 * CLIENT/STANDALONE
1667 *
1668 ****************************************************/
1669#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
1670
1671
1672 /* --- Initialize modules. ---
1673 */
1674 TPT((0, FIL__, __LINE__, _("msg=<Initialize modules.>\n")))
1675 for (modnum = 0; modList[modnum].name != NULL; ++modnum)
1676 {
1677 status = modList[modnum].mod_init(&(modList[modnum]));
1678 if ( status < 0 )
1679 {
1680 if (status == (-1)) {
1681 sh_error_handle (SH_ERR_NOTICE, FIL__, __LINE__, status,
1682 MSG_MOD_FAIL,
1683 _(modList[modnum].name),
1684 status+SH_MOD_OFFSET);
1685 } else {
1686 sh_error_handle ((-1), FIL__, __LINE__, status, MSG_MOD_FAIL,
1687 _(modList[modnum].name),
1688 status+SH_MOD_OFFSET);
1689 }
1690 modList[modnum].initval = SH_MOD_FAILED;
1691 }
1692 else
1693 {
1694 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_MOD_OK,
1695 _(modList[modnum].name));
1696 modList[modnum].initval = status;
1697 }
1698 }
1699
1700 /* -------- TEST SETUP ---------
1701 */
1702 (void) sh_files_setrec();
1703 (void) sh_files_test_setup();
1704
1705
1706 /* -------- NICE LEVEL ---------
1707 */
1708 if (0 != sh.flag.nice)
1709 {
1710#ifdef HAVE_SETPRIORITY
1711 /*@-unrecog@*/
1712 (void) setpriority(PRIO_PROCESS, 0, sh.flag.nice);
1713 /*@+unrecog@*/
1714#else
1715 (void) nice(sh.flag.nice);
1716#endif
1717 }
1718
1719 /* -------- MAIN LOOP ---------
1720 */
1721 sh.statistics.bytes_speed = 0;
1722 sh.statistics.bytes_hashed = 0;
1723
1724 while (1 == 1)
1725 {
1726 ++cct;
1727
1728 BREAKEXIT(sh_error_handle);
1729
1730 TPT((0, FIL__, __LINE__, _("msg=<Start main loop.>, iter=<%ld>\n"), cct))
1731
1732 tcurrent = time (NULL);
1733
1734 if (sig_raised > 0)
1735 {
1736
1737 TPT((0, FIL__, __LINE__, _("msg=<Process a signal.>\n")))
1738
1739 if (sig_termfast == 1) /* SIGTERM */
1740 {
1741 TPT((0, FIL__, __LINE__, _("msg=<Terminate.>\n")));
1742 /* strncpy (sh_sig_msg, _("SIGTERM"), 20); */
1743 --sig_raised; --sig_urgent;
1744 aud_exit (FIL__, __LINE__, EXIT_SUCCESS);
1745 }
1746
1747 if (sig_force_check == 1) /* SIGTTOU */
1748 {
1749 TPT((0, FIL__, __LINE__, _("msg=<Check run triggered.>\n")));
1750 flag_check_1 = 1;
1751 flag_check_2 = 1;
1752 sig_force_check = 0;
1753 --sig_raised;
1754 }
1755
1756 if (sig_config_read_again == 1 && /* SIGHUP */
1757 sh_global_suspend_flag == 0)
1758 {
1759 TPT((0, FIL__, __LINE__, _("msg=<Re-read configuration.>\n")))
1760 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_RECONF);
1761
1762 sh_thread_pause_flag = S_TRUE;
1763
1764#if defined(WITH_EXTERNAL)
1765 /* delete list of external tasks
1766 */
1767 (void) sh_ext_cleanup();
1768#endif
1769#if defined(SH_WITH_MAIL)
1770 sh_nmail_free();
1771#endif
1772
1773 /* delete the file list, make all database
1774 * entries visible (allignore = FALSE)
1775 */
1776 (void) sh_files_deldirstack ();
1777 (void) sh_files_delfilestack ();
1778 (void) sh_files_delglobstack ();
1779 (void) sh_ignore_clean ();
1780 (void) hash_full_tree ();
1781 sh_audit_delete_all ();
1782
1783
1784#if defined(SH_WITH_CLIENT)
1785 reset_count_dev_server();
1786#endif
1787#if defined(SH_WITH_CLIENT) || defined(SH_STANDALONE)
1788
1789
1790 FileSchedOne = free_sched(FileSchedOne);
1791 FileSchedTwo = free_sched(FileSchedTwo);
1792
1793 for (modnum = 0; modList[modnum].name != NULL; ++modnum)
1794 {
1795 /* sh_thread_pause_flag is true, and we block in lock
1796 * until check has returned, so we are sure check will
1797 * not run until sh_thread_pause_flag is set to false
1798 */
1799 /* if (modList[modnum].initval >= SH_MOD_ACTIVE) */
1800 (void) modList[modnum].mod_reconf();
1801 }
1802#endif
1803
1804 reset_count_dev_console();
1805 reset_count_dev_time();
1806
1807 (void) sh_unix_maskreset();
1808
1809 /* Should this be included ???
1810 * (i.e. should we reload the database ?)
1811 */
1812#ifdef RELOAD_DATABASE
1813 sh_hash_hashdelete();
1814#endif
1815 (void) sl_trust_purge_user();
1816 (void) sh_files_hle_reg (NULL);
1817 (void) sh_prelink_run (NULL, NULL, 0);
1818
1819 /* --------------------------
1820 * --- READ CONFIGURATION ---
1821 * --------------------------
1822 */
1823 (void) sh_readconf_read ();
1824 sig_config_read_again = 0;
1825 (void) sh_files_setrec();
1826 (void) sh_files_test_setup();
1827 if (0 != sh.flag.nice)
1828 {
1829#ifdef HAVE_SETPRIORITY
1830 setpriority(PRIO_PROCESS, 0, sh.flag.nice);
1831#else
1832 nice(sh.flag.nice);
1833#endif
1834 }
1835
1836 if (sh.flag.checkSum == SH_CHECK_INIT)
1837 {
1838 sh.flag.isdaemon = S_FALSE;
1839 sh.flag.loop = S_FALSE;
1840 }
1841
1842
1843 /* --- Initialize modules. ---
1844 */
1845 TPT((0, FIL__, __LINE__, _("msg=<Initialize modules.>\n")));
1846 for (modnum = 0; modList[modnum].name != NULL; ++modnum)
1847 {
1848 status = modList[modnum].mod_init(&(modList[modnum]));
1849
1850 if (status < 0)
1851 {
1852 if (status == (-1)) {
1853 sh_error_handle (SH_ERR_NOTICE, FIL__, __LINE__,
1854 status, MSG_MOD_FAIL,
1855 _(modList[modnum].name),
1856 status+SH_MOD_OFFSET);
1857 } else {
1858 sh_error_handle ((-1), FIL__, __LINE__,
1859 status, MSG_MOD_FAIL,
1860 _(modList[modnum].name),
1861 status+SH_MOD_OFFSET);
1862 }
1863 modList[modnum].initval = SH_MOD_FAILED;
1864 }
1865 else
1866 {
1867 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_MOD_OK,
1868 _(modList[modnum].name));
1869 modList[modnum].initval = status;
1870 }
1871 }
1872
1873 /* module is properly set up now
1874 */
1875 sh_thread_pause_flag = S_FALSE;
1876
1877 --sig_raised;
1878 }
1879
1880 if (sig_fresh_trail == 1) /* SIGIOT */
1881 {
1882 if (sh_global_suspend_flag == 0)
1883 {
1884 SH_MUTEX_LOCK(mutex_thread_nolog);
1885
1886 /* Logfile access
1887 */
1888#ifdef SH_USE_XML
1889 (void) sh_log_file (NULL, NULL);
1890#endif
1891 TPT((0, FIL__, __LINE__, _("msg=<Logfile stop/restart.>\n")));
1892 sh_error_only_stderr (S_TRUE);
1893 (void) sh_unix_rm_lock_file(sh.srvlog.name);
1894 (void) retry_msleep(3, 0);
1895 sh.flag.log_start = S_TRUE;
1896 sh_error_only_stderr (S_FALSE);
1897 sh_thread_pause_flag = S_FALSE;
1898 sig_fresh_trail = 0;
1899 --sig_raised;
1900 SH_MUTEX_UNLOCK(mutex_thread_nolog);
1901 }
1902 }
1903
1904 if (sig_terminate == 1) /* SIGQUIT */
1905 {
1906 TPT((0, FIL__, __LINE__, _("msg=<Terminate.>\n")));
1907 strncpy (sh_sig_msg, _("Quit"), 20);
1908 --sig_raised; --sig_urgent;
1909 aud_exit (FIL__, __LINE__, EXIT_SUCCESS);
1910 }
1911
1912 if (sig_debug_switch == 1) /* SIGUSR1 */
1913 {
1914 TPT((0, FIL__, __LINE__, _("msg=<Debug switch.>\n")));
1915 sh_error_dbg_switch();
1916 sig_debug_switch = 0;
1917 --sig_raised;
1918 }
1919
1920 if (sig_suspend_switch > 0) /* SIGUSR2 */
1921 {
1922 TPT((0, FIL__, __LINE__, _("msg=<Suspend switch.>\n")));
1923 if (sh_global_suspend_flag != 1) {
1924 SH_MUTEX_LOCK_UNSAFE(mutex_thread_nolog);
1925 sh_global_suspend_flag = 1;
1926 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_SUSPEND,
1927 sh.prg_name);
1928 } else {
1929 sh_global_suspend_flag = 0;
1930 SH_MUTEX_UNLOCK_UNSAFE(mutex_thread_nolog);
1931 }
1932 --sig_suspend_switch;
1933 --sig_raised; --sig_urgent;
1934 }
1935 sig_raised = (sig_raised < 0) ? 0 : sig_raised;
1936 sig_urgent = (sig_urgent < 0) ? 0 : sig_urgent;
1937 TPT((0, FIL__, __LINE__, _("msg=<End signal processing.>\n")));
1938 }
1939
1940 if (sh_global_suspend_flag == 1)
1941 {
1942 (void) retry_msleep (1, 0);
1943 continue;
1944 }
1945
1946 /* see whether its time to check files
1947 */
1948 if (sh.flag.checkSum == SH_CHECK_INIT ||
1949 (sh.flag.checkSum == SH_CHECK_CHECK &&
1950 (sh.flag.isdaemon == S_FALSE && sh.flag.loop == S_FALSE)))
1951 {
1952 flag_check_1 = 1;
1953 if (FileSchedTwo != NULL)
1954 flag_check_2 = 1;
1955 }
1956 else if (sh.flag.checkSum == SH_CHECK_CHECK ||
1957 (sh.flag.update == S_TRUE &&
1958 (sh.flag.isdaemon == S_TRUE || sh.flag.loop == S_TRUE)))
1959 {
1960 if (FileSchedOne == NULL)
1961 {
1962 /* use interval if we have no schedule
1963 */
1964 if (tcurrent - sh.fileCheck.alarm_last >=
1965 sh.fileCheck.alarm_interval)
1966 flag_check_1 = 1;
1967 }
1968 else
1969 {
1970 flag_check_1 = test_sched(FileSchedOne);
1971 if (FileSchedTwo != NULL)
1972 flag_check_2 = test_sched(FileSchedTwo);
1973 if (flag_check_2 == 1)
1974 flag_check_1 = 1;
1975 }
1976 }
1977
1978 check_done = 0;
1979
1980 if (sh.flag.checkSum != SH_CHECK_NONE &&
1981 (flag_check_1 == 1 || flag_check_2 == 1))
1982 {
1983 /* Refresh list files matching glob patterns.
1984 */
1985 if (sh.flag.checkSum != SH_CHECK_INIT)
1986 sh_files_check_globPatterns();
1987
1988 /*
1989 * check directories and files
1990 * ORDER IS IMPORTANT -- DIRZ FIRST
1991 */
1992 sh.statistics.bytes_hashed = 0;
1993 sh.statistics.time_start = time (NULL);
1994 sh.statistics.dirs_checked = 0;
1995 sh.statistics.files_checked = 0;
1996
1997 TPT((0, FIL__, __LINE__, _("msg=<Check directories.>\n")))
1998 BREAKEXIT(sh_dirs_chk);
1999 if (flag_check_1 == 1)
2000 {
2001 (void) sh_dirs_chk (1);
2002#ifndef SH_PROFILE
2003 (void) retry_aud_chdir (FIL__, __LINE__, "/");
2004#endif
2005 }
2006 if (flag_check_2 == 1)
2007 {
2008 (void) sh_dirs_chk (2);
2009#ifndef SH_PROFILE
2010 (void) retry_aud_chdir (FIL__, __LINE__, "/");
2011#endif
2012 }
2013 TPT((0, FIL__, __LINE__, _("msg=<Check files.>\n")))
2014 BREAKEXIT(sh_files_chk);
2015 if (flag_check_1 == 1)
2016 (void) sh_files_chk ();
2017
2018 if (sig_urgent > 0)
2019 continue;
2020
2021 /*
2022 * check for files not visited
2023 */
2024 if (flag_check_2 == 1 || FileSchedTwo == NULL)
2025 {
2026 TPT((0, FIL__, __LINE__, _("msg=<Check for missing files.>\n")))
2027 sh_hash_unvisited (ShDFLevel[SH_ERR_T_FILE]);
2028 }
2029
2030 if (sig_urgent > 0)
2031 continue;
2032
2033 /* reset
2034 */
2035 TPT((0, FIL__, __LINE__, _("msg=<Reset status.>\n")))
2036 sh_dirs_reset ();
2037 if (sig_urgent > 0)
2038 continue;
2039
2040 sh_files_reset ();
2041 flag_check_1 = 0;
2042 flag_check_2 = 0;
2043 check_done = 1;
2044
2045 (void) sh_prelink_run (NULL, NULL, 0);
2046
2047 if (sig_urgent > 0)
2048 continue;
2049
2050 runtim = time(NULL) - sh.statistics.time_start;
2051 sh.statistics.time_check = runtim;
2052
2053 if ((sh.statistics.dirs_checked == 0) &&
2054 (sh.statistics.files_checked == 0))
2055 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_CHECK_0);
2056
2057 else
2058 {
2059 st_1 = (float) sh.statistics.bytes_hashed;
2060 st_2 = (float) runtim;
2061
2062
2063 if (st_1 > FLT_EPSILON && st_2 > FLT_EPSILON)
2064 st_1 = st_1/st_2;
2065 else if (st_1 > FLT_EPSILON)
2066 st_1 = (float) (st_1 * 1.0);
2067 else
2068 st_1 = 0.0;
2069
2070 sh.statistics.bytes_speed = (unsigned long) st_1;
2071
2072 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_CHECK_1,
2073 (long) runtim,
2074 0.001 * st_1);
2075 }
2076 sh.fileCheck.alarm_last = time (NULL);
2077
2078 if (sig_urgent > 0)
2079 continue;
2080
2081 /*
2082 * flush mail queue
2083 */
2084#if defined(SH_WITH_MAIL)
2085 TPT((0, FIL__, __LINE__, _("msg=<Flush mail queue.>\n")))
2086 (void) sh_nmail_flush ();
2087#endif
2088 }
2089
2090 if (sig_urgent > 0)
2091 continue;
2092
2093 /* execute modules
2094 */
2095 TPT((0, FIL__, __LINE__, _("msg=<Execute modules.>\n")))
2096 for (modnum = 0; modList[modnum].name != NULL; ++modnum)
2097 {
2098 if (modList[modnum].initval == SH_MOD_ACTIVE &&
2099 0 != modList[modnum].mod_timer(tcurrent))
2100 if (0 != (status = modList[modnum].mod_check()))
2101 sh_error_handle ((-1), FIL__, __LINE__, status, MSG_MOD_EXEC,
2102 _(modList[modnum].name), (long) (status+SH_MOD_OFFSET));
2103 }
2104
2105 /* 27.05.2002 avoid empty database
2106 * 22.10.2002 moved here b/o suid check initialization
2107 */
2108 if (sh.flag.checkSum == SH_CHECK_INIT)
2109 sh_hash_pushdata (NULL, NULL);
2110
2111 /* write out database
2112 */
2113 if (sh.flag.checkSum == SH_CHECK_CHECK &&
2114 sh.flag.update == S_TRUE &&
2115 check_done == 1)
2116 sh_hash_writeout ();
2117
2118 /* no-op unless MEM_LOG is defined in sh_mem.c
2119 */
2120#ifdef MEM_DEBUG
2121 sh_mem_dump ();
2122#endif
2123
2124 {
2125 char * stale;
2126
2127 stale = sl_check_stale();
2128 if (stale)
2129 {
2130 sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, 0, MSG_E_SUBGEN,
2131 stale, _("sl_check_stale"));
2132 }
2133
2134 stale = sl_check_badfd();
2135 if (stale)
2136 {
2137 sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, 0, MSG_E_SUBGEN,
2138 stale, _("sl_check_stale"));
2139 }
2140 }
2141
2142 /* no loop if not daemon
2143 */
2144 if (sh.flag.isdaemon != S_TRUE && sh.flag.loop == S_FALSE)
2145 break;
2146 if (sig_urgent > 0)
2147 continue;
2148
2149 /* see whether its time to send mail
2150 */
2151#if defined(SH_WITH_MAIL)
2152 if (tcurrent - sh.mailTime.alarm_last >= sh.mailTime.alarm_interval)
2153 {
2154 TPT((0, FIL__, __LINE__, _("msg=<Flush mail queue.>\n")))
2155 (void) sh_nmail_flush ();
2156 sh.mailTime.alarm_last = time (NULL);
2157 }
2158#endif
2159 if (sig_urgent > 0)
2160 continue;
2161
2162 /* log the timestamp
2163 */
2164 if ((int)(tcurrent - told) >= sh.looptime )
2165 {
2166 TPT((0, FIL__, __LINE__, _("msg=<Log the timestamp.>\n")))
2167 told = tcurrent;
2168#ifdef MEM_DEBUG
2169 sh_mem_check();
2170 sh_unix_count_mlock();
2171#else
2172 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_STAMP);
2173#endif
2174 }
2175
2176 /* seed / re-seed the PRNG if required
2177 */
2178 (void) taus_seed();
2179
2180 if (sig_urgent > 0)
2181 continue;
2182
2183 /* reset cache
2184 */
2185 sh_userid_destroy();
2186
2187 /* go to sleep
2188 */
2189 (void) retry_msleep (1, 0);
2190
2191 BREAKEXIT(sh_derr);
2192 (void) sh_derr();
2193 }
2194
2195 /* ------ END -----------
2196 */
2197
2198
2199
2200 /*
2201 * cleanup
2202 */
2203 TPT((0, FIL__, __LINE__, _("msg=<Cleanup.>\n")));
2204 sh_hash_hashdelete();
2205
2206#if defined(SH_WITH_MAIL)
2207 if (sh.mailNum.alarm_last > 0)
2208 (void)sh_nmail_flush ();
2209#endif
2210
2211 /* #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) */
2212#endif
2213
2214#if 0
2215 {
2216 char command[128];
2217 sprintf(command, "/bin/cat /proc/%d/status", (int) getpid());
2218 system(command); /* flawfinder: ignore *//* debug code */
2219 malloc_stats();
2220 }
2221#endif
2222
2223 aud_exit (FIL__, __LINE__, EXIT_SUCCESS);
2224 SL_RETURN(0, _("main"));
2225}
Note: See TracBrowser for help on using the repository browser.