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 | #include <stdio.h>
|
---|
23 | #include <stdlib.h>
|
---|
24 | #include <stdarg.h>
|
---|
25 | #include <string.h>
|
---|
26 | #include <ctype.h>
|
---|
27 | #include <limits.h>
|
---|
28 | #include <errno.h>
|
---|
29 |
|
---|
30 | /* Required on FreeBSD
|
---|
31 | */
|
---|
32 | #include <sys/types.h>
|
---|
33 |
|
---|
34 | #ifdef HAVE_MEMORY_H
|
---|
35 | #include <memory.h>
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK)
|
---|
39 | #include <sys/mman.h>
|
---|
40 | #endif
|
---|
41 |
|
---|
42 |
|
---|
43 |
|
---|
44 | #include "samhain.h"
|
---|
45 |
|
---|
46 | #include "sh_cat.h"
|
---|
47 | #include "sh_database.h"
|
---|
48 | #include "sh_error.h"
|
---|
49 | #include "sh_utils.h"
|
---|
50 | #include "sh_unix.h"
|
---|
51 | #include "sh_tiger.h"
|
---|
52 | #include "sh_mail.h"
|
---|
53 | #include "sh_forward.h"
|
---|
54 | #include "sh_prelude.h"
|
---|
55 |
|
---|
56 | #if defined(WITH_DATABASE)
|
---|
57 | #include "sh_tools.h"
|
---|
58 | #endif
|
---|
59 |
|
---|
60 | #if defined(WITH_EXTERNAL)
|
---|
61 | #include "sh_extern.h"
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | #undef FIL__
|
---|
65 | #define FIL__ _("sh_error.c")
|
---|
66 | /*@-noret -compmempass@*/
|
---|
67 | extern int clt_class;
|
---|
68 |
|
---|
69 | int flag_err_debug = SL_FALSE;
|
---|
70 | int flag_err_info = SL_FALSE;
|
---|
71 |
|
---|
72 | int ShDFLevel[SH_ERR_T_END];
|
---|
73 |
|
---|
74 | typedef struct _log_t {
|
---|
75 | char file[SH_PATHBUF];
|
---|
76 | char format[SH_PATHBUF];
|
---|
77 | /*@null@*/char * msg;
|
---|
78 | size_t msg_len;
|
---|
79 | int severity;
|
---|
80 | int class;
|
---|
81 | int pid;
|
---|
82 | long status;
|
---|
83 | long line;
|
---|
84 | char timestamp[TIM_MAX];
|
---|
85 | } sh_log_t;
|
---|
86 |
|
---|
87 |
|
---|
88 | struct _errFlags errFlags;
|
---|
89 |
|
---|
90 | static int sh_error_init (void);
|
---|
91 |
|
---|
92 | /*@owned@*//*@null@*/inline
|
---|
93 | static char * get_format(unsigned long msg_id, /*@out@*/int * priority,
|
---|
94 | /*@out@*/unsigned int * class);
|
---|
95 |
|
---|
96 | static int sh_error_string (struct _log_t * lmsg, va_list vl);
|
---|
97 |
|
---|
98 | extern int sh_log_console (/*@null@*/char *message);
|
---|
99 | extern int sh_log_syslog (int severity, /*@null@*/char *message);
|
---|
100 | extern int sh_log_file (/*@null@*/char *message,
|
---|
101 | /*@null@*/char * inet_peer);
|
---|
102 | /* convert a string to a numeric priority
|
---|
103 | */
|
---|
104 | int sh_error_convert_level (char * str_s);
|
---|
105 |
|
---|
106 | static int IsInitialized = BAD;
|
---|
107 |
|
---|
108 | /* --- Only log to stderr. ---
|
---|
109 | */
|
---|
110 | int OnlyStderr = S_TRUE;
|
---|
111 |
|
---|
112 |
|
---|
113 | /*********************************************
|
---|
114 | * utility functions for verifying entries
|
---|
115 | *********************************************/
|
---|
116 |
|
---|
117 | int sh_error_verify (char * s)
|
---|
118 | {
|
---|
119 | char * foo;
|
---|
120 |
|
---|
121 | if (s[0] == '/')
|
---|
122 | {
|
---|
123 | foo = sh_tiger_hash_gpg (s, TIGER_FILE, 0);
|
---|
124 | fprintf (stdout, _("%s\n"), foo);
|
---|
125 | SH_FREE(foo);
|
---|
126 | }
|
---|
127 | else
|
---|
128 | {
|
---|
129 | fprintf (stdout, _("string=<%s>, hash=<%s>\n"),
|
---|
130 | s, sh_tiger_hash (s, TIGER_DATA,
|
---|
131 | (unsigned long) sl_strlen(s)));
|
---|
132 | }
|
---|
133 | (void) fflush(stdout);
|
---|
134 | _exit (EXIT_SUCCESS);
|
---|
135 | /*@i@*/return 0;
|
---|
136 | }
|
---|
137 |
|
---|
138 |
|
---|
139 |
|
---|
140 | /*********************************************
|
---|
141 | * end utility functions
|
---|
142 | *********************************************/
|
---|
143 |
|
---|
144 | void sh_error_only_stderr (int flag)
|
---|
145 | {
|
---|
146 | OnlyStderr = flag;
|
---|
147 | return;
|
---|
148 | }
|
---|
149 |
|
---|
150 | static int dbg_store = 0;
|
---|
151 | static int dbg_flag = 0;
|
---|
152 |
|
---|
153 | static
|
---|
154 | void compute_flag_err_debug()
|
---|
155 | {
|
---|
156 | if ((errFlags.loglevel & SH_ERR_ALL) != 0)
|
---|
157 | flag_err_debug = SL_TRUE;
|
---|
158 | else if ((errFlags.printlevel & SH_ERR_ALL) != 0)
|
---|
159 | flag_err_debug = SL_TRUE;
|
---|
160 | else if ((errFlags.maillevel & SH_ERR_ALL) != 0)
|
---|
161 | flag_err_debug = SL_TRUE;
|
---|
162 | else if ((errFlags.exportlevel & SH_ERR_ALL) != 0)
|
---|
163 | flag_err_debug = SL_TRUE;
|
---|
164 | else if ((errFlags.sysloglevel & SH_ERR_ALL) != 0)
|
---|
165 | flag_err_debug = SL_TRUE;
|
---|
166 | else if ((errFlags.externallevel & SH_ERR_ALL) != 0)
|
---|
167 | flag_err_debug = SL_TRUE;
|
---|
168 | else if ((errFlags.databaselevel & SH_ERR_ALL) != 0)
|
---|
169 | flag_err_debug = SL_TRUE;
|
---|
170 | else if ((errFlags.preludelevel & SH_ERR_ALL) != 0)
|
---|
171 | flag_err_debug = SL_TRUE;
|
---|
172 | else
|
---|
173 | flag_err_debug = SL_FALSE;
|
---|
174 | return;
|
---|
175 | }
|
---|
176 |
|
---|
177 | static
|
---|
178 | void compute_flag_err_info()
|
---|
179 | {
|
---|
180 | if ((errFlags.loglevel & SH_ERR_INFO) != 0)
|
---|
181 | flag_err_info = SL_TRUE;
|
---|
182 | else if ((errFlags.printlevel & SH_ERR_INFO) != 0)
|
---|
183 | flag_err_info = SL_TRUE;
|
---|
184 | else if ((errFlags.maillevel & SH_ERR_INFO) != 0)
|
---|
185 | flag_err_info = SL_TRUE;
|
---|
186 | else if ((errFlags.exportlevel & SH_ERR_INFO) != 0)
|
---|
187 | flag_err_info = SL_TRUE;
|
---|
188 | else if ((errFlags.sysloglevel & SH_ERR_INFO) != 0)
|
---|
189 | flag_err_info = SL_TRUE;
|
---|
190 | else if ((errFlags.externallevel & SH_ERR_INFO) != 0)
|
---|
191 | flag_err_info = SL_TRUE;
|
---|
192 | else if ((errFlags.databaselevel & SH_ERR_INFO) != 0)
|
---|
193 | flag_err_info = SL_TRUE;
|
---|
194 | else if ((errFlags.preludelevel & SH_ERR_INFO) != 0)
|
---|
195 | flag_err_info = SL_TRUE;
|
---|
196 | else
|
---|
197 | flag_err_info = SL_FALSE;
|
---|
198 | return;
|
---|
199 | }
|
---|
200 |
|
---|
201 | void sh_error_dbg_switch()
|
---|
202 | {
|
---|
203 | if (dbg_flag == 0)
|
---|
204 | {
|
---|
205 | dbg_store = errFlags.printlevel;
|
---|
206 | errFlags.printlevel = (SH_ERR_ALL | SH_ERR_INFO | SH_ERR_NOTICE |
|
---|
207 | SH_ERR_WARN | SH_ERR_STAMP | SH_ERR_ERR |
|
---|
208 | SH_ERR_SEVERE | SH_ERR_FATAL);
|
---|
209 | dbg_flag = 1;
|
---|
210 | flag_err_debug = SL_TRUE;
|
---|
211 | }
|
---|
212 | else {
|
---|
213 | errFlags.printlevel = dbg_store;
|
---|
214 | dbg_store = 0;
|
---|
215 | dbg_flag = 0;
|
---|
216 | compute_flag_err_debug();
|
---|
217 | }
|
---|
218 | return;
|
---|
219 | }
|
---|
220 |
|
---|
221 | static int sh_error_set_classmask (/*@notnull@*/char * c, int * facility_mask)
|
---|
222 | {
|
---|
223 | char * p;
|
---|
224 | int num = 0;
|
---|
225 | unsigned int i;
|
---|
226 | size_t len;
|
---|
227 |
|
---|
228 | SL_ENTER(_("sh_error_set_classmask"));
|
---|
229 |
|
---|
230 | if (c == NULL)
|
---|
231 | SL_RETURN( -1, _("sh_error_set_classmask"));
|
---|
232 |
|
---|
233 | if (IsInitialized == BAD)
|
---|
234 | (void) sh_error_init();
|
---|
235 |
|
---|
236 | if (c[0] == (char) 34)
|
---|
237 | ++c;
|
---|
238 | len = strlen(c);
|
---|
239 | if (c[len-1] == (char) 34)
|
---|
240 | c[len-1] = '\0';
|
---|
241 |
|
---|
242 | *facility_mask = 0;
|
---|
243 |
|
---|
244 | do {
|
---|
245 | if (num == 0)
|
---|
246 | {
|
---|
247 | p = strtok (c, " ,\t");
|
---|
248 | ++num;
|
---|
249 | }
|
---|
250 | else
|
---|
251 | p = strtok (NULL, " ,\t");
|
---|
252 |
|
---|
253 | if (p == NULL)
|
---|
254 | break;
|
---|
255 |
|
---|
256 | for (i = 0; i < SH_CLA_MAX; ++i)
|
---|
257 | {
|
---|
258 | if (i < SH_CLA_RAW_MAX) {
|
---|
259 | if (0 == strcmp(p, _(class_cat[i])))
|
---|
260 | *facility_mask |= (1 << i);
|
---|
261 | } else {
|
---|
262 | if (0 == strcmp(p, _(class_cat[SH_CLA_RAW_MAX + 0])))
|
---|
263 | *facility_mask |= OTHER_CLA;
|
---|
264 | if (0 == strcmp(p, _(class_cat[SH_CLA_RAW_MAX + 1])))
|
---|
265 | *facility_mask |= RUN_NEW;
|
---|
266 | if (0 == strcmp(p, _(class_cat[SH_CLA_RAW_MAX + 2])))
|
---|
267 | *facility_mask |= FIL_NEW;
|
---|
268 | if (0 == strcmp(p, _(class_cat[SH_CLA_RAW_MAX + 3])))
|
---|
269 | *facility_mask |= ERROR_CLA;
|
---|
270 | }
|
---|
271 | }
|
---|
272 |
|
---|
273 | } while (p);
|
---|
274 |
|
---|
275 | SL_RETURN( 0, _("sh_error_set_classmask"));
|
---|
276 | }
|
---|
277 |
|
---|
278 | int sh_error_log_mask (char * c)
|
---|
279 | {
|
---|
280 | return (sh_error_set_classmask(c, &(errFlags.log_class)));
|
---|
281 | }
|
---|
282 | int sh_error_mail_mask (char * c)
|
---|
283 | {
|
---|
284 | return (sh_error_set_classmask(c, &(errFlags.mail_class)));
|
---|
285 | }
|
---|
286 | int sh_error_print_mask (char * c)
|
---|
287 | {
|
---|
288 | return (sh_error_set_classmask(c, &(errFlags.print_class)));
|
---|
289 | }
|
---|
290 | int sh_error_export_mask (char * c)
|
---|
291 | {
|
---|
292 | return (sh_error_set_classmask(c, &(errFlags.export_class)));
|
---|
293 | }
|
---|
294 | int sh_error_syslog_mask (char * c)
|
---|
295 | {
|
---|
296 | return (sh_error_set_classmask(c, &(errFlags.syslog_class)));
|
---|
297 | }
|
---|
298 | int sh_error_external_mask (char * c)
|
---|
299 | {
|
---|
300 | return (sh_error_set_classmask(c, &(errFlags.external_class)));
|
---|
301 | }
|
---|
302 | int sh_error_database_mask (char * c)
|
---|
303 | {
|
---|
304 | return (sh_error_set_classmask(c, &(errFlags.database_class)));
|
---|
305 | }
|
---|
306 | int sh_error_prelude_mask (char * c)
|
---|
307 | {
|
---|
308 | return (sh_error_set_classmask(c, &(errFlags.prelude_class)));
|
---|
309 | }
|
---|
310 |
|
---|
311 |
|
---|
312 |
|
---|
313 | /*@owned@*/char * sh_error_message (int tellme)
|
---|
314 | {
|
---|
315 |
|
---|
316 | #if defined(HAVE_STRERROR)
|
---|
317 | /*@i@*/return strerror(tellme);
|
---|
318 | #else
|
---|
319 |
|
---|
320 | #ifdef EACCES
|
---|
321 | if (tellme == EACCES) return _("Permission denied.");
|
---|
322 | #endif
|
---|
323 | #ifdef EAGAIN
|
---|
324 | if (tellme == EAGAIN) return _("Try again.");
|
---|
325 | #endif
|
---|
326 | #ifdef EBADF
|
---|
327 | if (tellme == EBADF) return _("File descriptor in bad state.");
|
---|
328 | #endif
|
---|
329 | #ifdef EEXIST
|
---|
330 | if (tellme == EEXIST) return _("File exists.");
|
---|
331 | #endif
|
---|
332 | #ifdef EFAULT
|
---|
333 | if (tellme == EFAULT) return _("Bad address.");
|
---|
334 | #endif
|
---|
335 | #ifdef EINVAL
|
---|
336 | if (tellme == EINVAL) return _("Invalid argument.");
|
---|
337 | #endif
|
---|
338 | #ifdef EISDIR
|
---|
339 | if (tellme == EISDIR) return _("Is a directory.");
|
---|
340 | #endif
|
---|
341 | #ifdef EINTR
|
---|
342 | if (tellme == EINTR) return _("System call was interrupted.");
|
---|
343 | #endif
|
---|
344 | #ifdef EIO
|
---|
345 | if (tellme == EIO) return _("Low-level I/O error.");
|
---|
346 | #endif
|
---|
347 | #ifdef ELOOP
|
---|
348 | if (tellme == ELOOP) return _("Too many symbolic links encountered.");
|
---|
349 | #endif
|
---|
350 | #ifdef EMFILE
|
---|
351 | if (tellme == EMFILE) return _("Too many open files.");
|
---|
352 | #endif
|
---|
353 | #ifdef EMLINK
|
---|
354 | if (tellme == EMLINK) return _("Too many links.");
|
---|
355 | #endif
|
---|
356 | #ifdef ENAMETOOLONG
|
---|
357 | if (tellme == ENAMETOOLONG)
|
---|
358 | return _("File name too long.");
|
---|
359 | #endif
|
---|
360 | #ifdef ENFILE
|
---|
361 | if (tellme == ENFILE) return _("File table overflow.");
|
---|
362 | #endif
|
---|
363 | #ifdef ENOENT
|
---|
364 | if (tellme == ENOENT) return _("File does not exist.");
|
---|
365 | #endif
|
---|
366 | #ifdef ENOMEM
|
---|
367 | if (tellme == ENOMEM) return _("Out of memory.");
|
---|
368 | #endif
|
---|
369 | #ifdef ENOSPC
|
---|
370 | if (tellme == ENOSPC) return _("No space on device.");
|
---|
371 | #endif
|
---|
372 | #ifdef ENOTDIR
|
---|
373 | if (tellme == ENOTDIR) return _("Not a directory.");
|
---|
374 | #endif
|
---|
375 | #ifdef ENOTSOCK
|
---|
376 | if (tellme == ENOTSOCK) return _("Not a socket.");
|
---|
377 | #endif
|
---|
378 | #ifdef EOPNOTSUPP
|
---|
379 | if (tellme == EOPNOTSUPP) return _("Socket is not of type SOCK_STREAM.");
|
---|
380 | #endif
|
---|
381 | #ifdef EPERM
|
---|
382 | if (tellme == EPERM) return _("Permission denied.");
|
---|
383 | #endif
|
---|
384 | #ifdef EPIPE
|
---|
385 | if (tellme == EPIPE) return _("No read on pipe.");
|
---|
386 | #endif
|
---|
387 | #ifdef EROFS
|
---|
388 | if (tellme == EROFS) return _("Read-only file system.");
|
---|
389 | #endif
|
---|
390 | #ifdef ETXTBSY
|
---|
391 | if (tellme == ETXTBSY) return _("Text file busy.");
|
---|
392 | #endif
|
---|
393 | #ifdef EWOULDBLOCK
|
---|
394 | if (tellme == EWOULDBLOCK)
|
---|
395 | return _("No connections on non-blocking socket.");
|
---|
396 | #endif
|
---|
397 | #ifdef EXDEV
|
---|
398 | if (tellme == EXDEV) return _("Not on same file system.");
|
---|
399 | #endif
|
---|
400 | return _("Unknown error");
|
---|
401 | #endif /* ifndef HAVE_STRERROR */
|
---|
402 | }
|
---|
403 |
|
---|
404 |
|
---|
405 | /* switch off file log
|
---|
406 | */
|
---|
407 | void sh_error_logoff()
|
---|
408 | {
|
---|
409 | errFlags.HaveLog = BAD;
|
---|
410 | return;
|
---|
411 | }
|
---|
412 |
|
---|
413 | /* switch on file log
|
---|
414 | */
|
---|
415 | void sh_error_logrestore()
|
---|
416 | {
|
---|
417 | errFlags.HaveLog = GOOD;
|
---|
418 | return;
|
---|
419 | }
|
---|
420 |
|
---|
421 | /* --- Relate priority levels to literals. ---
|
---|
422 | */
|
---|
423 | typedef struct eef
|
---|
424 | {
|
---|
425 | char * str;
|
---|
426 | int val;
|
---|
427 | } eef_struc;
|
---|
428 |
|
---|
429 | static eef_struc eef_tab[] =
|
---|
430 | {
|
---|
431 | { N_("none"), SH_ERR_NOT },
|
---|
432 | { N_("debug"), SH_ERR_ALL },
|
---|
433 | { N_("info"), SH_ERR_INFO },
|
---|
434 | { N_("notice"), SH_ERR_NOTICE },
|
---|
435 | { N_("warn"), SH_ERR_WARN },
|
---|
436 | { N_("mark"), SH_ERR_STAMP },
|
---|
437 | { N_("err"), SH_ERR_ERR },
|
---|
438 | { N_("crit"), SH_ERR_SEVERE },
|
---|
439 | { N_("alert"), SH_ERR_FATAL },
|
---|
440 | #if defined(SH_WITH_SERVER)
|
---|
441 | #define SH_EEF_MAX 10
|
---|
442 | { N_("inet"), SH_ERR_INET },
|
---|
443 | #else
|
---|
444 | #define SH_EEF_MAX 9
|
---|
445 | #endif
|
---|
446 | };
|
---|
447 |
|
---|
448 | int sh_error_convert_level (char * str_s)
|
---|
449 | {
|
---|
450 | int i;
|
---|
451 | int level = (-1);
|
---|
452 |
|
---|
453 | SL_ENTER(_("sh_error_convert_level"));
|
---|
454 |
|
---|
455 | if (str_s == NULL)
|
---|
456 | SL_RETURN( -1, _("sh_error_convert_level"));
|
---|
457 |
|
---|
458 | for (i = 0; i < SH_EEF_MAX; ++i)
|
---|
459 | {
|
---|
460 | if (0 == sl_strncmp(str_s, _(eef_tab[i].str),
|
---|
461 | sl_strlen(eef_tab[i].str)))
|
---|
462 | {
|
---|
463 | level = eef_tab[i].val;
|
---|
464 | break;
|
---|
465 | }
|
---|
466 | }
|
---|
467 |
|
---|
468 | SL_RETURN( level, _("sh_error_convert_level"));
|
---|
469 | }
|
---|
470 |
|
---|
471 |
|
---|
472 | /* --- Set severity levels. ---
|
---|
473 | */
|
---|
474 | int sh_error_set_iv (int iv, char * str_s)
|
---|
475 | {
|
---|
476 | int level = (-1);
|
---|
477 |
|
---|
478 | SL_ENTER(_("sh_error_set_iv"));
|
---|
479 |
|
---|
480 | if (IsInitialized == BAD)
|
---|
481 | (void) sh_error_init();
|
---|
482 |
|
---|
483 | level = sh_error_convert_level (str_s);
|
---|
484 |
|
---|
485 | if (level == (-1))
|
---|
486 | {
|
---|
487 | sh_error_handle ((-1), FIL__, __LINE__, EINVAL, MSG_EINVALS,
|
---|
488 | _("severity"),
|
---|
489 | str_s != NULL ? str_s : _("(NULL)"));
|
---|
490 | SL_RETURN (-1, _("sh_error_set_iv"));
|
---|
491 | }
|
---|
492 |
|
---|
493 | if (iv > SH_ERR_T_START && iv < SH_ERR_T_END)
|
---|
494 | {
|
---|
495 | ShDFLevel[iv] = level;
|
---|
496 | }
|
---|
497 | else
|
---|
498 | {
|
---|
499 | sh_error_handle ((-1), FIL__, __LINE__, EINVAL, MSG_EINVALL,
|
---|
500 | _("severity"), (long) iv);
|
---|
501 | SL_RETURN (-1, _("sh_error_set_iv"));
|
---|
502 | }
|
---|
503 | SL_RETURN (0, _("sh_error_set_iv"));
|
---|
504 | }
|
---|
505 |
|
---|
506 | int sh_error_set_level(char * str_in, int * facility)
|
---|
507 | {
|
---|
508 | register int i, j, f = BAD;
|
---|
509 |
|
---|
510 | int old_facility;
|
---|
511 | char * str_s = str_in;
|
---|
512 |
|
---|
513 | SL_ENTER(_("sh_error_set_level"));
|
---|
514 |
|
---|
515 | if (IsInitialized == BAD)
|
---|
516 | (void) sh_error_init();
|
---|
517 |
|
---|
518 | old_facility = *facility;
|
---|
519 | *facility = 0;
|
---|
520 |
|
---|
521 | checkstr:
|
---|
522 |
|
---|
523 | if (str_s != NULL)
|
---|
524 | {
|
---|
525 | if (0 == sl_strncmp(str_s, _(eef_tab[0].str), sl_strlen(eef_tab[0].str)))
|
---|
526 | {
|
---|
527 | *facility |= eef_tab[0].val; /* This is 'none' */
|
---|
528 | for (i = 1; i < SH_EEF_MAX; ++i)
|
---|
529 | *facility &= ~eef_tab[i].val;
|
---|
530 | f = GOOD;
|
---|
531 | }
|
---|
532 | else if (str_s[0] == '*') /* all */
|
---|
533 | {
|
---|
534 | for (i = 1; i < SH_EEF_MAX; ++i)
|
---|
535 | *facility |= eef_tab[i].val;
|
---|
536 | f = GOOD;
|
---|
537 | }
|
---|
538 | else if (str_s[0] == '=')
|
---|
539 | {
|
---|
540 | for (i = 1; i < SH_EEF_MAX; ++i)
|
---|
541 | if (0 == sl_strncmp(&str_s[1], _(eef_tab[i].str),
|
---|
542 | sl_strlen(eef_tab[i].str)))
|
---|
543 | {
|
---|
544 | *facility |= eef_tab[i].val;
|
---|
545 | f = GOOD;
|
---|
546 | }
|
---|
547 | }
|
---|
548 | else if (str_s[0] == '!')
|
---|
549 | {
|
---|
550 | if (str_s[1] == '*' ||
|
---|
551 | 0 == sl_strncmp(&str_s[1], _(eef_tab[1].str),
|
---|
552 | sl_strlen(eef_tab[1].str)))
|
---|
553 | {
|
---|
554 | *facility |= eef_tab[0].val; /* This is 'none' */
|
---|
555 | for (i = 1; i < SH_EEF_MAX; ++i)
|
---|
556 | *facility &= ~eef_tab[i].val;
|
---|
557 | f = GOOD;
|
---|
558 | }
|
---|
559 | else if (str_s[1] == '=')
|
---|
560 | {
|
---|
561 | for (i = 1; i < SH_EEF_MAX; ++i)
|
---|
562 | {
|
---|
563 | if (0 == sl_strncmp(&str_s[2], _(eef_tab[i].str),
|
---|
564 | sl_strlen(eef_tab[i].str)))
|
---|
565 | {
|
---|
566 | *facility &= ~eef_tab[i].val;
|
---|
567 | f = GOOD;
|
---|
568 | }
|
---|
569 | }
|
---|
570 | }
|
---|
571 | else
|
---|
572 | {
|
---|
573 | for (i = 1; i < SH_EEF_MAX; ++i)
|
---|
574 | {
|
---|
575 | if (0 == sl_strncmp(&str_s[1], _(eef_tab[i].str),
|
---|
576 | sl_strlen(eef_tab[i].str)))
|
---|
577 | {
|
---|
578 | for (j = i; j < SH_EEF_MAX; ++j)
|
---|
579 | {
|
---|
580 | *facility &= ~eef_tab[j].val;
|
---|
581 | }
|
---|
582 | f = GOOD;
|
---|
583 | }
|
---|
584 | }
|
---|
585 | }
|
---|
586 | }
|
---|
587 | else /* plain severity name */
|
---|
588 | {
|
---|
589 | for (i = 1; i < SH_EEF_MAX; ++i)
|
---|
590 | {
|
---|
591 | if (0 == sl_strncmp(str_s, _(eef_tab[i].str),
|
---|
592 | sl_strlen(eef_tab[i].str)))
|
---|
593 | {
|
---|
594 | for (j = i; j < SH_EEF_MAX; ++j)
|
---|
595 | {
|
---|
596 | *facility |= eef_tab[j].val;
|
---|
597 | }
|
---|
598 | f = GOOD;
|
---|
599 | break;
|
---|
600 | }
|
---|
601 | }
|
---|
602 | }
|
---|
603 | }
|
---|
604 |
|
---|
605 | /* skip to end of string
|
---|
606 | */
|
---|
607 | while (*str_s != '\0' && *str_s != ';' && *str_s != ',' &&
|
---|
608 | *str_s != ' ' && *str_s != '\t')
|
---|
609 | ++str_s;
|
---|
610 |
|
---|
611 | /* skip seperator
|
---|
612 | */
|
---|
613 | while ((*str_s != '\0') &&
|
---|
614 | (*str_s == ';' || *str_s == ',' || *str_s == ' ' || *str_s == '\t'))
|
---|
615 | ++str_s;
|
---|
616 |
|
---|
617 | if (*str_s != '\0')
|
---|
618 | {
|
---|
619 | f = BAD;
|
---|
620 | goto checkstr;
|
---|
621 | }
|
---|
622 |
|
---|
623 | if (f == BAD)
|
---|
624 | {
|
---|
625 | *facility = old_facility;
|
---|
626 | sh_error_handle ((-1), FIL__, __LINE__, EINVAL, MSG_EINVALS,
|
---|
627 | _("priority"), str_in);
|
---|
628 | SL_RETURN (-1, _("sh_error_set_level"));
|
---|
629 | }
|
---|
630 | compute_flag_err_debug();
|
---|
631 | compute_flag_err_info();
|
---|
632 | SL_RETURN (0, _("sh_error_set_level"));
|
---|
633 | }
|
---|
634 |
|
---|
635 | #ifdef SH_WITH_CLIENT
|
---|
636 | /* set severity for TCP export
|
---|
637 | */
|
---|
638 | int sh_error_setexport(char * str_s)
|
---|
639 | {
|
---|
640 | static int reject = 0;
|
---|
641 | if (reject == 1)
|
---|
642 | return (0);
|
---|
643 |
|
---|
644 | if (sh.flag.opts == S_TRUE)
|
---|
645 | reject = 1;
|
---|
646 |
|
---|
647 | return (sh_error_set_level(str_s, &errFlags.exportlevel));
|
---|
648 | }
|
---|
649 | #endif
|
---|
650 |
|
---|
651 | /* set severity for printing
|
---|
652 | */
|
---|
653 | extern void dlog_set_active(int flag);
|
---|
654 |
|
---|
655 | int sh_error_setprint(char * str_s)
|
---|
656 | {
|
---|
657 | static int reject = 0;
|
---|
658 | int retval;
|
---|
659 |
|
---|
660 | if (reject == 1)
|
---|
661 | return (0);
|
---|
662 |
|
---|
663 | if (sh.flag.opts == S_TRUE)
|
---|
664 | reject = 1;
|
---|
665 |
|
---|
666 | retval = sh_error_set_level(str_s, &errFlags.printlevel);
|
---|
667 |
|
---|
668 | if (0 != (errFlags.printlevel & SH_ERR_INFO))
|
---|
669 | dlog_set_active(1);
|
---|
670 | if (0 != (errFlags.printlevel & SH_ERR_ALL))
|
---|
671 | dlog_set_active(2);
|
---|
672 | return retval;
|
---|
673 | }
|
---|
674 |
|
---|
675 |
|
---|
676 | /* set level for error logging
|
---|
677 | */
|
---|
678 | int sh_error_setlog(char * str_s)
|
---|
679 | {
|
---|
680 | static int reject = 0;
|
---|
681 | if (reject == 1)
|
---|
682 | return (0);
|
---|
683 |
|
---|
684 | if (sh.flag.opts == S_TRUE)
|
---|
685 | reject = 1;
|
---|
686 |
|
---|
687 | return ( sh_error_set_level(str_s, &errFlags.loglevel) );
|
---|
688 | }
|
---|
689 |
|
---|
690 |
|
---|
691 | /* set severity for syslog
|
---|
692 | */
|
---|
693 | int sh_error_set_syslog (char * str_s)
|
---|
694 | {
|
---|
695 | static int reject = 0;
|
---|
696 | if (reject == 1)
|
---|
697 | return (0);
|
---|
698 |
|
---|
699 | if (sh.flag.opts == S_TRUE)
|
---|
700 | reject = 1;
|
---|
701 |
|
---|
702 | return (sh_error_set_level(str_s, &errFlags.sysloglevel));
|
---|
703 | }
|
---|
704 |
|
---|
705 | #if defined(WITH_EXTERNAL)
|
---|
706 | /* set severity for external
|
---|
707 | */
|
---|
708 | int sh_error_set_external (char * str_s)
|
---|
709 | {
|
---|
710 | static int reject = 0;
|
---|
711 | if (reject == 1)
|
---|
712 | return (0);
|
---|
713 |
|
---|
714 | if (sh.flag.opts == S_TRUE)
|
---|
715 | reject = 1;
|
---|
716 |
|
---|
717 | return (sh_error_set_level(str_s, &errFlags.externallevel));
|
---|
718 | }
|
---|
719 | #endif
|
---|
720 |
|
---|
721 | #if defined(WITH_DATABASE)
|
---|
722 | /* set severity for database
|
---|
723 | */
|
---|
724 | int sh_error_set_database (char * str_s)
|
---|
725 | {
|
---|
726 | static int reject = 0;
|
---|
727 | if (reject == 1)
|
---|
728 | return (0);
|
---|
729 |
|
---|
730 | if (sh.flag.opts == S_TRUE)
|
---|
731 | reject = 1;
|
---|
732 |
|
---|
733 | return (sh_error_set_level(str_s, &errFlags.databaselevel));
|
---|
734 | }
|
---|
735 | #endif
|
---|
736 |
|
---|
737 | #if defined(HAVE_LIBPRELUDE)
|
---|
738 | /* set severity for prelude
|
---|
739 | */
|
---|
740 | int sh_error_set_prelude (char * str_s)
|
---|
741 | {
|
---|
742 | static int reject = 0;
|
---|
743 |
|
---|
744 | if (reject == 1)
|
---|
745 | return (0);
|
---|
746 |
|
---|
747 | if (sh.flag.opts == S_TRUE)
|
---|
748 | reject = 1;
|
---|
749 |
|
---|
750 | return sh_error_set_level(str_s, &errFlags.preludelevel);
|
---|
751 | }
|
---|
752 | #endif
|
---|
753 |
|
---|
754 | /* init or re-init log facilities that need it
|
---|
755 | */
|
---|
756 | void sh_error_fixup()
|
---|
757 | {
|
---|
758 | #if defined(HAVE_LIBPRELUDE_9)
|
---|
759 | if ((errFlags.preludelevel & SH_ERR_NOT) == 0)
|
---|
760 | sh_prelude_init();
|
---|
761 | else
|
---|
762 | sh_prelude_stop();
|
---|
763 | #endif
|
---|
764 | #ifdef WITH_DATABASE
|
---|
765 | sh_database_reset();
|
---|
766 | #endif
|
---|
767 | return;
|
---|
768 | }
|
---|
769 |
|
---|
770 | /* to be called from sh_prelude_reset
|
---|
771 | */
|
---|
772 | void sh_error_init_prelude()
|
---|
773 | {
|
---|
774 | #if defined(HAVE_LIBPRELUDE_9)
|
---|
775 | if ((errFlags.preludelevel & SH_ERR_NOT) == 0)
|
---|
776 | sh_prelude_init();
|
---|
777 | else
|
---|
778 | sh_prelude_stop();
|
---|
779 | #endif
|
---|
780 | return;
|
---|
781 | }
|
---|
782 |
|
---|
783 |
|
---|
784 | /* set severity for mailing
|
---|
785 | */
|
---|
786 | int sh_error_setseverity (char * str_s)
|
---|
787 | {
|
---|
788 | static int reject = 0;
|
---|
789 | if (reject == 1)
|
---|
790 | return (0);
|
---|
791 |
|
---|
792 | if (sh.flag.opts == S_TRUE)
|
---|
793 | reject = 1;
|
---|
794 |
|
---|
795 | return (sh_error_set_level(str_s, &errFlags.maillevel));
|
---|
796 | }
|
---|
797 |
|
---|
798 | #ifdef SH_WITH_SERVER
|
---|
799 | static char inet_peer[SH_MINIBUF] = { '\0' };
|
---|
800 |
|
---|
801 | void sh_error_set_peer(const char * str)
|
---|
802 | {
|
---|
803 | if (str == NULL)
|
---|
804 | inet_peer[0] = '\0';
|
---|
805 | else
|
---|
806 | sl_strlcpy(inet_peer, str, SH_MINIBUF);
|
---|
807 | }
|
---|
808 | #endif
|
---|
809 |
|
---|
810 |
|
---|
811 | /**********************************************************
|
---|
812 | **********************************************************
|
---|
813 | *
|
---|
814 | * -------- MAIN ERROR HANDLING FUNCTION -----------------
|
---|
815 | *
|
---|
816 | *
|
---|
817 | * this function should be called to report an error
|
---|
818 | *
|
---|
819 | **********************************************************
|
---|
820 | **********************************************************/
|
---|
821 |
|
---|
822 | void sh_error_handle (int sev, char * file, long line,
|
---|
823 | long status, unsigned long msg_id, ...)
|
---|
824 | {
|
---|
825 | va_list vl; /* argument list */
|
---|
826 | struct _log_t * lmsg;
|
---|
827 |
|
---|
828 | int severity;
|
---|
829 | unsigned int class;
|
---|
830 | char * fmt;
|
---|
831 |
|
---|
832 | int flag_inet = S_FALSE;
|
---|
833 | int class_inet = clt_class; /* initialize from global */
|
---|
834 |
|
---|
835 | #ifdef SH_WITH_SERVER
|
---|
836 | char local_inet_peer[SH_MINIBUF];
|
---|
837 | #endif
|
---|
838 |
|
---|
839 | #ifdef SH_WITH_CLIENT
|
---|
840 | char * ex_msg;
|
---|
841 | #endif
|
---|
842 | #if defined(WITH_DATABASE)
|
---|
843 | char * escape_msg;
|
---|
844 | #endif
|
---|
845 |
|
---|
846 | static int own_block = 0;
|
---|
847 |
|
---|
848 | /*
|
---|
849 | * Block a facility for errors generated
|
---|
850 | * within that facility.
|
---|
851 | */
|
---|
852 | static int print_block = 0;
|
---|
853 | #if defined(SH_WITH_MAIL)
|
---|
854 | static int mail_block = 0;
|
---|
855 | #endif
|
---|
856 | static int syslog_block = 0;
|
---|
857 | static int log_block = 0;
|
---|
858 | #if defined(SH_WITH_CLIENT)
|
---|
859 | static int export_block = 0;
|
---|
860 | #endif
|
---|
861 | #if defined(WITH_EXTERNAL)
|
---|
862 | static int external_block = 0;
|
---|
863 | #endif
|
---|
864 | #if defined(WITH_DATABASE)
|
---|
865 | static int database_block = 0;
|
---|
866 | #endif
|
---|
867 | #ifdef HAVE_LIBPRELUDE
|
---|
868 | static int prelude_block = 0;
|
---|
869 | #endif
|
---|
870 |
|
---|
871 | SL_ENTER(_("sh_error_handle"));
|
---|
872 |
|
---|
873 | #ifdef SH_WITH_SERVER
|
---|
874 | /* copy the global string into a local array
|
---|
875 | */
|
---|
876 | if ((msg_id == MSG_TCP_MSG) && (inet_peer[0] != '\0'))
|
---|
877 | {
|
---|
878 | sl_strlcpy(local_inet_peer, inet_peer, SH_MINIBUF);
|
---|
879 | sh_error_set_peer(NULL);
|
---|
880 | }
|
---|
881 | else
|
---|
882 | local_inet_peer[0] = '\0';
|
---|
883 | #endif
|
---|
884 |
|
---|
885 | clt_class = (-1); /* reset global */
|
---|
886 |
|
---|
887 | if (own_block == 1)
|
---|
888 | {
|
---|
889 | SL_RET0(_("sh_error_handle"));
|
---|
890 | }
|
---|
891 |
|
---|
892 | /* --- Initialize to default values. ---
|
---|
893 | */
|
---|
894 | own_block = 1;
|
---|
895 | if (IsInitialized == BAD)
|
---|
896 | (void) sh_error_init();
|
---|
897 | own_block = 0;
|
---|
898 |
|
---|
899 | /* --- Consistency checks. ---
|
---|
900 | */
|
---|
901 | own_block = 1;
|
---|
902 | fmt = /*@i@*/get_format (msg_id, &severity, &class);
|
---|
903 | own_block = 0;
|
---|
904 |
|
---|
905 | if (class_inet != (-1))
|
---|
906 | class = (unsigned int) class_inet;
|
---|
907 |
|
---|
908 | ASSERT((fmt != NULL), _("fmt != NULL"))
|
---|
909 | if (fmt == NULL)
|
---|
910 | {
|
---|
911 | fprintf(stderr,
|
---|
912 | _("ERROR: msg=<NULL format>, file=<%s>, line=<%ld>\n"),
|
---|
913 | file, line);
|
---|
914 | SL_RET0(_("sh_error_handle"));
|
---|
915 | }
|
---|
916 |
|
---|
917 | /* --- Override the catalogue severity. ---
|
---|
918 | */
|
---|
919 | if (sev != (-1))
|
---|
920 | severity = sev;
|
---|
921 |
|
---|
922 | if ((severity & SH_ERR_INET) != 0)
|
---|
923 | {
|
---|
924 | flag_inet = S_TRUE;
|
---|
925 | }
|
---|
926 |
|
---|
927 | /* --- Messages not wanted for logging. ---
|
---|
928 | */
|
---|
929 | if ( ( (errFlags.printlevel & severity ) == 0 ||
|
---|
930 | (errFlags.print_class & (1 << class)) == 0 ) &&
|
---|
931 | ( (errFlags.loglevel & severity ) == 0 ||
|
---|
932 | (errFlags.log_class & (1 << class)) == 0 ) &&
|
---|
933 | ( (errFlags.sysloglevel & severity ) == 0 ||
|
---|
934 | (errFlags.syslog_class & (1 << class)) == 0 ) &&
|
---|
935 | #ifdef SH_WITH_CLIENT
|
---|
936 | ( (errFlags.exportlevel & severity ) == 0 ||
|
---|
937 | (errFlags.export_class & (1 << class)) == 0 ) &&
|
---|
938 | #endif
|
---|
939 | #ifdef WITH_EXTERNAL
|
---|
940 | ( (errFlags.externallevel & severity ) == 0 ||
|
---|
941 | (errFlags.external_class & (1 << class)) == 0 ) &&
|
---|
942 | #endif
|
---|
943 | #ifdef HAVE_LIBPRELUDE
|
---|
944 | ( (errFlags.preludelevel & severity ) == 0 ||
|
---|
945 | (errFlags.prelude_class & (1 << class)) == 0 ) &&
|
---|
946 | #endif
|
---|
947 | #ifdef WITH_DATABASE
|
---|
948 | ( (errFlags.databaselevel & severity ) == 0 ||
|
---|
949 | (errFlags.database_class & (1 << class)) == 0 ) &&
|
---|
950 | #endif
|
---|
951 | ( (errFlags.maillevel & severity ) == 0 ||
|
---|
952 | (errFlags.mail_class & (1 << class)) == 0 )
|
---|
953 | #ifdef SH_WITH_SERVER
|
---|
954 | && (flag_inet == S_FALSE)
|
---|
955 | #endif
|
---|
956 | )
|
---|
957 | {
|
---|
958 | SL_RET0(_("sh_error_handle"));
|
---|
959 | }
|
---|
960 |
|
---|
961 | if ((severity & SH_ERR_NOT) != 0)
|
---|
962 | {
|
---|
963 | SL_RET0(_("sh_error_handle"));
|
---|
964 | }
|
---|
965 |
|
---|
966 |
|
---|
967 | /* Allocate space for the message.
|
---|
968 | */
|
---|
969 | own_block = 1;
|
---|
970 | lmsg = (struct _log_t *) SH_ALLOC(sizeof(struct _log_t));
|
---|
971 | MLOCK( (char *) lmsg, sizeof(struct _log_t));
|
---|
972 | /*@i@*/lmsg->msg = NULL;
|
---|
973 |
|
---|
974 | /*@i@*/(void) sl_strlcpy(lmsg->format, fmt, SH_PATHBUF);
|
---|
975 | (void) sl_strlcpy(lmsg->file, file, SH_PATHBUF);
|
---|
976 | lmsg->severity = severity;
|
---|
977 | lmsg->class = (int) class;
|
---|
978 | lmsg->line = line;
|
---|
979 | lmsg->status = status;
|
---|
980 | own_block = 0;
|
---|
981 |
|
---|
982 |
|
---|
983 | /* Format the log message with timestamp etc.
|
---|
984 | * Allocate lmsg->msg
|
---|
985 | */
|
---|
986 | own_block = 1;
|
---|
987 | va_start (vl, msg_id);
|
---|
988 | (void) sh_error_string (lmsg, vl);
|
---|
989 | va_end (vl);
|
---|
990 | own_block = 0;
|
---|
991 |
|
---|
992 |
|
---|
993 | /* Log to stderr.
|
---|
994 | */
|
---|
995 | if ( ((errFlags.printlevel & severity) != 0 &&
|
---|
996 | (errFlags.print_class & (1 << class)) != 0 &&
|
---|
997 | (errFlags.printlevel & SH_ERR_NOT) == 0)
|
---|
998 | #ifdef SH_WITH_SERVER
|
---|
999 | || (flag_inet == S_TRUE)
|
---|
1000 | #endif
|
---|
1001 | )
|
---|
1002 | {
|
---|
1003 | if (print_block == 0 && (errFlags.printlevel & SH_ERR_NOT) == 0)
|
---|
1004 | {
|
---|
1005 | /* no truncation
|
---|
1006 | */
|
---|
1007 | print_block = 1;
|
---|
1008 | TPT(( 0, FIL__, __LINE__, lmsg->msg));
|
---|
1009 | /*
|
---|
1010 | * Reports first error after failure. Always tries.
|
---|
1011 | */
|
---|
1012 | (void) sh_log_console (lmsg->msg);
|
---|
1013 | print_block = 0;
|
---|
1014 | }
|
---|
1015 | }
|
---|
1016 |
|
---|
1017 |
|
---|
1018 | /* Full logging enabled.
|
---|
1019 | */
|
---|
1020 | if (OnlyStderr == BAD) /* full error logging enabled */
|
---|
1021 | {
|
---|
1022 |
|
---|
1023 | /* Log to syslog.
|
---|
1024 | */
|
---|
1025 | if ( (errFlags.sysloglevel & severity) != 0 &&
|
---|
1026 | (errFlags.syslog_class & (1 << class)) != 0 &&
|
---|
1027 | #ifndef INET_SYSLOG
|
---|
1028 | (flag_inet != S_TRUE) && /* !inet->syslog */
|
---|
1029 | #endif
|
---|
1030 | (errFlags.sysloglevel & SH_ERR_NOT) == 0 )
|
---|
1031 | {
|
---|
1032 | /* will truncate to 1023 bytes
|
---|
1033 | */
|
---|
1034 | if (syslog_block == 0)
|
---|
1035 | {
|
---|
1036 | syslog_block = 1;
|
---|
1037 | /*
|
---|
1038 | * Ignores errors. Always tries.
|
---|
1039 | */
|
---|
1040 | (void) sh_log_syslog (lmsg->severity, lmsg->msg);
|
---|
1041 | syslog_block = 0;
|
---|
1042 | }
|
---|
1043 | }
|
---|
1044 |
|
---|
1045 | #if defined(WITH_EXTERNAL)
|
---|
1046 | /*
|
---|
1047 | * -- external facility
|
---|
1048 | */
|
---|
1049 | if ((errFlags.externallevel & severity) != 0 &&
|
---|
1050 | (errFlags.external_class & (1 << class)) != 0 &&
|
---|
1051 | (errFlags.externallevel & SH_ERR_NOT) == 0 &&
|
---|
1052 | class != AUD)
|
---|
1053 | {
|
---|
1054 | if (external_block == 0)
|
---|
1055 | {
|
---|
1056 | /* no truncation
|
---|
1057 | */
|
---|
1058 | external_block = 1;
|
---|
1059 | /*
|
---|
1060 | * Reports first error after failure. Always tries.
|
---|
1061 | */
|
---|
1062 | (void) sh_ext_execute ('l', 'o', 'g', lmsg->msg, 0);
|
---|
1063 | external_block = 0;
|
---|
1064 | }
|
---|
1065 | }
|
---|
1066 | #endif
|
---|
1067 |
|
---|
1068 | #if defined(WITH_DATABASE)
|
---|
1069 | /*
|
---|
1070 | * -- database facility
|
---|
1071 | */
|
---|
1072 | if ((errFlags.databaselevel & severity) != 0 &&
|
---|
1073 | (errFlags.database_class & (1 << class)) != 0 &&
|
---|
1074 | (errFlags.databaselevel & SH_ERR_NOT) == 0 &&
|
---|
1075 | class != AUD)
|
---|
1076 | {
|
---|
1077 | if (database_block == 0)
|
---|
1078 | {
|
---|
1079 | /* truncates; query_max is 16k
|
---|
1080 | */
|
---|
1081 | database_block = 1;
|
---|
1082 | #ifndef SH_STANDALONE
|
---|
1083 | if (msg_id == MSG_TCP_MSG
|
---|
1084 | #ifdef INET_SYSLOG
|
---|
1085 | || msg_id == MSG_INET_SYSLOG
|
---|
1086 | #endif
|
---|
1087 | )
|
---|
1088 | {
|
---|
1089 | /* do not escape twice
|
---|
1090 | */
|
---|
1091 | /*
|
---|
1092 | * Reports failure every 60 min. Always tries.
|
---|
1093 | */
|
---|
1094 | (void) sh_database_insert (lmsg->msg);
|
---|
1095 | }
|
---|
1096 | else
|
---|
1097 | #endif
|
---|
1098 | {
|
---|
1099 | escape_msg = sh_tools_safe_name(lmsg->msg, 0);
|
---|
1100 | /*
|
---|
1101 | * Reports failure every 60 min. Always tries.
|
---|
1102 | */
|
---|
1103 | (void) sh_database_insert (escape_msg);
|
---|
1104 | SH_FREE(escape_msg);
|
---|
1105 | }
|
---|
1106 | database_block = 0;
|
---|
1107 | }
|
---|
1108 | }
|
---|
1109 | #endif
|
---|
1110 |
|
---|
1111 | /****************************************************
|
---|
1112 | * Optionally include client code for TCP forwarding
|
---|
1113 | * to log server
|
---|
1114 | ****************************************************/
|
---|
1115 | #ifdef SH_WITH_CLIENT
|
---|
1116 | /* Export by TCP.
|
---|
1117 | */
|
---|
1118 | if ((errFlags.exportlevel & severity ) != 0 &&
|
---|
1119 | (errFlags.export_class & (1 << class)) != 0 &&
|
---|
1120 | (errFlags.exportlevel & SH_ERR_NOT) == 0 &&
|
---|
1121 | class != AUD &&
|
---|
1122 | sh.flag.isserver != GOOD &&
|
---|
1123 | (flag_inet == S_FALSE) ) /* don't log inet to export */
|
---|
1124 | {
|
---|
1125 | if (export_block == 0)
|
---|
1126 | {
|
---|
1127 | int retval;
|
---|
1128 |
|
---|
1129 | /* will truncate to 65280 bytes
|
---|
1130 | */
|
---|
1131 | export_block = 1;
|
---|
1132 | ex_msg = SH_ALLOC (64 + sl_strlen(lmsg->msg) + 1);
|
---|
1133 | /*@-bufferoverflowhigh@*/
|
---|
1134 | sprintf(ex_msg, _("%d?%u?%s"), /* known to fit */
|
---|
1135 | severity, class, lmsg->msg);
|
---|
1136 | /*@-bufferoverflowhigh@*/
|
---|
1137 | retval = sh_forward (ex_msg);
|
---|
1138 | SH_FREE(ex_msg);
|
---|
1139 | export_block = 0;
|
---|
1140 | if (retval == -2)
|
---|
1141 | {
|
---|
1142 | sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_QUEUE_FULL,
|
---|
1143 | _("log server"));
|
---|
1144 | }
|
---|
1145 | }
|
---|
1146 | }
|
---|
1147 | #endif
|
---|
1148 |
|
---|
1149 |
|
---|
1150 | /* Log to mail.
|
---|
1151 | */
|
---|
1152 | #if defined(SH_WITH_MAIL)
|
---|
1153 | if ((errFlags.maillevel & severity ) != 0 &&
|
---|
1154 | (errFlags.mail_class & (1 << class)) != 0 &&
|
---|
1155 | (errFlags.maillevel & SH_ERR_NOT) == 0 &&
|
---|
1156 | class != AUD &&
|
---|
1157 | (flag_inet == S_FALSE) ) /* don't log inet to email */
|
---|
1158 | {
|
---|
1159 | if (mail_block == 0)
|
---|
1160 | {
|
---|
1161 | int retval;
|
---|
1162 |
|
---|
1163 | /* will truncate to 998 bytes
|
---|
1164 | */
|
---|
1165 | mail_block = 1;
|
---|
1166 |
|
---|
1167 | BREAKEXIT(sh_mail_msg);
|
---|
1168 | if ( (severity & SH_ERR_FATAL) == 0)
|
---|
1169 | retval = sh_mail_pushstack (lmsg->msg);
|
---|
1170 | else
|
---|
1171 | retval = sh_mail_msg (lmsg->msg);
|
---|
1172 |
|
---|
1173 | mail_block = 0;
|
---|
1174 | if (retval == -2)
|
---|
1175 | {
|
---|
1176 | sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_QUEUE_FULL,
|
---|
1177 | _("email"));
|
---|
1178 | }
|
---|
1179 | }
|
---|
1180 | }
|
---|
1181 | #endif
|
---|
1182 |
|
---|
1183 | #ifdef HAVE_LIBPRELUDE
|
---|
1184 | if (((errFlags.preludelevel & severity ) != 0 &&
|
---|
1185 | (errFlags.prelude_class & (1 << class)) != 0 &&
|
---|
1186 | (errFlags.preludelevel & SH_ERR_NOT) == 0 &&
|
---|
1187 | (class != AUD))
|
---|
1188 | #ifdef SH_WITH_SERVER
|
---|
1189 | || (flag_inet == S_TRUE)
|
---|
1190 | #endif
|
---|
1191 | )
|
---|
1192 | {
|
---|
1193 | if (prelude_block == 0)
|
---|
1194 | {
|
---|
1195 | /* will truncate to 998 bytes
|
---|
1196 | */
|
---|
1197 | prelude_block = 1;
|
---|
1198 |
|
---|
1199 | BREAKEXIT(sh_prelude_alert);
|
---|
1200 | /*
|
---|
1201 | * Reports first error after failure. Always tries.
|
---|
1202 | */
|
---|
1203 | (void) sh_prelude_alert (severity, (int) class, lmsg->msg,
|
---|
1204 | lmsg->status, msg_id);
|
---|
1205 |
|
---|
1206 | prelude_block = 0;
|
---|
1207 | }
|
---|
1208 | }
|
---|
1209 | #endif
|
---|
1210 |
|
---|
1211 | /* Log to logfile
|
---|
1212 | */
|
---|
1213 |
|
---|
1214 | if ( ( ( (errFlags.loglevel & severity) != 0 &&
|
---|
1215 | (errFlags.log_class & (1 << class)) != 0 &&
|
---|
1216 | (errFlags.loglevel & SH_ERR_NOT) == 0 )
|
---|
1217 | #ifdef SH_WITH_SERVER
|
---|
1218 | || (flag_inet == S_TRUE)
|
---|
1219 | #endif
|
---|
1220 | ) &&
|
---|
1221 | class != AUD &&
|
---|
1222 | (errFlags.HaveLog != BAD) && /* temporary switched off */
|
---|
1223 | (severity & SH_ERR_NOT) == 0 /* paranoia */
|
---|
1224 | )
|
---|
1225 | {
|
---|
1226 | if (log_block == 0)
|
---|
1227 | {
|
---|
1228 | /* no truncation
|
---|
1229 | */
|
---|
1230 | log_block = 1;
|
---|
1231 | BREAKEXIT(sh_log_file);
|
---|
1232 | #ifdef SH_WITH_SERVER
|
---|
1233 | if (0 != sl_ret_euid())
|
---|
1234 | {
|
---|
1235 | /*
|
---|
1236 | * Reports first error after failure. Always tries.
|
---|
1237 | */
|
---|
1238 | if (local_inet_peer[0] == '\0')
|
---|
1239 | (void) sh_log_file (lmsg->msg, NULL);
|
---|
1240 | else
|
---|
1241 | (void) sh_log_file (lmsg->msg, local_inet_peer);
|
---|
1242 | }
|
---|
1243 | #else
|
---|
1244 | (void) sh_log_file (lmsg->msg, NULL);
|
---|
1245 | #endif
|
---|
1246 | /* sh_log_file (lmsg->msg); */
|
---|
1247 | log_block = 0;
|
---|
1248 | }
|
---|
1249 | }
|
---|
1250 |
|
---|
1251 | }
|
---|
1252 |
|
---|
1253 | /* Cleanup.
|
---|
1254 | */
|
---|
1255 | own_block = 1;
|
---|
1256 |
|
---|
1257 | if (lmsg->msg)
|
---|
1258 | SH_FREE( lmsg->msg );
|
---|
1259 |
|
---|
1260 | memset ( lmsg, (int) '\0', sizeof(struct _log_t) );
|
---|
1261 | MUNLOCK( (char *) lmsg, sizeof(struct _log_t) );
|
---|
1262 | SH_FREE( lmsg );
|
---|
1263 | own_block = 0;
|
---|
1264 |
|
---|
1265 | /*@i@*/SL_RET0(_("sh_error_handle"));
|
---|
1266 | /*@i@*/}
|
---|
1267 |
|
---|
1268 |
|
---|
1269 | /* -------------------------
|
---|
1270 | *
|
---|
1271 | * private functions below
|
---|
1272 | *
|
---|
1273 | * -------------------------
|
---|
1274 | */
|
---|
1275 |
|
---|
1276 |
|
---|
1277 | /* --- Get the format from the message catalog. ---
|
---|
1278 | */
|
---|
1279 | /*@owned@*/ /*@null@*/inline
|
---|
1280 | static char * get_format(unsigned long msg_id, /*@out@*/ int * priority,
|
---|
1281 | /*@out@*/unsigned int * class)
|
---|
1282 | {
|
---|
1283 | int i = 0;
|
---|
1284 |
|
---|
1285 | SL_ENTER(_("get_format"));
|
---|
1286 | while (1 == 1)
|
---|
1287 | {
|
---|
1288 | if ( msg_cat[i].format == NULL )
|
---|
1289 | break;
|
---|
1290 |
|
---|
1291 | if ( (unsigned long) msg_cat[i].id == msg_id)
|
---|
1292 | {
|
---|
1293 | *priority = (int) msg_cat[i].priority;
|
---|
1294 | *class = (unsigned int) msg_cat[i].class;
|
---|
1295 | SL_RETURN (_(msg_cat[i].format), _("get_format"));
|
---|
1296 | }
|
---|
1297 | ++i;
|
---|
1298 | }
|
---|
1299 | *priority = SH_ERR_ERR;
|
---|
1300 | *class = ERR;
|
---|
1301 | SL_RETURN (NULL, _("get_format"));
|
---|
1302 | }
|
---|
1303 |
|
---|
1304 | /*@null@*//*@only@*/static char * ehead_format = NULL;
|
---|
1305 |
|
---|
1306 | /* allocate space for user-defined message header
|
---|
1307 | */
|
---|
1308 | int sh_error_ehead (/*@null@*/char * str_s)
|
---|
1309 | {
|
---|
1310 | size_t size;
|
---|
1311 | char * s;
|
---|
1312 |
|
---|
1313 | SL_ENTER(_("sh_error_ehead"));
|
---|
1314 |
|
---|
1315 | if (str_s == NULL)
|
---|
1316 | {
|
---|
1317 | SL_RETURN (-1, _("sh_error_ehead"));
|
---|
1318 | }
|
---|
1319 |
|
---|
1320 | /* ascii 34 ist t\"ttelchen
|
---|
1321 | */
|
---|
1322 | /*@i@*/ if (str_s[0] == 34) s = &str_s[1];
|
---|
1323 | else s = str_s;
|
---|
1324 |
|
---|
1325 | size = /*@i@*/strlen(s);
|
---|
1326 | if (/*@i@*/s[size-1] == (char) 34) --size;
|
---|
1327 |
|
---|
1328 | if (ehead_format != NULL)
|
---|
1329 | SH_FREE(ehead_format);
|
---|
1330 |
|
---|
1331 | /*@i@*/ehead_format = SH_ALLOC(size+1);
|
---|
1332 | /*@i@*/ (void) sl_strlcpy(ehead_format, s, size+1);
|
---|
1333 |
|
---|
1334 | SL_RETURN( 0, _("sh_error_ehead"));
|
---|
1335 | }
|
---|
1336 |
|
---|
1337 | #if !defined(VA_COPY)
|
---|
1338 | #if defined(__GNUC__) && defined(__PPC__) && (defined(_CALL_SYSV) || defined(_WIN32))
|
---|
1339 | #define VA_COPY(ap1, ap2) (*(ap1) = *(ap2))
|
---|
1340 | #elif defined(VA_COPY_AS_ARRAY)
|
---|
1341 | #define VA_COPY(ap1, ap2) memmove ((ap1), (ap2), sizeof (va_list))
|
---|
1342 | #else /* va_list is a pointer */
|
---|
1343 | #define VA_COPY(ap1, ap2) ((ap1) = (ap2))
|
---|
1344 | #endif
|
---|
1345 | #endif
|
---|
1346 |
|
---|
1347 |
|
---|
1348 | /* print an error into string
|
---|
1349 | */
|
---|
1350 | static int sh_error_string (struct _log_t * lmsg, va_list vl)
|
---|
1351 | {
|
---|
1352 | size_t len;
|
---|
1353 | int required;
|
---|
1354 | unsigned long line;
|
---|
1355 | char sev[16] = "";
|
---|
1356 | char cla[16] = "";
|
---|
1357 | char tst[64] = "";
|
---|
1358 | char *p;
|
---|
1359 | va_list vl2;
|
---|
1360 |
|
---|
1361 | st_format rep_ehead_tab[] = {
|
---|
1362 | { 'S', S_FMT_STRING, 0, 0, NULL}, /* severity */
|
---|
1363 | { 'T', S_FMT_STRING, 0, 0, NULL}, /* timestamp */
|
---|
1364 | { 'F', S_FMT_STRING, 0, 0, NULL}, /* file */
|
---|
1365 | { 'L', S_FMT_ULONG, 0, 0, NULL}, /* line */
|
---|
1366 | { 'C', S_FMT_STRING, 0, 0, NULL}, /* class */
|
---|
1367 | { 'E', S_FMT_LONG, 0, 0, NULL}, /* status */
|
---|
1368 | {'\0', S_FMT_ULONG, 0, 0, NULL},
|
---|
1369 | };
|
---|
1370 |
|
---|
1371 | SL_ENTER(_("sh_error_string"));
|
---|
1372 |
|
---|
1373 | if (ehead_format == NULL)
|
---|
1374 | {
|
---|
1375 | ehead_format = SH_ALLOC(64);
|
---|
1376 | #ifdef SH_USE_XML
|
---|
1377 | if ((errFlags.printlevel & SH_ERR_ALL) == 0)
|
---|
1378 | (void) sl_strlcpy(ehead_format,
|
---|
1379 | _("<log sev=\"%S\" tstamp=\"%T\" "), 64);
|
---|
1380 | else
|
---|
1381 | (void) sl_strlcpy(ehead_format,
|
---|
1382 | _("<log sev=\"%S\" tstamp=\"%T\" p.f=\"%F\" p.l=\"%L\" p.s=\"%E\" "), 64);
|
---|
1383 | #else
|
---|
1384 | if ((errFlags.printlevel & SH_ERR_ALL) == 0)
|
---|
1385 | (void) sl_strlcpy(ehead_format, _("%S %T "), 64);
|
---|
1386 | else
|
---|
1387 | (void) sl_strlcpy(ehead_format, _("%S %T (%F, %L, %E) "), 64);
|
---|
1388 | #endif
|
---|
1389 | }
|
---|
1390 |
|
---|
1391 | /* header of error message
|
---|
1392 | */
|
---|
1393 | #ifdef SH_USE_XML
|
---|
1394 | if ( (lmsg->severity & SH_ERR_INET) != 0)
|
---|
1395 | (void) sl_strlcpy (sev, _("RCVT"), 11);
|
---|
1396 | else if ( (lmsg->severity & SH_ERR_ALL) != 0)
|
---|
1397 | (void) sl_strlcpy (sev, _("DEBG"), 11);
|
---|
1398 | else if ( (lmsg->severity & SH_ERR_INFO) != 0)
|
---|
1399 | (void) sl_strlcpy (sev, _("INFO"), 11);
|
---|
1400 | else if ( (lmsg->severity & SH_ERR_NOTICE) != 0)
|
---|
1401 | (void) sl_strlcpy (sev, _("NOTE"), 11);
|
---|
1402 | else if ( (lmsg->severity & SH_ERR_WARN) != 0)
|
---|
1403 | (void) sl_strlcpy (sev, _("WARN"), 11);
|
---|
1404 | else if ( (lmsg->severity & SH_ERR_STAMP) != 0)
|
---|
1405 | (void) sl_strlcpy (sev, _("MARK"), 11);
|
---|
1406 | else if ( (lmsg->severity & SH_ERR_ERR) != 0)
|
---|
1407 | (void) sl_strlcpy (sev, _("ERRO"), 11);
|
---|
1408 | else if ( (lmsg->severity & SH_ERR_SEVERE) != 0)
|
---|
1409 | (void) sl_strlcpy (sev, _("CRIT"), 11);
|
---|
1410 | else if ( (lmsg->severity & SH_ERR_FATAL) != 0)
|
---|
1411 | (void) sl_strlcpy (sev, _("ALRT"), 11);
|
---|
1412 | else {
|
---|
1413 | (void) sl_strlcpy (sev, _("????"), 11);
|
---|
1414 | #else
|
---|
1415 | #if defined(INET_SYSLOG)
|
---|
1416 | if ( (lmsg->severity & SH_ERR_INET) != 0)
|
---|
1417 | (void) sl_strlcpy (sev, _("<NET> : "), 11);
|
---|
1418 | #else
|
---|
1419 | if ( (lmsg->severity & SH_ERR_INET) != 0)
|
---|
1420 | (void) sl_strlcpy (sev, _("<TCP> : "), 11);
|
---|
1421 | #endif
|
---|
1422 | else if ( (lmsg->severity & SH_ERR_ALL) != 0)
|
---|
1423 | (void) sl_strlcpy (sev, _("DEBUG : "), 11);
|
---|
1424 | else if ( (lmsg->severity & SH_ERR_INFO) != 0)
|
---|
1425 | (void) sl_strlcpy (sev, _("INFO : "), 11);
|
---|
1426 | else if ( (lmsg->severity & SH_ERR_NOTICE) != 0)
|
---|
1427 | (void) sl_strlcpy (sev, _("NOTICE : "), 11);
|
---|
1428 | else if ( (lmsg->severity & SH_ERR_WARN) != 0)
|
---|
1429 | (void) sl_strlcpy (sev, _("WARN : "), 11);
|
---|
1430 | else if ( (lmsg->severity & SH_ERR_STAMP) != 0)
|
---|
1431 | (void) sl_strlcpy (sev, _("MARK : "), 11);
|
---|
1432 | else if ( (lmsg->severity & SH_ERR_ERR) != 0)
|
---|
1433 | (void) sl_strlcpy (sev, _("ERROR : "), 11);
|
---|
1434 | else if ( (lmsg->severity & SH_ERR_SEVERE) != 0)
|
---|
1435 | (void) sl_strlcpy (sev, _("CRIT : "), 11);
|
---|
1436 | else if ( (lmsg->severity & SH_ERR_FATAL) != 0)
|
---|
1437 | (void) sl_strlcpy (sev, _("ALERT : "), 11);
|
---|
1438 | else {
|
---|
1439 | (void) sl_strlcpy (sev, _("??? : "), 11);
|
---|
1440 | #endif
|
---|
1441 | }
|
---|
1442 |
|
---|
1443 | (void) sl_strlcpy (tst, sh_unix_time (0), 64);
|
---|
1444 | line = (unsigned long) lmsg->line;
|
---|
1445 | (void) sl_strlcpy (cla, _(class_cat[lmsg->class]), 11);
|
---|
1446 |
|
---|
1447 | /*@i@*/rep_ehead_tab[0].data_str = sev;
|
---|
1448 | /*@i@*/rep_ehead_tab[1].data_str = tst;
|
---|
1449 | /*@i@*/rep_ehead_tab[2].data_str = lmsg->file;
|
---|
1450 | /*@i@*/rep_ehead_tab[3].data_ulong = line;
|
---|
1451 | /*@i@*/rep_ehead_tab[4].data_str = cla;
|
---|
1452 | /*@i@*/rep_ehead_tab[5].data_long = lmsg->status;
|
---|
1453 |
|
---|
1454 | p = /*@i@*/sh_util_formatted(ehead_format, rep_ehead_tab);
|
---|
1455 |
|
---|
1456 | /* --- copy the header to lmsg->msg ---
|
---|
1457 | */
|
---|
1458 | /*@i@*/lmsg->msg = SH_ALLOC(SH_BUFSIZE);
|
---|
1459 | lmsg->msg_len = SH_BUFSIZE;
|
---|
1460 |
|
---|
1461 | if (p)
|
---|
1462 | {
|
---|
1463 | (void) sl_strlcpy (lmsg->msg, p, SH_BUFSIZE);
|
---|
1464 | SH_FREE(p);
|
---|
1465 | }
|
---|
1466 | else
|
---|
1467 | {
|
---|
1468 | lmsg->msg[0] = '\0';
|
---|
1469 | }
|
---|
1470 |
|
---|
1471 |
|
---|
1472 | /* --- copy message to lmsg->msg ---
|
---|
1473 | */
|
---|
1474 | if ( NULL == strchr(lmsg->format, '%') )
|
---|
1475 | {
|
---|
1476 | (void) sl_strlcat (lmsg->msg, lmsg->format, (size_t) lmsg->msg_len);
|
---|
1477 | }
|
---|
1478 | else
|
---|
1479 | {
|
---|
1480 | /* use VA_COPY */
|
---|
1481 | /*@i@*/VA_COPY(vl2, vl);
|
---|
1482 | len = sl_strlen(lmsg->msg);
|
---|
1483 | /*@i@*/required = sl_vsnprintf(&(lmsg->msg[len]),
|
---|
1484 | (lmsg->msg_len - len), lmsg->format, vl);
|
---|
1485 | if ( (required + len) > (lmsg->msg_len - 4) )
|
---|
1486 | {
|
---|
1487 | /*@i@*/p = SH_ALLOC(required + len + 4);
|
---|
1488 | (void) sl_strlcpy (p, lmsg->msg, required + len + 1);
|
---|
1489 | SH_FREE(lmsg->msg);
|
---|
1490 | lmsg->msg = p;
|
---|
1491 | lmsg->msg_len = required + len + 4;
|
---|
1492 | (void) sl_vsnprintf(&(lmsg->msg[len]),
|
---|
1493 | (required + len + 1), lmsg->format, vl2);
|
---|
1494 | }
|
---|
1495 | va_end(vl2);
|
---|
1496 | }
|
---|
1497 |
|
---|
1498 | #ifdef SH_USE_XML
|
---|
1499 | /* closing tag
|
---|
1500 | */
|
---|
1501 | if (lmsg->msg[sl_strlen(lmsg->msg)-1] != '>')
|
---|
1502 | (void) sl_strlcat (lmsg->msg, _(" />"), lmsg->msg_len);
|
---|
1503 | #endif
|
---|
1504 |
|
---|
1505 | SL_RETURN(0, _("sh_error_string"));
|
---|
1506 | }
|
---|
1507 |
|
---|
1508 |
|
---|
1509 |
|
---|
1510 |
|
---|
1511 | /* --- Initialize. ---
|
---|
1512 | */
|
---|
1513 | static int sh_error_init ()
|
---|
1514 | {
|
---|
1515 | register int j;
|
---|
1516 |
|
---|
1517 | SL_ENTER(_("sh_error_init"));
|
---|
1518 |
|
---|
1519 | errFlags.debug = 0;
|
---|
1520 | errFlags.HaveLog = GOOD;
|
---|
1521 | errFlags.sysloglevel = SH_ERR_NOT;
|
---|
1522 | #if defined(SH_STEALTH)
|
---|
1523 | errFlags.loglevel = SH_ERR_NOT;
|
---|
1524 | #else
|
---|
1525 | errFlags.loglevel = (SH_ERR_STAMP | SH_ERR_ERR | SH_ERR_SEVERE |
|
---|
1526 | SH_ERR_FATAL);
|
---|
1527 | #endif
|
---|
1528 | errFlags.externallevel = SH_ERR_NOT;
|
---|
1529 | errFlags.databaselevel = SH_ERR_NOT;
|
---|
1530 | errFlags.preludelevel = SH_ERR_NOT;
|
---|
1531 | errFlags.maillevel = SH_ERR_FATAL;
|
---|
1532 | #if defined(SH_STEALTH)
|
---|
1533 | errFlags.printlevel = SH_ERR_NOT;
|
---|
1534 | #else
|
---|
1535 | errFlags.printlevel = (SH_ERR_INFO | SH_ERR_NOTICE | SH_ERR_WARN |
|
---|
1536 | SH_ERR_STAMP | SH_ERR_ERR | SH_ERR_SEVERE |
|
---|
1537 | SH_ERR_FATAL);
|
---|
1538 | flag_err_info = SL_TRUE;
|
---|
1539 | #endif
|
---|
1540 | errFlags.exportlevel = (SH_ERR_STAMP | SH_ERR_ERR | SH_ERR_SEVERE |
|
---|
1541 | SH_ERR_FATAL);
|
---|
1542 |
|
---|
1543 | errFlags.log_class = 0xFFFF;
|
---|
1544 | errFlags.print_class = 0xFFFF;
|
---|
1545 | errFlags.mail_class = 0xFFFF;
|
---|
1546 | errFlags.export_class = 0xFFFF;
|
---|
1547 | errFlags.syslog_class = 0xFFFF;
|
---|
1548 | errFlags.external_class = 0xFFFF;
|
---|
1549 | errFlags.database_class = 0xFFFF;
|
---|
1550 | errFlags.prelude_class = 0xFFFF;
|
---|
1551 |
|
---|
1552 |
|
---|
1553 | for (j = 0; j < SH_ERR_T_END; ++j)
|
---|
1554 | ShDFLevel[j] = SH_ERR_SEVERE;
|
---|
1555 |
|
---|
1556 | IsInitialized = GOOD;
|
---|
1557 | SL_RETURN (0, _("sh_error_init"));
|
---|
1558 | }
|
---|