summaryrefslogtreecommitdiff
path: root/sysdep/unix
diff options
context:
space:
mode:
Diffstat (limited to 'sysdep/unix')
-rw-r--r--sysdep/unix/io.c19
-rw-r--r--sysdep/unix/main.c8
-rw-r--r--sysdep/unix/unix.h2
3 files changed, 13 insertions, 16 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index 02d59abb..d86c8cb8 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -1075,7 +1075,7 @@ bad_no_log:
return -1;
}
-int
+void
sk_open_unix(sock *s, char *name)
{
int fd;
@@ -1084,15 +1084,13 @@ sk_open_unix(sock *s, char *name)
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0)
- die("sk_open_unix: socket: %m");
+ ERR("socket");
s->fd = fd;
if (err = sk_setup(s))
goto bad;
unlink(name);
-
- if (strlen(name) >= sizeof(sa.sun_path))
- die("sk_open_unix: path too long");
+ /* Path length checked in test_old_bird() */
sa.sun_family = AF_UNIX;
strcpy(sa.sun_path, name);
if (bind(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) < 0)
@@ -1100,13 +1098,11 @@ sk_open_unix(sock *s, char *name)
if (listen(fd, 8))
ERR("listen");
sk_insert(s);
- return 0;
+ return;
-bad:
+ bad:
log(L_ERR "sk_open_unix: %s: %m", err);
- close(fd);
- s->fd = -1;
- return -1;
+ die("Unable to create control socket %s", name);
}
static int
@@ -1519,9 +1515,10 @@ test_old_bird(char *path)
struct sockaddr_un sa;
fd = socket(AF_UNIX, SOCK_STREAM, 0);
-
if (fd < 0)
die("Cannot create socket: %m");
+ if (strlen(path) >= sizeof(sa.sun_path))
+ die("Socket path too long");
bzero(&sa, sizeof(sa));
sa.sun_family = AF_UNIX;
strcpy(sa.sun_path, path);
diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c
index 2245692c..e0e0d636 100644
--- a/sysdep/unix/main.c
+++ b/sysdep/unix/main.c
@@ -298,8 +298,7 @@ cli_init_unix(void)
s->type = SK_UNIX_PASSIVE;
s->rx_hook = cli_connect;
s->rbsize = 1024;
- if (sk_open_unix(s, path_control_socket) < 0)
- die("Unable to create control socket %s", path_control_socket);
+ sk_open_unix(s, path_control_socket);
}
/*
@@ -457,6 +456,9 @@ main(int argc, char **argv)
rt_init();
if_init();
+ if (!parse_and_exit)
+ cli_init_unix();
+
protos_build();
proto_build(&proto_unix_kernel);
proto_build(&proto_unix_iface);
@@ -483,8 +485,6 @@ main(int argc, char **argv)
signal_init();
- cli_init_unix();
-
#ifdef LOCAL_DEBUG
async_dump_flag = 1;
#endif
diff --git a/sysdep/unix/unix.h b/sysdep/unix/unix.h
index 0b179e00..4de74f28 100644
--- a/sysdep/unix/unix.h
+++ b/sysdep/unix/unix.h
@@ -49,7 +49,7 @@ void io_init(void);
void io_loop(void);
void fill_in_sockaddr(sockaddr *sa, ip_addr a, unsigned port);
void get_sockaddr(sockaddr *sa, ip_addr *a, unsigned *port, int check);
-int sk_open_unix(struct birdsock *s, char *name);
+void sk_open_unix(struct birdsock *s, char *name);
void *tracked_fopen(struct pool *, char *name, char *mode);
void test_old_bird(char *path);