source: trunk/src/sh_readconf.c@ 280

Last change on this file since 280 was 279, checked in by katerina, 15 years ago

Fix for tickets #200 to #206 (kernel check, login checks, bugfixes).

File size: 38.9 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 <stdlib.h>
24#include <stdio.h>
25#include <string.h>
26#include <ctype.h>
27
28
29#include "samhain.h"
30#include "sh_calls.h"
31#include "sh_error.h"
32#include "sh_extern.h"
33#include "sh_files.h"
34#include "sh_forward.h"
35#include "sh_gpg.h"
36#include "sh_hash.h"
37#include "sh_ignore.h"
38#include "sh_database.h"
39#include "sh_mail.h"
40#include "sh_modules.h"
41#include "sh_nmail.h"
42#include "sh_prelink.h"
43#ifdef HAVE_LIBPRELUDE
44#include "sh_prelude.h"
45#endif
46#include "sh_tiger.h"
47#include "sh_tools.h"
48#include "sh_unix.h"
49#include "sh_utils.h"
50
51
52extern int set_reverse_lookup (const char * c);
53
54#undef FIL__
55#define FIL__ _("sh_readconf.c")
56
57typedef enum {
58 SH_SECTION_NONE,
59 SH_SECTION_LOG,
60 SH_SECTION_MISC,
61 SH_SECTION_ATTRIBUTES,
62 SH_SECTION_READONLY,
63 SH_SECTION_LOGFILES,
64 SH_SECTION_LOGGROW,
65 SH_SECTION_NOIGNORE,
66 SH_SECTION_ALLIGNORE,
67 SH_SECTION_USER0,
68 SH_SECTION_USER1,
69 SH_SECTION_USER2,
70 SH_SECTION_USER3,
71 SH_SECTION_USER4,
72 SH_SECTION_PRELINK,
73#if defined (SH_WITH_MAIL)
74 SH_SECTION_MAIL,
75#endif
76#if defined (SH_WITH_CLIENT)
77 SH_SECTION_CLT,
78#endif
79#ifdef WITH_EXTERNAL
80 SH_SECTION_EXTERNAL,
81#endif
82#ifdef WITH_DATABASE
83 SH_SECTION_DATABASE,
84#endif
85#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
86 SH_SECTION_OTHER,
87#endif
88#ifdef SH_WITH_SERVER
89 SH_SECTION_CLIENTS,
90 SH_SECTION_SRV,
91#endif
92 SH_SECTION_THRESHOLD
93} ShSectionType;
94
95typedef struct str_ListSections {
96 const char * name;
97 int type;
98} sh_str_ListSections;
99
100struct str_ListSections tab_ListSections[] = {
101 { N_("[Log]"), SH_SECTION_LOG},
102 { N_("[Misc]"), SH_SECTION_MISC},
103 { N_("[Attributes]"), SH_SECTION_ATTRIBUTES},
104 { N_("[ReadOnly]"), SH_SECTION_READONLY},
105 { N_("[LogFiles]"), SH_SECTION_LOGFILES},
106 { N_("[GrowingLogFiles]"), SH_SECTION_LOGGROW},
107 { N_("[IgnoreAll]"), SH_SECTION_ALLIGNORE},
108 { N_("[IgnoreNone]"), SH_SECTION_NOIGNORE},
109 { N_("[User0]"), SH_SECTION_USER0},
110 { N_("[User1]"), SH_SECTION_USER1},
111 { N_("[User2]"), SH_SECTION_USER2},
112 { N_("[User3]"), SH_SECTION_USER3},
113 { N_("[User4]"), SH_SECTION_USER4},
114 { N_("[Prelink]"), SH_SECTION_PRELINK},
115#ifdef WITH_EXTERNAL
116 { N_("[External]"), SH_SECTION_EXTERNAL},
117#endif
118#ifdef WITH_DATABASE
119 { N_("[Database]"), SH_SECTION_DATABASE},
120#endif
121 { N_("[EventSeverity]"), SH_SECTION_THRESHOLD},
122#ifdef SH_WITH_SERVER
123 { N_("[Clients]"), SH_SECTION_CLIENTS},
124 { N_("[Server]"), SH_SECTION_SRV},
125#endif
126#if defined (SH_WITH_CLIENT)
127 { N_("[Client]"), SH_SECTION_CLT},
128#endif
129#if defined (SH_WITH_MAIL)
130 { N_("[Mail]"), SH_SECTION_MAIL},
131#endif
132 { NULL, SH_SECTION_NONE}
133};
134
135static char * sh_readconf_expand_value (const char * str)
136{
137 char * tmp = (char*)str;
138 char * out;
139
140 while (tmp && isspace((int)*tmp)) ++tmp;
141
142 if (tmp[0] == '$' && tmp[1] == '(')
143 {
144 size_t len = strlen(tmp);
145 while (isspace((int) tmp[len-1])) { tmp[len-1] = '\0'; --len; }
146 if (tmp[len-1] == ')')
147 {
148 tmp[len-1] = '\0';
149 out = sh_ext_popen_str(&tmp[2]);
150 return out;
151 }
152 }
153 return sh_util_strdup(str);
154}
155
156enum {
157 SH_RC_ANY = 0,
158 SH_RC_HOST = 1,
159 SH_RC_SYSTEM = 2,
160 SH_RC_FILE = 3,
161 SH_RC_IFACE = 4,
162 SH_RC_CMD = 5
163};
164
165
166static int sh_readconf_cond_match(char * str, int line)
167{
168 int match = 0;
169 int negate = 1;
170 int cond_type = SH_RC_ANY;
171 char myident[3*SH_MINIBUF+3];
172 struct stat buf;
173
174 char * p = str;
175
176 if (*p == '!') { negate = 0; ++p; }
177 if (*p == '$') {
178 cond_type = SH_RC_SYSTEM; ++p; /* [!]$system */
179 }
180 else { /* *p == '@' */
181
182 ++p; while (isspace((int)*p)) ++p;
183
184 if (0 != strncasecmp(p, _("if "), 3)) {
185 cond_type = SH_RC_HOST; /* [!]$host */
186 }
187
188 else {
189
190 p += 3; while (isspace((int)*p)) ++p; /* skip the 'if\s+' */
191
192 if (0 == strncasecmp(p, _("not "), 4))
193 {
194 p += 4; while (isspace((int)*p)) ++p;
195 negate = 0;
196 }
197 else if (0 == strncmp(p, _("!"), 1))
198 {
199 ++p; while (isspace((int)*p)) ++p;
200 negate = 0;
201 }
202
203 if (0 == strncasecmp(p, _("file_exists "), 12))
204 {
205 p += 12; cond_type = SH_RC_FILE;
206 }
207 else if (0 == strncasecmp(p, _("interface_exists "), 17))
208 {
209 p += 17; cond_type = SH_RC_IFACE;
210 }
211 else if (0 == strncasecmp(p, _("hostname_matches "), 17))
212 {
213 p += 17; cond_type = SH_RC_HOST;
214 }
215 else if (0 == strncasecmp(p, _("system_matches "), 15))
216 {
217 p += 15; cond_type = SH_RC_SYSTEM;
218 }
219 else if (0 == strncasecmp(p, _("command_succeeds "), 17))
220 {
221 p += 17; cond_type = SH_RC_CMD;
222 }
223 else
224 {
225 char errbuf[SH_ERRBUF_SIZE];
226 sl_snprintf(errbuf, sizeof(errbuf),
227 _("Unsupported test at line %d of configuration file"),
228 line);
229 sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, 0, MSG_E_SUBGEN,
230 errbuf,
231 _("sh_readconf_cond_match"));
232 return 0;
233 }
234 }
235 }
236
237 while (isspace((int)*p)) ++p;
238
239 switch (cond_type)
240 {
241 case SH_RC_HOST:
242 if (sl_strncmp (p, sh.host.name, strlen(sh.host.name)) == 0
243#ifdef HAVE_REGEX_H
244 || sh_util_regcmp (p, sh.host.name) == 0
245#endif
246 )
247 match = negate;
248 break;
249 case SH_RC_SYSTEM:
250 /*
251 * The system type, release, and machine.
252 */
253 sl_snprintf(myident, sizeof(myident), _("%s:%s:%s"),
254 sh.host.system, /* flawfinder: ignore */
255 sh.host.release, sh.host.machine);
256
257 if (sl_strncmp (p, myident, strlen(myident)) == 0
258#ifdef HAVE_REGEX_H
259 || sh_util_regcmp (p, myident) == 0
260#endif
261 )
262 match = negate;
263 break;
264 case SH_RC_FILE:
265 if (0 == retry_lstat(FIL__, __LINE__, p, &buf))
266 match = negate;
267 break;
268 case SH_RC_IFACE:
269 if (sh_tools_iface_is_present(p))
270 match = negate;
271 break;
272 case SH_RC_CMD:
273 if (0 == sh_unix_run_command(p))
274 match = negate;
275 break;
276 default:
277 match = 0;
278 }
279 return match;
280}
281
282static int sh_readconf_is_end (char * str)
283{
284 int retval = 0;
285
286 if (str[0] == '@' || str[0] == '$')
287 {
288 char * p = str;
289 ++p; while (isspace((int)*p)) ++p;
290 if (
291 (0 == strncasecmp (p, _("end"), 3) && (p[3] == '\0' || isspace((int)p[3]))) ||
292 (0 == strncasecmp (p, _("fi"), 2) && (p[2] == '\0' || isspace((int)p[2])))
293 )
294 {
295 return 1;
296 }
297 }
298 return retval;
299}
300
301static int sh_readconf_is_else (char * str)
302{
303 int retval = 0;
304
305 if (str[0] == '@')
306 {
307 char * p = str;
308 ++p; while (isspace((int)*p)) ++p;
309 if ( 0 == strncasecmp (p, _("else"), 4) && (p[4] == '\0' || isspace((int)p[4])) )
310 {
311 return 1;
312 }
313 }
314 return retval;
315}
316
317static int sh_readconfig_line (char * line);
318
319static ShSectionType read_mode = SH_SECTION_NONE;
320
321static int conf_line = 0;
322
323/* --- Read the configuration file. ---
324 */
325int sh_readconf_read (void)
326{
327#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
328 /* This is for modules.
329 */
330 int modnum;
331#endif
332
333 int i;
334
335 SL_TICKET fd = -1;
336#if defined(SH_STEALTH) && !defined(SH_STEALTH_MICRO)
337 SL_TICKET fdTmp = -1;
338 SL_TICKET open_tmp (void);
339#endif
340 char * tmp;
341
342 char line_in[512+2];
343 char * line;
344
345 /* This is for nested conditionals.
346 */
347 int cond_depth = 0;
348 int cond_excl = 0;
349
350 int local_file = 1;
351 char local_flag = 'R';
352
353#if defined(WITH_GPG) || defined(WITH_PGP)
354 int signed_content = S_FALSE;
355 int true_content = S_FALSE;
356#endif
357#if defined(SH_STEALTH) && !defined(SH_STEALTH_MICRO)
358 int hidden_count = 0;
359#endif
360 uid_t euid;
361 char hashbuf[KEYBUF_SIZE];
362
363 SL_ENTER(_("sh_readconf_read"));
364
365 /* --- Open config file, exit on failure. ---
366 */
367#if defined(SH_WITH_CLIENT)
368 if (0 == sl_strcmp(file_path('C', 'R'), _("REQ_FROM_SERVER")))
369 {
370 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_D_START);
371
372 fd = sh_forward_req_file(_("CONF"));
373
374 if (!SL_ISERROR(fd))
375 local_file = 0;
376 else if (sh.flag.checkSum != SH_CHECK_INIT)
377 aud_exit (FIL__, __LINE__, EXIT_FAILURE);
378 else
379 {
380 sh_error_handle ((-1), FIL__, __LINE__, fd, MSG_D_FAIL);
381 local_file = 1;
382 local_flag = 'I';
383 }
384 }
385#endif
386
387 /* Use a local configuration file.
388 */
389 if (local_file == 1)
390 {
391 if (0 != tf_trust_check (file_path('C', local_flag), SL_YESPRIV))
392 {
393 sl_get_euid(&euid);
394 dlog(1, FIL__, __LINE__,
395 _("The configuration file: %s is untrusted, i.e. an\nuntrusted user owns or can write to some directory in the path.\n"),
396 ( (NULL == file_path('C', local_flag))
397 ? _("(null)") : file_path('C', local_flag) ));
398 sh_error_handle ((-1), FIL__, __LINE__, EACCES, MSG_TRUST,
399 (long) euid,
400 ( (NULL == file_path('C', local_flag))
401 ? _("(null)") : file_path('C', local_flag) )
402 );
403 aud_exit (FIL__, __LINE__, EXIT_FAILURE);
404 }
405 if (SL_ISERROR(fd = sl_open_read(FIL__, __LINE__,
406 file_path('C',local_flag),SL_YESPRIV)))
407 {
408 sl_get_euid(&euid);
409 dlog(1, FIL__, __LINE__,
410 _("Could not open the local configuration file for reading because\nof the following error: %s (errnum = %ld)\nIf this is a permission problem, you need to change file permissions\nto make the file readable for the effective UID: %d\n"),
411 sl_get_errmsg(), fd, (int) euid);
412 sh_error_handle ((-1), FIL__, __LINE__, fd, MSG_NOACCESS,
413 (long) euid,
414 ( (NULL == file_path('C', local_flag))
415 ? _("(null)") : file_path('C', local_flag) )
416 );
417 aud_exit (FIL__, __LINE__, EXIT_FAILURE);
418 }
419 }
420
421 /* Compute the checksum of the open file.
422 */
423 sl_strlcpy(sh.conf.hash,
424 sh_tiger_hash(file_path('C',local_flag), fd, TIGER_NOLIM,
425 hashbuf, sizeof(hashbuf)),
426 KEY_LEN+1);
427 sl_rewind (fd);
428
429#if defined(SH_STEALTH) && !defined(SH_STEALTH_MICRO)
430 /* extract the data and copy to temporary file
431 */
432 fdTmp = open_tmp();
433
434 sh_unix_getline_stealth (0, NULL, 0); /* initialize */
435
436 while ( sh_unix_getline_stealth (fd, line_in, 512) > 0) {
437 hidden_count++;
438 if (line_in[0] == '\n')
439 {
440 sl_write(fdTmp, line_in, 1);
441 }
442 else
443 {
444 sl_write_line(fdTmp, line_in, sl_strlen(line_in));
445 }
446#if defined(WITH_GPG) || defined(WITH_PGP)
447 if (0 == sl_strncmp(line_in, _("-----END PGP SIGNATURE-----"), 25))
448 break;
449#else
450 if (0 == sl_strncmp(line_in, _("[EOF]"), 5))
451 break;
452#endif
453 if (hidden_count > 4096) /* arbitrary safeguard */
454 break;
455 }
456 sl_close(fd);
457 fd = fdTmp;
458 sl_rewind (fd);
459#endif
460
461
462 /* --- Start reading lines. ---
463 */
464 conf_line = 0;
465
466 while ( sh_unix_getline (fd, line_in, 512) > 0) {
467
468 ++conf_line;
469
470 line = &(line_in[0]);
471
472 /* fprintf(stderr, "<%s>\n", line); */
473
474 /* Sun May 27 18:40:05 CEST 2001
475 */
476#if defined(WITH_GPG) || defined(WITH_PGP)
477 if (signed_content == S_FALSE)
478 {
479 if (0 == sl_strcmp(line, _("-----BEGIN PGP SIGNED MESSAGE-----")))
480 signed_content = S_TRUE;
481 else
482 continue;
483 }
484 else if (true_content == S_FALSE)
485 {
486 if (line[0] == '\n')
487 true_content = S_TRUE;
488 else
489 continue;
490 }
491 else if (signed_content == S_TRUE)
492 {
493 if (0 == sl_strcmp(line, _("-----BEGIN PGP SIGNATURE-----")))
494 break;
495 else if (0 == sl_strcmp(line, _("-----BEGIN PGP SIGNED MESSAGE-----")))
496 {
497 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
498 _("second signed message in file"),
499 _("sh_readconf_read"));
500 dlog(1, FIL__, __LINE__,
501 _("There seems to be more than one signed message in the configuration\nfile. Please make sure there is only one signed message.\n"));
502 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EXIT_ABORT1,
503 sh.prg_name);
504 aud_exit (FIL__, __LINE__,EXIT_FAILURE);
505 }
506 }
507#endif
508
509 /* Skip leading white space.
510 */
511 while (isspace((int)*line)) ++line;
512
513
514 /* Skip header etc.
515 */
516 if (line[0] == '#' || line[0] == '\0' || line[0] == ';' ||
517 (line[0] == '/' && line[1] == '/'))
518 continue;
519
520 /* Clip off trailing white space.
521 */
522 tmp = line + sl_strlen( line ); --tmp;
523 while( isspace((int) *tmp ) && tmp >= line ) *tmp-- = '\0';
524
525
526 /* --- an @host/@if/$system directive -------------- */
527
528 if (line[0] == '@' || (line[0] == '!' && line[1] == '@') ||
529 line[0] == '$' || (line[0] == '!' && line[1] == '$'))
530 {
531 if (sh_readconf_is_end(line))
532 {
533 if (0 == cond_depth) {
534 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EINVALD,
535 _("config file"),
536 (long) conf_line);
537 }
538 else {
539 if (cond_excl == cond_depth)
540 cond_excl = 0;
541 --cond_depth;
542 }
543 }
544 else if (sh_readconf_is_else(line))
545 {
546 if (0 == cond_depth) {
547 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EINVALD,
548 _("config file"),
549 (long) conf_line);
550 }
551 else if (cond_excl == cond_depth) {
552 cond_excl = 0;
553 }
554 else if (cond_excl == 0) {
555 cond_excl = cond_depth;
556 }
557 }
558 else
559 {
560 if (sh_readconf_cond_match(line, conf_line)) {
561 ++cond_depth;
562 }
563 else {
564 ++cond_depth;
565 if (cond_excl == 0)
566 cond_excl = cond_depth;
567 }
568 }
569 continue;
570 }
571
572 /****************************************************
573 *
574 * Only carry on if this section is intended for us
575 *
576 ****************************************************/
577
578 if (cond_excl != 0) {
579 continue;
580 }
581
582 /* ------- starts a section ------------ */
583
584 else if (line[0] == '[')
585 {
586 read_mode = SH_SECTION_NONE;
587
588 if (0 == sl_strncasecmp (line, _("[EOF]"), 5)) {
589 goto nopel;
590 }
591
592 i = 0;
593
594 while (tab_ListSections[i].name != 0)
595 {
596 if (sl_strncasecmp (line, _(tab_ListSections[i].name),
597 sl_strlen(tab_ListSections[i].name)) == 0)
598 {
599 read_mode = tab_ListSections[i].type;
600 break;
601 }
602 ++i;
603 }
604
605#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
606 if (read_mode == SH_SECTION_NONE)
607 {
608 for (modnum = 0; modList[modnum].name != NULL; ++modnum)
609 {
610 if (0 == sl_strncasecmp (line, _(modList[modnum].conf_section),
611 sl_strlen(modList[modnum].conf_section)) )
612 read_mode = SH_SECTION_OTHER;
613 }
614 }
615#endif
616 if (read_mode == SH_SECTION_NONE)
617 {
618 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EINVALHEAD,
619 (long) conf_line);
620 }
621 }
622
623 /* --- an %schedule directive ------------ */
624
625 else if (line[0] == '%' || (line[0] == '!' && line[1] == '%'))
626 {
627#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
628 if (line[0] == '!' && 0 == sl_strcasecmp(&(line[2]), _("SCHEDULE_TWO")))
629 set_dirList(1);
630 else if (0 == sl_strcasecmp(&(line[1]), _("SCHEDULE_TWO")))
631 set_dirList(2);
632#else
633 ;
634#endif
635 }
636
637 /* ------ no new section -------------- */
638
639
640 else if (read_mode != SH_SECTION_NONE)
641 {
642 if (0 != sh_readconfig_line (line))
643 {
644 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EINVALCONF,
645 (long) conf_line);
646 }
647 }
648 } /* while getline() */
649
650 nopel:
651
652 if (0 != cond_depth)
653 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EINVALDD,
654 _("config file"),
655 (long) conf_line);
656
657#if defined(WITH_GPG) || defined(WITH_PGP)
658 /* Validate signature of open file.
659 */
660 sl_rewind (fd);
661 if (0 != sh_gpg_check_sign (fd, 0, 1))
662 aud_exit (FIL__, __LINE__, EXIT_FAILURE);
663#endif
664
665 sl_close (fd);
666
667 sh_error_fixup();
668
669 read_mode = SH_SECTION_NONE; /* reset b/o sighup reload */
670
671 SL_RETURN( 0, _("sh_readconf_read"));
672}
673
674int sh_readconf_set_path (char * which, const char * what)
675{
676 int len;
677 SL_ENTER( _("sh_readconf_set_path"));
678
679 if (which == NULL || what == NULL)
680 {
681 TPT((0, FIL__, __LINE__ , _("msg=<Input error>\n")));
682 SL_RETURN( -1, _("sh_readconf_set_path"));
683 }
684
685 if (0 == sl_strcmp(what, _("AUTO")))
686 {
687 len = sl_strlen(which);
688 if ( (len + sl_strlen(sh.host.name) + 2) > SH_PATHBUF)
689 {
690 TPT((0, FIL__, __LINE__ , _("msg=<Path too large: %s:%s>\n"),
691 which, sh.host.name));
692 SL_RETURN( -1, _("sh_readconf_set_path"));
693 }
694 else
695 {
696 which[len] = ':'; which[len+1] = '\0';
697 sl_strlcat(which, sh.host.name, SH_PATHBUF);
698 }
699 }
700 else /* not auto */
701 {
702 if (sl_strlen(what) > (SH_PATHBUF-1))
703 {
704 TPT((0, FIL__, __LINE__ , _("msg=<Path too large: %s>\n"), what));
705 SL_RETURN( -1, _("sh_readconf_set_path"));
706 }
707 else
708 {
709 sl_strlcpy(which, what, SH_PATHBUF);
710 }
711 }
712 SL_RETURN( 0, _("sh_readconf_set_path"));
713}
714
715int sh_readconf_set_database_path (const char * what)
716{
717 return (sh_readconf_set_path(sh.data.path, what));
718}
719
720int sh_readconf_set_logfile_path (const char * what)
721{
722 return (sh_readconf_set_path(sh.srvlog.name, what));
723}
724
725int sh_readconf_set_lockfile_path (const char * what)
726{
727 return( sh_readconf_set_path(sh.srvlog.alt, what));
728}
729
730
731
732
733typedef enum {
734 SET_MAILTIME,
735 SET_FILETIME
736} ShTimerItem;
737
738
739int sh_readconf_setTime (const char * str, ShTimerItem what)
740{
741 unsigned long i = atoi (str);
742
743 SL_ENTER( _("sh_readconf_setTime"));
744
745 if (i < LONG_MAX)
746 {
747 if (what == SET_MAILTIME)
748 {
749 TPT((0, FIL__, __LINE__, _("msg=<Set mail timer to %ld>\n"), i));
750 sh.mailTime.alarm_interval = i;
751 }
752 else if (what == SET_FILETIME)
753 {
754 TPT((0, FIL__, __LINE__, _("msg=<Set filecheck timer to %ld>\n"),i));
755 sh.fileCheck.alarm_interval = i;
756 }
757
758 SL_RETURN( 0, _("sh_readconf_setTime"));
759 }
760 else
761 {
762 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EINVALL,
763 _("set timer"), (long) i);
764 SL_RETURN( (-1), _("sh_readconf_setTime"));
765 }
766}
767
768int sh_readconf_setMailtime (const char * c)
769{
770 return sh_readconf_setTime (c, SET_MAILTIME);
771}
772
773int sh_readconf_setFiletime (const char * c)
774{
775 return sh_readconf_setTime (c, SET_FILETIME);
776}
777
778int sh_readconf_set_nice (const char * c)
779{
780 long val;
781
782 SL_ENTER(_("sh_readconf_set_nice"));
783
784 val = strtol (c, (char **)NULL, 10);
785 if (val < -20 || val > 20)
786 {
787 SL_RETURN((-1), _("sh_readconf_set_nice"));
788 }
789
790 val = (val < -19 ? -19 : val);
791 val = (val > 19 ? 19 : val);
792
793 sh.flag.nice = val;
794 SL_RETURN((0), _("sh_readconf_set_nice"));
795}
796
797#ifdef FANCY_LIBCAP
798int sh_readconf_setCaps(const char * c)
799{
800 int i;
801 SL_ENTER(_("sh_readconf_setCaps"));
802
803 i = sh_util_flagval(c, &sl_useCaps);
804 SL_RETURN((i), _("sh_readconf_setCaps"));
805}
806#endif
807
808typedef struct _cfg_options {
809 const char * optname;
810 ShSectionType section;
811 ShSectionType alt_section;
812 int (*func)(const char * opt);
813} cfg_options;
814
815#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
816extern int sh_set_schedule_one(const char * str);
817extern int sh_set_schedule_two(const char * str);
818#endif
819#if defined (SH_WITH_SERVER)
820extern int sh_socket_use (const char * c);
821extern int sh_socket_uid (const char * c);
822extern int sh_socket_password (const char * c);
823#endif
824
825cfg_options ext_table[] = {
826#if defined(WITH_EXTERNAL)
827 { N_("opencommand"), SH_SECTION_EXTERNAL, SH_SECTION_NONE,
828 sh_ext_setcommand },
829 { N_("closecommand"), SH_SECTION_EXTERNAL, SH_SECTION_NONE,
830 sh_ext_close_command },
831 { N_("setcommandline"), SH_SECTION_EXTERNAL, SH_SECTION_NONE,
832 sh_ext_add_argv },
833 { N_("setchecksum"), SH_SECTION_EXTERNAL, SH_SECTION_NONE,
834 sh_ext_checksum },
835 { N_("setdefault"), SH_SECTION_EXTERNAL, SH_SECTION_NONE,
836 sh_ext_add_default },
837 { N_("setenviron"), SH_SECTION_EXTERNAL, SH_SECTION_NONE,
838 sh_ext_add_environ },
839 { N_("setdeadtime"), SH_SECTION_EXTERNAL, SH_SECTION_NONE,
840 sh_ext_deadtime },
841 { N_("settype"), SH_SECTION_EXTERNAL, SH_SECTION_NONE,
842 sh_ext_type },
843 { N_("setcredentials"), SH_SECTION_EXTERNAL, SH_SECTION_NONE,
844 sh_ext_priv },
845 { N_("setfilternot"), SH_SECTION_EXTERNAL, SH_SECTION_NONE,
846 sh_ext_add_not },
847 { N_("setfilterand"), SH_SECTION_EXTERNAL, SH_SECTION_NONE,
848 sh_ext_add_and },
849 { N_("setfilteror"), SH_SECTION_EXTERNAL, SH_SECTION_NONE,
850 sh_ext_add_or },
851 { N_("externalseverity"),SH_SECTION_LOG, SH_SECTION_EXTERNAL,
852 sh_error_set_external },
853 { N_("externalclass"), SH_SECTION_LOG, SH_SECTION_EXTERNAL,
854 sh_error_external_mask },
855#endif
856
857#if defined(WITH_DATABASE)
858 { N_("usepersistent"), SH_SECTION_DATABASE, SH_SECTION_NONE,
859 sh_database_use_persistent },
860 { N_("setdbname"), SH_SECTION_DATABASE, SH_SECTION_NONE,
861 sh_database_set_database },
862 { N_("setdbtable"), SH_SECTION_DATABASE, SH_SECTION_NONE,
863 sh_database_set_table },
864 { N_("setdbhost"), SH_SECTION_DATABASE, SH_SECTION_NONE,
865 sh_database_set_host },
866 { N_("setdbuser"), SH_SECTION_DATABASE, SH_SECTION_NONE,
867 sh_database_set_user },
868 { N_("setdbpassword"), SH_SECTION_DATABASE, SH_SECTION_NONE,
869 sh_database_set_password },
870 { N_("addtodbhash"), SH_SECTION_DATABASE, SH_SECTION_NONE,
871 sh_database_add_to_hash },
872 { N_("databaseseverity"),SH_SECTION_LOG, SH_SECTION_DATABASE,
873 sh_error_set_database },
874 { N_("databaseclass"), SH_SECTION_LOG, SH_SECTION_DATABASE,
875 sh_error_database_mask },
876 { N_("setdbservertstamp"), SH_SECTION_DATABASE, SH_SECTION_NONE,
877 set_enter_wrapper },
878#endif
879
880
881#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
882 { N_("dir"), SH_SECTION_ATTRIBUTES, SH_SECTION_NONE,
883 sh_files_pushdir_attr },
884 { N_("file"), SH_SECTION_ATTRIBUTES, SH_SECTION_NONE,
885 sh_files_pushfile_attr },
886 { N_("dir"), SH_SECTION_READONLY, SH_SECTION_NONE,
887 sh_files_pushdir_ro },
888 { N_("file"), SH_SECTION_READONLY, SH_SECTION_NONE,
889 sh_files_pushfile_ro },
890 { N_("dir"), SH_SECTION_LOGFILES, SH_SECTION_NONE,
891 sh_files_pushdir_log },
892 { N_("file"), SH_SECTION_LOGFILES, SH_SECTION_NONE,
893 sh_files_pushfile_log },
894 { N_("dir"), SH_SECTION_LOGGROW, SH_SECTION_NONE,
895 sh_files_pushdir_glog },
896 { N_("file"), SH_SECTION_LOGGROW, SH_SECTION_NONE,
897 sh_files_pushfile_glog },
898 { N_("dir"), SH_SECTION_NOIGNORE, SH_SECTION_NONE,
899 sh_files_pushdir_noig },
900 { N_("file"), SH_SECTION_NOIGNORE, SH_SECTION_NONE,
901 sh_files_pushfile_noig },
902 { N_("dir"), SH_SECTION_ALLIGNORE, SH_SECTION_NONE,
903 sh_files_pushdir_allig },
904 { N_("file"), SH_SECTION_ALLIGNORE, SH_SECTION_NONE,
905 sh_files_pushfile_allig },
906
907 { N_("dir"), SH_SECTION_USER0, SH_SECTION_NONE,
908 sh_files_pushdir_user0 },
909 { N_("file"), SH_SECTION_USER0, SH_SECTION_NONE,
910 sh_files_pushfile_user0 },
911 { N_("dir"), SH_SECTION_USER1, SH_SECTION_NONE,
912 sh_files_pushdir_user1 },
913 { N_("file"), SH_SECTION_USER1, SH_SECTION_NONE,
914 sh_files_pushfile_user1 },
915 { N_("dir"), SH_SECTION_USER2, SH_SECTION_NONE,
916 sh_files_pushdir_user2 },
917 { N_("file"), SH_SECTION_USER2, SH_SECTION_NONE,
918 sh_files_pushfile_user2 },
919 { N_("dir"), SH_SECTION_USER3, SH_SECTION_NONE,
920 sh_files_pushdir_user3 },
921 { N_("file"), SH_SECTION_USER3, SH_SECTION_NONE,
922 sh_files_pushfile_user3 },
923 { N_("dir"), SH_SECTION_USER4, SH_SECTION_NONE,
924 sh_files_pushdir_user4 },
925 { N_("file"), SH_SECTION_USER4, SH_SECTION_NONE,
926 sh_files_pushfile_user4 },
927 { N_("dir"), SH_SECTION_PRELINK, SH_SECTION_NONE,
928 sh_files_pushdir_prelink },
929 { N_("file"), SH_SECTION_PRELINK, SH_SECTION_NONE,
930 sh_files_pushfile_prelink },
931
932 { N_("ignoreadded"), SH_SECTION_MISC, SH_SECTION_NONE,
933 sh_ignore_add_new },
934 { N_("ignoremissing"), SH_SECTION_MISC, SH_SECTION_NONE,
935 sh_ignore_add_del },
936
937 { N_("filecheckscheduleone"), SH_SECTION_MISC, SH_SECTION_NONE,
938 sh_set_schedule_one },
939 { N_("filecheckscheduletwo"), SH_SECTION_MISC, SH_SECTION_NONE,
940 sh_set_schedule_two },
941
942 { N_("usehardlinkcheck"), SH_SECTION_MISC, SH_SECTION_NONE,
943 sh_files_check_hardlinks },
944 { N_("usersrccheck"), SH_SECTION_MISC, SH_SECTION_NONE,
945 sh_files_use_rsrc },
946 { N_("hardlinkoffset"), SH_SECTION_MISC, SH_SECTION_NONE,
947 sh_files_hle_reg },
948#if defined(USE_XATTR)
949 { N_("useselinuxcheck"), SH_SECTION_MISC, SH_SECTION_NONE,
950 sh_unix_setcheckselinux },
951#endif
952#if defined(USE_ACL)
953 { N_("useaclcheck"), SH_SECTION_MISC, SH_SECTION_NONE,
954 sh_unix_setcheckacl },
955#endif
956 { N_("loosedircheck"), SH_SECTION_MISC, SH_SECTION_NONE,
957 sh_hash_loosedircheck },
958 { N_("addokchars"), SH_SECTION_MISC, SH_SECTION_NONE,
959 sh_util_obscure_ok },
960 { N_("filenamesareutf8"), SH_SECTION_MISC, SH_SECTION_NONE,
961 sh_util_obscure_utf8 },
962 { N_("setrecursionlevel"), SH_SECTION_MISC, SH_SECTION_NONE,
963 sh_files_setrecursion },
964 { N_("checksumtest"), SH_SECTION_MISC, SH_SECTION_NONE,
965 sh_util_setchecksum },
966 { N_("reportonlyonce"), SH_SECTION_MISC, SH_SECTION_NONE,
967 sh_files_reportonce },
968 { N_("reportfulldetail"), SH_SECTION_MISC, SH_SECTION_NONE,
969 sh_files_fulldetail },
970 { N_("uselocaltime"), SH_SECTION_MISC, SH_SECTION_NONE,
971 sh_unix_uselocaltime },
972
973 { N_("setnicelevel"), SH_SECTION_MISC, SH_SECTION_NONE,
974 sh_readconf_set_nice },
975
976#if defined(FANCY_LIBCAP)
977 { N_("usecaps"), SH_SECTION_MISC, SH_SECTION_NONE,
978 sh_readconf_setCaps },
979#endif
980
981 { N_("setdropcache"), SH_SECTION_MISC, SH_SECTION_NONE,
982 sl_set_drop_cache },
983
984 { N_("setiolimit"), SH_SECTION_MISC, SH_SECTION_NONE,
985 sh_unix_set_io_limit },
986
987 { N_("versionstring"), SH_SECTION_MISC, SH_SECTION_NONE,
988 sh_hash_version_string },
989
990 { N_("digestalgo"), SH_SECTION_MISC, SH_SECTION_NONE,
991 sh_tiger_hashtype },
992
993 { N_("redefreadonly"), SH_SECTION_MISC, SH_SECTION_NONE,
994 sh_files_redef_readonly },
995
996 { N_("redeflogfiles"), SH_SECTION_MISC, SH_SECTION_NONE,
997 sh_files_redef_logfiles },
998
999 { N_("redefgrowinglogfiles"), SH_SECTION_MISC, SH_SECTION_NONE,
1000 sh_files_redef_loggrow },
1001
1002 { N_("redefattributes"), SH_SECTION_MISC, SH_SECTION_NONE,
1003 sh_files_redef_attributes },
1004
1005 { N_("redefignorenone"), SH_SECTION_MISC, SH_SECTION_NONE,
1006 sh_files_redef_noignore },
1007
1008 { N_("redefignoreall"), SH_SECTION_MISC, SH_SECTION_NONE,
1009 sh_files_redef_allignore },
1010
1011 { N_("redefuser0"), SH_SECTION_MISC, SH_SECTION_NONE,
1012 sh_files_redef_user0 },
1013
1014 { N_("redefuser1"), SH_SECTION_MISC, SH_SECTION_NONE,
1015 sh_files_redef_user1 },
1016
1017 { N_("redefuser2"), SH_SECTION_MISC, SH_SECTION_NONE,
1018 sh_files_redef_user2 },
1019
1020 { N_("redefuser3"), SH_SECTION_MISC, SH_SECTION_NONE,
1021 sh_files_redef_user3 },
1022
1023 { N_("redefuser4"), SH_SECTION_MISC, SH_SECTION_NONE,
1024 sh_files_redef_user4 },
1025
1026 { N_("redefprelink"), SH_SECTION_MISC, SH_SECTION_NONE,
1027 sh_files_redef_prelink },
1028
1029
1030 { N_("setprelinkpath"), SH_SECTION_MISC, SH_SECTION_NONE,
1031 sh_prelink_set_path },
1032 { N_("setprelinkchecksum"), SH_SECTION_MISC, SH_SECTION_NONE,
1033 sh_prelink_set_hash },
1034
1035 /* client or standalone
1036 */
1037#endif
1038
1039#ifdef SH_WITH_SERVER
1040#ifdef INET_SYSLOG
1041 { N_("setudpactive"), SH_SECTION_SRV, SH_SECTION_MISC,
1042 set_syslog_active },
1043#endif
1044 { N_("setusesocket"), SH_SECTION_SRV, SH_SECTION_MISC,
1045 sh_socket_use },
1046 { N_("setsocketallowuid"), SH_SECTION_SRV, SH_SECTION_MISC,
1047 sh_socket_uid },
1048 { N_("setsocketpassword"), SH_SECTION_SRV, SH_SECTION_MISC,
1049 sh_socket_password },
1050 { N_("setstripdomain"), SH_SECTION_SRV, SH_SECTION_MISC,
1051 sh_forward_set_strip },
1052 { N_("useseparatelogs"), SH_SECTION_SRV, SH_SECTION_MISC,
1053 set_flag_sep_log },
1054 { N_("setchrootdir"), SH_SECTION_SRV, SH_SECTION_MISC,
1055 sh_unix_set_chroot },
1056 { N_("setclienttimelimit"), SH_SECTION_SRV, SH_SECTION_MISC,
1057 sh_forward_set_time_limit },
1058 { N_("setconnectiontimeout"),SH_SECTION_SRV, SH_SECTION_MISC,
1059 sh_forward_set_timeout },
1060 { N_("useclientseverity"), SH_SECTION_SRV, SH_SECTION_MISC,
1061 sh_forward_use_clt_sev },
1062 { N_("useclientclass"), SH_SECTION_SRV, SH_SECTION_MISC,
1063 sh_forward_use_clt_class },
1064 { N_("severitylookup"), SH_SECTION_SRV, SH_SECTION_MISC,
1065 sh_forward_lookup_level },
1066 { N_("setclientfromaccept"), SH_SECTION_SRV, SH_SECTION_MISC,
1067 set_socket_peer },
1068 { N_("setserverport"), SH_SECTION_SRV, SH_SECTION_MISC,
1069 sh_forward_set_port },
1070 { N_("setserverinterface"), SH_SECTION_SRV, SH_SECTION_MISC,
1071 sh_forward_set_interface },
1072 { N_("client"), SH_SECTION_CLIENTS, SH_SECTION_NONE,
1073 sh_forward_register_client },
1074#endif
1075
1076#if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
1077 { N_("exportseverity"), SH_SECTION_LOG, SH_SECTION_NONE,
1078 sh_error_setexport },
1079 { N_("exportclass"), SH_SECTION_LOG, SH_SECTION_NONE,
1080 sh_error_export_mask },
1081#if defined(SH_WITH_SERVER)
1082 { N_("setlogserver"), SH_SECTION_SRV, SH_SECTION_MISC,
1083 sh_forward_setlogserver },
1084#else
1085 { N_("setlogserver"), SH_SECTION_CLT, SH_SECTION_MISC,
1086 sh_forward_setlogserver },
1087 { N_("setthrottle"), SH_SECTION_CLT, SH_SECTION_MISC,
1088 sh_forward_set_throttle_delay},
1089#endif
1090#endif
1091 { N_("setfilechecktime"), SH_SECTION_MISC, SH_SECTION_NONE,
1092 sh_readconf_setFiletime },
1093 { N_("setlooptime"), SH_SECTION_MISC, SH_SECTION_NONE,
1094 sh_util_setlooptime },
1095
1096#ifdef SH_WITH_MAIL
1097 { N_("mailseverity"), SH_SECTION_LOG, SH_SECTION_NONE,
1098 sh_error_setseverity },
1099 { N_("mailclass"), SH_SECTION_LOG, SH_SECTION_NONE,
1100 sh_error_mail_mask },
1101 { N_("setmailtime"), SH_SECTION_MAIL, SH_SECTION_MISC,
1102 sh_readconf_setMailtime },
1103 { N_("setmailnum"), SH_SECTION_MAIL, SH_SECTION_MISC,
1104 sh_mail_setNum },
1105 { N_("setmailrelay"), SH_SECTION_MAIL, SH_SECTION_MISC,
1106 sh_mail_set_relay },
1107 { N_("setmailport"), SH_SECTION_MAIL, SH_SECTION_MISC,
1108 sh_mail_set_port },
1109 { N_("mailsingle"), SH_SECTION_MAIL, SH_SECTION_MISC,
1110 sh_mail_setFlag },
1111 { N_("mailsubject"), SH_SECTION_MAIL, SH_SECTION_MISC,
1112 set_mail_subject },
1113 { N_("setmailsender"), SH_SECTION_MAIL, SH_SECTION_MISC,
1114 sh_mail_set_sender },
1115 { N_("setmailalias"), SH_SECTION_MAIL, SH_SECTION_MISC,
1116 sh_nmail_add_alias },
1117 { N_("setmailaddress"), SH_SECTION_MAIL, SH_SECTION_MISC,
1118 sh_nmail_add_recipient },
1119 { N_("closeaddress"), SH_SECTION_MAIL, SH_SECTION_MISC,
1120 sh_nmail_close_recipient },
1121 { N_("setaddrseverity"), SH_SECTION_MAIL, SH_SECTION_MISC,
1122 sh_nmail_set_severity },
1123 { N_("setmailfilternot"), SH_SECTION_MAIL, SH_SECTION_MISC,
1124 sh_nmail_add_not },
1125 { N_("setmailfilterand"), SH_SECTION_MAIL, SH_SECTION_MISC,
1126 sh_nmail_add_and },
1127 { N_("setmailfilteror"), SH_SECTION_MAIL, SH_SECTION_MISC,
1128 sh_nmail_add_or },
1129#endif
1130 { N_("setbindaddress"), SH_SECTION_MISC, SH_SECTION_NONE,
1131 sh_calls_set_bind_addr },
1132 { N_("daemon"), SH_SECTION_MISC, SH_SECTION_NONE,
1133 sh_unix_setdeamon },
1134 { N_("samhainpath"), SH_SECTION_MISC, SH_SECTION_NONE,
1135 sh_unix_self_hash },
1136 { N_("trusteduser"), SH_SECTION_MISC, SH_SECTION_NONE,
1137 tf_add_trusted_user },
1138 { N_("settimeserver"), SH_SECTION_MISC, SH_SECTION_NONE,
1139 sh_unix_settimeserver },
1140
1141 { N_("printseverity"), SH_SECTION_LOG, SH_SECTION_NONE,
1142 sh_error_setprint },
1143 { N_("printclass"), SH_SECTION_LOG, SH_SECTION_NONE,
1144 sh_error_print_mask },
1145
1146 { N_("logseverity"), SH_SECTION_LOG, SH_SECTION_NONE,
1147 sh_error_setlog },
1148 { N_("logclass"), SH_SECTION_LOG, SH_SECTION_NONE,
1149 sh_error_log_mask },
1150
1151 { N_("syslogseverity"), SH_SECTION_LOG, SH_SECTION_NONE,
1152 sh_error_set_syslog },
1153 { N_("syslogclass"), SH_SECTION_LOG, SH_SECTION_NONE,
1154 sh_error_syslog_mask },
1155#ifdef HAVE_LIBPRELUDE
1156 { N_("preludeseverity"), SH_SECTION_LOG, SH_SECTION_NONE,
1157 sh_error_set_prelude },
1158 { N_("preludeclass"), SH_SECTION_LOG, SH_SECTION_NONE,
1159 sh_error_prelude_mask },
1160 { N_("preludeprofile"), SH_SECTION_MISC, SH_SECTION_NONE,
1161 sh_prelude_set_profile },
1162 { N_("preludemaptoinfo"), SH_SECTION_MISC, SH_SECTION_NONE,
1163 sh_prelude_map_info },
1164 { N_("preludemaptolow"), SH_SECTION_MISC, SH_SECTION_NONE,
1165 sh_prelude_map_low },
1166 { N_("preludemaptomedium"), SH_SECTION_MISC, SH_SECTION_NONE,
1167 sh_prelude_map_medium },
1168 { N_("preludemaptohigh"), SH_SECTION_MISC, SH_SECTION_NONE,
1169 sh_prelude_map_high },
1170#endif
1171
1172 { N_("logcalls"), SH_SECTION_LOG, SH_SECTION_NONE,
1173 sh_aud_set_functions },
1174
1175 { N_("messageheader"), SH_SECTION_MISC, SH_SECTION_NONE,
1176 sh_error_ehead },
1177
1178 { N_("setconsole"), SH_SECTION_MISC, SH_SECTION_NONE,
1179 sh_log_set_console },
1180
1181#ifdef WITH_MESSAGE_QUEUE
1182 { N_("messagequeueactive"),SH_SECTION_MISC, SH_SECTION_NONE,
1183 enable_msgq },
1184#endif
1185
1186 { N_("setreverselookup"), SH_SECTION_MISC, SH_SECTION_NONE,
1187 set_reverse_lookup },
1188
1189 { N_("setdatabasepath"), SH_SECTION_MISC, SH_SECTION_NONE,
1190 sh_readconf_set_database_path },
1191
1192 { N_("setlogfilepath"), SH_SECTION_MISC, SH_SECTION_NONE,
1193 sh_readconf_set_logfile_path },
1194
1195 { N_("setlockfilepath"), SH_SECTION_MISC, SH_SECTION_NONE,
1196 sh_readconf_set_lockfile_path },
1197
1198 { N_("hidesetup"), SH_SECTION_MISC, SH_SECTION_NONE,
1199 sh_util_hidesetup },
1200
1201 { N_("syslogfacility"), SH_SECTION_LOG, SH_SECTION_MISC,
1202 sh_log_set_facility },
1203
1204 { N_("syslogmapstampto"), SH_SECTION_LOG, SH_SECTION_MISC,
1205 sh_log_set_stamp_priority },
1206
1207 { N_("mactype"), SH_SECTION_MISC, SH_SECTION_NONE,
1208 sh_util_sigtype },
1209
1210 { NULL, 0, 0, NULL}
1211};
1212
1213
1214
1215
1216static int sh_readconfig_line (char * line)
1217{
1218 char * key;
1219 const char * value;
1220 char * tmp;
1221 int i;
1222 int good_opt = -1;
1223
1224#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
1225 int modnum, modkey;
1226#endif
1227
1228 static const char *dummy = N_("dummy");
1229
1230 static const char *closing[] = {
1231 N_("closecommand"),
1232 N_("closeaddress"),
1233 N_("logmonendgroup"),
1234 N_("logmonendhost"),
1235 NULL
1236 };
1237
1238 static const char *ident[] = {
1239 N_("severityreadonly"),
1240 N_("severitylogfiles"),
1241 N_("severitygrowinglogs"),
1242 N_("severityignorenone"),
1243 N_("severityignoreall"),
1244 N_("severityattributes"),
1245 N_("severitydirs"),
1246 N_("severityfiles"),
1247 N_("severitynames"),
1248 N_("severityuser0"),
1249 N_("severityuser1"),
1250 N_("severityuser2"),
1251 N_("severityuser3"),
1252 N_("severityuser4"),
1253 N_("severityprelink"),
1254 NULL
1255 };
1256
1257 static int identnum[] = {
1258 SH_ERR_T_RO,
1259 SH_ERR_T_LOGS,
1260 SH_ERR_T_GLOG,
1261 SH_ERR_T_NOIG,
1262 SH_ERR_T_ALLIG,
1263 SH_ERR_T_ATTR,
1264 SH_ERR_T_DIR,
1265 SH_ERR_T_FILE,
1266 SH_ERR_T_NAME,
1267 SH_ERR_T_USER0,
1268 SH_ERR_T_USER1,
1269 SH_ERR_T_USER2,
1270 SH_ERR_T_USER3,
1271 SH_ERR_T_USER4,
1272 SH_ERR_T_PRELINK,
1273 };
1274
1275 SL_ENTER(_("sh_readconf_line"));
1276
1277 /* convert to lowercase */
1278
1279 tmp = line;
1280 while (*tmp != '=' && *tmp != '\0')
1281 {
1282 *tmp = tolower( (int) *tmp);
1283 ++tmp;
1284 }
1285
1286 key = line;
1287
1288 /* interpret line */
1289
1290 value = strchr(line, '=');
1291
1292 if (value == NULL || (*value) == '\0')
1293 {
1294 if (key != NULL)
1295 {
1296 i = 0;
1297 while (closing[i] != NULL)
1298 {
1299 if (sl_strncmp(key,_(closing[i]),sl_strlen(closing[i])-1) == 0)
1300 {
1301 value = dummy;
1302 goto ok_novalue;
1303 }
1304 ++i;
1305 }
1306
1307 TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: not key=value: %s>\n"),
1308 line));
1309 }
1310 SL_RETURN(good_opt, _("sh_readconf_line"));
1311 }
1312 else
1313 ++value;
1314
1315 /* skip leading whitespace
1316 */
1317 while ((*value) == ' ' || (*value) == '\t')
1318 ++value;
1319
1320 if ((*value) == '\0') /* no value */
1321 {
1322 if (key != NULL)
1323 {
1324 TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: not key=value: %s>\n"),
1325 line));
1326 }
1327 SL_RETURN(good_opt, _("sh_readconf_line"));
1328 }
1329
1330 ok_novalue:
1331
1332 if (!sl_is_suid())
1333 {
1334 TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: %s>\n"), line));
1335 }
1336
1337 /* Expand shell expressions. This return allocated memory which we must free.
1338 */
1339 value = sh_readconf_expand_value(value);
1340
1341 if (!value || (*value) == '\0')
1342 {
1343 TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: empty after shell expansion: %s>\n"),
1344 line));
1345 SL_RETURN(good_opt, _("sh_readconf_line"));
1346 }
1347
1348#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
1349 if (read_mode == SH_SECTION_OTHER)
1350 {
1351 for (modnum = 0; modList[modnum].name != NULL; ++modnum)
1352 {
1353 for (modkey = 0; modList[modnum].conf_table[modkey].the_opt != NULL;
1354 ++modkey)
1355 {
1356 if (sl_strncmp (key,
1357 _(modList[modnum].conf_table[modkey].the_opt),
1358 sl_strlen(modList[modnum].conf_table[modkey].the_opt) ) == 0)
1359 {
1360 good_opt = 0;
1361 if (0 != modList[modnum].conf_table[modkey].func(value))
1362 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EINVALS,
1363 _(modList[modnum].conf_table[modkey].the_opt), value);
1364 if (!sl_is_suid())
1365 {
1366 TPT(( 0, FIL__, __LINE__,
1367 _("msg=<line = %s, option = %s>\n"), line,
1368 _(modList[modnum].conf_table[modkey].the_opt)));
1369 }
1370 goto outburst;
1371 }
1372 }
1373 }
1374 }
1375 outburst:
1376#endif
1377
1378
1379 if (read_mode == SH_SECTION_THRESHOLD)
1380 {
1381 i = 0;
1382 while (ident[i] != NULL) {
1383 if (sl_strncmp (key, _(ident[i]), sl_strlen(ident[i])-1) == 0)
1384 {
1385 good_opt = 0;
1386 sh_error_set_iv (identnum[i], value);
1387 break;
1388 }
1389 ++i;
1390 }
1391 }
1392 else
1393 {
1394 i = 0;
1395 while (ext_table[i].optname != NULL)
1396 {
1397 if ((ext_table[i].section == read_mode ||
1398 ext_table[i].alt_section == read_mode) &&
1399 sl_strncmp (key, _(ext_table[i].optname),
1400 sl_strlen(ext_table[i].optname)) == 0)
1401 {
1402 good_opt = 0;
1403 if (0 != ext_table[i].func (value))
1404 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EINVALS,
1405 _(ext_table[i].optname), value);
1406 break;
1407 }
1408 ++i;
1409 }
1410 }
1411
1412 SH_FREE((char*)value);
1413
1414 SL_RETURN(good_opt, _("sh_readconf_line"));
1415}
1416
1417
Note: See TracBrowser for help on using the repository browser.