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