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