]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/import/importd.c
util-lib: split string parsing related calls from util.[ch] into parse-util.[ch]
[thirdparty/systemd.git] / src / import / importd.c
index 05a619ac0cd34ebdb0c54cc800cffba370b68412..975907e3c922d9f3efca32af6eff840fad0860ce 100644 (file)
 #include <sys/prctl.h>
 
 #include "sd-bus.h"
-#include "util.h"
-#include "strv.h"
-#include "bus-util.h"
+
 #include "bus-common-errors.h"
-#include "socket-util.h"
-#include "mkdir.h"
+#include "bus-util.h"
 #include "def.h"
-#include "missing.h"
+#include "fd-util.h"
+#include "hostname-util.h"
+#include "import-util.h"
 #include "machine-pool.h"
+#include "missing.h"
+#include "mkdir.h"
+#include "parse-util.h"
 #include "path-util.h"
-#include "import-util.h"
 #include "process-util.h"
 #include "signal-util.h"
+#include "socket-util.h"
+#include "strv.h"
+#include "util.h"
 
 typedef struct Transfer Transfer;
 typedef struct Manager Manager;
@@ -166,6 +170,7 @@ static int transfer_new(Manager *m, Transfer **ret) {
         t->type = _TRANSFER_TYPE_INVALID;
         t->log_fd = -1;
         t->stdin_fd = -1;
+        t->stdout_fd = -1;
         t->verify = _IMPORT_VERIFY_INVALID;
 
         id = m->current_transfer_id + 1;
@@ -551,8 +556,7 @@ static Manager *manager_unref(Manager *m) {
 
         bus_verify_polkit_async_registry_free(m->polkit_registry);
 
-        sd_bus_close(m->bus);
-        sd_bus_unref(m->bus);
+        m->bus = sd_bus_flush_close_unref(m->bus);
         sd_event_unref(m->event);
 
         free(m);
@@ -599,14 +603,11 @@ static int manager_on_notify(sd_event_source *s, int fd, uint32_t revents, void
 
         cmsg_close_all(&msghdr);
 
-        CMSG_FOREACH(cmsg, &msghdr) {
+        CMSG_FOREACH(cmsg, &msghdr)
                 if (cmsg->cmsg_level == SOL_SOCKET &&
-                           cmsg->cmsg_type == SCM_CREDENTIALS &&
-                           cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred))) {
-
+                    cmsg->cmsg_type == SCM_CREDENTIALS &&
+                    cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred)))
                         ucred = (struct ucred*) CMSG_DATA(cmsg);
-                }
-        }
 
         if (msghdr.msg_flags & MSG_TRUNC) {
                 log_warning("Got overly long notification datagram, ignoring.");
@@ -735,6 +736,7 @@ static int method_import_tar_or_raw(sd_bus_message *msg, void *userdata, sd_bus_
                         msg,
                         CAP_SYS_ADMIN,
                         "org.freedesktop.import1.import",
+                        NULL,
                         false,
                         UID_INVALID,
                         &m->polkit_registry,
@@ -799,6 +801,7 @@ static int method_export_tar_or_raw(sd_bus_message *msg, void *userdata, sd_bus_
                         msg,
                         CAP_SYS_ADMIN,
                         "org.freedesktop.import1.export",
+                        NULL,
                         false,
                         UID_INVALID,
                         &m->polkit_registry,
@@ -864,6 +867,7 @@ static int method_pull_tar_or_raw(sd_bus_message *msg, void *userdata, sd_bus_er
                         msg,
                         CAP_SYS_ADMIN,
                         "org.freedesktop.import1.pull",
+                        NULL,
                         false,
                         UID_INVALID,
                         &m->polkit_registry,
@@ -945,6 +949,7 @@ static int method_pull_dkr(sd_bus_message *msg, void *userdata, sd_bus_error *er
                         msg,
                         CAP_SYS_ADMIN,
                         "org.freedesktop.import1.pull",
+                        NULL,
                         false,
                         UID_INVALID,
                         &m->polkit_registry,
@@ -1079,6 +1084,7 @@ static int method_cancel(sd_bus_message *msg, void *userdata, sd_bus_error *erro
                         msg,
                         CAP_SYS_ADMIN,
                         "org.freedesktop.import1.pull",
+                        NULL,
                         false,
                         UID_INVALID,
                         &t->manager->polkit_registry,
@@ -1108,6 +1114,7 @@ static int method_cancel_transfer(sd_bus_message *msg, void *userdata, sd_bus_er
                         msg,
                         CAP_SYS_ADMIN,
                         "org.freedesktop.import1.pull",
+                        NULL,
                         false,
                         UID_INVALID,
                         &m->polkit_registry,
@@ -1301,7 +1308,7 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
-        assert_se(sigprocmask_many(SIG_BLOCK, SIGCHLD, -1) >= 0);
+        assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, -1) >= 0);
 
         r = manager_new(&m);
         if (r < 0) {