add log_year option
This commit is contained in:
@@ -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"
|
||||
|
@@ -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
|
||||
|
||||
/*
|
||||
|
28
logging.c
28
logging.c
@@ -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);
|
||||
|
Reference in New Issue
Block a user