summaryrefslogtreecommitdiff
path: root/usr.sbin/ldpd/control.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@cvs.openbsd.org>2017-03-03 23:30:58 +0000
committerRenato Westphal <renato@cvs.openbsd.org>2017-03-03 23:30:58 +0000
commit0019a22123f7c0dc97d4cbec810e849674afe0b9 (patch)
tree892ffd1c4584dba01caa75d3ade8503dc77a89dc /usr.sbin/ldpd/control.c
parentca4c2bd031f6a1ed7093ab27da6c87a45fffc02f (diff)
Allow to specify an alternate control socket.
This is required to run multiple instances of ldpd. OK claudio@
Diffstat (limited to 'usr.sbin/ldpd/control.c')
-rw-r--r--usr.sbin/ldpd/control.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/usr.sbin/ldpd/control.c b/usr.sbin/ldpd/control.c
index b6a209912e7..fe0eebdbea6 100644
--- a/usr.sbin/ldpd/control.c
+++ b/usr.sbin/ldpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.28 2017/01/08 23:04:42 krw Exp $ */
+/* $OpenBSD: control.c,v 1.29 2017/03/03 23:30:57 renato Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -42,7 +42,7 @@ struct ctl_conns ctl_conns;
static int control_fd;
int
-control_init(void)
+control_init(char *path)
{
struct sockaddr_un sun;
int fd;
@@ -56,28 +56,28 @@ control_init(void)
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX;
- strlcpy(sun.sun_path, LDPD_SOCKET, sizeof(sun.sun_path));
+ strlcpy(sun.sun_path, path, sizeof(sun.sun_path));
- if (unlink(LDPD_SOCKET) == -1)
+ if (unlink(path) == -1)
if (errno != ENOENT) {
- log_warn("%s: unlink %s", __func__, LDPD_SOCKET);
+ log_warn("%s: unlink %s", __func__, path);
close(fd);
return (-1);
}
old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH);
if (bind(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) {
- log_warn("%s: bind: %s", __func__, LDPD_SOCKET);
+ log_warn("%s: bind: %s", __func__, path);
close(fd);
umask(old_umask);
return (-1);
}
umask(old_umask);
- if (chmod(LDPD_SOCKET, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1) {
+ if (chmod(path, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1) {
log_warn("%s: chmod", __func__);
close(fd);
- (void)unlink(LDPD_SOCKET);
+ (void)unlink(path);
return (-1);
}
@@ -98,11 +98,11 @@ control_listen(void)
}
void
-control_cleanup(void)
+control_cleanup(char *path)
{
accept_del(control_fd);
close(control_fd);
- unlink(LDPD_SOCKET);
+ unlink(path);
}
/* ARGSUSED */