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