X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fimport%2Fimport-dkr.c;h=0e9927509004c3ec5b4d9c840def08266118af9b;hp=cebec28144f4851278baa5c1082af636847f588a;hb=3d7415f43f0fe6a821d7bc4a341ba371e8a30ef3;hpb=ff2670ad11a1a29d483b7a246c95b159ddc1137c diff --git a/src/import/import-dkr.c b/src/import/import-dkr.c index cebec2814..0e9927509 100644 --- a/src/import/import-dkr.c +++ b/src/import/import-dkr.c @@ -28,10 +28,11 @@ #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; -}