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