version 1.11, 2003/03/28 18:55:30 |
version 1.12, 2003/04/03 19:15:34 |
|
|
#ifdef HAVE_UNISTD_H |
#ifdef HAVE_UNISTD_H |
# include <unistd.h> |
# include <unistd.h> |
#endif /* HAVE_UNISTD_H */ |
#endif /* HAVE_UNISTD_H */ |
|
#ifdef HAVE_ERR_H |
|
# include <err.h> |
|
#else |
|
# include "emul/err.h" |
|
#endif /* HAVE_ERR_H */ |
#include <pwd.h> |
#include <pwd.h> |
#include <signal.h> |
#include <signal.h> |
#include <time.h> |
#include <time.h> |
|
|
#include "sudo.h" |
#include "sudo.h" |
|
|
#ifndef lint |
#ifndef lint |
static const char rcsid[] = "$Sudo: logging.c,v 1.159 2003/03/24 21:09:27 millert Exp $"; |
static const char rcsid[] = "$Sudo: logging.c,v 1.160 2003/04/02 18:25:19 millert Exp $"; |
#endif /* lint */ |
#endif /* lint */ |
|
|
static void do_syslog __P((int, char *)); |
static void do_syslog __P((int, char *)); |
|
|
va_start(ap); |
va_start(ap); |
#endif |
#endif |
#ifdef LOG_NFACILITIES |
#ifdef LOG_NFACILITIES |
openlog(Argv[0], 0, def_ival(I_LOGFAC)); |
openlog("sudo", 0, def_ival(I_LOGFAC)); |
#else |
#else |
openlog(Argv[0], 0); |
openlog("sudo", 0); |
#endif |
#endif |
vsnprintf(buf, sizeof(buf), fmt, ap); |
vsnprintf(buf, sizeof(buf), fmt, ap); |
#ifdef BROKEN_SYSLOG |
#ifdef BROKEN_SYSLOG |
|
|
/* |
/* |
* Tell the user. |
* Tell the user. |
*/ |
*/ |
(void) fprintf(stderr, "%s: %s", Argv[0], message); |
|
if (flags & USE_ERRNO) |
if (flags & USE_ERRNO) |
(void) fprintf(stderr, ": %s", strerror(serrno)); |
warn("%s", message); |
(void) fputc('\n', stderr); |
else |
|
warnx("%s", message); |
|
|
/* |
/* |
* Send a copy of the error via mail. |
* Send a copy of the error via mail. |
|
|
(void) sigaddset(&set, SIGCHLD); |
(void) sigaddset(&set, SIGCHLD); |
(void) sigprocmask(SIG_BLOCK, &set, &oset); |
(void) sigprocmask(SIG_BLOCK, &set, &oset); |
|
|
if (pipe(pfd) == -1) { |
if (pipe(pfd) == -1) |
(void) fprintf(stderr, "%s: cannot open pipe: %s\n", |
err(1, "cannot open pipe"); |
Argv[0], strerror(errno)); |
|
exit(1); |
|
} |
|
|
|
switch (pid = fork()) { |
switch (pid = fork()) { |
case -1: |
case -1: |
/* Error. */ |
/* Error. */ |
(void) fprintf(stderr, "%s: cannot fork: %s\n", |
err(1, "cannot fork"); |
Argv[0], strerror(errno)); |
|
exit(1); |
|
break; |
break; |
case 0: |
case 0: |
{ |
{ |