[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"
|
---|
[214] | 36 | #include "sh_nmail.h"
|
---|
[1] | 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"
|
---|
[197] | 46 | #include "sh_tools.h"
|
---|
[1] | 47 |
|
---|
| 48 | #ifdef WITH_DATABASE
|
---|
| 49 | #include "sh_database.h"
|
---|
| 50 | #endif
|
---|
| 51 |
|
---|
[181] | 52 | #ifdef HAVE_LIBPRELUDE
|
---|
[1] | 53 | #include "sh_prelude.h"
|
---|
| 54 | #endif
|
---|
| 55 |
|
---|
[22] | 56 | extern int set_reverse_lookup (const char * c);
|
---|
[1] | 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,
|
---|
[27] | 73 | SH_SECTION_USER2,
|
---|
| 74 | SH_SECTION_USER3,
|
---|
| 75 | SH_SECTION_USER4,
|
---|
[1] | 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 {
|
---|
[170] | 100 | const char * name;
|
---|
[1] | 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},
|
---|
[27] | 115 | { N_("[User2]"), SH_SECTION_USER2},
|
---|
| 116 | { N_("[User3]"), SH_SECTION_USER3},
|
---|
| 117 | { N_("[User4]"), SH_SECTION_USER4},
|
---|
[1] | 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 |
|
---|
[211] | 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 |
|
---|
[197] | 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;
|
---|
[199] | 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 | )
|
---|
[197] | 298 | {
|
---|
| 299 | return 1;
|
---|
| 300 | }
|
---|
| 301 | }
|
---|
| 302 | return retval;
|
---|
| 303 | }
|
---|
[1] | 304 |
|
---|
[199] | 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 |
|
---|
[1] | 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 | */
|
---|
[197] | 351 | int cond_depth = 0;
|
---|
| 352 | int cond_excl = 0;
|
---|
| 353 |
|
---|
[1] | 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;
|
---|
[133] | 365 | char hashbuf[KEYBUF_SIZE];
|
---|
[1] | 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,
|
---|
[160] | 427 | sh_tiger_hash(file_path('C',local_flag), fd, TIGER_NOLIM, hashbuf, sizeof(hashbuf)),
|
---|
[1] | 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();
|
---|
[194] | 435 |
|
---|
| 436 | sh_unix_getline_stealth (0, NULL, 0); /* initialize */
|
---|
| 437 |
|
---|
[1] | 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 | */
|
---|
[197] | 513 | while (isspace((int)*line)) ++line;
|
---|
[1] | 514 |
|
---|
[197] | 515 |
|
---|
[1] | 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 |
|
---|
[197] | 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 | }
|
---|
[199] | 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 | }
|
---|
[197] | 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 |
|
---|
[1] | 584 | /* ------- starts a section ------------ */
|
---|
| 585 |
|
---|
[197] | 586 | else if (line[0] == '[')
|
---|
[1] | 587 | {
|
---|
| 588 | read_mode = SH_SECTION_NONE;
|
---|
| 589 |
|
---|
[197] | 590 | if (0 == sl_strncmp (line, _("[EOF]"), 5)) {
|
---|
| 591 | goto nopel;
|
---|
| 592 | }
|
---|
[1] | 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 |
|
---|
[197] | 642 | else if (read_mode != SH_SECTION_NONE)
|
---|
[1] | 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 | }
|
---|
[197] | 650 | } /* while getline() */
|
---|
[1] | 651 |
|
---|
| 652 | nopel:
|
---|
| 653 |
|
---|
[197] | 654 | if (0 != cond_depth)
|
---|
[1] | 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 |
|
---|
[22] | 676 | int sh_readconf_set_path (char * which, const char * what)
|
---|
[1] | 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 |
|
---|
[22] | 717 | int sh_readconf_set_database_path (const char * what)
|
---|
[1] | 718 | {
|
---|
| 719 | return (sh_readconf_set_path(sh.data.path, what));
|
---|
| 720 | }
|
---|
| 721 |
|
---|
[22] | 722 | int sh_readconf_set_logfile_path (const char * what)
|
---|
[1] | 723 | {
|
---|
| 724 | return (sh_readconf_set_path(sh.srvlog.name, what));
|
---|
| 725 | }
|
---|
| 726 |
|
---|
[22] | 727 | int sh_readconf_set_lockfile_path (const char * what)
|
---|
[1] | 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 |
|
---|
[22] | 741 | int sh_readconf_setTime (const char * str, ShTimerItem what)
|
---|
[1] | 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 |
|
---|
[22] | 770 | int sh_readconf_setMailtime (const char * c)
|
---|
[1] | 771 | {
|
---|
| 772 | return sh_readconf_setTime (c, SET_MAILTIME);
|
---|
| 773 | }
|
---|
| 774 |
|
---|
[22] | 775 | int sh_readconf_setFiletime (const char * c)
|
---|
[1] | 776 | {
|
---|
| 777 | return sh_readconf_setTime (c, SET_FILETIME);
|
---|
| 778 | }
|
---|
| 779 |
|
---|
[22] | 780 | int sh_readconf_set_nice (const char * c)
|
---|
[1] | 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
|
---|
[22] | 800 | int sh_readconf_setCaps(const char * c)
|
---|
[1] | 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 {
|
---|
[170] | 811 | const char * optname;
|
---|
[1] | 812 | ShSectionType section;
|
---|
| 813 | ShSectionType alt_section;
|
---|
[22] | 814 | int (*func)(const char * opt);
|
---|
[1] | 815 | } cfg_options;
|
---|
| 816 |
|
---|
| 817 | #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
|
---|
[22] | 818 | extern int sh_set_schedule_one(const char * str);
|
---|
| 819 | extern int sh_set_schedule_two(const char * str);
|
---|
[1] | 820 | #endif
|
---|
| 821 | #if defined (SH_WITH_SERVER)
|
---|
[22] | 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);
|
---|
[1] | 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 },
|
---|
[164] | 831 | { N_("closecommand"), SH_SECTION_EXTERNAL, SH_SECTION_NONE,
|
---|
| 832 | sh_ext_close_command },
|
---|
[1] | 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,
|
---|
[22] | 854 | sh_error_set_external },
|
---|
[1] | 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 |
|
---|
[22] | 882 |
|
---|
[1] | 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 },
|
---|
[27] | 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 },
|
---|
[1] | 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 },
|
---|
[68] | 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
|
---|
[205] | 956 | { N_("loosedircheck"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 957 | sh_hash_loosedircheck },
|
---|
[1] | 958 | { N_("addokchars"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 959 | sh_util_obscure_ok },
|
---|
[77] | 960 | { N_("filenamesareutf8"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
[68] | 961 | sh_util_obscure_utf8 },
|
---|
[1] | 962 | { N_("setrecursionlevel"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
[22] | 963 | sh_files_setrecursion },
|
---|
[1] | 964 | { N_("checksumtest"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
[22] | 965 | sh_util_setchecksum },
|
---|
[1] | 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 |
|
---|
[196] | 981 | { N_("setdropcache"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 982 | sl_set_drop_cache },
|
---|
| 983 |
|
---|
[1] | 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 |
|
---|
[27] | 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 |
|
---|
[1] | 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 },
|
---|
[22] | 1034 |
|
---|
[1] | 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,
|
---|
[22] | 1051 | sh_forward_set_strip },
|
---|
[1] | 1052 | { N_("useseparatelogs"), SH_SECTION_SRV, SH_SECTION_MISC,
|
---|
| 1053 | set_flag_sep_log },
|
---|
| 1054 | { N_("setchrootdir"), SH_SECTION_SRV, SH_SECTION_MISC,
|
---|
[22] | 1055 | sh_unix_set_chroot },
|
---|
[1] | 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 |
|
---|
[27] | 1074 | #if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
|
---|
[1] | 1075 | { N_("exportseverity"), SH_SECTION_LOG, SH_SECTION_NONE,
|
---|
[22] | 1076 | sh_error_setexport },
|
---|
[1] | 1077 | { N_("exportclass"), SH_SECTION_LOG, SH_SECTION_NONE,
|
---|
| 1078 | sh_error_export_mask },
|
---|
[27] | 1079 | #if defined(SH_WITH_SERVER)
|
---|
| 1080 | { N_("setlogserver"), SH_SECTION_SRV, SH_SECTION_MISC,
|
---|
| 1081 | sh_forward_setlogserver },
|
---|
| 1082 | #else
|
---|
[1] | 1083 | { N_("setlogserver"), SH_SECTION_CLT, SH_SECTION_MISC,
|
---|
| 1084 | sh_forward_setlogserver },
|
---|
| 1085 | #endif
|
---|
[27] | 1086 | #endif
|
---|
[1] | 1087 | { N_("setfilechecktime"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1088 | sh_readconf_setFiletime },
|
---|
| 1089 | { N_("setlooptime"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
[22] | 1090 | sh_util_setlooptime },
|
---|
[1] | 1091 |
|
---|
| 1092 | #ifdef SH_WITH_MAIL
|
---|
| 1093 | { N_("mailseverity"), SH_SECTION_LOG, SH_SECTION_NONE,
|
---|
[22] | 1094 | sh_error_setseverity },
|
---|
[1] | 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_("mailsingle"), SH_SECTION_MAIL, SH_SECTION_MISC,
|
---|
| 1104 | sh_mail_setFlag },
|
---|
| 1105 | { N_("mailsubject"), SH_SECTION_MAIL, SH_SECTION_MISC,
|
---|
| 1106 | set_mail_subject },
|
---|
| 1107 | { N_("setmailsender"), SH_SECTION_MAIL, SH_SECTION_MISC,
|
---|
| 1108 | sh_mail_set_sender },
|
---|
[214] | 1109 | { N_("setmailaddress"), SH_SECTION_MAIL, SH_SECTION_MISC,
|
---|
| 1110 | sh_nmail_add_recipient },
|
---|
| 1111 | { N_("closeaddress"), SH_SECTION_MAIL, SH_SECTION_MISC,
|
---|
| 1112 | sh_nmail_close_recipient },
|
---|
| 1113 | { N_("setaddrseverity"), SH_SECTION_MAIL, SH_SECTION_MISC,
|
---|
| 1114 | sh_nmail_set_severity },
|
---|
[1] | 1115 | { N_("setmailfilternot"), SH_SECTION_MAIL, SH_SECTION_MISC,
|
---|
[214] | 1116 | sh_nmail_add_not },
|
---|
[1] | 1117 | { N_("setmailfilterand"), SH_SECTION_MAIL, SH_SECTION_MISC,
|
---|
[214] | 1118 | sh_nmail_add_and },
|
---|
[1] | 1119 | { N_("setmailfilteror"), SH_SECTION_MAIL, SH_SECTION_MISC,
|
---|
[214] | 1120 | sh_nmail_add_or },
|
---|
[1] | 1121 | #endif
|
---|
| 1122 | { N_("setbindaddress"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
[22] | 1123 | sh_calls_set_bind_addr },
|
---|
[1] | 1124 | { N_("daemon"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
[22] | 1125 | sh_unix_setdeamon },
|
---|
[1] | 1126 | { N_("samhainpath"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1127 | sh_unix_self_hash },
|
---|
| 1128 | { N_("trusteduser"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1129 | tf_add_trusted_user },
|
---|
| 1130 | { N_("settimeserver"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1131 | sh_unix_settimeserver },
|
---|
| 1132 |
|
---|
| 1133 | { N_("printseverity"), SH_SECTION_LOG, SH_SECTION_NONE,
|
---|
[22] | 1134 | sh_error_setprint },
|
---|
[1] | 1135 | { N_("printclass"), SH_SECTION_LOG, SH_SECTION_NONE,
|
---|
| 1136 | sh_error_print_mask },
|
---|
| 1137 |
|
---|
| 1138 | { N_("logseverity"), SH_SECTION_LOG, SH_SECTION_NONE,
|
---|
[22] | 1139 | sh_error_setlog },
|
---|
[1] | 1140 | { N_("logclass"), SH_SECTION_LOG, SH_SECTION_NONE,
|
---|
| 1141 | sh_error_log_mask },
|
---|
| 1142 |
|
---|
| 1143 | { N_("syslogseverity"), SH_SECTION_LOG, SH_SECTION_NONE,
|
---|
[22] | 1144 | sh_error_set_syslog },
|
---|
[1] | 1145 | { N_("syslogclass"), SH_SECTION_LOG, SH_SECTION_NONE,
|
---|
| 1146 | sh_error_syslog_mask },
|
---|
| 1147 | #ifdef HAVE_LIBPRELUDE
|
---|
| 1148 | { N_("preludeseverity"), SH_SECTION_LOG, SH_SECTION_NONE,
|
---|
[22] | 1149 | sh_error_set_prelude },
|
---|
[1] | 1150 | { N_("preludeclass"), SH_SECTION_LOG, SH_SECTION_NONE,
|
---|
| 1151 | sh_error_prelude_mask },
|
---|
| 1152 | { N_("preludeprofile"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1153 | sh_prelude_set_profile },
|
---|
| 1154 | { N_("preludemaptoinfo"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1155 | sh_prelude_map_info },
|
---|
| 1156 | { N_("preludemaptolow"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1157 | sh_prelude_map_low },
|
---|
| 1158 | { N_("preludemaptomedium"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1159 | sh_prelude_map_medium },
|
---|
| 1160 | { N_("preludemaptohigh"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1161 | sh_prelude_map_high },
|
---|
| 1162 | #endif
|
---|
| 1163 |
|
---|
| 1164 | { N_("logcalls"), SH_SECTION_LOG, SH_SECTION_NONE,
|
---|
| 1165 | sh_aud_set_functions },
|
---|
| 1166 |
|
---|
| 1167 | { N_("messageheader"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1168 | sh_error_ehead },
|
---|
| 1169 |
|
---|
| 1170 | { N_("setconsole"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1171 | sh_log_set_console },
|
---|
| 1172 |
|
---|
| 1173 | #ifdef WITH_MESSAGE_QUEUE
|
---|
| 1174 | { N_("messagequeueactive"),SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1175 | enable_msgq },
|
---|
| 1176 | #endif
|
---|
| 1177 |
|
---|
| 1178 | { N_("setreverselookup"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1179 | set_reverse_lookup },
|
---|
| 1180 |
|
---|
| 1181 | { N_("setdatabasepath"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1182 | sh_readconf_set_database_path },
|
---|
| 1183 |
|
---|
| 1184 | { N_("setlogfilepath"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1185 | sh_readconf_set_logfile_path },
|
---|
| 1186 |
|
---|
| 1187 | { N_("setlockfilepath"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1188 | sh_readconf_set_lockfile_path },
|
---|
| 1189 |
|
---|
| 1190 | { N_("hidesetup"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1191 | sh_util_hidesetup },
|
---|
| 1192 |
|
---|
| 1193 | { N_("syslogfacility"), SH_SECTION_LOG, SH_SECTION_MISC,
|
---|
| 1194 | sh_log_set_facility },
|
---|
| 1195 |
|
---|
| 1196 | { N_("mactype"), SH_SECTION_MISC, SH_SECTION_NONE,
|
---|
| 1197 | sh_util_sigtype },
|
---|
| 1198 |
|
---|
| 1199 | { NULL, 0, 0, NULL}
|
---|
| 1200 | };
|
---|
| 1201 |
|
---|
| 1202 |
|
---|
| 1203 |
|
---|
| 1204 |
|
---|
| 1205 | static int sh_readconfig_line (char * line)
|
---|
[164] | 1206 | {
|
---|
| 1207 | char * key;
|
---|
[170] | 1208 | const char * value;
|
---|
[1] | 1209 | char * tmp;
|
---|
| 1210 | int i;
|
---|
| 1211 | int good_opt = -1;
|
---|
| 1212 |
|
---|
| 1213 | #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
|
---|
| 1214 | int modnum, modkey;
|
---|
| 1215 | #endif
|
---|
| 1216 |
|
---|
[170] | 1217 | static const char *dummy = N_("dummy");
|
---|
[164] | 1218 |
|
---|
[170] | 1219 | static const char *closing[] = {
|
---|
[164] | 1220 | N_("closecommand"),
|
---|
[214] | 1221 | N_("closeaddress"),
|
---|
[186] | 1222 | N_("logmonendgroup"),
|
---|
| 1223 | N_("logmonendhost"),
|
---|
[164] | 1224 | NULL
|
---|
| 1225 | };
|
---|
| 1226 |
|
---|
[170] | 1227 | static const char *ident[] = {
|
---|
[1] | 1228 | N_("severityreadonly"),
|
---|
| 1229 | N_("severitylogfiles"),
|
---|
| 1230 | N_("severitygrowinglogs"),
|
---|
| 1231 | N_("severityignorenone"),
|
---|
| 1232 | N_("severityignoreall"),
|
---|
| 1233 | N_("severityattributes"),
|
---|
| 1234 | N_("severitydirs"),
|
---|
| 1235 | N_("severityfiles"),
|
---|
| 1236 | N_("severitynames"),
|
---|
| 1237 | N_("severityuser0"),
|
---|
| 1238 | N_("severityuser1"),
|
---|
[27] | 1239 | N_("severityuser2"),
|
---|
| 1240 | N_("severityuser3"),
|
---|
| 1241 | N_("severityuser4"),
|
---|
[1] | 1242 | N_("severityprelink"),
|
---|
| 1243 | NULL
|
---|
| 1244 | };
|
---|
| 1245 |
|
---|
| 1246 | static int identnum[] = {
|
---|
| 1247 | SH_ERR_T_RO,
|
---|
| 1248 | SH_ERR_T_LOGS,
|
---|
| 1249 | SH_ERR_T_GLOG,
|
---|
| 1250 | SH_ERR_T_NOIG,
|
---|
| 1251 | SH_ERR_T_ALLIG,
|
---|
| 1252 | SH_ERR_T_ATTR,
|
---|
| 1253 | SH_ERR_T_DIR,
|
---|
| 1254 | SH_ERR_T_FILE,
|
---|
| 1255 | SH_ERR_T_NAME,
|
---|
| 1256 | SH_ERR_T_USER0,
|
---|
| 1257 | SH_ERR_T_USER1,
|
---|
[27] | 1258 | SH_ERR_T_USER2,
|
---|
| 1259 | SH_ERR_T_USER3,
|
---|
| 1260 | SH_ERR_T_USER4,
|
---|
[1] | 1261 | SH_ERR_T_PRELINK,
|
---|
| 1262 | };
|
---|
| 1263 |
|
---|
| 1264 | SL_ENTER(_("sh_readconf_line"));
|
---|
| 1265 |
|
---|
[164] | 1266 | /* convert to lowercase */
|
---|
| 1267 |
|
---|
| 1268 | tmp = line;
|
---|
| 1269 | while (*tmp != '=' && *tmp != '\0')
|
---|
| 1270 | {
|
---|
| 1271 | *tmp = tolower( (int) *tmp);
|
---|
| 1272 | ++tmp;
|
---|
| 1273 | }
|
---|
| 1274 |
|
---|
| 1275 | key = line;
|
---|
| 1276 |
|
---|
[1] | 1277 | /* interpret line */
|
---|
| 1278 |
|
---|
[164] | 1279 | value = strchr(line, '=');
|
---|
| 1280 |
|
---|
| 1281 | if (value == NULL || (*value) == '\0')
|
---|
[1] | 1282 | {
|
---|
[164] | 1283 | if (key != NULL)
|
---|
[1] | 1284 | {
|
---|
[164] | 1285 | i = 0;
|
---|
| 1286 | while (closing[i] != NULL)
|
---|
| 1287 | {
|
---|
| 1288 | if (sl_strncmp(key,_(closing[i]),sl_strlen(closing[i])-1) == 0)
|
---|
| 1289 | {
|
---|
| 1290 | value = dummy;
|
---|
| 1291 | goto ok_novalue;
|
---|
| 1292 | }
|
---|
| 1293 | ++i;
|
---|
| 1294 | }
|
---|
| 1295 |
|
---|
[1] | 1296 | TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: not key=value: %s>\n"),
|
---|
| 1297 | line));
|
---|
| 1298 | }
|
---|
| 1299 | SL_RETURN(good_opt, _("sh_readconf_line"));
|
---|
| 1300 | }
|
---|
| 1301 | else
|
---|
[164] | 1302 | ++value;
|
---|
[1] | 1303 |
|
---|
| 1304 | /* skip leading whitespace
|
---|
| 1305 | */
|
---|
[164] | 1306 | while ((*value) == ' ' || (*value) == '\t')
|
---|
| 1307 | ++value;
|
---|
[1] | 1308 |
|
---|
[164] | 1309 | if ((*value) == '\0') /* no value */
|
---|
[1] | 1310 | {
|
---|
[164] | 1311 | if (key != NULL)
|
---|
[1] | 1312 | {
|
---|
| 1313 | TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: not key=value: %s>\n"),
|
---|
| 1314 | line));
|
---|
| 1315 | }
|
---|
| 1316 | SL_RETURN(good_opt, _("sh_readconf_line"));
|
---|
| 1317 | }
|
---|
| 1318 |
|
---|
[164] | 1319 | ok_novalue:
|
---|
[1] | 1320 |
|
---|
| 1321 | if (!sl_is_suid())
|
---|
| 1322 | {
|
---|
| 1323 | TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: %s>\n"), line));
|
---|
| 1324 | }
|
---|
| 1325 |
|
---|
[211] | 1326 | /* Expand shell expressions. This return allocated memory which we must free.
|
---|
| 1327 | */
|
---|
| 1328 | value = sh_readconf_expand_value(value);
|
---|
[1] | 1329 |
|
---|
[211] | 1330 | if (!value || (*value) == '\0')
|
---|
| 1331 | {
|
---|
| 1332 | TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: empty after shell expansion: %s>\n"),
|
---|
| 1333 | line));
|
---|
| 1334 | SL_RETURN(good_opt, _("sh_readconf_line"));
|
---|
| 1335 | }
|
---|
| 1336 |
|
---|
[1] | 1337 | #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
|
---|
| 1338 | if (read_mode == SH_SECTION_OTHER)
|
---|
| 1339 | {
|
---|
| 1340 | for (modnum = 0; modList[modnum].name != NULL; ++modnum)
|
---|
| 1341 | {
|
---|
| 1342 | for (modkey = 0; modList[modnum].conf_table[modkey].the_opt != NULL;
|
---|
| 1343 | ++modkey)
|
---|
| 1344 | {
|
---|
[164] | 1345 | if (sl_strncmp (key,
|
---|
[1] | 1346 | _(modList[modnum].conf_table[modkey].the_opt),
|
---|
| 1347 | sl_strlen(modList[modnum].conf_table[modkey].the_opt) ) == 0)
|
---|
| 1348 | {
|
---|
| 1349 | good_opt = 0;
|
---|
[164] | 1350 | if (0 != modList[modnum].conf_table[modkey].func(value))
|
---|
[1] | 1351 | sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EINVALS,
|
---|
[164] | 1352 | _(modList[modnum].conf_table[modkey].the_opt), value);
|
---|
[1] | 1353 | if (!sl_is_suid())
|
---|
| 1354 | {
|
---|
| 1355 | TPT(( 0, FIL__, __LINE__,
|
---|
| 1356 | _("msg=<line = %s, option = %s>\n"), line,
|
---|
| 1357 | _(modList[modnum].conf_table[modkey].the_opt)));
|
---|
| 1358 | }
|
---|
| 1359 | goto outburst;
|
---|
| 1360 | }
|
---|
| 1361 | }
|
---|
| 1362 | }
|
---|
| 1363 | }
|
---|
| 1364 | outburst:
|
---|
| 1365 | #endif
|
---|
| 1366 |
|
---|
| 1367 |
|
---|
| 1368 | if (read_mode == SH_SECTION_THRESHOLD)
|
---|
| 1369 | {
|
---|
| 1370 | i = 0;
|
---|
| 1371 | while (ident[i] != NULL) {
|
---|
[164] | 1372 | if (sl_strncmp (key, _(ident[i]), sl_strlen(ident[i])-1) == 0)
|
---|
[1] | 1373 | {
|
---|
| 1374 | good_opt = 0;
|
---|
[164] | 1375 | sh_error_set_iv (identnum[i], value);
|
---|
[1] | 1376 | break;
|
---|
| 1377 | }
|
---|
| 1378 | ++i;
|
---|
| 1379 | }
|
---|
| 1380 | }
|
---|
| 1381 | else
|
---|
| 1382 | {
|
---|
| 1383 | i = 0;
|
---|
| 1384 | while (ext_table[i].optname != NULL)
|
---|
| 1385 | {
|
---|
| 1386 | if ((ext_table[i].section == read_mode ||
|
---|
| 1387 | ext_table[i].alt_section == read_mode) &&
|
---|
[164] | 1388 | sl_strncmp (key, _(ext_table[i].optname),
|
---|
[1] | 1389 | sl_strlen(ext_table[i].optname)) == 0)
|
---|
| 1390 | {
|
---|
| 1391 | good_opt = 0;
|
---|
[164] | 1392 | if (0 != ext_table[i].func (value))
|
---|
[1] | 1393 | sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EINVALS,
|
---|
[164] | 1394 | _(ext_table[i].optname), value);
|
---|
[1] | 1395 | break;
|
---|
| 1396 | }
|
---|
| 1397 | ++i;
|
---|
| 1398 | }
|
---|
| 1399 | }
|
---|
| 1400 |
|
---|
[211] | 1401 | SH_FREE((char*)value);
|
---|
| 1402 |
|
---|
[1] | 1403 | SL_RETURN(good_opt, _("sh_readconf_line"));
|
---|
| 1404 | }
|
---|
| 1405 |
|
---|
| 1406 |
|
---|