[systemd-commits] 9 commits - Makefile.am TODO src/import src/machine src/shared

Lennart Poettering lennart at kemper.freedesktop.org
Thu Jan 22 08:51:00 PST 2015


 Makefile.am                |   17 -
 TODO                       |   15 -
 src/import/import-common.c |    5 
 src/import/import.c        |  440 ---------------------------------------------
 src/import/importd.c       |   14 -
 src/import/pull.c          |  440 +++++++++++++++++++++++++++++++++++++++++++++
 src/machine/machinectl.c   |   91 +++++----
 src/shared/util.h          |   18 +
 8 files changed, 528 insertions(+), 512 deletions(-)

New commits:
commit a8683176ee1da908c65721468141a74892791fda
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 22 17:50:26 2015 +0100

    update TODO

diff --git a/TODO b/TODO
index 2c01b2c..fb77052 100644
--- a/TODO
+++ b/TODO
@@ -33,14 +33,18 @@ Release 219 preparations:
 
 * rework journald sigbus stuff to use mutex
 
-* machinectl: document new importd commands
-
-* machinectl: when pressing C-c during transfers, send Cancel to server.
-
 * machinectl: show progress percentage in list
 
 * nspawn: don't change superblock mount options from nspawn for cgroup hierarchies
 
+* importd: sandbox things
+
+* "systemctl kill" is broken
+
+* the dbus1 connection user id is actually the euid, not the uid, and creds should return that
+
+* sd-bus make dsrt happy, and change userspace header for kdbus to yyyyuta{tv}v
+
 Features:
 
 * import-dkr: support tarsum checksum verification, if it becomes reality one day...
@@ -53,8 +57,6 @@ Features:
 
 * bus-proxy: reload policy when PID 1 reports a reload
 
-* the dbus1 connection user id is actually the euid, not the uid, and creds should return that
-
 * introduce systemd-nspawn-ephemeral at .service, and hook it into "machinectl start" with a new --ephemeral switch
 
 * logind,machined: add generic catch-all polkit verbs for most priviliged operations, similar to systemd itself
@@ -345,7 +347,6 @@ Features:
 * sd-bus:
   - GetAllProperties() on a non-existing object does not result in a failure currently
   - kdbus: process fd=-1 for incoming msgs
-  - make dsrt happy, and change userspace header for kdbus to yyyyuta{tv}v
   - port to sd-resolve for connecting to TCP dbus servers
   - kdbus: maybe add controlling tty metadata fields
   - see if we can introduce a new sd_bus_get_owner_machine_id() call to retrieve the machine ID of the machine of the bus itself

commit b9a5f8588facd64fcff0f75fa91e3f80730b93f2
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 22 17:49:28 2015 +0100

    import: only define the _to_string() enum mapping function, thus making gcc shut up

diff --git a/src/import/importd.c b/src/import/importd.c
index 92ad801..3e417b1 100644
--- a/src/import/importd.c
+++ b/src/import/importd.c
@@ -86,7 +86,7 @@ static const char* const transfer_type_table[_TRANSFER_TYPE_MAX] = {
         [TRANSFER_DKR] = "dkr",
 };
 
-DEFINE_PRIVATE_STRING_TABLE_LOOKUP(transfer_type, TransferType);
+DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(transfer_type, TransferType);
 
 static Transfer *transfer_unref(Transfer *t) {
         if (!t)
diff --git a/src/shared/util.h b/src/shared/util.h
index bfa5633..ca0c2e5 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -348,12 +348,14 @@ static inline uint32_t random_u32(void) {
 }
 
 /* For basic lookup tables with strictly enumerated entries */
-#define __DEFINE_STRING_TABLE_LOOKUP(name,type,scope)                   \
+#define _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,scope)          \
         scope const char *name##_to_string(type i) {                    \
                 if (i < 0 || i >= (type) ELEMENTSOF(name##_table))      \
                         return NULL;                                    \
                 return name##_table[i];                                 \
-        }                                                               \
+        }
+
+#define _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,scope)        \
         scope type name##_from_string(const char *s) {                  \
                 type i;                                                 \
                 if (!s)                                                 \
@@ -363,11 +365,17 @@ static inline uint32_t random_u32(void) {
                             streq(name##_table[i], s))                  \
                                 return i;                               \
                 return (type) -1;                                       \
-        }                                                               \
+        }
+
+#define _DEFINE_STRING_TABLE_LOOKUP(name,type,scope)                    \
+        _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,scope)          \
+        _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,scope)        \
         struct __useless_struct_to_allow_trailing_semicolon__
 
-#define DEFINE_STRING_TABLE_LOOKUP(name,type) __DEFINE_STRING_TABLE_LOOKUP(name,type,)
-#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP(name,type) __DEFINE_STRING_TABLE_LOOKUP(name,type,static)
+#define DEFINE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,)
+#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,static)
+#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,static)
+#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,static)
 
 /* For string conversions where numbers are also acceptable */
 #define DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(name,type,max)         \

commit aa9bd4992ff0240f6ceecb70ec364d5d9c7574f4
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 22 17:38:10 2015 +0100

    import: now that the worker binary is called "systemd-pull" we can shorten the verbs
    
    Atfer all "systemd-pull pull-tar" is unnecessarily redundant, over
    "systemd-pull tar"...

