summaryrefslogtreecommitdiff
path: root/src/initctl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-05-20 01:13:43 +0200
committerLennart Poettering <lennart@poettering.net>2010-05-20 01:13:43 +0200
commit7c394faa38de389638e19b19212ed50aca870e3c (patch)
tree475a9da2fa7d10160705ed9a83bc419a75718b90 /src/initctl.c
parentff876e283a61320b718ec752d93b1fd40a5fdd0c (diff)
sd-daemon: add API to verify socket types
Diffstat (limited to 'src/initctl.c')
-rw-r--r--src/initctl.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/initctl.c b/src/initctl.c
index 9d8eceea52..407d32d93f 100644
--- a/src/initctl.c
+++ b/src/initctl.c
@@ -280,6 +280,20 @@ static int server_init(Server *s, unsigned n_sockets) {
for (i = 0; i < n_sockets; i++) {
struct epoll_event ev;
Fifo *f;
+ int fd;
+
+ fd = SD_LISTEN_FDS_START+i;
+
+ if ((r = sd_is_fifo(fd, NULL)) < 0) {
+ log_error("Failed to determine file descriptor type: %s", strerror(-r));
+ goto fail;
+ }
+
+ if (!r) {
+ log_error("Wrong file descriptor type.");
+ r = -EINVAL;
+ goto fail;
+ }
if (!(f = new0(Fifo, 1))) {
r = -ENOMEM;
@@ -292,7 +306,7 @@ static int server_init(Server *s, unsigned n_sockets) {
zero(ev);
ev.events = EPOLLIN;
ev.data.ptr = f;
- if (epoll_ctl(s->epoll_fd, EPOLL_CTL_ADD, SD_LISTEN_FDS_START+i, &ev) < 0) {
+ if (epoll_ctl(s->epoll_fd, EPOLL_CTL_ADD, fd, &ev) < 0) {
r = -errno;
fifo_free(f);
log_error("Failed to add fifo fd to epoll object: %s", strerror(errno));