version 1.8, 2002/06/12 06:07:16 |
version 1.9, 2003/03/15 21:23:54 |
|
|
/* |
/* |
* Copyright (c) 1994-1996,1998-2001 Todd C. Miller <Todd.Miller@courtesan.com> |
* Copyright (c) 1994-1996,1998-2003 Todd C. Miller <Todd.Miller@courtesan.com> |
* All rights reserved. |
* All rights reserved. |
* |
* |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
|
|
#include "sudo.h" |
#include "sudo.h" |
|
|
#ifndef lint |
#ifndef lint |
static const char rcsid[] = "$Sudo: logging.c,v 1.153 2002/01/16 21:28:25 millert Exp $"; |
static const char rcsid[] = "$Sudo: logging.c,v 1.157 2003/03/15 20:31:02 millert Exp $"; |
#endif /* lint */ |
#endif /* lint */ |
|
|
static void do_syslog __P((int, char *)); |
static void do_syslog __P((int, char *)); |
|
|
int pri; |
int pri; |
char *msg; |
char *msg; |
{ |
{ |
int count; |
size_t count; |
char *p; |
char *p; |
char *tmp; |
char *tmp; |
char save; |
char save; |
|
|
char *beg, *oldend, *end; |
char *beg, *oldend, *end; |
FILE *fp; |
FILE *fp; |
mode_t oldmask; |
mode_t oldmask; |
int maxlen = def_ival(I_LOGLINELEN); |
size_t maxlen; |
|
|
oldmask = umask(077); |
oldmask = umask(077); |
|
maxlen = def_ival(I_LOGLINELEN) > 0 ? def_ival(I_LOGLINELEN) : 0; |
fp = fopen(def_str(I_LOGFILE), "a"); |
fp = fopen(def_str(I_LOGFILE), "a"); |
(void) umask(oldmask); |
(void) umask(oldmask); |
if (fp == NULL) { |
if (fp == NULL) { |
|
|
|
|
/* Become root if we are not already to avoid user control */ |
/* Become root if we are not already to avoid user control */ |
if (geteuid() != 0) |
if (geteuid() != 0) |
set_perms(PERM_ROOT, 0); |
set_perms(PERM_ROOT); |
|
|
/* Expand printf-style format + args. */ |
/* Expand printf-style format + args. */ |
evasprintf(&message, fmt, ap); |
evasprintf(&message, fmt, ap); |
|
|
* (so user cannot kill it) or as the user (for the paranoid). |
* (so user cannot kill it) or as the user (for the paranoid). |
*/ |
*/ |
#ifndef NO_ROOT_MAILER |
#ifndef NO_ROOT_MAILER |
set_perms(PERM_FULL_ROOT, 0); |
set_perms(PERM_FULL_ROOT); |
execve(mpath, argv, root_envp); |
execve(mpath, argv, root_envp); |
#else |
#else |
set_perms(PERM_FULL_USER, 0); |
set_perms(PERM_FULL_USER); |
execv(mpath, argv); |
execv(mpath, argv); |
#endif /* NO_ROOT_MAILER */ |
#endif /* NO_ROOT_MAILER */ |
_exit(127); |
_exit(127); |