ubusd: remove systemd socket activation support
authorJohn Crispin <john@phrozen.org>
Wed, 1 Jun 2016 09:37:30 +0000 (11:37 +0200)
committerJohn Crispin <john@phrozen.org>
Wed, 1 Jun 2016 09:39:34 +0000 (11:39 +0200)
Signed-off-by: John Crispin <john@phrozen.org>
CMakeLists.txt
systemd/CMakeLists.txt [deleted file]
systemd/ubus.service.in [deleted file]
systemd/ubus.socket.in [deleted file]
ubusd.c

index faab342560ea8970b66d09e1f56d56ee52a82a9e..70a0de6536d9060c9e9717b9ab81670a77b51c0d 100644 (file)
@@ -5,7 +5,6 @@ ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
 
 OPTION(BUILD_LUA "build Lua plugin" ON)
 OPTION(BUILD_EXAMPLES "build examples" ON)
-OPTION(ENABLE_SYSTEMD "systemd support" OFF)
 
 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
 SET(UBUS_UNIX_SOCKET "/var/run/ubus.sock")
@@ -53,20 +52,3 @@ INSTALL(TARGETS ubusd
 )
 
 INSTALL(FILES ubusmsg.h ubus_common.h libubus.h DESTINATION include)
-
-# FIXME: this works but certainly can be done better:
-SET(UBUSD_BINARY "${CMAKE_INSTALL_PREFIX}/sbin/ubusd")
-
-# do this after the installs so we have the proper paths
-IF(ENABLE_SYSTEMD)
-  INCLUDE(FindPkgConfig)
-  PKG_CHECK_MODULES(SYSTEMD libsystemd REQUIRED)
-
-  SET_PROPERTY(TARGET ubusd APPEND PROPERTY COMPILE_FLAGS "${SYSTEMD_CFLAGS}")
-  SET_PROPERTY(TARGET ubusd APPEND PROPERTY LINK_FLAGS "${SYSTEMD_LDFLAGS}")
-  SET_PROPERTY(TARGET ubusd APPEND PROPERTY INCLUDE_DIRECTORIES ${SYSTEMD_INCLUDE_DIRS})
-  TARGET_LINK_LIBRARIES(ubusd ${SYSTEMD_LIBRARIES})
-  ADD_DEFINITIONS( -DENABLE_SYSTEMD)
-
-  ADD_SUBDIRECTORY(systemd)
-ENDIF()
diff --git a/systemd/CMakeLists.txt b/systemd/CMakeLists.txt
deleted file mode 100644 (file)
index 54b754b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIGURE_FILE(ubus.socket.in ubus.socket)
-CONFIGURE_FILE(ubus.service.in ubus.service)
-
-# Cmakes pkgconfig support is very limited, so for now just hardcode
-SET(SYSTEMD_SYSUNIT_DIR "${SYSTEMD_PREFIX}/lib/systemd/system")
-INSTALL(FILES ${CMAKE_BINARY_DIR}/systemd/ubus.socket ${CMAKE_BINARY_DIR}/systemd/ubus.service
-       DESTINATION ${SYSTEMD_SYSUNIT_DIR})
diff --git a/systemd/ubus.service.in b/systemd/ubus.service.in
deleted file mode 100644 (file)
index 185a42f..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=OpenWrt micro bus
-Requires=ubus.socket
-
-[Service]
-ExecStart=@UBUSD_BINARY@
diff --git a/systemd/ubus.socket.in b/systemd/ubus.socket.in
deleted file mode 100644 (file)
index 364beb7..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-[Unit]
-Description=OpenWrt micro bus socket
-
-[Socket]
-ListenStream=@UBUS_UNIX_SOCKET@
-
-[Install]
-WantedBy=sockets.target
diff --git a/ubusd.c b/ubusd.c
index 5b1d52c808924c1e40eb3d699225db981ad9e1e3..7279a706f47e44caf92d5433326b5b733bb1b440 100644 (file)
--- a/ubusd.c
+++ b/ubusd.c
@@ -22,9 +22,6 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
-#ifdef ENABLE_SYSTEMD
-#include <systemd/sd-daemon.h>
-#endif
 
 #include <libubox/blob.h>
 #include <libubox/uloop.h>
@@ -383,12 +380,8 @@ static void sighup_handler(int sig)
 int main(int argc, char **argv)
 {
        const char *ubus_socket = UBUS_UNIX_SOCKET;
-       bool remove_socket = true;
        int ret = 0;
        int ch;
-#ifdef ENABLE_SYSTEMD
-       int n_fds;
-#endif
 
        signal(SIGPIPE, SIG_IGN);
        signal(SIGHUP, sighup_handler);
@@ -409,37 +402,19 @@ int main(int argc, char **argv)
                }
        }
 
-#ifdef ENABLE_SYSTEMD
-       n_fds = sd_listen_fds(1);
-       if (n_fds > 1) {
-               fprintf(stderr, "Too many file descriptors received.\n");
-               ret = -1;
+       unlink(ubus_socket);
+       umask(0111);
+       server_fd.fd = usock(USOCK_UNIX | USOCK_SERVER | USOCK_NONBLOCK, ubus_socket, NULL);
+       if (server_fd.fd < 0) {
+               perror("usock");
+               ret = -1;
                goto out;
-       } else if (n_fds == 1) {
-               server_fd.fd = SD_LISTEN_FDS_START + 0;
-               fcntl(server_fd.fd, F_SETFD, fcntl(server_fd.fd, F_GETFD) | FD_CLOEXEC);
-               fcntl(server_fd.fd, F_SETFL, fcntl(server_fd.fd, F_GETFL) | O_NONBLOCK);
-
-               remove_socket = false;
-       } else
-#endif
-       {
-               unlink(ubus_socket);
-               umask(0111);
-               server_fd.fd = usock(USOCK_UNIX | USOCK_SERVER | USOCK_NONBLOCK, ubus_socket, NULL);
-               if (server_fd.fd < 0) {
-                       perror("usock");
-                       ret = -1;
-                       goto out;
-               }
        }
        uloop_fd_add(&server_fd, ULOOP_READ | ULOOP_EDGE_TRIGGER);
        ubusd_acl_load();
 
        uloop_run();
-
-       if (remove_socket)
-               unlink(ubus_socket);
+       unlink(ubus_socket);
 
 out:
        uloop_done();