static char *logline;
extern int errorlineno;
-/*
- * length of syslog-like header info used for mail and file logs
- * is len("Mon MM HH:MM:SS : username : ")
- */
-#define LOG_HEADER_LEN 29
-
#ifdef BROKEN_SYSLOG
#define MAXSYSLOGTRIES 16 /* num of retries for broken syslogs */
#define SYSLOG(a,b,c,d) syslog_wrapper(a,b,c,d)
int code;
{
char *p;
- int count;
+ int count, header_length;
time_t now;
#if (LOGGING & SLOG_FILE)
mode_t oldmask;
char *tmp, save;
#endif /* LOGGING & SLOG_SYSLOG */
+ /*
+ * length of syslog-like header info used for mail and file logs
+ * is len("DDD MM HH:MM:SS : username : ") with an additional
+ * len("HOST=hostname : ") if HOST_IN_LOG is defined.
+ */
+ header_length = 21 + strlen(user_name);
+#ifdef HOST_IN_LOG
+ header_length += 8 + strlen(shost);
+#endif
+
/*
* Allocate enough memory for logline so we won't overflow it
*/
- count = LOG_HEADER_LEN + 136 + 2 * MAXPATHLEN + strlen(tty) + strlen(cwd) +
+ count = header_length + 136 + 2 * MAXPATHLEN + strlen(tty) + strlen(cwd) +
strlen(runas_user);
if (cmnd_args)
count += strlen(cmnd_args);
*/
now = time((time_t) 0);
p = ctime(&now) + 4;
- (void) sprintf(logline, "%15.15s : %8.8s : ", p, user_name);
+#ifdef HOST_IN_LOG
+ (void) sprintf(logline, "%15.15s : %s : HOST=%s : ", p, user_name, shost);
+#else
+ (void) sprintf(logline, "%15.15s : %s : ", p, user_name);
+#endif
/*
* we need a pointer to the end of logline for cheap appends.
*/
- p = logline + LOG_HEADER_LEN;
+ p = logline + header_length;
switch (code) {
/*
* Log the full line, breaking into multiple syslog(3) calls if necesary
*/
- p = &logline[LOG_HEADER_LEN]; /* skip past the date and user */
+ p = &logline[header_length]; /* skip past the date, host, and user */
for (count = 0; count < strlen(logline) / MAXSYSLOGLEN + 1; count++) {
if (strlen(p) > MAXSYSLOGLEN) {
/*
char *beg, *oldend, *end;
int maxlen = MAXLOGFILELEN;
+#ifndef WRAP_LOG
+ (void) fprintf(fp, "%s\n", logline);
+#else
/*
* Print out logline with word wrap
*/
beg = NULL; /* exit condition */
}
}
+#endif
(void) fclose(fp);
}