diff --git a/src/import/importd.c b/src/import/importd.c
index 40900ce..92ad801 100644
--- a/src/import/importd.c
+++ b/src/import/importd.c
@@ -343,9 +343,7 @@ static int transfer_start(Transfer *t) {
         if (t->pid == 0) {
                 const char *cmd[] = {
                         "systemd-pull",
-                        t->type == TRANSFER_TAR ? "pull-tar" :
-                        t->type == TRANSFER_RAW ? "pull-raw" :
-                                                      "pull-dkr",
+                        transfer_type_to_string(t->type),
                         "--verify",
                         NULL, /* verify argument */
                         NULL, /* maybe --force */
diff --git a/src/import/pull.c b/src/import/pull.c
index 9bd8b77..ee3ff68 100644
--- a/src/import/pull.c
+++ b/src/import/pull.c
@@ -328,9 +328,9 @@ static int help(int argc, char *argv[], void *userdata) {
                "     --image-root=            Image root directory\n"
                "     --dkr-index-url=URL      Specify index URL to use for downloads\n\n"
                "Commands:\n"
-               "  pull-tar URL [NAME]         Download a TAR image\n"
-               "  pull-raw URL [NAME]         Download a RAW image\n"
-               "  pull-dkr REMOTE [NAME]      Download a DKR image\n",
+               "  tar URL [NAME]              Download a TAR image\n"
+               "  raw URL [NAME]              Download a RAW image\n"
+               "  dkr REMOTE [NAME]           Download a DKR image\n",
                program_invocation_short_name);
 
         return 0;
@@ -412,10 +412,10 @@ static int parse_argv(int argc, char *argv[]) {
 static int import_main(int argc, char *argv[]) {
 
         static const Verb verbs[] = {
-                { "help",     VERB_ANY, VERB_ANY, 0, help     },
-                { "pull-tar", 2,        3,        0, pull_tar },
-                { "pull-raw", 2,        3,        0, pull_raw },
-                { "pull-dkr", 2,        3,        0, pull_dkr },
+                { "help", VERB_ANY, VERB_ANY, 0, help     },
+                { "tar",  2,        3,        0, pull_tar },
+                { "raw",  2,        3,        0, pull_raw },
+                { "dkr",  2,        3,        0, pull_dkr },
                 {}
         };
 

commit ff828763c40cd138658abf9ed7a19da73c92dec1
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 22 17:34:54 2015 +0100

    importd: try to minimize confusion by renaming "systemd-import" binary to "systemd-pull"
    
    This way "systemd-importd" is the daemon that uses "systemd-pull" as
    backend worker.

diff --git a/Makefile.am b/Makefile.am
index 440ba88..d5344b9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5273,24 +5273,21 @@ if HAVE_GCRYPT
 
 rootlibexec_PROGRAMS += \
 	systemd-importd \
-	systemd-import
+	systemd-pull
 
 systemd_importd_SOURCES = \
-	src/import/importd.c \
-	src/import/importd.h
+	src/import/importd.c
 
 systemd_importd_CFLAGS = \
 	$(AM_CFLAGS) \
-	-D SYSTEMD_IMPORT_PATH=\"$(rootlibexecdir)/systemd-import\" \
-	-D VENDOR_KEYRING_PATH=\"$(rootlibexecdir)/import-pubring.gpg\" \
-	-D USER_KEYRING_PATH=\"$(pkgsysconfdir)/import-pubring.gpg\"
+	-D SYSTEMD_PULL_PATH=\"$(rootlibexecdir)/systemd-import\"
 
 systemd_importd_LDADD = \
 	libsystemd-internal.la \
 	libsystemd-shared.la
 
-systemd_import_SOURCES = \
-	src/import/import.c \
+systemd_pull_SOURCES = \
+	src/import/pull.c \
 	src/import/import-raw.c \
 	src/import/import-raw.h \
 	src/import/import-tar.c \
@@ -5308,7 +5305,7 @@ systemd_import_SOURCES = \
 	src/import/qcow2-util.c \
 	src/import/qcow2-util.h
 
-systemd_import_CFLAGS = \
+systemd_pull_CFLAGS = \
 	$(AM_CFLAGS) \
 	$(LIBCURL_CFLAGS) \
 	$(XZ_CFLAGS) \
@@ -5317,7 +5314,7 @@ systemd_import_CFLAGS = \
 	-D VENDOR_KEYRING_PATH=\"$(rootlibexecdir)/import-pubring.gpg\" \
 	-D USER_KEYRING_PATH=\"$(pkgsysconfdir)/import-pubring.gpg\"
 
-systemd_import_LDADD = \
+systemd_pull_LDADD = \
 	libsystemd-internal.la \
 	libsystemd-label.la \
 	libsystemd-shared.la \
diff --git a/src/import/import.c b/src/import/import.c
deleted file mode 100644
index 9bd8b77..0000000
--- a/src/import/import.c
+++ /dev/null
@@ -1,440 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <getopt.h>
-
-#include "sd-event.h"
-#include "event-util.h"
-#include "verbs.h"
-#include "build.h"
-#include "machine-image.h"
-#include "import-tar.h"
-#include "import-raw.h"
-#include "import-dkr.h"
-#include "import-util.h"
-
-static bool arg_force = false;
-static const char *arg_image_root = "/var/lib/machines";
-static ImportVerify arg_verify = IMPORT_VERIFY_SIGNATURE;
-static const char* arg_dkr_index_url = DEFAULT_DKR_INDEX_URL;
-
-static int interrupt_signal_handler(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
-        log_notice("Transfer aborted.");
-        sd_event_exit(sd_event_source_get_event(s), EINTR);
-        return 0;
-}
-
-static void on_tar_finished(TarImport *import, int error, void *userdata) {
-        sd_event *event = userdata;
-        assert(import);
-
-        if (error == 0)
-                log_info("Operation completed successfully.");
-
-        sd_event_exit(event, abs(error));
-}
-
-static int pull_tar(int argc, char *argv[], void *userdata) {
-        _cleanup_(tar_import_unrefp) TarImport *import = NULL;
-        _cleanup_event_unref_ sd_event *event = NULL;
-        const char *url, *local;
-        _cleanup_free_ char *l = NULL, *ll = NULL;
-        int r;
-
-        url = argv[1];
-        if (!http_url_is_valid(url)) {
-                log_error("URL '%s' is not valid.", url);
-                return -EINVAL;
-        }
-
-        if (argc >= 3)
-                local = argv[2];
-        else {
-                r = import_url_last_component(url, &l);
-                if (r < 0)
-                        return log_error_errno(r, "Failed get final component of URL: %m");
-
-                local = l;
-        }
-
-        if (isempty(local) || streq(local, "-"))
-                local = NULL;
-
-        if (local) {
-                r = tar_strip_suffixes(local, &ll);
-                if (r < 0)
-                        return log_oom();
-
-                local = ll;
-
-                if (!machine_name_is_valid(local)) {
-                        log_error("Local image name '%s' is not valid.", local);
-                        return -EINVAL;
-                }
-
-                if (!arg_force) {
-                        r = image_find(local, NULL);
-                        if (r < 0)
-                                return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local);
-                        else if (r > 0) {
-                                log_error_errno(EEXIST, "Image '%s' already exists.", local);
-                                return -EEXIST;
-                        }
-                }
-
-                log_info("Pulling '%s', saving as '%s'.", url, local);
-        } else
-                log_info("Pulling '%s'.", url);
-
-        r = sd_event_default(&event);
-        if (r < 0)
-                return log_error_errno(r, "Failed to allocate event loop: %m");
-
-        assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
-        sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler,  NULL);
-        sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
-
-        r = tar_import_new(&import, event, arg_image_root, on_tar_finished, event);
-        if (r < 0)
-                return log_error_errno(r, "Failed to allocate importer: %m");
-
-        r = tar_import_pull(import, url, local, arg_force, arg_verify);
-        if (r < 0)
-                return log_error_errno(r, "Failed to pull image: %m");
-
-        r = sd_event_loop(event);
-        if (r < 0)
-                return log_error_errno(r, "Failed to run event loop: %m");
-
-        log_info("Exiting.");
-        return -r;
-}
-
-static void on_raw_finished(RawImport *import, int error, void *userdata) {
-        sd_event *event = userdata;
-        assert(import);
-
-        if (error == 0)
-                log_info("Operation completed successfully.");
-
-        sd_event_exit(event, abs(error));
-}
-
-static int pull_raw(int argc, char *argv[], void *userdata) {
-        _cleanup_(raw_import_unrefp) RawImport *import = NULL;
-        _cleanup_event_unref_ sd_event *event = NULL;
-        const char *url, *local;
-        _cleanup_free_ char *l = NULL, *ll = NULL;
-        int r;
-
-        url = argv[1];
-        if (!http_url_is_valid(url)) {
-                log_error("URL '%s' is not valid.", url);
-                return -EINVAL;
-        }
-
-        if (argc >= 3)
-                local = argv[2];
-        else {
-                r = import_url_last_component(url, &l);
-                if (r < 0)
-                        return log_error_errno(r, "Failed get final component of URL: %m");
-
-                local = l;
-        }
-
-        if (isempty(local) || streq(local, "-"))
-                local = NULL;
-
-        if (local) {
-                r = raw_strip_suffixes(local, &ll);
-                if (r < 0)
-                        return log_oom();
-
-                local = ll;
-
-                if (!machine_name_is_valid(local)) {
-                        log_error("Local image name '%s' is not valid.", local);
-                        return -EINVAL;
-                }
-
-                if (!arg_force) {
-                        r = image_find(local, NULL);
-                        if (r < 0)
-                                return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local);
-                        else if (r > 0) {
-                                log_error_errno(EEXIST, "Image '%s' already exists.", local);
-                                return -EEXIST;
-                        }
-                }
-
-                log_info("Pulling '%s', saving as '%s'.", url, local);
-        } else
-                log_info("Pulling '%s'.", url);
-
-        r = sd_event_default(&event);
-        if (r < 0)
-                return log_error_errno(r, "Failed to allocate event loop: %m");
-
-        assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
-        sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler,  NULL);
-        sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
-
-        r = raw_import_new(&import, event, arg_image_root, on_raw_finished, event);
-        if (r < 0)
-                return log_error_errno(r, "Failed to allocate importer: %m");
-
-        r = raw_import_pull(import, url, local, arg_force, arg_verify);
-        if (r < 0)
-                return log_error_errno(r, "Failed to pull image: %m");
-
-        r = sd_event_loop(event);
-        if (r < 0)
-                return log_error_errno(r, "Failed to run event loop: %m");
-
-        log_info("Exiting.");
-        return -r;
-}
-
-static void on_dkr_finished(DkrImport *import, int error, void *userdata) {
-        sd_event *event = userdata;
-        assert(import);
-
-        if (error == 0)
-                log_info("Operation completed successfully.");
-
-        sd_event_exit(event, abs(error));
-}
-
-static int pull_dkr(int argc, char *argv[], void *userdata) {
-        _cleanup_(dkr_import_unrefp) DkrImport *import = NULL;
-        _cleanup_event_unref_ sd_event *event = NULL;
-        const char *name, *tag, *local;
-        int r;
-
-        if (!arg_dkr_index_url) {
-                log_error("Please specify an index URL with --dkr-index-url=");
-                return -EINVAL;
-        }
-
-        if (arg_verify != IMPORT_VERIFY_NO) {
-                log_error("Imports from dkr do not support image verification, please pass --verify=no.");
-                return -EINVAL;
-        }
-
-        tag = strchr(argv[1], ':');
-        if (tag) {
-                name = strndupa(argv[1], tag - argv[1]);
-                tag++;
-        } else {
-                name = argv[1];
-                tag = "latest";
-        }
-
-        if (!dkr_name_is_valid(name)) {
-                log_error("Remote name '%s' is not valid.", name);
-                return -EINVAL;
-        }
-
-        if (!dkr_tag_is_valid(tag)) {
-                log_error("Tag name '%s' is not valid.", tag);
-                return -EINVAL;
-        }
-
-        if (argc >= 3)
-                local = argv[2];
-        else {
-                local = strchr(name, '/');
-                if (local)
-                        local++;
-                else
-                        local = name;
-        }
-
-        if (isempty(local) || streq(local, "-"))
-                local = NULL;
-
-        if (local) {
-                if (!machine_name_is_valid(local)) {
-                        log_error("Local image name '%s' is not valid.", local);
-                        return -EINVAL;
-                }
-
-                if (!arg_force) {
-                        r = image_find(local, NULL);
-                        if (r < 0)
-                                return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local);
-                        else if (r > 0) {
-                                log_error_errno(EEXIST, "Image '%s' already exists.", local);
-                                return -EEXIST;
-                        }
-                }
-
-                log_info("Pulling '%s' with tag '%s', saving as '%s'.", name, tag, local);
-        } else
-                log_info("Pulling '%s' with tag '%s'.", name, tag);
-
-        r = sd_event_default(&event);
-        if (r < 0)
-                return log_error_errno(r, "Failed to allocate event loop: %m");
-
-        assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
-        sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler,  NULL);
-        sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
-
-        r = dkr_import_new(&import, event, arg_dkr_index_url, arg_image_root, on_dkr_finished, event);
-        if (r < 0)
-                return log_error_errno(r, "Failed to allocate importer: %m");
-
-        r = dkr_import_pull(import, name, tag, local, arg_force);
-        if (r < 0)
-                return log_error_errno(r, "Failed to pull image: %m");
-
-        r = sd_event_loop(event);
-        if (r < 0)
-                return log_error_errno(r, "Failed to run event loop: %m");
-
-        log_info("Exiting.");
-        return -r;
-}
-
-static int help(int argc, char *argv[], void *userdata) {
-
-        printf("%s [OPTIONS...] {COMMAND} ...\n\n"
-               "Import container or virtual machine image.\n\n"
-               "  -h --help                   Show this help\n"
-               "     --version                Show package version\n"
-               "     --force                  Force creation of image\n"
-               "     --verify=                Verify downloaded image, one of: 'no',\n"
-               "                              'checksum', 'signature'.\n"
-               "     --image-root=            Image root directory\n"
-               "     --dkr-index-url=URL      Specify index URL to use for downloads\n\n"
-               "Commands:\n"
-               "  pull-tar URL [NAME]         Download a TAR image\n"
-               "  pull-raw URL [NAME]         Download a RAW image\n"
-               "  pull-dkr REMOTE [NAME]      Download a DKR image\n",
-               program_invocation_short_name);
-
-        return 0;
-}
-
-static int parse_argv(int argc, char *argv[]) {
-
-        enum {
-                ARG_VERSION = 0x100,
-                ARG_FORCE,
-                ARG_DKR_INDEX_URL,
-                ARG_IMAGE_ROOT,
-                ARG_VERIFY,
-        };
-
-        static const struct option options[] = {
-                { "help",            no_argument,       NULL, 'h'                 },
-                { "version",         no_argument,       NULL, ARG_VERSION         },
-                { "force",           no_argument,       NULL, ARG_FORCE           },
-                { "dkr-index-url",   required_argument, NULL, ARG_DKR_INDEX_URL   },
-                { "image-root",      required_argument, NULL, ARG_IMAGE_ROOT      },
-                { "verify",          required_argument, NULL, ARG_VERIFY          },
-                {}
-        };
-
-        int c;
-
-        assert(argc >= 0);
-        assert(argv);
-
-        while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
-
-                switch (c) {
-
-                case 'h':
-                        return help(0, NULL, NULL);
-
-                case ARG_VERSION:
-                        puts(PACKAGE_STRING);
-                        puts(SYSTEMD_FEATURES);
-                        return 0;
-
-                case ARG_FORCE:
-                        arg_force = true;
-                        break;
-
-                case ARG_DKR_INDEX_URL:
-                        if (!http_url_is_valid(optarg)) {
-                                log_error("Index URL is not valid: %s", optarg);
-                                return -EINVAL;
-                        }
-
-                        arg_dkr_index_url = optarg;
-                        break;
-
-                case ARG_IMAGE_ROOT:
-                        arg_image_root = optarg;
-                        break;
-
-                case ARG_VERIFY:
-                        arg_verify = import_verify_from_string(optarg);
-                        if (arg_verify < 0) {
-                                log_error("Invalid verification setting '%s'", optarg);
-                                return -EINVAL;
-                        }
-
-                        break;
-
-                case '?':
-                        return -EINVAL;
-
-                default:
-                        assert_not_reached("Unhandled option");
-                }
-
-        return 1;
-}
-
-static int import_main(int argc, char *argv[]) {
-
-        static const Verb verbs[] = {
-                { "help",     VERB_ANY, VERB_ANY, 0, help     },
-                { "pull-tar", 2,        3,        0, pull_tar },
-                { "pull-raw", 2,        3,        0, pull_raw },
-                { "pull-dkr", 2,        3,        0, pull_dkr },
-                {}
-        };
-
-        return dispatch_verb(argc, argv, verbs, NULL);
-}
-
-int main(int argc, char *argv[]) {
-        int r;
-
-        setlocale(LC_ALL, "");
-        log_parse_environment();
-        log_open();
-
-        r = parse_argv(argc, argv);
-        if (r <= 0)
-                goto finish;
-
-        r = import_main(argc, argv);
-
-finish:
-        return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
-}
diff --git a/src/import/importd.c b/src/import/importd.c
index a3545cd..40900ce 100644
--- a/src/import/importd.c
+++ b/src/import/importd.c
@@ -342,7 +342,7 @@ static int transfer_start(Transfer *t) {
                 return -errno;
         if (t->pid == 0) {
                 const char *cmd[] = {
-                        "systemd-import",
+                        "systemd-pull",
                         t->type == TRANSFER_TAR ? "pull-tar" :
                         t->type == TRANSFER_RAW ? "pull-raw" :
                                                       "pull-dkr",
@@ -413,7 +413,7 @@ static int transfer_start(Transfer *t) {
                         cmd[k++] = t->local;
                 cmd[k] = NULL;
 
-                execv(SYSTEMD_IMPORT_PATH, (char * const *) cmd);
+                execv(SYSTEMD_PULL_PATH, (char * const *) cmd);
                 log_error_errno(errno, "Failed to execute import tool: %m");
                 _exit(EXIT_FAILURE);
         }
diff --git a/src/import/pull.c b/src/import/pull.c
new file mode 100644
index 0000000..9bd8b77
--- /dev/null
+++ b/src/import/pull.c
@@ -0,0 +1,440 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2014 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <getopt.h>
+
+#include "sd-event.h"
+#include "event-util.h"
+#include "verbs.h"
+#include "build.h"
+#include "machine-image.h"
+#include "import-tar.h"
+#include "import-raw.h"
+#include "import-dkr.h"
+#include "import-util.h"
+
+static bool arg_force = false;
+static const char *arg_image_root = "/var/lib/machines";
+static ImportVerify arg_verify = IMPORT_VERIFY_SIGNATURE;
+static const char* arg_dkr_index_url = DEFAULT_DKR_INDEX_URL;
+
+static int interrupt_signal_handler(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
+        log_notice("Transfer aborted.");
+        sd_event_exit(sd_event_source_get_event(s), EINTR);
+        return 0;
+}
+
+static void on_tar_finished(TarImport *import, int error, void *userdata) {
+        sd_event *event = userdata;
+        assert(import);
+
+        if (error == 0)
+                log_info("Operation completed successfully.");
+
+        sd_event_exit(event, abs(error));
+}
+
+static int pull_tar(int argc, char *argv[], void *userdata) {
+        _cleanup_(tar_import_unrefp) TarImport *import = NULL;
+        _cleanup_event_unref_ sd_event *event = NULL;
+        const char *url, *local;
+        _cleanup_free_ char *l = NULL, *ll = NULL;
+        int r;
+
+        url = argv[1];
+        if (!http_url_is_valid(url)) {
+                log_error("URL '%s' is not valid.", url);
+                return -EINVAL;
+        }
+
+        if (argc >= 3)
+                local = argv[2];
+        else {
+                r = import_url_last_component(url, &l);
+                if (r < 0)
+                        return log_error_errno(r, "Failed get final component of URL: %m");
+
+                local = l;
+        }
+
+        if (isempty(local) || streq(local, "-"))
+                local = NULL;
+
+        if (local) {
+                r = tar_strip_suffixes(local, &ll);
+                if (r < 0)
+                        return log_oom();
+
+                local = ll;
+
+                if (!machine_name_is_valid(local)) {
+                        log_error("Local image name '%s' is not valid.", local);
+                        return -EINVAL;
+                }
+
+                if (!arg_force) {
+                        r = image_find(local, NULL);
+                        if (r < 0)
+                                return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local);
+                        else if (r > 0) {
+                                log_error_errno(EEXIST, "Image '%s' already exists.", local);
+                                return -EEXIST;
+                        }
+                }
+
+                log_info("Pulling '%s', saving as '%s'.", url, local);
+        } else
+                log_info("Pulling '%s'.", url);
+
+        r = sd_event_default(&event);
+        if (r < 0)
+                return log_error_errno(r, "Failed to allocate event loop: %m");
+
+        assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
+        sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler,  NULL);
+        sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
+
+        r = tar_import_new(&import, event, arg_image_root, on_tar_finished, event);
+        if (r < 0)
+                return log_error_errno(r, "Failed to allocate importer: %m");
+
+        r = tar_import_pull(import, url, local, arg_force, arg_verify);
+        if (r < 0)
+                return log_error_errno(r, "Failed to pull image: %m");
+
+        r = sd_event_loop(event);
+        if (r < 0)
+                return log_error_errno(r, "Failed to run event loop: %m");
+
+        log_info("Exiting.");
+        return -r;
+}
+
+static void on_raw_finished(RawImport *import, int error, void *userdata) {
+        sd_event *event = userdata;
+        assert(import);
+
+        if (error == 0)
+                log_info("Operation completed successfully.");
+
+        sd_event_exit(event, abs(error));
+}
+
+static int pull_raw(int argc, char *argv[], void *userdata) {
+        _cleanup_(raw_import_unrefp) RawImport *import = NULL;
+        _cleanup_event_unref_ sd_event *event = NULL;
+        const char *url, *local;
+        _cleanup_free_ char *l = NULL, *ll = NULL;
+        int r;
+
+        url = argv[1];
+        if (!http_url_is_valid(url)) {
+                log_error("URL '%s' is not valid.", url);
+                return -EINVAL;
+        }
+
+        if (argc >= 3)
+                local = argv[2];
+        else {
+                r = import_url_last_component(url, &l);
+                if (r < 0)
+                        return log_error_errno(r, "Failed get final component of URL: %m");
+
+                local = l;
+        }
+
+        if (isempty(local) || streq(local, "-"))
+                local = NULL;
+
+        if (local) {
+                r = raw_strip_suffixes(local, &ll);
+                if (r < 0)
+                        return log_oom();
+
+                local = ll;
+
+                if (!machine_name_is_valid(local)) {
+                        log_error("Local image name '%s' is not valid.", local);
+                        return -EINVAL;
+                }
+
+                if (!arg_force) {
+                        r = image_find(local, NULL);
+                        if (r < 0)
+                                return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local);
+                        else if (r > 0) {
+                                log_error_errno(EEXIST, "Image '%s' already exists.", local);
+                                return -EEXIST;
+                        }
+                }
+
+                log_info("Pulling '%s', saving as '%s'.", url, local);
+        } else
+                log_info("Pulling '%s'.", url);
+
+        r = sd_event_default(&event);
+        if (r < 0)
+                return log_error_errno(r, "Failed to allocate event loop: %m");
+
+        assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
+        sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler,  NULL);
+        sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
+
+        r = raw_import_new(&import, event, arg_image_root, on_raw_finished, event);
+        if (r < 0)
+                return log_error_errno(r, "Failed to allocate importer: %m");
+
+        r = raw_import_pull(import, url, local, arg_force, arg_verify);
+        if (r < 0)
+                return log_error_errno(r, "Failed to pull image: %m");
+
+        r = sd_event_loop(event);
+        if (r < 0)
+                return log_error_errno(r, "Failed to run event loop: %m");
+
+        log_info("Exiting.");
+        return -r;
+}
+
+static void on_dkr_finished(DkrImport *import, int error, void *userdata) {
+        sd_event *event = userdata;
+        assert(import);
+
+        if (error == 0)
+                log_info("Operation completed successfully.");
+
+        sd_event_exit(event, abs(error));
+}
+
+static int pull_dkr(int argc, char *argv[], void *userdata) {
+        _cleanup_(dkr_import_unrefp) DkrImport *import = NULL;
+        _cleanup_event_unref_ sd_event *event = NULL;
+        const char *name, *tag, *local;
+        int r;
+
+        if (!arg_dkr_index_url) {
+                log_error("Please specify an index URL with --dkr-index-url=");
+                return -EINVAL;
+        }
+
+        if (arg_verify != IMPORT_VERIFY_NO) {
+                log_error("Imports from dkr do not support image verification, please pass --verify=no.");
+                return -EINVAL;
+        }
+
+        tag = strchr(argv[1], ':');
+        if (tag) {
+                name = strndupa(argv[1], tag - argv[1]);
+                tag++;
+        } else {
+                name = argv[1];
+                tag = "latest";
+        }
+
+        if (!dkr_name_is_valid(name)) {
+                log_error("Remote name '%s' is not valid.", name);
+                return -EINVAL;
+        }
+
+        if (!dkr_tag_is_valid(tag)) {
+                log_error("Tag name '%s' is not valid.", tag);
+                return -EINVAL;
+        }
+
+        if (argc >= 3)
+                local = argv[2];
+        else {
+                local = strchr(name, '/');
+                if (local)
+                        local++;
+                else
+                        local = name;
+        }
+
+        if (isempty(local) || streq(local, "-"))
+                local = NULL;
+
+        if (local) {
+                if (!machine_name_is_valid(local)) {
+                        log_error("Local image name '%s' is not valid.", local);
+                        return -EINVAL;
+                }
+
+                if (!arg_force) {
+                        r = image_find(local, NULL);
+                        if (r < 0)
+                                return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local);
+                        else if (r > 0) {
+                                log_error_errno(EEXIST, "Image '%s' already exists.", local);
+                                return -EEXIST;
+                        }
+                }
+
+                log_info("Pulling '%s' with tag '%s', saving as '%s'.", name, tag, local);
+        } else
+                log_info("Pulling '%s' with tag '%s'.", name, tag);
+
+        r = sd_event_default(&event);
+        if (r < 0)
+                return log_error_errno(r, "Failed to allocate event loop: %m");
+
+        assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
+        sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler,  NULL);
+        sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
+
+        r = dkr_import_new(&import, event, arg_dkr_index_url, arg_image_root, on_dkr_finished, event);
+        if (r < 0)
+                return log_error_errno(r, "Failed to allocate importer: %m");
+
+        r = dkr_import_pull(import, name, tag, local, arg_force);
+        if (r < 0)
+                return log_error_errno(r, "Failed to pull image: %m");
+
+        r = sd_event_loop(event);
+        if (r < 0)
+                return log_error_errno(r, "Failed to run event loop: %m");
+
+        log_info("Exiting.");
+        return -r;
+}
+
+static int help(int argc, char *argv[], void *userdata) {
+
+        printf("%s [OPTIONS...] {COMMAND} ...\n\n"
+               "Import container or virtual machine image.\n\n"
+               "  -h --help                   Show this help\n"
+               "     --version                Show package version\n"
+               "     --force                  Force creation of image\n"
+               "     --verify=                Verify downloaded image, one of: 'no',\n"
+               "                              'checksum', 'signature'.\n"
+               "     --image-root=            Image root directory\n"
+               "     --dkr-index-url=URL      Specify index URL to use for downloads\n\n"
+               "Commands:\n"
+               "  pull-tar URL [NAME]         Download a TAR image\n"
+               "  pull-raw URL [NAME]         Download a RAW image\n"
+               "  pull-dkr REMOTE [NAME]      Download a DKR image\n",
+               program_invocation_short_name);
+
+        return 0;
+}
+
+static int parse_argv(int argc, char *argv[]) {
+
+        enum {
+                ARG_VERSION = 0x100,
+                ARG_FORCE,
+                ARG_DKR_INDEX_URL,
+                ARG_IMAGE_ROOT,
+                ARG_VERIFY,
+        };
+
+        static const struct option options[] = {
+                { "help",            no_argument,       NULL, 'h'                 },
+                { "version",         no_argument,       NULL, ARG_VERSION         },
+                { "force",           no_argument,       NULL, ARG_FORCE           },
+                { "dkr-index-url",   required_argument, NULL, ARG_DKR_INDEX_URL   },
+                { "image-root",      required_argument, NULL, ARG_IMAGE_ROOT      },
+                { "verify",          required_argument, NULL, ARG_VERIFY          },
+                {}
+        };
+
+        int c;
+
+        assert(argc >= 0);
+        assert(argv);
+
+        while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
+
+                switch (c) {
+
+                case 'h':
+                        return help(0, NULL, NULL);
+
+                case ARG_VERSION:
+                        puts(PACKAGE_STRING);
+                        puts(SYSTEMD_FEATURES);
+                        return 0;
+
+                case ARG_FORCE:
+                        arg_force = true;
+                        break;
+
+                case ARG_DKR_INDEX_URL:
+                        if (!http_url_is_valid(optarg)) {
+                                log_error("Index URL is not valid: %s", optarg);
+                                return -EINVAL;
+                        }
+
+                        arg_dkr_index_url = optarg;
+                        break;
+
+                case ARG_IMAGE_ROOT:
+                        arg_image_root = optarg;
+                        break;
+
+                case ARG_VERIFY:
+                        arg_verify = import_verify_from_string(optarg);
+                        if (arg_verify < 0) {
+                                log_error("Invalid verification setting '%s'", optarg);
+                                return -EINVAL;
+                        }
+
+                        break;
+
+                case '?':
+                        return -EINVAL;
+
+                default:
+                        assert_not_reached("Unhandled option");
+                }
+
+        return 1;
+}
+
+static int import_main(int argc, char *argv[]) {
+
+        static const Verb verbs[] = {
+                { "help",     VERB_ANY, VERB_ANY, 0, help     },
+                { "pull-tar", 2,        3,        0, pull_tar },
+                { "pull-raw", 2,        3,        0, pull_raw },
+                { "pull-dkr", 2,        3,        0, pull_dkr },
+                {}
+        };
+
+        return dispatch_verb(argc, argv, verbs, NULL);
+}
+
+int main(int argc, char *argv[]) {
+        int r;
+
+        setlocale(LC_ALL, "");
+        log_parse_environment();
+        log_open();
+
+        r = parse_argv(argc, argv);
+        if (r <= 0)
+                goto finish;
+
+        r = import_main(argc, argv);
+
+finish:
+        return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+}

