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
This commit is contained in:
Gregory Neil Shapiro 2003-05-17 20:05:18 +00:00
parent 94deb3f034
commit a22139f98d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=115108
2 changed files with 7 additions and 10 deletions

View File

@ -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

View File

@ -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 */