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_host", T_FLAG, FL_LOG_HOST, NULL,
|
||||||
"Log the hostname in the (non-syslog) log file"
|
"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,
|
"shell_noargs", T_FLAG, FL_SHELL_NOARGS, NULL,
|
||||||
"If sudo is invoked with no arguments, start a shell"
|
"If sudo is invoked with no arguments, start a shell"
|
||||||
|
@@ -68,6 +68,7 @@
|
|||||||
#define FL_PATH_INFO 0x02000
|
#define FL_PATH_INFO 0x02000
|
||||||
#define FL_FQDN 0x04000
|
#define FL_FQDN 0x04000
|
||||||
#define FL_INSULTS 0x08000
|
#define FL_INSULTS 0x08000
|
||||||
|
#define FL_LOG_YEAR 0x10000
|
||||||
#define FL_MAX 0xFFFFF
|
#define FL_MAX 0xFFFFF
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
28
logging.c
28
logging.c
@@ -149,7 +149,7 @@ static void
|
|||||||
do_logfile(msg)
|
do_logfile(msg)
|
||||||
char *msg;
|
char *msg;
|
||||||
{
|
{
|
||||||
char *full_line;
|
char *full_line, *timestr;
|
||||||
char *beg, *oldend, *end;
|
char *beg, *oldend, *end;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
mode_t oldmask;
|
mode_t oldmask;
|
||||||
@@ -172,21 +172,25 @@ do_logfile(msg)
|
|||||||
send_mail(full_line);
|
send_mail(full_line);
|
||||||
free(full_line);
|
free(full_line);
|
||||||
} else {
|
} 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) {
|
if (sudo_inttable[I_LOGLEN] == 0) {
|
||||||
/* Don't pretty-print long log file lines (hard to grep) */
|
/* Don't pretty-print long log file lines (hard to grep) */
|
||||||
if (sudo_flag_set(FL_LOG_HOST))
|
if (sudo_flag_set(FL_LOG_HOST))
|
||||||
(void) fprintf(fp, "%15.15s : %s : HOST=%s : %s\n",
|
(void) fprintf(fp, "%s : %s : HOST=%s : %s\n", timestr,
|
||||||
ctime(&now) + 4, user_name, user_shost, msg);
|
user_name, user_shost, msg);
|
||||||
else
|
else
|
||||||
(void) fprintf(fp, "%15.15s : %s : %s\n", ctime(&now) + 4,
|
(void) fprintf(fp, "%s : %s : %s\n", timestr, user_name, msg);
|
||||||
user_name, msg);
|
|
||||||
} else {
|
} else {
|
||||||
if (sudo_flag_set(FL_LOG_HOST))
|
if (sudo_flag_set(FL_LOG_HOST))
|
||||||
easprintf(&full_line, "%15.15s : %s : HOST=%s : %s",
|
easprintf(&full_line, "%s : %s : HOST=%s : %s", timestr,
|
||||||
ctime(&now) + 4, user_name, user_shost, msg);
|
user_name, user_shost, msg);
|
||||||
else
|
else
|
||||||
easprintf(&full_line, "%15.15s : %s : %s", ctime(&now) + 4,
|
easprintf(&full_line, "%s : %s : %s", timestr, user_name, msg);
|
||||||
user_name, msg);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print out full_line with word wrap
|
* Print out full_line with word wrap
|
||||||
@@ -465,7 +469,11 @@ send_mail(line)
|
|||||||
}
|
}
|
||||||
now = time((time_t) 0);
|
now = time((time_t) 0);
|
||||||
p = ctime(&now) + 4;
|
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);
|
user_name, line);
|
||||||
fclose(mail);
|
fclose(mail);
|
||||||
reapchild(0);
|
reapchild(0);
|
||||||
|
Reference in New Issue
Block a user