chiark / gitweb /
import: introduce new mini-daemon systemd-importd, and make machinectl a client to it
[elogind.git] / src / import / import-dkr.c
index cebec28144f4851278baa5c1082af636847f588a..0e9927509004c3ec5b4d9c840def08266118af9b 100644 (file)
 #include "btrfs-util.h"
 #include "utf8.h"
 #include "mkdir.h"
+#include "import-util.h"
 #include "curl-util.h"
 #include "aufs-util.h"
-#include "import-util.h"
 #include "import-job.h"
+#include "import-common.h"
 #include "import-dkr.h"
 
 struct DkrImport {
@@ -454,7 +455,7 @@ static int dkr_import_job_on_open_disk(ImportJob *j) {
                 }
 
                 if (pipefd[0] != STDIN_FILENO)
-                        safe_close(pipefd[0]);
+                        pipefd[0] = safe_close(pipefd[0]);
 
                 null_fd = open("/dev/null", O_WRONLY|O_NOCTTY);
                 if (null_fd < 0) {
@@ -468,7 +469,11 @@ static int dkr_import_job_on_open_disk(ImportJob *j) {
                 }
 
                 if (null_fd != STDOUT_FILENO)
-                        safe_close(null_fd);
+                        null_fd = safe_close(null_fd);
+
+                fd_cloexec(STDIN_FILENO, false);
+                fd_cloexec(STDOUT_FILENO, false);
+                fd_cloexec(STDERR_FILENO, false);
 
                 execlp("tar", "tar", "--numeric-owner", "-C", i->temp_path, "-px", NULL);
                 log_error_errno(errno, "Failed to execute tar: %m");
@@ -850,34 +855,3 @@ int dkr_import_pull(DkrImport *i, const char *name, const char *tag, const char
 
         return import_job_begin(i->images_job);
 }
-
-bool dkr_name_is_valid(const char *name) {
-        const char *slash, *p;
-
-        if (isempty(name))
-                return false;
-
-        slash = strchr(name, '/');
-        if (!slash)
-                return false;
-
-        if (!filename_is_valid(slash + 1))
-                return false;
-
-        p = strndupa(name, slash - name);
-        if (!filename_is_valid(p))
-                return false;
-
-        return true;
-}
-
-bool dkr_id_is_valid(const char *id) {
-
-        if (!filename_is_valid(id))
-                return false;
-
-        if (!in_charset(id, "0123456789abcdef"))
-                return false;
-
-        return true;
-}