source: trunk/src/sh_readconf.c@ 205

Last change on this file since 205 was 205, checked in by katerina, 16 years ago

New option LooseDirCheck (ticket #132). Also, replace _exit() with raise(SIGKILL).

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