send_mail(full_line);
efree(full_line);
} else {
+ time_t now;
+
+ now = time(NULL);
if (def_loglinelen == 0) {
/* Don't pretty-print long log file lines (hard to grep) */
if (def_log_host)
(void) fprintf(fp, "%s : %s : HOST=%s : %s\n",
- get_timestr(def_log_year), user_name, user_shost, msg);
+ get_timestr(now, def_log_year), user_name, user_shost, msg);
else
- (void) fprintf(fp, "%s : %s : %s\n", get_timestr(def_log_year),
- user_name, msg);
+ (void) fprintf(fp, "%s : %s : %s\n",
+ get_timestr(now, def_log_year), user_name, msg);
} else {
if (def_log_host)
easprintf(&full_line, "%s : %s : HOST=%s : %s",
- get_timestr(def_log_year), user_name, user_shost, msg);
+ get_timestr(now, def_log_year), user_name, user_shost, msg);
else
- easprintf(&full_line, "%s : %s : %s", get_timestr(def_log_year),
- user_name, msg);
+ easprintf(&full_line, "%s : %s : %s",
+ get_timestr(now, def_log_year), user_name, msg);
/*
* Print out full_line with word wrap
(void) fputc(*p, mail);
}
(void) fprintf(mail, "\n\n%s : %s : %s : %s\n\n", user_host,
- get_timestr(def_log_year), user_name, line);
+ get_timestr(time(NULL), def_log_year), user_name, line);
fclose(mail);
do {
#ifdef HAVE_WAITPID
__unused static const char rcsid[] = "$Sudo$";
#endif /* lint */
-char *get_timestr __P((int));
+char *get_timestr __P((time_t, int));
/*
* Return an ascii string with the current date + time
* Uses strftime() if available, else falls back to ctime().
*/
char *
-get_timestr(log_year)
+get_timestr(tstamp, log_year)
+ time_t tstamp;
int log_year;
{
char *s;
- time_t now = time((time_t) 0);
#ifdef HAVE_STRFTIME
static char buf[128];
struct tm *timeptr;
- timeptr = localtime(&now);
+ timeptr = localtime(&tstamp);
if (log_year)
s = "%h %e %T %Y";
else
#endif /* HAVE_STRFTIME */
- s = ctime(&now) + 4; /* skip day of the week */
+ s = ctime(&tstamp) + 4; /* skip day of the week */
if (log_year)
s[20] = '\0'; /* avoid the newline */
else