From 02f3b3510d0b0af1b034d8390f9ca5d05444595f Mon Sep 17 00:00:00 2001 From: gshapiro Date: Sat, 17 May 2003 20:05:18 +0000 Subject: Avoid code duplication by using libutil's trimdomain() instead of an incorrect re-implementation. PR: 52223, 52342 Submitted by: Dan Nelson Approved by: re (bmah/rwatson) MFC after: 2 days --- usr.sbin/syslogd/Makefile | 3 +++ usr.sbin/syslogd/syslogd.c | 14 ++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) (limited to 'usr.sbin') 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 #include #include +#include #include #include @@ -99,6 +100,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -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 */ -- cgit v1.1