|
Lines 45-50
Link Here
|
| 45 |
#include <syslog.h> |
45 |
#include <syslog.h> |
| 46 |
#include <unistd.h> |
46 |
#include <unistd.h> |
| 47 |
#include <errno.h> |
47 |
#include <errno.h> |
|
|
48 |
#include <fcntl.h> |
| 48 |
#if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H) |
49 |
#if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H) |
| 49 |
# include <vis.h> |
50 |
# include <vis.h> |
| 50 |
#endif |
51 |
#endif |
|
Lines 56-61
static LogLevel log_level = SYSLOG_LEVEL
Link Here
|
| 56 |
static int log_on_stderr = 1; |
57 |
static int log_on_stderr = 1; |
| 57 |
static int log_facility = LOG_AUTH; |
58 |
static int log_facility = LOG_AUTH; |
| 58 |
static char *argv0; |
59 |
static char *argv0; |
|
|
60 |
int log_fd_keep = 0; |
| 59 |
|
61 |
|
| 60 |
extern char *__progname; |
62 |
extern char *__progname; |
| 61 |
|
63 |
|
|
Lines 310-315
log_init(char *av0, LogLevel level, Sysl
Link Here
|
| 310 |
exit(1); |
312 |
exit(1); |
| 311 |
} |
313 |
} |
| 312 |
|
314 |
|
|
|
315 |
if (log_fd_keep != 0) |
| 316 |
return; |
| 313 |
/* |
317 |
/* |
| 314 |
* If an external library (eg libwrap) attempts to use syslog |
318 |
* If an external library (eg libwrap) attempts to use syslog |
| 315 |
* immediately after reexec, syslog may be pointing to the wrong |
319 |
* immediately after reexec, syslog may be pointing to the wrong |
|
Lines 392-401
do_log(LogLevel level, const char *fmt,
Link Here
|
| 392 |
syslog_r(pri, &sdata, "%.500s", fmtbuf); |
396 |
syslog_r(pri, &sdata, "%.500s", fmtbuf); |
| 393 |
closelog_r(&sdata); |
397 |
closelog_r(&sdata); |
| 394 |
#else |
398 |
#else |
|
|
399 |
if (!log_fd_keep) { |
| 395 |
openlog(argv0 ? argv0 : __progname, LOG_PID, log_facility); |
400 |
openlog(argv0 ? argv0 : __progname, LOG_PID, log_facility); |
|
|
401 |
} |
| 396 |
syslog(pri, "%.500s", fmtbuf); |
402 |
syslog(pri, "%.500s", fmtbuf); |
|
|
403 |
if (!log_fd_keep) { |
| 397 |
closelog(); |
404 |
closelog(); |
|
|
405 |
} |
| 398 |
#endif |
406 |
#endif |
| 399 |
} |
407 |
} |
| 400 |
errno = saved_errno; |
408 |
errno = saved_errno; |
| 401 |
} |
409 |
} |
|
|
410 |
|
| 411 |
void |
| 412 |
open_log(void) |
| 413 |
{ |
| 414 |
int temp1, temp2; |
| 415 |
|
| 416 |
temp1 = open("/dev/null", O_RDONLY); |
| 417 |
openlog(argv0 ? argv0 : __progname, LOG_PID|LOG_NDELAY, log_facility); |
| 418 |
temp2 = open("/dev/null", O_RDONLY); |
| 419 |
if (temp1 + 2 == temp2) |
| 420 |
log_fd_keep = temp1 + 1; |
| 421 |
else |
| 422 |
log_fd_keep = -1; |
| 423 |
|
| 424 |
if (temp1 != -1) |
| 425 |
close(temp1); |
| 426 |
if (temp2 != -1) |
| 427 |
close(temp2); |
| 428 |
} |