summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syslogd
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2003-05-17 20:05:18 +0000
committergshapiro <gshapiro@FreeBSD.org>2003-05-17 20:05:18 +0000
commit02f3b3510d0b0af1b034d8390f9ca5d05444595f (patch)
tree95625d94b2c250c22a2f7552df0cfe821958dc8c /usr.sbin/syslogd
parent320fc630d47c01877e06487a30718973c148da1d (diff)
downloadFreeBSD-src-02f3b3510d0b0af1b034d8390f9ca5d05444595f.zip
FreeBSD-src-02f3b3510d0b0af1b034d8390f9ca5d05444595f.tar.gz
Avoid code duplication by using libutil's trimdomain() instead of
an incorrect re-implementation. PR: 52223, 52342 Submitted by: Dan Nelson <dnelson@allantgroup.com> Approved by: re (bmah/rwatson) MFC after: 2 days
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r--usr.sbin/syslogd/Makefile3
-rw-r--r--usr.sbin/syslogd/syslogd.c14
2 files changed, 7 insertions, 10 deletions
diff --git a/usr.sbin/syslogd/Makefile b/usr.sbin/syslogd/Makefile
index a961eb9..96abfba 100644
--- a/usr.sbin/syslogd/Makefile
+++ b/usr.sbin/syslogd/Makefile
@@ -7,6 +7,9 @@ PROG= syslogd
MAN= syslog.conf.5 syslogd.8
SRCS= syslogd.c ttymsg.c
+DPADD+= ${LIBUTIL}
+LDADD+= -lutil
+
WARNS?= 1
CFLAGS+=-DINET6 -I${.CURDIR}/../../usr.bin/wall
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index e54d817..5d2f21b 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -90,6 +90,7 @@ __FBSDID("$FreeBSD$");
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/syslimits.h>
+#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
@@ -99,6 +100,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <libutil.h>
#include <limits.h>
#include <paths.h>
#include <signal.h>
@@ -262,7 +264,6 @@ static int Debug; /* debug flag */
static int resolve = 1; /* resolve hostname */
static char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */
static char *LocalDomain; /* our local domain name */
-static int LocalDomainLen; /* length of LocalDomain */
static int *finet; /* Internet datagram socket */
static int fklog = -1; /* /dev/klog */
static int Initialized; /* set when we have initialized ourselves */
@@ -1308,9 +1309,7 @@ cvthname(struct sockaddr *f)
hl = strlen(hname);
if (hl > 0 && hname[hl-1] == '.')
hname[--hl] = '\0';
- if (hl > LocalDomainLen && hname[hl-LocalDomainLen] == '.' &&
- strcasecmp(hname + hl - LocalDomainLen + 1, LocalDomain) == 0)
- hname[hl-LocalDomainLen] = '\0';
+ trimdomain(hname, hl);
return (hname);
}
@@ -1409,7 +1408,6 @@ init(int signo)
} else {
LocalDomain = "";
}
- LocalDomainLen = strlen(LocalDomain);
/*
* Close all open log files.
@@ -1631,11 +1629,7 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host)
hl = strlen(f->f_host);
if (hl > 0 && f->f_host[hl-1] == '.')
f->f_host[--hl] = '\0';
- if (hl > LocalDomainLen &&
- f->f_host[hl-LocalDomainLen] == '.' &&
- strcasecmp(f->f_host + hl - LocalDomainLen + 1,
- LocalDomain) == 0)
- f->f_host[hl-LocalDomainLen] = '\0';
+ trimdomain(f->f_host, hl);
}
/* save program name if any */
OpenPOWER on IntegriCloud