aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/syslogd
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
commit98e0ffaefb0f241cda3a72395d3be04192ae0d47 (patch)
tree55c065b6730aaac2afb6c29933ee6ec5fa4c4249 /usr.sbin/syslogd
parentb17ff922d4072ae132ece458f5b5d74a236880ac (diff)
parente81032ad243db32b8fd615b2d55ee94b9f6a5b6a (diff)
downloadsrc-98e0ffaefb0f241cda3a72395d3be04192ae0d47.tar.gz
src-98e0ffaefb0f241cda3a72395d3be04192ae0d47.zip
Merge sync of head
Notes
Notes: svn path=/projects/bmake/; revision=283595
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r--usr.sbin/syslogd/Makefile3
-rw-r--r--usr.sbin/syslogd/pathnames.h2
-rw-r--r--usr.sbin/syslogd/syslogd.815
-rw-r--r--usr.sbin/syslogd/syslogd.c25
4 files changed, 28 insertions, 17 deletions
diff --git a/usr.sbin/syslogd/Makefile b/usr.sbin/syslogd/Makefile
index 069e093ccd21..716efbe7d597 100644
--- a/usr.sbin/syslogd/Makefile
+++ b/usr.sbin/syslogd/Makefile
@@ -9,8 +9,7 @@ PROG= syslogd
MAN= syslog.conf.5 syslogd.8
SRCS= syslogd.c ttymsg.c
-DPADD= ${LIBUTIL}
-LDADD= -lutil
+LIBADD= util
WARNS?= 3
diff --git a/usr.sbin/syslogd/pathnames.h b/usr.sbin/syslogd/pathnames.h
index 24fbc4cfa0ad..00631e0e4bf2 100644
--- a/usr.sbin/syslogd/pathnames.h
+++ b/usr.sbin/syslogd/pathnames.h
@@ -30,8 +30,6 @@
* $FreeBSD$
*/
-#include <paths.h>
-
#define _PATH_KLOG "/dev/klog"
#define _PATH_LOGCONF "/etc/syslog.conf"
#define _PATH_LOGPID "/var/run/syslog.pid"
diff --git a/usr.sbin/syslogd/syslogd.8 b/usr.sbin/syslogd/syslogd.8
index 5b175a6fd718..b2e8818883c0 100644
--- a/usr.sbin/syslogd/syslogd.8
+++ b/usr.sbin/syslogd/syslogd.8
@@ -28,7 +28,7 @@
.\" @(#)syslogd.8 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd May 13, 2008
+.Dd March 3, 2015
.Dt SYSLOGD 8
.Os
.Sh NAME
@@ -36,7 +36,7 @@
.Nd log systems messages
.Sh SYNOPSIS
.Nm
-.Op Fl 468ACcdkNnosTuv
+.Op Fl 468ACcdFkNnosTuv
.Op Fl a Ar allowed_peer
.Op Fl b Ar bind_address
.Op Fl f Ar config_file
@@ -213,6 +213,17 @@ This is probably only of use to developers working on
Specify the pathname of an alternate configuration file;
the default is
.Pa /etc/syslog.conf .
+.It Fl F
+Run
+.Nm
+in the foreground, rather than going into daemon mode. This is useful if
+some other process uses
+.Xr fork 2
+and
+.Xr exec 3
+to run
+.Nm ,
+and wants to monitor when and how it exits.
.It Fl k
Disable the translation of
messages received with facility
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 60c74d1d3d59..baa79c865e1a 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -271,6 +271,7 @@ static struct filed *Files; /* Log files that we write to */
static struct filed consfile; /* Console */
static int Debug; /* debug flag */
+static int Foreground = 0; /* Run in foreground, instead of daemonizing */
static int resolve = 1; /* resolve hostname */
static char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */
static const char *LocalDomain; /* our local domain name */
@@ -360,7 +361,7 @@ main(int argc, char *argv[])
dprintf("madvise() failed: %s\n", strerror(errno));
bindhostname = NULL;
- while ((ch = getopt(argc, argv, "468Aa:b:cCdf:kl:m:nNop:P:sS:Tuv"))
+ while ((ch = getopt(argc, argv, "468Aa:b:cCdf:Fkl:m:nNop:P:sS:Tuv"))
!= -1)
switch (ch) {
case '4':
@@ -396,6 +397,9 @@ main(int argc, char *argv[])
case 'f': /* configuration file */
ConfFile = optarg;
break;
+ case 'F': /* run in foreground instead of daemon */
+ Foreground++;
+ break;
case 'k': /* keep remote kern fac */
KeepKernFac = 1;
break;
@@ -487,14 +491,14 @@ main(int argc, char *argv[])
warn("cannot open pid file");
}
- if (!Debug) {
+ if ((!Foreground) && (!Debug)) {
ppid = waitdaemon(0, 0, 30);
if (ppid < 0) {
warn("could not become daemon");
pidfile_remove(pfh);
exit(1);
}
- } else {
+ } else if (Debug) {
setlinebuf(stdout);
}
@@ -557,7 +561,8 @@ main(int argc, char *argv[])
if (finet) {
if (SecureMode) {
for (i = 0; i < *finet; i++) {
- if (shutdown(finet[i+1], SHUT_RD) < 0) {
+ if (shutdown(finet[i+1], SHUT_RD) < 0 &&
+ errno != ENOTCONN) {
logerror("shutdown");
if (!Debug)
die(0);
@@ -713,7 +718,7 @@ usage(void)
{
fprintf(stderr, "%s\n%s\n%s\n%s\n",
- "usage: syslogd [-468ACcdknosTuv] [-a allowed_peer]",
+ "usage: syslogd [-468ACcdFknosTuv] [-a allowed_peer]",
" [-b bind_address] [-f config_file]",
" [-l [mode:]path] [-m mark_interval]",
" [-P pid_file] [-p log_socket]");
@@ -1020,7 +1025,7 @@ logmsg(int pri, const char *msg, const char *from, int flags)
*/
if (no_compress - (f->f_type != F_PIPE) < 1 &&
(flags & MARK) == 0 && msglen == f->f_prevlen &&
- f->f_prevline && !strcmp(msg, f->f_prevline) &&
+ !strcmp(msg, f->f_prevline) &&
!strcasecmp(from, f->f_prevhost)) {
(void)strlcpy(f->f_lasttime, timestamp,
sizeof(f->f_lasttime));
@@ -1175,11 +1180,9 @@ fprintlog(struct filed *f, int flags, const char *msg)
v->iov_base = repbuf;
v->iov_len = snprintf(repbuf, sizeof repbuf,
"last message repeated %d times", f->f_prevcount);
- } else if (f->f_prevline) {
+ } else {
v->iov_base = f->f_prevline;
v->iov_len = f->f_prevlen;
- } else {
- return;
}
v++;
@@ -1542,7 +1545,7 @@ init(int signo)
struct filed *f, *next, **nextp;
char *p;
char cline[LINE_MAX];
- char prog[NAME_MAX+1];
+ char prog[LINE_MAX];
char host[MAXHOSTNAMELEN];
char oldLocalHostName[MAXHOSTNAMELEN];
char hostMsg[2*MAXHOSTNAMELEN+40];
@@ -1664,7 +1667,7 @@ init(int signo)
(void)strlcpy(prog, "*", sizeof(prog));
continue;
}
- for (i = 0; i < NAME_MAX; i++) {
+ for (i = 0; i < LINE_MAX - 1; i++) {
if (!isprint(p[i]) || isspace(p[i]))
break;
prog[i] = p[i];