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