source: trunk/src/sh_readconf.c@ 197

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

Rewrite of code for conditionals in configuration file, supports more tests now (ticket #129).

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