summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ldpd/control.c14
-rw-r--r--ldpd/ldp_vty_exec.c4
-rw-r--r--ldpd/ldpd.c43
-rw-r--r--ldpd/ldpd.h1
-rw-r--r--ldpd/ldpe.c3
-rw-r--r--ldpd/ldpe.h2
6 files changed, 50 insertions, 17 deletions
diff --git a/ldpd/control.c b/ldpd/control.c
index ba303cc12..8a2280be0 100644
--- a/ldpd/control.c
+++ b/ldpd/control.c
@@ -51,28 +51,28 @@ control_init(void)
memset(&s_un, 0, sizeof(s_un));
s_un.sun_family = AF_UNIX;
- strlcpy(s_un.sun_path, LDPD_SOCKET, sizeof(s_un.sun_path));
+ strlcpy(s_un.sun_path, ctl_sock_path, sizeof(s_un.sun_path));
- if (unlink(LDPD_SOCKET) == -1)
+ if (unlink(ctl_sock_path) == -1)
if (errno != ENOENT) {
- log_warn("%s: unlink %s", __func__, LDPD_SOCKET);
+ log_warn("%s: unlink %s", __func__, ctl_sock_path);
close(fd);
return (-1);
}
old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH);
if (bind(fd, (struct sockaddr *)&s_un, sizeof(s_un)) == -1) {
- log_warn("%s: bind: %s", __func__, LDPD_SOCKET);
+ log_warn("%s: bind: %s", __func__, ctl_sock_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(ctl_sock_path, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1) {
log_warn("%s: chmod", __func__);
close(fd);
- (void)unlink(LDPD_SOCKET);
+ (void)unlink(ctl_sock_path);
return (-1);
}
@@ -97,7 +97,7 @@ control_cleanup(void)
{
accept_del(control_fd);
close(control_fd);
- unlink(LDPD_SOCKET);
+ unlink(ctl_sock_path);
}
/* ARGSUSED */
diff --git a/ldpd/ldp_vty_exec.c b/ldpd/ldp_vty_exec.c
index a57cf3c3f..a9138be2f 100644
--- a/ldpd/ldp_vty_exec.c
+++ b/ldpd/ldp_vty_exec.c
@@ -405,9 +405,9 @@ ldp_vty_connect(struct imsgbuf *ibuf)
memset(&s_un, 0, sizeof(s_un));
s_un.sun_family = AF_UNIX;
- strlcpy(s_un.sun_path, LDPD_SOCKET, sizeof(s_un.sun_path));
+ strlcpy(s_un.sun_path, ctl_sock_path, sizeof(s_un.sun_path));
if (connect(ctl_sock, (struct sockaddr *)&s_un, sizeof(s_un)) == -1) {
- log_warn("%s: connect: %s", __func__, LDPD_SOCKET);
+ log_warn("%s: connect: %s", __func__, ctl_sock_path);
close(ctl_sock);
return (-1);
}
diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c
index 5d0e79aec..40726ba0b 100644
--- a/ldpd/ldpd.c
+++ b/ldpd/ldpd.c
@@ -43,7 +43,7 @@
static void ldpd_shutdown(void);
static pid_t start_child(enum ldpd_process, char *, int,
- const char *, const char *);
+ const char *, const char *, const char *);
static int main_dispatch_ldpe(struct thread *);
static int main_dispatch_lde(struct thread *);
static int main_imsg_send_ipc_sockets(struct imsgbuf *,
@@ -118,8 +118,12 @@ struct zebra_privs_t ldpd_privs =
/* VTY Socket prefix */
char vty_sock_path[MAXPATHLEN] = LDP_VTYSH_PATH;
+/* CTL Socket path */
+char ctl_sock_path[MAXPATHLEN] = LDPD_SOCKET;
+
/* LDPd options. */
#define OPTION_VTYSOCK 1000
+#define OPTION_CTLSOCK 1001
static struct option longopts[] =
{
{ "daemon", no_argument, NULL, 'd'},
@@ -131,6 +135,7 @@ static struct option longopts[] =
{ "vty_addr", required_argument, NULL, 'A'},
{ "vty_port", required_argument, NULL, 'P'},
{ "vty_socket", required_argument, NULL, OPTION_VTYSOCK},
+ { "ctl_socket", required_argument, NULL, OPTION_CTLSOCK},
{ "user", required_argument, NULL, 'u'},
{ "group", required_argument, NULL, 'g'},
{ "version", no_argument, NULL, 'v'},
@@ -154,6 +159,7 @@ Daemon which manages LDP.\n\n\
-A, --vty_addr Set vty's bind address\n\
-P, --vty_port Set vty's port number\n\
--vty_socket Override vty socket path\n\
+ --ctl_socket Override ctl socket path\n\
-u, --user User to run as\n\
-g, --group Group to run as\n\
-v, --version Print program version\n\
@@ -219,6 +225,8 @@ main(int argc, char *argv[])
char *vty_addr = NULL;
int vty_port = LDP_VTY_PORT;
char *vty_sock_name;
+ char *ctl_sock_custom_path = NULL;
+ char *ctl_sock_name;
int daemon_mode = 0;
const char *user = NULL;
const char *group = NULL;
@@ -282,6 +290,25 @@ main(int argc, char *argv[])
case OPTION_VTYSOCK:
set_socket_path(vty_sock_path, LDP_VTYSH_PATH, optarg, sizeof (vty_sock_path));
break;
+ case OPTION_CTLSOCK:
+ ctl_sock_name = strrchr(LDPD_SOCKET, '/');
+ if (ctl_sock_name)
+ /* skip '/' */
+ ctl_sock_name++;
+ else
+ /*
+ * LDPD_SOCKET configured as relative path
+ * during config? Should really never happen for
+ * sensible config
+ */
+ ctl_sock_name = (char *)LDPD_SOCKET;
+ ctl_sock_custom_path = optarg;
+ strlcpy(ctl_sock_path, ctl_sock_custom_path,
+ sizeof(ctl_sock_path));
+ strlcat(ctl_sock_path, "/", sizeof(ctl_sock_path));
+ strlcat(ctl_sock_path, ctl_sock_name,
+ sizeof(ctl_sock_path));
+ break;
case 'u':
user = optarg;
break;
@@ -328,7 +355,7 @@ main(int argc, char *argv[])
if (lflag)
lde(user, group);
else if (eflag)
- ldpe(user, group);
+ ldpe(user, group, ctl_sock_path);
master = thread_master_create();
@@ -370,9 +397,9 @@ main(int argc, char *argv[])
/* start children */
lde_pid = start_child(PROC_LDE_ENGINE, saved_argv0,
- pipe_parent2lde[1], user, group);
+ pipe_parent2lde[1], user, group, ctl_sock_custom_path);
ldpe_pid = start_child(PROC_LDP_ENGINE, saved_argv0,
- pipe_parent2ldpe[1], user, group);
+ pipe_parent2ldpe[1], user, group, ctl_sock_custom_path);
/* drop privileges */
if (user)
@@ -468,9 +495,9 @@ ldpd_shutdown(void)
static pid_t
start_child(enum ldpd_process p, char *argv0, int fd, const char *user,
- const char *group)
+ const char *group, const char *ctl_sock_custom_path)
{
- char *argv[7];
+ char *argv[9];
int argc = 0;
pid_t pid;
@@ -506,6 +533,10 @@ start_child(enum ldpd_process p, char *argv0, int fd, const char *user,
argv[argc++] = (char *)"-g";
argv[argc++] = (char *)group;
}
+ if (ctl_sock_custom_path) {
+ argv[argc++] = (char *)"--ctl_socket";
+ argv[argc++] = (char *)ctl_sock_custom_path;
+ }
argv[argc++] = NULL;
execvp(argv0, argv);
diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h
index 630b19248..e58d8e485 100644
--- a/ldpd/ldpd.h
+++ b/ldpd/ldpd.h
@@ -672,6 +672,7 @@ int sock_set_ipv6_mcast_loop(int);
/* quagga */
extern struct thread_master *master;
+extern char ctl_sock_path[MAXPATHLEN];
/* ldp_zebra.c */
void ldp_zebra_init(struct thread_master *);
diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c
index 37a3d79a2..0d0fe5c9e 100644
--- a/ldpd/ldpe.c
+++ b/ldpd/ldpe.c
@@ -99,7 +99,7 @@ static struct quagga_signal_t ldpe_signals[] =
/* label distribution protocol engine */
void
-ldpe(const char *user, const char *group)
+ldpe(const char *user, const char *group, const char *ctl_path)
{
struct thread thread;
@@ -128,6 +128,7 @@ ldpe(const char *user, const char *group)
ldpe_privs.group = group;
zprivs_init(&ldpe_privs);
+ strlcpy(ctl_sock_path, ctl_path, sizeof(ctl_sock_path));
if (control_init() == -1)
fatalx("control socket setup failed");
diff --git a/ldpd/ldpe.h b/ldpd/ldpe.h
index aab1a7fd9..da90c7cad 100644
--- a/ldpd/ldpe.h
+++ b/ldpd/ldpe.h
@@ -183,7 +183,7 @@ int tlv_decode_fec_elm(struct nbr *, struct ldp_msg *, char *,
uint16_t, struct map *);
/* ldpe.c */
-void ldpe(const char *, const char *);
+void ldpe(const char *, const char *, const char *);
int ldpe_imsg_compose_parent(int, pid_t, void *,
uint16_t);
int ldpe_imsg_compose_lde(int, uint32_t, pid_t, void *,