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