chiark / gitweb /
core: make sure PrivateDevices= makes /dev/log available
[elogind.git] / src / initctl / initctl.c
index 3c5986171fe054bba27f57bb41efb4346a9e2ce8..f3f6f7304073f44cc9660f35d9d6fef4c9de977d 100644 (file)
@@ -114,7 +114,7 @@ static void change_runlevel(Server *s, int runlevel) {
         assert(s);
 
         target = translate_runlevel(runlevel, &isolate);
-        if(!target) {
+        if (!target) {
                 log_warning("Got request for unknown runlevel %c, ignoring.", runlevel);
                 return;
         }
@@ -217,7 +217,7 @@ static int fifo_process(Fifo *f) {
                 if (errno == EAGAIN)
                         return 0;
 
-                log_warning("Failed to read from fifo: %s", strerror(errno));
+                log_warning("Failed to read from fifo: %m");
                 return -1;
         }
 
@@ -245,7 +245,7 @@ static void fifo_free(Fifo *f) {
                 if (f->server)
                         epoll_ctl(f->server->epoll_fd, EPOLL_CTL_DEL, f->fd, NULL);
 
-                close_nointr_nofail(f->fd);
+                safe_close(f->fd);
         }
 
         free(f);
@@ -257,8 +257,7 @@ static void server_done(Server *s) {
         while (s->fifos)
                 fifo_free(s->fifos);
 
-        if (s->epoll_fd >= 0)
-                close_nointr_nofail(s->epoll_fd);
+        safe_close(s->epoll_fd);
 
         if (s->bus) {
                 sd_bus_flush(s->bus);
@@ -278,7 +277,7 @@ static int server_init(Server *s, unsigned n_sockets) {
         s->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
         if (s->epoll_fd < 0) {
                 r = -errno;
-                log_error("Failed to create epoll object: %s", strerror(errno));
+                log_error("Failed to create epoll object: %m");
                 goto fail;
         }
 
@@ -305,8 +304,7 @@ static int server_init(Server *s, unsigned n_sockets) {
                 f = new0(Fifo, 1);
                 if (!f) {
                         r = -ENOMEM;
-                        log_error("Failed to create fifo object: %s",
-                                  strerror(errno));
+                        log_error("Failed to create fifo object: %m");
                         goto fail;
                 }
 
@@ -318,8 +316,7 @@ static int server_init(Server *s, unsigned n_sockets) {
                 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));
+                        log_error("Failed to add fifo fd to epoll object: %m");
                         goto fail;
                 }
 
@@ -329,7 +326,7 @@ static int server_init(Server *s, unsigned n_sockets) {
                 s->n_fifos ++;
         }
 
-        r = bus_connect_system(&s->bus);
+        r = bus_open_system_systemd(&s->bus);
         if (r < 0) {
                 log_error("Failed to get D-Bus connection: %s", strerror(-r));
                 r = -EIO;
@@ -386,7 +383,8 @@ int main(int argc, char *argv[]) {
 
         umask(0022);
 
-        if ((n = sd_listen_fds(true)) < 0) {
+        n = sd_listen_fds(true);
+        if (n < 0) {
                 log_error("Failed to read listening file descriptors from environment: %s", strerror(-r));
                 return EXIT_FAILURE;
         }
@@ -399,7 +397,7 @@ int main(int argc, char *argv[]) {
         if (server_init(&server, (unsigned) n) < 0)
                 return EXIT_FAILURE;
 
-        log_debug("systemd-initctl running as pid %lu", (unsigned long) getpid());
+        log_debug("systemd-initctl running as pid "PID_FMT, getpid());
 
         sd_notify(false,
                   "READY=1\n"
@@ -416,7 +414,7 @@ int main(int argc, char *argv[]) {
                         if (errno == EINTR)
                                 continue;
 
-                        log_error("epoll_wait() failed: %s", strerror(errno));
+                        log_error("epoll_wait() failed: %m");
                         goto fail;
                 }
 
@@ -429,7 +427,7 @@ int main(int argc, char *argv[]) {
 
         r = EXIT_SUCCESS;
 
-        log_debug("systemd-initctl stopped as pid %lu", (unsigned long) getpid());
+        log_debug("systemd-initctl stopped as pid "PID_FMT, getpid());
 
 fail:
         sd_notify(false,