summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syslogd
diff options
context:
space:
mode:
authorpaul <paul@FreeBSD.org>1995-09-11 13:55:11 +0000
committerpaul <paul@FreeBSD.org>1995-09-11 13:55:11 +0000
commit75317367c5639135a2e4ee215d48e0fe2fc0a9fc (patch)
tree26e5131082a1fa4dba48ed47d9026512790e7c3b /usr.sbin/syslogd
parent1b15405165baa6d27d795f8a4afc3d7f6e9288a1 (diff)
downloadFreeBSD-src-75317367c5639135a2e4ee215d48e0fe2fc0a9fc.zip
FreeBSD-src-75317367c5639135a2e4ee215d48e0fe2fc0a9fc.tar.gz
Remove unconditional unlink at startup and conditionalised the unlink at exit
so that it only unlinks the file if syslogd knows it created it. If the path specified for the socket already exists then syslogd will now exit with an "address already in use" error which is more sensible than blindly unlinking the existing filename. This stops syslogd -d foo/bar from unlinking foo/bar if it's a real file.
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r--usr.sbin/syslogd/syslogd.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 7a6c27e..03d95b6 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -190,6 +190,7 @@ int LogPort; /* port number for INET connections */
int Initialized = 0; /* set when we have initialized ourselves */
int MarkInterval = 20 * 60; /* interval between marks in seconds */
int MarkSeq = 0; /* mark sequence number */
+int created_lsock = 0; /* Flag if local socket created */
void cfline __P((char *, struct filed *, char *));
char *cvthname __P((struct sockaddr_in *));
@@ -258,7 +259,6 @@ main(argc, argv)
(void)signal(SIGCHLD, reapchild);
(void)signal(SIGALRM, domark);
(void)alarm(TIMERINTVL);
- (void)unlink(LogName);
#ifndef SUN_LEN
#define SUN_LEN(unp) (strlen((unp)->sun_path) + 2)
@@ -274,7 +274,8 @@ main(argc, argv)
logerror(line);
dprintf("cannot create %s (%d)\n", LogName, errno);
die(0);
- }
+ } else
+ created_lsock = 1;
finet = socket(AF_INET, SOCK_DGRAM, 0);
inetm = 0;
if (finet >= 0) {
@@ -876,7 +877,8 @@ die(signo)
errno = 0;
logerror(buf);
}
- (void)unlink(LogName);
+ if (created_lsock)
+ (void)unlink(LogName);
exit(0);
}
OpenPOWER on IntegriCloud