-/* $OpenBSD: log.c,v 1.3 2017/04/06 14:55:43 bluhm Exp $ */
+/* $OpenBSD: log.c,v 1.4 2017/04/28 14:52:13 bluhm Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
#include "log.h"
#include "syslogd.h"
-static int debug;
static int verbose;
static int facility;
static const char *log_procname;
{
extern char *__progname;
- debug = n_debug;
verbose = n_debug;
facility = fac;
log_procinit(__progname);
log_procname = procname;
}
-void
-log_setdebug(int d)
-{
- debug = d;
-}
-
-int
-log_getdebug(void)
-{
- return (debug);
-}
-
void
log_setverbose(int v)
{
void
vlog(int pri, const char *fmt, va_list ap)
{
- char ebuf[ERRBUFSIZE];
- size_t l;
int saved_errno = errno;
- if (debug) {
- l = snprintf(ebuf, sizeof(ebuf), "%s: ", log_procname);
- if (l < sizeof(ebuf))
- vsnprintf(ebuf+l, sizeof(ebuf)-l, fmt, ap);
- fprintf(stderr, "%s\n", ebuf);
- fflush(stderr);
- } else
- vlogmsg(facility|pri, log_procname, fmt, ap);
+ vlogmsg(facility|pri, log_procname, fmt, ap);
errno = saved_errno;
}
-/* $OpenBSD: log.h,v 1.2 2017/04/05 11:31:45 bluhm Exp $ */
+/* $OpenBSD: log.h,v 1.3 2017/04/28 14:52:13 bluhm Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
void log_init(int, int);
void log_procinit(const char *);
-void log_setdebug(int);
-int log_getdebug(void);
void log_setverbose(int);
int log_getverbose(void);
void log_warn(const char *, ...)
-/* $OpenBSD: syslogd.c,v 1.243 2017/04/25 17:45:50 bluhm Exp $ */
+/* $OpenBSD: syslogd.c,v 1.244 2017/04/28 14:52:13 bluhm Exp $ */
/*
* Copyright (c) 1983, 1988, 1993, 1994
int Foreground; /* run in foreground, instead of daemonizing */
char LocalHostName[HOST_NAME_MAX+1]; /* our hostname */
char *LocalDomain; /* our local domain name */
+int Started = 0; /* set after privsep */
int Initialized = 0; /* set when we have initialized ourselves */
int MarkInterval = 20 * 60; /* interval between marks in seconds */
log_init(Debug, LOG_SYSLOG);
log_procinit("syslogd");
- log_setdebug(1);
if (Debug)
setvbuf(stdout, NULL, _IOLBF, 0);
if (pledge("stdio unix inet recvfd", NULL) == -1)
err(1, "pledge");
+ Started = 1;
+
/* Process is now unprivileged and inside a chroot */
if (Debug)
event_set_log_callback(logevent);
init();
- log_setdebug(0);
-
/* Allocate ctl socket reply buffer if we have a ctl socket */
if (fd_ctlsock != -1 &&
(ctl_reply = malloc(CTL_REPLY_MAXSIZE)) == NULL)
l = snprintf(msg, sizeof(msg), "%s[%d]: ", proc, getpid());
if (l < sizeof(msg))
vsnprintf(msg + l, sizeof(msg) - l, fmt, ap);
+ if (!Started) {
+ fprintf(stderr, "%s\n", msg);
+ return;
+ }
logline(pri, ADDDATE, LocalHostName, msg);
}
f->f_file = priv_open_tty(ctty);
if (f->f_file >= 0) {
+ strlcpy(f->f_lasttime, timestamp,
+ sizeof(f->f_lasttime));
+ strlcpy(f->f_prevhost, from,
+ sizeof(f->f_prevhost));
fprintlog(f, flags, msg);
(void)close(f->f_file);
f->f_file = -1;