commit 6adf7b5e46d32376868feef0197e6ada352aa6f2
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 22 17:31:59 2015 +0100

    machinectl: when downloading an image, clarify that C-c will not cancel the download, but continue it in the background

diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 8e2780e..5a42f26 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -1733,19 +1733,14 @@ static int enable_machine(int argc, char *argv[], void *userdata) {
         return 0;
 }
 
-typedef struct PullContext {
-        const char *path;
-        int result;
-} PullContext;
-
 static int match_log_message(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
-        PullContext *c = userdata;
-        const char *line;
+        const char **our_path = userdata, *line;
         unsigned priority;
         int r;
 
         assert(bus);
         assert(m);
+        assert(our_path);
 
         r = sd_bus_message_read(m, "us", &priority, &line);
         if (r < 0) {
@@ -1753,7 +1748,7 @@ static int match_log_message(sd_bus *bus, sd_bus_message *m, void *userdata, sd_
                 return 0;
         }
 
-        if (!streq_ptr(c->path, sd_bus_message_get_path(m)))
+        if (!streq_ptr(*our_path, sd_bus_message_get_path(m)))
                 return 0;
 
         if (arg_quiet && LOG_PRI(priority) >= LOG_INFO)
@@ -1764,14 +1759,13 @@ static int match_log_message(sd_bus *bus, sd_bus_message *m, void *userdata, sd_
 }
 
 static int match_transfer_removed(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
-        PullContext *c = userdata;
-        const char *path, *result;
+        const char **our_path = userdata, *path, *result;
         uint32_t id;
         int r;
 
         assert(bus);
         assert(m);
-        assert(c);
+        assert(our_path);
 
         r = sd_bus_message_read(m, "uos", &id, &path, &result);
         if (r < 0) {
@@ -1779,10 +1773,21 @@ static int match_transfer_removed(sd_bus *bus, sd_bus_message *m, void *userdata
                 return 0;
         }
 
-        if (!streq_ptr(c->path, path))
+        if (!streq_ptr(*our_path, path))
                 return 0;
 
-        c->result = streq_ptr(result, "done");
+        sd_event_exit(sd_bus_get_event(bus), !streq_ptr(result, "done"));
+        return 0;
+}
+
+static int transfer_signal_handler(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
+        assert(s);
+        assert(si);
+
+        if (!arg_quiet)
+                log_info("Continuing download in the background. Use \"machinectl cancel-transfer %" PRIu32 "\" to arbort transfer.", PTR_TO_UINT32(userdata));
+
+        sd_event_exit(sd_event_source_get_event(s), EINTR);
         return 0;
 }
 
@@ -1790,9 +1795,8 @@ static int pull_image_common(sd_bus *bus, sd_bus_message *m) {
         _cleanup_bus_slot_unref_ sd_bus_slot *slot_job_removed = NULL, *slot_log_message = NULL;
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
         _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
-        PullContext c = {
-                .result = -1,
-        };
+        _cleanup_event_unref_ sd_event* event = NULL;
+        const char *path = NULL;
         uint32_t id;
         int r;
 
@@ -1801,6 +1805,14 @@ static int pull_image_common(sd_bus *bus, sd_bus_message *m) {
 
         polkit_agent_open_if_enabled();
 
+        r = sd_event_default(&event);
+        if (r < 0)
+                return log_error_errno(r, "Failed to get event loop: %m");
+
+        r = sd_bus_attach_event(bus, event, 0);
+        if (r < 0)
+                return log_error_errno(r, "Failed to attach bus to event loop: %m");
+
         r = sd_bus_message_set_allow_interactive_authorization(m, arg_ask_password);
         if (r < 0)
                 return bus_log_create_error(r);
@@ -1813,7 +1825,7 @@ static int pull_image_common(sd_bus *bus, sd_bus_message *m) {
                         "interface='org.freedesktop.import1.Manager',"
                         "member='TransferRemoved',"
                         "path='/org/freedesktop/import1'",
-                        match_transfer_removed, &c);
+                        match_transfer_removed, &path);
         if (r < 0)
                 return log_error_errno(r, "Failed to install match: %m");
 
@@ -1824,7 +1836,7 @@ static int pull_image_common(sd_bus *bus, sd_bus_message *m) {
                         "sender='org.freedesktop.import1',"
                         "interface='org.freedesktop.import1.Transfer',"
                         "member='LogMessage'",
-                        match_log_message, &c);
+                        match_log_message, &path);
         if (r < 0)
                 return log_error_errno(r, "Failed to install match: %m");
 
@@ -1834,25 +1846,23 @@ static int pull_image_common(sd_bus *bus, sd_bus_message *m) {
                 return r;
         }
 
-        r = sd_bus_message_read(reply, "uo", &id, &c.path);
+        r = sd_bus_message_read(reply, "uo", &id, &path);
         if (r < 0)
                 return bus_log_parse_error(r);
 
-        for (;;) {
-                r = sd_bus_process(bus, NULL);
-                if (r < 0)
-                        return r;
+        sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1);
 
-                /* The match sets this to NULL when we are done */
-                if (c.result >= 0)
-                        break;
+        if (!arg_quiet)
+                log_info("Enqueued transfer job %u. Press C-c to continue download in background.", id);
 
-                r = sd_bus_wait(bus, (uint64_t) -1);
-                if (r < 0)
-                        return r;
-        }
+        sd_event_add_signal(event, NULL, SIGINT, transfer_signal_handler, UINT32_TO_PTR(id));
+        sd_event_add_signal(event, NULL, SIGTERM, transfer_signal_handler, UINT32_TO_PTR(id));
+
+        r = sd_event_loop(event);
+        if (r < 0)
+                return log_error_errno(r, "Failed to run event loop: %m");
 
-        return c.result ? 0 : -EINVAL;
+        return -r;
 }
 
 static int pull_tar(int argc, char *argv[], void *userdata) {

commit 813c65c34beae2eed1f93d9317f97d7e806389f5
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 22 17:30:58 2015 +0100

    machinectl: minor simplification

diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index ec403e8..8e2780e 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -1355,7 +1355,6 @@ static int login_machine(int argc, char *argv[], void *userdata) {
         int master = -1, r, ret = 0;
         sd_bus *bus = userdata;
         const char *pty, *match;
-        sigset_t mask;
         char last_char = 0;
         bool machine_died;
 
@@ -1417,9 +1416,7 @@ static int login_machine(int argc, char *argv[], void *userdata) {
         if (r < 0)
                 return bus_log_parse_error(r);
 
-        assert_se(sigemptyset(&mask) == 0);
-        sigset_add_many(&mask, SIGWINCH, SIGTERM, SIGINT, -1);
-        assert_se(sigprocmask(SIG_BLOCK, &mask, NULL) == 0);
+        sigprocmask_many(SIG_BLOCK, SIGWINCH, SIGTERM, SIGINT, -1);
 
         log_info("Connected to machine %s. Press ^] three times within 1s to exit session.", argv[1]);
 

commit 6e18cc9fa078d2a967251017ddb5baefb104b720
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 22 17:30:40 2015 +0100

    machinectl: parse verify setting client-side

diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 1bda9a0..ec403e8 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -71,7 +71,7 @@ static bool arg_ask_password = true;
 static unsigned arg_lines = 10;
 static OutputMode arg_output = OUTPUT_SHORT;
 static bool arg_force = false;
-static const char* arg_verify = NULL;
+static ImportVerify arg_verify = IMPORT_VERIFY_SIGNATURE;
 static const char* arg_dkr_index_url = NULL;
 
 static void pager_open_if_enabled(void) {
@@ -1914,7 +1914,7 @@ static int pull_tar(int argc, char *argv[], void *userdata) {
                         "sssb",
                         remote,
                         local,
-                        arg_verify,
+                        import_verify_to_string(arg_verify),
                         arg_force);
         if (r < 0)
                 return bus_log_create_error(r);
@@ -1978,7 +1978,7 @@ static int pull_raw(int argc, char *argv[], void *userdata) {
                         "sssb",
                         remote,
                         local,
-                        arg_verify,
+                        import_verify_to_string(arg_verify),
                         arg_force);
         if (r < 0)
                 return bus_log_create_error(r);
@@ -2051,7 +2051,7 @@ static int pull_dkr(int argc, char *argv[], void *userdata) {
                         remote,
                         tag,
                         local,
-                        arg_verify,
+                        import_verify_to_string(arg_verify),
                         arg_force);
         if (r < 0)
                 return bus_log_create_error(r);
@@ -2394,7 +2394,11 @@ static int parse_argv(int argc, char *argv[]) {
                         break;
 
                 case ARG_VERIFY:
-                        arg_verify = optarg;
+                        arg_verify = import_verify_from_string(optarg);
+                        if (arg_verify < 0) {
+                                log_error("Failed to parse --verify= setting: %s", optarg);
+                                return -EINVAL;
+                        }
                         break;
 
                 case ARG_FORCE:

commit 09d46cfd41d14f65cb5fe8798a6f7d964700fcd0
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 22 17:30:02 2015 +0100

    importd: minor log improvements

diff --git a/src/import/importd.c b/src/import/importd.c
index 92de430..a3545cd 100644
--- a/src/import/importd.c
+++ b/src/import/importd.c
@@ -166,7 +166,7 @@ static void transfer_send_log_line(Transfer *t, const char *line) {
 
         syslog_parse_priority(&line, &priority, true);
 
-        log_full(priority, "(transfer%" PRIu32 "): %s", t->id, line);
+        log_full(priority, "(transfer%" PRIu32 ") %s", t->id, line);
 
         r = sd_bus_emit_signal(
                         t->manager->bus,
@@ -782,7 +782,7 @@ static int method_cancel_transfer(sd_bus *bus, sd_bus_message *msg, void *userda
 
         t = hashmap_get(m->transfers, UINT32_TO_PTR(id));
         if (!t)
-                return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_TRANSFER, "Not transfer by id %" PRIu32, id);
+                return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_TRANSFER, "No transfer by id %" PRIu32, id);
 
         r = transfer_cancel(t);
         if (r < 0)

commit 1c49d1ba850f9306d5cebc0441ef66ffa33d348b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 22 17:07:27 2015 +0100

    import: make the user verficiation keyring override the vendor keyring, instead of extending it
    
    This way the user has the ability to remove keys from the
    vendor-supplied keyring if he intends so.

diff --git a/src/import/import-common.c b/src/import/import-common.c
index 395f998..561c77a 100644
--- a/src/import/import-common.c
+++ b/src/import/import-common.c
@@ -358,8 +358,7 @@ int import_verify(
                         "--no-auto-check-trustdb",
                         "--batch",
                         "--trust-model=always",
-                        "--keyring=" VENDOR_KEYRING_PATH,
-                        NULL, /* maybe user keyring */
+                        NULL, /* keyring to use */
                         NULL, /* --verify */
                         NULL, /* signature file */
                         NULL, /* dash */
@@ -403,6 +402,8 @@ int import_verify(
                  * otherwise. */
                 if (access(USER_KEYRING_PATH, F_OK) >= 0)
                         cmd[k++] = "--keyring=" USER_KEYRING_PATH;
+                else
+                        cmd[k++] = "--keyring=" VENDOR_KEYRING_PATH;
 
                 cmd[k++] = "--verify";
                 cmd[k++] = sig_file_path;



More information about the systemd-commits mailing list