add log_year option

This commit is contained in:
Todd C. Miller
1999-09-14 16:56:32 +00:00
parent c1f71dcd85
commit 80ac47fb07
3 changed files with 22 additions and 10 deletions

View File

@@ -147,6 +147,9 @@ struct sudo_defs_types {
}, {
"log_host", T_FLAG, FL_LOG_HOST, NULL,
"Log the hostname in the (non-syslog) log file"
}, {
"log_year", T_FLAG, FL_LOG_YEAR, NULL,
"Log the year in the (non-syslog) log file"
}, {
"shell_noargs", T_FLAG, FL_SHELL_NOARGS, NULL,
"If sudo is invoked with no arguments, start a shell"

View File

@@ -68,6 +68,7 @@
#define FL_PATH_INFO 0x02000
#define FL_FQDN 0x04000
#define FL_INSULTS 0x08000
#define FL_LOG_YEAR 0x10000
#define FL_MAX 0xFFFFF
/*

View File

@@ -149,7 +149,7 @@ static void
do_logfile(msg)
char *msg;
{
char *full_line;
char *full_line, *timestr;
char *beg, *oldend, *end;
FILE *fp;
mode_t oldmask;
@@ -172,21 +172,25 @@ do_logfile(msg)
send_mail(full_line);
free(full_line);
} else {
timestr = ctime(&now) + 4; /* skip day of the week */
if (sudo_flag_set(FL_LOG_YEAR))
timestr[20] = '\0'; /* avoid the newline */
else
timestr[15] = '\0'; /* don't care about year */
if (sudo_inttable[I_LOGLEN] == 0) {
/* Don't pretty-print long log file lines (hard to grep) */
if (sudo_flag_set(FL_LOG_HOST))
(void) fprintf(fp, "%15.15s : %s : HOST=%s : %s\n",
ctime(&now) + 4, user_name, user_shost, msg);
(void) fprintf(fp, "%s : %s : HOST=%s : %s\n", timestr,
user_name, user_shost, msg);
else
(void) fprintf(fp, "%15.15s : %s : %s\n", ctime(&now) + 4,
user_name, msg);
(void) fprintf(fp, "%s : %s : %s\n", timestr, user_name, msg);
} else {
if (sudo_flag_set(FL_LOG_HOST))
easprintf(&full_line, "%15.15s : %s : HOST=%s : %s",
ctime(&now) + 4, user_name, user_shost, msg);
easprintf(&full_line, "%s : %s : HOST=%s : %s", timestr,
user_name, user_shost, msg);
else
easprintf(&full_line, "%15.15s : %s : %s", ctime(&now) + 4,
user_name, msg);
easprintf(&full_line, "%s : %s : %s", timestr, user_name, msg);
/*
* Print out full_line with word wrap
@@ -465,7 +469,11 @@ send_mail(line)
}
now = time((time_t) 0);
p = ctime(&now) + 4;
(void) fprintf(mail, "\n\n%s : %15.15s : %s : %s\n\n", user_host, p,
if (sudo_flag_set(FL_LOG_YEAR))
p[20] = '\0'; /* avoid the newline */
else
p[15] = '\0'; /* don't care about year */
(void) fprintf(mail, "\n\n%s : %s : %s : %s\n\n", user_host, p,
user_name, line);
fclose(mail);
reapchild(0);