daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
923a60
From b4bfb025f7ab0878e8e7e980dbad5b0a5bed1555 Mon Sep 17 00:00:00 2001
923a60
From: Lennart Poettering <lennart@poettering.net>
923a60
Date: Thu, 10 Dec 2015 12:40:04 +0100
923a60
Subject: [PATCH] importd: drop dkr support
923a60
923a60
The current code is not compatible with current dkr protocols anyway,
923a60
and dkr has a different focus ("microservices") than nspawn anyway
923a60
("whole machine containers"), hence drop support for it, we cannot
923a60
reasonably keep this up to date, and it creates the impression we'd
923a60
actually care for the microservices usecase.
923a60
923a60
Cherry-picked from: b43d75c
923a60
Related: #1284974
923a60
---
923a60
 Makefile.am                             |   2 -
923a60
 TODO                                    |   4 -
923a60
 configure.ac                            |   9 -
923a60
 man/machinectl.xml                      |  58 --
923a60
 src/import/import-dkr.c                 | 891 ------------------------
923a60
 src/import/import-dkr.h                 |  36 -
923a60
 src/import/importd.c                    | 111 +--
923a60
 src/import/org.freedesktop.import1.conf |   4 -
923a60
 src/import/pull.c                       | 119 +---
923a60
 src/machine/machinectl.c                |  90 +--
923a60
 src/shared/import-util.c                |  31 -
923a60
 src/shared/import-util.h                |   4 -
923a60
 12 files changed, 5 insertions(+), 1354 deletions(-)
923a60
 delete mode 100644 src/import/import-dkr.c
923a60
 delete mode 100644 src/import/import-dkr.h
923a60
923a60
diff --git a/Makefile.am b/Makefile.am
923a60
index 3a09e0a62b..b0a34b212d 100644
923a60
--- a/Makefile.am
923a60
+++ b/Makefile.am
923a60
@@ -5369,8 +5369,6 @@ systemd_pull_SOURCES = \
923a60
 	src/import/import-raw.h \
923a60
 	src/import/import-tar.c \
923a60
 	src/import/import-tar.h \
923a60
-	src/import/import-dkr.c \
923a60
-	src/import/import-dkr.h \
923a60
 	src/import/import-job.c \
923a60
 	src/import/import-job.h \
923a60
 	src/import/import-common.c \
923a60
diff --git a/TODO b/TODO
923a60
index 90b2c4b30a..d96d2bf0ee 100644
923a60
--- a/TODO
923a60
+++ b/TODO
923a60
@@ -126,10 +126,6 @@ Features:
923a60
 
923a60
 * rework journald sigbus stuff to use mutex
923a60
 
923a60
-* import-dkr: support tarsum checksum verification, if it becomes reality one day...
923a60
-
923a60
-* import-dkr: convert json bits to nspawn configuration
923a60
-
923a60
 * import: support import from local files, and export to local files
923a60
 
923a60
 * core/cgroup: support net_cls modules, and support automatically allocating class ids, then add support for making firewall changes depending on it, to implement a per-service firewall
923a60
diff --git a/configure.ac b/configure.ac
923a60
index 9103f9b923..2734368dc0 100644
923a60
--- a/configure.ac
923a60
+++ b/configure.ac
923a60
@@ -1389,14 +1389,6 @@ AC_ARG_ENABLE([split-usr],
923a60
                 enable_split_usr=no
923a60
         ])])
923a60
 
923a60
-AC_ARG_WITH([dkr-index-url],
923a60
-        [AS_HELP_STRING([--dkr-index-url=URL], [Specify the default index URL to use for image downloads])],
923a60
-        [DEFAULT_DKR_INDEX_URL="\"$withval\""],
923a60
-        [DEFAULT_DKR_INDEX_URL="NULL"])
923a60
-
923a60
-AC_DEFINE_UNQUOTED(DEFAULT_DKR_INDEX_URL, [$DEFAULT_DKR_INDEX_URL], [Default index URL to use for image downloads])
923a60
-AC_SUBST(DEFAULT_DKR_INDEX_URL)
923a60
-
923a60
 AS_IF([test "x${enable_split_usr}" = "xyes"], [
923a60
         AC_DEFINE(HAVE_SPLIT_USR, 1, [Define if /bin, /sbin aren't symlinks into /usr])
923a60
 ])
923a60
@@ -1564,7 +1556,6 @@ AC_MSG_RESULT([
923a60
         Maximum System UID:      ${SYSTEM_UID_MAX}
923a60
         Maximum System GID:      ${SYSTEM_GID_MAX}
923a60
         Certificate root:        ${CERTIFICATEROOT}
923a60
-        Default dkr Index        ${DEFAULT_DKR_INDEX_URL}
923a60
 
923a60
         CFLAGS:                  ${OUR_CFLAGS} ${CFLAGS}
923a60
         CPPFLAGS:                ${OUR_CPPFLAGS} ${CPPFLAGS}
923a60
diff --git a/man/machinectl.xml b/man/machinectl.xml
923a60
index 640cb8b7d6..b0a7f2ae49 100644
923a60
--- a/man/machinectl.xml
923a60
+++ b/man/machinectl.xml
923a60
@@ -204,16 +204,6 @@
923a60
         image.</para></listitem>
923a60
       </varlistentry>
923a60
 
923a60
-      <varlistentry>
923a60
-        <term><option>--dkr-index-url</option></term>
923a60
-
923a60
-        <listitem><para>Specifies the index server to use for
923a60
-        downloading <literal>dkr</literal> images with the
923a60
-        <command>pull-dkr</command>. Takes a
923a60
-        <literal>http://</literal>, <literal>https://</literal>
923a60
-        URL.</para></listitem>
923a60
-      </varlistentry>
923a60
-
923a60
       <xi:include href="user-system-options.xml" xpointer="host" />
923a60
       <xi:include href="user-system-options.xml" xpointer="machine" />
923a60
 
923a60
@@ -602,42 +592,6 @@
923a60
         below.</para></listitem>
923a60
       </varlistentry>
923a60
 
923a60
-      <varlistentry>
923a60
-        <term><command>pull-dkr</command> <replaceable>REMOTE</replaceable> [<replaceable>NAME</replaceable>]</term>
923a60
-
923a60
-        <listitem><para>Downloads a <literal>dkr</literal> container
923a60
-        image and makes it available locally. The remote name refers
923a60
-        to a <literal>dkr</literal> container name. If omitted, the
923a60
-        local machine name is derived from the <literal>dkr</literal>
923a60
-        container name.</para>
923a60
-
923a60
-        <para>Image verification is not available for
923a60
-        <literal>dkr</literal> containers, and thus
923a60
-        <option>--verify=no</option> must always be specified with
923a60
-        this command.</para>
923a60
-
923a60
-        <para>This command downloads all (missing) layers for the
923a60
-        specified container and places them in read-only subvolumes in
923a60
-        <filename>/var/lib/machines/</filename>. A writable snapshot
923a60
-        of the newest layer is then created under the specified local
923a60
-        machine name. To omit creation of this writable snapshot, pass
923a60
-        <literal>-</literal> as local machine name.</para>
923a60
-
923a60
-        <para>The read-only layer subvolumes are prefixed with
923a60
-        <filename>.dkr-</filename>, and thus now shown by
923a60
-        <command>list-images</command>, unless <option>--all</option>
923a60
-        is passed.</para>
923a60
-
923a60
-        <para>To specify the <literal>dkr</literal> index server to
923a60
-        use for looking up the specified container, use
923a60
-        <option>--dkr-index-url=</option>.</para>
923a60
-
923a60
-        <para>Note that pressing C-c during execution of this command
923a60
-        will not abort the download. Use
923a60
-        <command>cancel-transfer</command>, described
923a60
-        below.</para></listitem>
923a60
-      </varlistentry>
923a60
-
923a60
       <varlistentry>
923a60
         <term><command>list-transfers</command></term>
923a60
 
923a60
@@ -728,18 +682,6 @@
923a60
       the machine started as system service. With the last command a
923a60
       login prompt into the container is requested.</para>
923a60
     </example>
923a60
-
923a60
-    <example>
923a60
-      <title>Download a Fedora <literal>dkr</literal> image</title>
923a60
-
923a60
-      <programlisting># machinectl pull-dkr --verify=no mattdm/fedora
923a60
-# systemd-nspawn -M fedora</programlisting>
923a60
-
923a60
-      <para>Downloads a <literal>dkr</literal> image and opens a shell
923a60
-      in it. Note that the specified download command might require an
923a60
-      index server to be specified with the
923a60
-      <literal>--dkr-index-url=</literal>.</para>
923a60
-    </example>
923a60
   </refsect1>
923a60
 
923a60
   <refsect1>
923a60
diff --git a/src/import/import-dkr.c b/src/import/import-dkr.c
923a60
deleted file mode 100644
923a60
index fb72f6cee3..0000000000
923a60
--- a/src/import/import-dkr.c
923a60
+++ /dev/null
923a60
@@ -1,891 +0,0 @@
923a60
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
923a60
-
923a60
-/***
923a60
-  This file is part of systemd.
923a60
-
923a60
-  Copyright 2014 Lennart Poettering
923a60
-
923a60
-  systemd is free software; you can redistribute it and/or modify it
923a60
-  under the terms of the GNU Lesser General Public License as published by
923a60
-  the Free Software Foundation; either version 2.1 of the License, or
923a60
-  (at your option) any later version.
923a60
-
923a60
-  systemd is distributed in the hope that it will be useful, but
923a60
-  WITHOUT ANY WARRANTY; without even the implied warranty of
923a60
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
923a60
-  Lesser General Public License for more details.
923a60
-
923a60
-  You should have received a copy of the GNU Lesser General Public License
923a60
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
923a60
-***/
923a60
-
923a60
-#include <curl/curl.h>
923a60
-#include <sys/prctl.h>
923a60
-
923a60
-#include "sd-daemon.h"
923a60
-#include "json.h"
923a60
-#include "strv.h"
923a60
-#include "btrfs-util.h"
923a60
-#include "utf8.h"
923a60
-#include "mkdir.h"
923a60
-#include "import-util.h"
923a60
-#include "curl-util.h"
923a60
-#include "aufs-util.h"
923a60
-#include "import-job.h"
923a60
-#include "import-common.h"
923a60
-#include "import-dkr.h"
923a60
-
923a60
-typedef enum DkrProgress {
923a60
-        DKR_SEARCHING,
923a60
-        DKR_RESOLVING,
923a60
-        DKR_METADATA,
923a60
-        DKR_DOWNLOADING,
923a60
-        DKR_COPYING,
923a60
-} DkrProgress;
923a60
-
923a60
-struct DkrImport {
923a60
-        sd_event *event;
923a60
-        CurlGlue *glue;
923a60
-
923a60
-        char *index_url;
923a60
-        char *image_root;
923a60
-
923a60
-        ImportJob *images_job;
923a60
-        ImportJob *tags_job;
923a60
-        ImportJob *ancestry_job;
923a60
-        ImportJob *json_job;
923a60
-        ImportJob *layer_job;
923a60
-
923a60
-        char *name;
923a60
-        char *tag;
923a60
-        char *id;
923a60
-
923a60
-        char *response_token;
923a60
-        char **response_registries;
923a60
-
923a60
-        char **ancestry;
923a60
-        unsigned n_ancestry;
923a60
-        unsigned current_ancestry;
923a60
-
923a60
-        DkrImportFinished on_finished;
923a60
-        void *userdata;
923a60
-
923a60
-        char *local;
923a60
-        bool force_local;
923a60
-
923a60
-        char *temp_path;
923a60
-        char *final_path;
923a60
-
923a60
-        pid_t tar_pid;
923a60
-};
923a60
-
923a60
-#define PROTOCOL_PREFIX "https://"
923a60
-
923a60
-#define HEADER_TOKEN "X-Do" /* the HTTP header for the auth token */ "cker-Token:"
923a60
-#define HEADER_REGISTRY "X-Do" /*the HTTP header for the registry */ "cker-Endpoints:"
923a60
-
923a60
-#define LAYERS_MAX 2048
923a60
-
923a60
-static void dkr_import_job_on_finished(ImportJob *j);
923a60
-
923a60
-DkrImport* dkr_import_unref(DkrImport *i) {
923a60
-        if (!i)
923a60
-                return NULL;
923a60
-
923a60
-        if (i->tar_pid > 1) {
923a60
-                (void) kill_and_sigcont(i->tar_pid, SIGKILL);
923a60
-                (void) wait_for_terminate(i->tar_pid, NULL);
923a60
-        }
923a60
-
923a60
-        import_job_unref(i->images_job);
923a60
-        import_job_unref(i->tags_job);
923a60
-        import_job_unref(i->ancestry_job);
923a60
-        import_job_unref(i->json_job);
923a60
-        import_job_unref(i->layer_job);
923a60
-
923a60
-        curl_glue_unref(i->glue);
923a60
-        sd_event_unref(i->event);
923a60
-
923a60
-        if (i->temp_path) {
923a60
-                (void) btrfs_subvol_remove(i->temp_path);
923a60
-                (void) rm_rf_dangerous(i->temp_path, false, true, false);
923a60
-                free(i->temp_path);
923a60
-        }
923a60
-
923a60
-        free(i->name);
923a60
-        free(i->tag);
923a60
-        free(i->id);
923a60
-        free(i->response_token);
923a60
-        free(i->response_registries);
923a60
-        strv_free(i->ancestry);
923a60
-        free(i->final_path);
923a60
-        free(i->index_url);
923a60
-        free(i->image_root);
923a60
-        free(i->local);
923a60
-        free(i);
923a60
-
923a60
-        return NULL;
923a60
-}
923a60
-
923a60
-int dkr_import_new(
923a60
-                DkrImport **ret,
923a60
-                sd_event *event,
923a60
-                const char *index_url,
923a60
-                const char *image_root,
923a60
-                DkrImportFinished on_finished,
923a60
-                void *userdata) {
923a60
-
923a60
-        _cleanup_(dkr_import_unrefp) DkrImport *i = NULL;
923a60
-        char *e;
923a60
-        int r;
923a60
-
923a60
-        assert(ret);
923a60
-        assert(index_url);
923a60
-
923a60
-        if (!http_url_is_valid(index_url))
923a60
-                return -EINVAL;
923a60
-
923a60
-        i = new0(DkrImport, 1);
923a60
-        if (!i)
923a60
-                return -ENOMEM;
923a60
-
923a60
-        i->on_finished = on_finished;
923a60
-        i->userdata = userdata;
923a60
-
923a60
-        i->image_root = strdup(image_root ?: "/var/lib/machines");
923a60
-        if (!i->image_root)
923a60
-                return -ENOMEM;
923a60
-
923a60
-        i->index_url = strdup(index_url);
923a60
-        if (!i->index_url)
923a60
-                return -ENOMEM;
923a60
-
923a60
-        e = endswith(i->index_url, "/");
923a60
-        if (e)
923a60
-                *e = 0;
923a60
-
923a60
-        if (event)
923a60
-                i->event = sd_event_ref(event);
923a60
-        else {
923a60
-                r = sd_event_default(&i->event);
923a60
-                if (r < 0)
923a60
-                        return r;
923a60
-        }
923a60
-
923a60
-        r = curl_glue_new(&i->glue, i->event);
923a60
-        if (r < 0)
923a60
-                return r;
923a60
-
923a60
-        i->glue->on_finished = import_job_curl_on_finished;
923a60
-        i->glue->userdata = i;
923a60
-
923a60
-        *ret = i;
923a60
-        i = NULL;
923a60
-
923a60
-        return 0;
923a60
-}
923a60
-
923a60
-static void dkr_import_report_progress(DkrImport *i, DkrProgress p) {
923a60
-        unsigned percent;
923a60
-
923a60
-        assert(i);
923a60
-
923a60
-        switch (p) {
923a60
-
923a60
-        case DKR_SEARCHING:
923a60
-                percent = 0;
923a60
-                if (i->images_job)
923a60
-                        percent += i->images_job->progress_percent * 5 / 100;
923a60
-                break;
923a60
-
923a60
-        case DKR_RESOLVING:
923a60
-                percent = 5;
923a60
-                if (i->tags_job)
923a60
-                        percent += i->tags_job->progress_percent * 5 / 100;
923a60
-                break;
923a60
-
923a60
-        case DKR_METADATA:
923a60
-                percent = 10;
923a60
-                if (i->ancestry_job)
923a60
-                        percent += i->ancestry_job->progress_percent * 5 / 100;
923a60
-                if (i->json_job)
923a60
-                        percent += i->json_job->progress_percent * 5 / 100;
923a60
-                break;
923a60
-
923a60
-        case DKR_DOWNLOADING:
923a60
-                percent = 20;
923a60
-                percent += 75 * i->current_ancestry / MAX(1U, i->n_ancestry);
923a60
-                if (i->layer_job)
923a60
-                        percent += i->layer_job->progress_percent * 75 / MAX(1U, i->n_ancestry) / 100;
923a60
-
923a60
-                break;
923a60
-
923a60
-        case DKR_COPYING:
923a60
-                percent = 95;
923a60
-                break;
923a60
-
923a60
-        default:
923a60
-                assert_not_reached("Unknown progress state");
923a60
-        }
923a60
-
923a60
-        sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent);
923a60
-        log_debug("Combined progress %u%%", percent);
923a60
-}
923a60
-
923a60
-static int parse_id(const void *payload, size_t size, char **ret) {
923a60
-        _cleanup_free_ char *buf = NULL, *id = NULL, *other = NULL;
923a60
-        union json_value v = {};
923a60
-        void *json_state = NULL;
923a60
-        const char *p;
923a60
-        int t;
923a60
-
923a60
-        assert(payload);
923a60
-        assert(ret);
923a60
-
923a60
-        if (size <= 0)
923a60
-                return -EBADMSG;
923a60
-
923a60
-        if (memchr(payload, 0, size))
923a60
-                return -EBADMSG;
923a60
-
923a60
-        buf = strndup(payload, size);
923a60
-        if (!buf)
923a60
-                return -ENOMEM;
923a60
-
923a60
-        p = buf;
923a60
-        t = json_tokenize(&p, &id, &v, &json_state, NULL);
923a60
-        if (t < 0)
923a60
-                return t;
923a60
-        if (t != JSON_STRING)
923a60
-                return -EBADMSG;
923a60
-
923a60
-        t = json_tokenize(&p, &other, &v, &json_state, NULL);
923a60
-        if (t < 0)
923a60
-                return t;
923a60
-        if (t != JSON_END)
923a60
-                return -EBADMSG;
923a60
-
923a60
-        if (!dkr_id_is_valid(id))
923a60
-                return -EBADMSG;
923a60
-
923a60
-        *ret = id;
923a60
-        id = NULL;
923a60
-
923a60
-        return 0;
923a60
-}
923a60
-
923a60
-static int parse_ancestry(const void *payload, size_t size, char ***ret) {
923a60
-        _cleanup_free_ char *buf = NULL;
923a60
-        void *json_state = NULL;
923a60
-        const char *p;
923a60
-        enum {
923a60
-                STATE_BEGIN,
923a60
-                STATE_ITEM,
923a60
-                STATE_COMMA,
923a60
-                STATE_END,
923a60
-        } state = STATE_BEGIN;
923a60
-        _cleanup_strv_free_ char **l = NULL;
923a60
-        size_t n = 0, allocated = 0;
923a60
-
923a60
-        if (size <= 0)
923a60
-                return -EBADMSG;
923a60
-
923a60
-        if (memchr(payload, 0, size))
923a60
-                return -EBADMSG;
923a60
-
923a60
-        buf = strndup(payload, size);
923a60
-        if (!buf)
923a60
-                return -ENOMEM;
923a60
-
923a60
-        p = buf;
923a60
-        for (;;) {
923a60
-                _cleanup_free_ char *str;
923a60
-                union json_value v = {};
923a60
-                int t;
923a60
-
923a60
-                t = json_tokenize(&p, &str, &v, &json_state, NULL);
923a60
-                if (t < 0)
923a60
-                        return t;
923a60
-
923a60
-                switch (state) {
923a60
-
923a60
-                case STATE_BEGIN:
923a60
-                        if (t == JSON_ARRAY_OPEN)
923a60
-                                state = STATE_ITEM;
923a60
-                        else
923a60
-                                return -EBADMSG;
923a60
-
923a60
-                        break;
923a60
-
923a60
-                case STATE_ITEM:
923a60
-                        if (t == JSON_STRING) {
923a60
-                                if (!dkr_id_is_valid(str))
923a60
-                                        return -EBADMSG;
923a60
-
923a60
-                                if (n+1 > LAYERS_MAX)
923a60
-                                        return -EFBIG;
923a60
-
923a60
-                                if (!GREEDY_REALLOC(l, allocated, n + 2))
923a60
-                                        return -ENOMEM;
923a60
-
923a60
-                                l[n++] = str;
923a60
-                                str = NULL;
923a60
-                                l[n] = NULL;
923a60
-
923a60
-                                state = STATE_COMMA;
923a60
-
923a60
-                        } else if (t == JSON_ARRAY_CLOSE)
923a60
-                                state = STATE_END;
923a60
-                        else
923a60
-                                return -EBADMSG;
923a60
-
923a60
-                        break;
923a60
-
923a60
-                case STATE_COMMA:
923a60
-                        if (t == JSON_COMMA)
923a60
-                                state = STATE_ITEM;
923a60
-                        else if (t == JSON_ARRAY_CLOSE)
923a60
-                                state = STATE_END;
923a60
-                        else
923a60
-                                return -EBADMSG;
923a60
-                        break;
923a60
-
923a60
-                case STATE_END:
923a60
-                        if (t == JSON_END) {
923a60
-
923a60
-                                if (strv_isempty(l))
923a60
-                                        return -EBADMSG;
923a60
-
923a60
-                                if (!strv_is_uniq(l))
923a60
-                                        return -EBADMSG;
923a60
-
923a60
-                                l = strv_reverse(l);
923a60
-
923a60
-                                *ret = l;
923a60
-                                l = NULL;
923a60
-                                return 0;
923a60
-                        } else
923a60
-                                return -EBADMSG;
923a60
-                }
923a60
-
923a60
-        }
923a60
-}
923a60
-
923a60
-static const char *dkr_import_current_layer(DkrImport *i) {
923a60
-        assert(i);
923a60
-
923a60
-        if (strv_isempty(i->ancestry))
923a60
-                return NULL;
923a60
-
923a60
-        return i->ancestry[i->current_ancestry];
923a60
-}
923a60
-
923a60
-static const char *dkr_import_current_base_layer(DkrImport *i) {
923a60
-        assert(i);
923a60
-
923a60
-        if (strv_isempty(i->ancestry))
923a60
-                return NULL;
923a60
-
923a60
-        if (i->current_ancestry <= 0)
923a60
-                return NULL;
923a60
-
923a60
-        return i->ancestry[i->current_ancestry-1];
923a60
-}
923a60
-
923a60
-static int dkr_import_add_token(DkrImport *i, ImportJob *j) {
923a60
-        const char *t;
923a60
-
923a60
-        assert(i);
923a60
-        assert(j);
923a60
-
923a60
-        if (i->response_token)
923a60
-                t = strjoina("Authorization: Token ", i->response_token);
923a60
-        else
923a60
-                t = HEADER_TOKEN " true";
923a60
-
923a60
-        j->request_header = curl_slist_new("Accept: application/json", t, NULL);
923a60
-        if (!j->request_header)
923a60
-                return -ENOMEM;
923a60
-
923a60
-        return 0;
923a60
-}
923a60
-
923a60
-static bool dkr_import_is_done(DkrImport *i) {
923a60
-        assert(i);
923a60
-        assert(i->images_job);
923a60
-
923a60
-        if (i->images_job->state != IMPORT_JOB_DONE)
923a60
-                return false;
923a60
-
923a60
-        if (!i->tags_job || i->tags_job->state != IMPORT_JOB_DONE)
923a60
-                return false;
923a60
-
923a60
-        if (!i->ancestry_job || i->ancestry_job->state != IMPORT_JOB_DONE)
923a60
-                return false;
923a60
-
923a60
-        if (!i->json_job || i->json_job->state != IMPORT_JOB_DONE)
923a60
-                return false;
923a60
-
923a60
-        if (i->layer_job && i->layer_job->state != IMPORT_JOB_DONE)
923a60
-                return false;
923a60
-
923a60
-        if (dkr_import_current_layer(i))
923a60
-                return false;
923a60
-
923a60
-        return true;
923a60
-}
923a60
-
923a60
-static int dkr_import_make_local_copy(DkrImport *i) {
923a60
-        int r;
923a60
-
923a60
-        assert(i);
923a60
-
923a60
-        if (!i->local)
923a60
-                return 0;
923a60
-
923a60
-        if (!i->final_path) {
923a60
-                i->final_path = strjoin(i->image_root, "/.dkr-", i->id, NULL);
923a60
-                if (!i->final_path)
923a60
-                        return log_oom();
923a60
-        }
923a60
-
923a60
-        r = import_make_local_copy(i->final_path, i->image_root, i->local, i->force_local);
923a60
-        if (r < 0)
923a60
-                return r;
923a60
-
923a60
-        return 0;
923a60
-}
923a60
-
923a60
-static int dkr_import_job_on_open_disk(ImportJob *j) {
923a60
-        const char *base;
923a60
-        DkrImport *i;
923a60
-        int r;
923a60
-
923a60
-        assert(j);
923a60
-        assert(j->userdata);
923a60
-
923a60
-        i = j->userdata;
923a60
-        assert(i->layer_job == j);
923a60
-        assert(i->final_path);
923a60
-        assert(!i->temp_path);
923a60
-        assert(i->tar_pid <= 0);
923a60
-
923a60
-        r = tempfn_random(i->final_path, &i->temp_path);
923a60
-        if (r < 0)
923a60
-                return log_oom();
923a60
-
923a60
-        mkdir_parents_label(i->temp_path, 0700);
923a60
-
923a60
-        base = dkr_import_current_base_layer(i);
923a60
-        if (base) {
923a60
-                const char *base_path;
923a60
-
923a60
-                base_path = strjoina(i->image_root, "/.dkr-", base);
923a60
-                r = btrfs_subvol_snapshot(base_path, i->temp_path, false, true);
923a60
-        } else
923a60
-                r = btrfs_subvol_make(i->temp_path);
923a60
-        if (r < 0)
923a60
-                return log_error_errno(r, "Failed to make btrfs subvolume %s: %m", i->temp_path);
923a60
-
923a60
-        j->disk_fd = import_fork_tar(i->temp_path, &i->tar_pid);
923a60
-        if (j->disk_fd < 0)
923a60
-                return j->disk_fd;
923a60
-
923a60
-        return 0;
923a60
-}
923a60
-
923a60
-static void dkr_import_job_on_progress(ImportJob *j) {
923a60
-        DkrImport *i;
923a60
-
923a60
-        assert(j);
923a60
-        assert(j->userdata);
923a60
-
923a60
-        i = j->userdata;
923a60
-
923a60
-        dkr_import_report_progress(
923a60
-                        i,
923a60
-                        j == i->images_job                       ? DKR_SEARCHING :
923a60
-                        j == i->tags_job                         ? DKR_RESOLVING :
923a60
-                        j == i->ancestry_job || j == i->json_job ? DKR_METADATA :
923a60
-                                                                   DKR_DOWNLOADING);
923a60
-}
923a60
-
923a60
-static int dkr_import_pull_layer(DkrImport *i) {
923a60
-        _cleanup_free_ char *path = NULL;
923a60
-        const char *url, *layer = NULL;
923a60
-        int r;
923a60
-
923a60
-        assert(i);
923a60
-        assert(!i->layer_job);
923a60
-        assert(!i->temp_path);
923a60
-        assert(!i->final_path);
923a60
-
923a60
-        for (;;) {
923a60
-                layer = dkr_import_current_layer(i);
923a60
-                if (!layer)
923a60
-                        return 0; /* no more layers */
923a60
-
923a60
-                path = strjoin(i->image_root, "/.dkr-", layer, NULL);
923a60
-                if (!path)
923a60
-                        return log_oom();
923a60
-
923a60
-                if (laccess(path, F_OK) < 0) {
923a60
-                        if (errno == ENOENT)
923a60
-                                break;
923a60
-
923a60
-                        return log_error_errno(errno, "Failed to check for container: %m");
923a60
-                }
923a60
-
923a60
-                log_info("Layer %s already exists, skipping.", layer);
923a60
-
923a60
-                i->current_ancestry++;
923a60
-
923a60
-                free(path);
923a60
-                path = NULL;
923a60
-        }
923a60
-
923a60
-        log_info("Pulling layer %s...", layer);
923a60
-
923a60
-        i->final_path = path;
923a60
-        path = NULL;
923a60
-
923a60
-        url = strjoina(PROTOCOL_PREFIX, i->response_registries[0], "/v1/images/", layer, "/layer");
923a60
-        r = import_job_new(&i->layer_job, url, i->glue, i);
923a60
-        if (r < 0)
923a60
-                return log_error_errno(r, "Failed to allocate layer job: %m");
923a60
-
923a60
-        r = dkr_import_add_token(i, i->layer_job);
923a60
-        if (r < 0)
923a60
-                return log_oom();
923a60
-
923a60
-        i->layer_job->on_finished = dkr_import_job_on_finished;
923a60
-        i->layer_job->on_open_disk = dkr_import_job_on_open_disk;
923a60
-        i->layer_job->on_progress = dkr_import_job_on_progress;
923a60
-
923a60
-        r = import_job_begin(i->layer_job);
923a60
-        if (r < 0)
923a60
-                return log_error_errno(r, "Failed to start layer job: %m");
923a60
-
923a60
-        return 0;
923a60
-}
923a60
-
923a60
-static void dkr_import_job_on_finished(ImportJob *j) {
923a60
-        DkrImport *i;
923a60
-        int r;
923a60
-
923a60
-        assert(j);
923a60
-        assert(j->userdata);
923a60
-
923a60
-        i = j->userdata;
923a60
-        if (j->error != 0) {
923a60
-                if (j == i->images_job)
923a60
-                        log_error_errno(j->error, "Failed to retrieve images list. (Wrong index URL?)");
923a60
-                else if (j == i->tags_job)
923a60
-                        log_error_errno(j->error, "Failed to retrieve tags list.");
923a60
-                else if (j == i->ancestry_job)
923a60
-                        log_error_errno(j->error, "Failed to retrieve ancestry list.");
923a60
-                else if (j == i->json_job)
923a60
-                        log_error_errno(j->error, "Failed to retrieve json data.");
923a60
-                else
923a60
-                        log_error_errno(j->error, "Failed to retrieve layer data.");
923a60
-
923a60
-                r = j->error;
923a60
-                goto finish;
923a60
-        }
923a60
-
923a60
-        if (i->images_job == j) {
923a60
-                const char *url;
923a60
-
923a60
-                assert(!i->tags_job);
923a60
-                assert(!i->ancestry_job);
923a60
-                assert(!i->json_job);
923a60
-                assert(!i->layer_job);
923a60
-
923a60
-                if (strv_isempty(i->response_registries)) {
923a60
-                        r = -EBADMSG;
923a60
-                        log_error("Didn't get registry information.");
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-                log_info("Index lookup succeeded, directed to registry %s.", i->response_registries[0]);
923a60
-                dkr_import_report_progress(i, DKR_RESOLVING);
923a60
-
923a60
-                url = strjoina(PROTOCOL_PREFIX, i->response_registries[0], "/v1/repositories/", i->name, "/tags/", i->tag);
923a60
-                r = import_job_new(&i->tags_job, url, i->glue, i);
923a60
-                if (r < 0) {
923a60
-                        log_error_errno(r, "Failed to allocate tags job: %m");
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-                r = dkr_import_add_token(i, i->tags_job);
923a60
-                if (r < 0) {
923a60
-                        log_oom();
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-                i->tags_job->on_finished = dkr_import_job_on_finished;
923a60
-                i->tags_job->on_progress = dkr_import_job_on_progress;
923a60
-
923a60
-                r = import_job_begin(i->tags_job);
923a60
-                if (r < 0) {
923a60
-                        log_error_errno(r, "Failed to start tags job: %m");
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-        } else if (i->tags_job == j) {
923a60
-                const char *url;
923a60
-                char *id = NULL;
923a60
-
923a60
-                assert(!i->ancestry_job);
923a60
-                assert(!i->json_job);
923a60
-                assert(!i->layer_job);
923a60
-
923a60
-                r = parse_id(j->payload, j->payload_size, &id;;
923a60
-                if (r < 0) {
923a60
-                        log_error_errno(r, "Failed to parse JSON id.");
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-                free(i->id);
923a60
-                i->id = id;
923a60
-
923a60
-                log_info("Tag lookup succeeded, resolved to layer %s.", i->id);
923a60
-                dkr_import_report_progress(i, DKR_METADATA);
923a60
-
923a60
-                url = strjoina(PROTOCOL_PREFIX, i->response_registries[0], "/v1/images/", i->id, "/ancestry");
923a60
-                r = import_job_new(&i->ancestry_job, url, i->glue, i);
923a60
-                if (r < 0) {
923a60
-                        log_error_errno(r, "Failed to allocate ancestry job: %m");
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-                r = dkr_import_add_token(i, i->ancestry_job);
923a60
-                if (r < 0) {
923a60
-                        log_oom();
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-                i->ancestry_job->on_finished = dkr_import_job_on_finished;
923a60
-                i->ancestry_job->on_progress = dkr_import_job_on_progress;
923a60
-
923a60
-                url = strjoina(PROTOCOL_PREFIX, i->response_registries[0], "/v1/images/", i->id, "/json");
923a60
-                r = import_job_new(&i->json_job, url, i->glue, i);
923a60
-                if (r < 0) {
923a60
-                        log_error_errno(r, "Failed to allocate json job: %m");
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-                r = dkr_import_add_token(i, i->json_job);
923a60
-                if (r < 0) {
923a60
-                        log_oom();
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-                i->json_job->on_finished = dkr_import_job_on_finished;
923a60
-                i->json_job->on_progress = dkr_import_job_on_progress;
923a60
-
923a60
-                r = import_job_begin(i->ancestry_job);
923a60
-                if (r < 0) {
923a60
-                        log_error_errno(r, "Failed to start ancestry job: %m");
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-                r = import_job_begin(i->json_job);
923a60
-                if (r < 0) {
923a60
-                        log_error_errno(r, "Failed to start json job: %m");
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-        } else if (i->ancestry_job == j) {
923a60
-                char **ancestry = NULL, **k;
923a60
-                unsigned n;
923a60
-
923a60
-                assert(!i->layer_job);
923a60
-
923a60
-                r = parse_ancestry(j->payload, j->payload_size, &ancestry);
923a60
-                if (r < 0) {
923a60
-                        log_error_errno(r, "Failed to parse JSON id.");
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-                n = strv_length(ancestry);
923a60
-                if (n <= 0 || !streq(ancestry[n-1], i->id)) {
923a60
-                        log_error("Ancestry doesn't end in main layer.");
923a60
-                        strv_free(ancestry);
923a60
-                        r = -EBADMSG;
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-                log_info("Ancestor lookup succeeded, requires layers:\n");
923a60
-                STRV_FOREACH(k, ancestry)
923a60
-                        log_info("\t%s", *k);
923a60
-
923a60
-                strv_free(i->ancestry);
923a60
-                i->ancestry = ancestry;
923a60
-                i->n_ancestry = n;
923a60
-                i->current_ancestry = 0;
923a60
-
923a60
-                dkr_import_report_progress(i, DKR_DOWNLOADING);
923a60
-
923a60
-                r = dkr_import_pull_layer(i);
923a60
-                if (r < 0)
923a60
-                        goto finish;
923a60
-
923a60
-        } else if (i->layer_job == j) {
923a60
-                assert(i->temp_path);
923a60
-                assert(i->final_path);
923a60
-
923a60
-                j->disk_fd = safe_close(j->disk_fd);
923a60
-
923a60
-                if (i->tar_pid > 0) {
923a60
-                        r = wait_for_terminate_and_warn("tar", i->tar_pid, true);
923a60
-                        i->tar_pid = 0;
923a60
-                        if (r < 0)
923a60
-                                goto finish;
923a60
-                }
923a60
-
923a60
-                r = aufs_resolve(i->temp_path);
923a60
-                if (r < 0) {
923a60
-                        log_error_errno(r, "Failed to resolve aufs whiteouts: %m");
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-                r = btrfs_subvol_set_read_only(i->temp_path, true);
923a60
-                if (r < 0) {
923a60
-                        log_error_errno(r, "Failed to mark snapshot read-only: %m");
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-                if (rename(i->temp_path, i->final_path) < 0) {
923a60
-                        log_error_errno(errno, "Failed to rename snaphsot: %m");
923a60
-                        goto finish;
923a60
-                }
923a60
-
923a60
-                log_info("Completed writing to layer %s.", i->final_path);
923a60
-
923a60
-                i->layer_job = import_job_unref(i->layer_job);
923a60
-                free(i->temp_path);
923a60
-                i->temp_path = NULL;
923a60
-                free(i->final_path);
923a60
-                i->final_path = NULL;
923a60
-
923a60
-                i->current_ancestry ++;
923a60
-                r = dkr_import_pull_layer(i);
923a60
-                if (r < 0)
923a60
-                        goto finish;
923a60
-
923a60
-        } else if (i->json_job != j)
923a60
-                assert_not_reached("Got finished event for unknown curl object");
923a60
-
923a60
-        if (!dkr_import_is_done(i))
923a60
-                return;
923a60
-
923a60
-        dkr_import_report_progress(i, DKR_COPYING);
923a60
-
923a60
-        r = dkr_import_make_local_copy(i);
923a60
-        if (r < 0)
923a60
-                goto finish;
923a60
-
923a60
-        r = 0;
923a60
-
923a60
-finish:
923a60
-        if (i->on_finished)
923a60
-                i->on_finished(i, r, i->userdata);
923a60
-        else
923a60
-                sd_event_exit(i->event, r);
923a60
-}
923a60
-
923a60
-static int dkr_import_job_on_header(ImportJob *j, const char *header, size_t sz)  {
923a60
-        _cleanup_free_ char *registry = NULL;
923a60
-        char *token;
923a60
-        DkrImport *i;
923a60
-        int r;
923a60
-
923a60
-        assert(j);
923a60
-        assert(j->userdata);
923a60
-
923a60
-        i = j->userdata;
923a60
-
923a60
-        r = curl_header_strdup(header, sz, HEADER_TOKEN, &token);
923a60
-        if (r < 0)
923a60
-                return log_oom();
923a60
-        if (r > 0) {
923a60
-                free(i->response_token);
923a60
-                i->response_token = token;
923a60
-                return 0;
923a60
-        }
923a60
-
923a60
-        r = curl_header_strdup(header, sz, HEADER_REGISTRY, &registry);
923a60
-        if (r < 0)
923a60
-                return log_oom();
923a60
-        if (r > 0) {
923a60
-                char **l, **k;
923a60
-
923a60
-                l = strv_split(registry, ",");
923a60
-                if (!l)
923a60
-                        return log_oom();
923a60
-
923a60
-                STRV_FOREACH(k, l) {
923a60
-                        if (!hostname_is_valid(*k)) {
923a60
-                                log_error("Registry hostname is not valid.");
923a60
-                                strv_free(l);
923a60
-                                return -EBADMSG;
923a60
-                        }
923a60
-                }
923a60
-
923a60
-                strv_free(i->response_registries);
923a60
-                i->response_registries = l;
923a60
-        }
923a60
-
923a60
-        return 0;
923a60
-}
923a60
-
923a60
-int dkr_import_pull(DkrImport *i, const char *name, const char *tag, const char *local, bool force_local) {
923a60
-        const char *url;
923a60
-        int r;
923a60
-
923a60
-        assert(i);
923a60
-
923a60
-        if (!dkr_name_is_valid(name))
923a60
-                return -EINVAL;
923a60
-
923a60
-        if (tag && !dkr_tag_is_valid(tag))
923a60
-                return -EINVAL;
923a60
-
923a60
-        if (local && !machine_name_is_valid(local))
923a60
-                return -EINVAL;
923a60
-
923a60
-        if (i->images_job)
923a60
-                return -EBUSY;
923a60
-
923a60
-        if (!tag)
923a60
-                tag = "latest";
923a60
-
923a60
-        r = free_and_strdup(&i->local, local);
923a60
-        if (r < 0)
923a60
-                return r;
923a60
-        i->force_local = force_local;
923a60
-
923a60
-        r = free_and_strdup(&i->name, name);
923a60
-        if (r < 0)
923a60
-                return r;
923a60
-        r = free_and_strdup(&i->tag, tag);
923a60
-        if (r < 0)
923a60
-                return r;
923a60
-
923a60
-        url = strjoina(i->index_url, "/v1/repositories/", name, "/images");
923a60
-
923a60
-        r = import_job_new(&i->images_job, url, i->glue, i);
923a60
-        if (r < 0)
923a60
-                return r;
923a60
-
923a60
-        r = dkr_import_add_token(i, i->images_job);
923a60
-        if (r < 0)
923a60
-                return r;
923a60
-
923a60
-        i->images_job->on_finished = dkr_import_job_on_finished;
923a60
-        i->images_job->on_header = dkr_import_job_on_header;
923a60
-        i->images_job->on_progress = dkr_import_job_on_progress;
923a60
-
923a60
-        return import_job_begin(i->images_job);
923a60
-}
923a60
diff --git a/src/import/import-dkr.h b/src/import/import-dkr.h
923a60
deleted file mode 100644
923a60
index 633c767965..0000000000
923a60
--- a/src/import/import-dkr.h
923a60
+++ /dev/null
923a60
@@ -1,36 +0,0 @@
923a60
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
923a60
-
923a60
-/***
923a60
-  This file is part of systemd.
923a60
-
923a60
-  Copyright 2014 Lennart Poettering
923a60
-
923a60
-  systemd is free software; you can redistribute it and/or modify it
923a60
-  under the terms of the GNU Lesser General Public License as published by
923a60
-  the Free Software Foundation; either version 2.1 of the License, or
923a60
-  (at your option) any later version.
923a60
-
923a60
-  systemd is distributed in the hope that it will be useful, but
923a60
-  WITHOUT ANY WARRANTY; without even the implied warranty of
923a60
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
923a60
-  Lesser General Public License for more details.
923a60
-
923a60
-  You should have received a copy of the GNU Lesser General Public License
923a60
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
923a60
-***/
923a60
-
923a60
-#pragma once
923a60
-
923a60
-#include "sd-event.h"
923a60
-#include "util.h"
923a60
-
923a60
-typedef struct DkrImport DkrImport;
923a60
-
923a60
-typedef void (*DkrImportFinished)(DkrImport *import, int error, void *userdata);
923a60
-
923a60
-int dkr_import_new(DkrImport **import, sd_event *event, const char *index_url, const char *image_root, DkrImportFinished on_finished, void *userdata);
923a60
-DkrImport* dkr_import_unref(DkrImport *import);
923a60
-
923a60
-DEFINE_TRIVIAL_CLEANUP_FUNC(DkrImport*, dkr_import_unref);
923a60
-
923a60
-int dkr_import_pull(DkrImport *import, const char *name, const char *tag, const char *local, bool force_local);
923a60
diff --git a/src/import/importd.c b/src/import/importd.c
923a60
index 1222bf3cd2..9aaf991f83 100644
923a60
--- a/src/import/importd.c
923a60
+++ b/src/import/importd.c
923a60
@@ -38,7 +38,6 @@ typedef struct Manager Manager;
923a60
 typedef enum TransferType {
923a60
         TRANSFER_TAR,
923a60
         TRANSFER_RAW,
923a60
-        TRANSFER_DKR,
923a60
         _TRANSFER_TYPE_MAX,
923a60
         _TRANSFER_TYPE_INVALID = -1,
923a60
 } TransferType;
923a60
@@ -56,8 +55,6 @@ struct Transfer {
923a60
         char *local;
923a60
         bool force_local;
923a60
 
923a60
-        char *dkr_index_url;
923a60
-
923a60
         pid_t pid;
923a60
 
923a60
         int log_fd;
923a60
@@ -91,7 +88,6 @@ struct Manager {
923a60
 static const char* const transfer_type_table[_TRANSFER_TYPE_MAX] = {
923a60
         [TRANSFER_TAR] = "tar",
923a60
         [TRANSFER_RAW] = "raw",
923a60
-        [TRANSFER_DKR] = "dkr",
923a60
 };
923a60
 
923a60
 DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(transfer_type, TransferType);
923a60
@@ -108,7 +104,6 @@ static Transfer *transfer_unref(Transfer *t) {
923a60
 
923a60
         free(t->remote);
923a60
         free(t->local);
923a60
-        free(t->dkr_index_url);
923a60
         free(t->object_path);
923a60
 
923a60
         if (t->pid > 0) {
923a60
@@ -355,7 +350,6 @@ static int transfer_start(Transfer *t) {
923a60
                         "--verify",
923a60
                         NULL, /* verify argument */
923a60
                         NULL, /* maybe --force */
923a60
-                        NULL, /* maybe --dkr-index-url */
923a60
                         NULL, /* the actual URL */
923a60
                         NULL, /* remote */
923a60
                         NULL, /* local */
923a60
@@ -410,11 +404,6 @@ static int transfer_start(Transfer *t) {
923a60
                 if (t->force_local)
923a60
                         cmd[k++] = "--force";
923a60
 
923a60
-                if (t->dkr_index_url) {
923a60
-                        cmd[k++] = "--dkr-index-url";
923a60
-                        cmd[k++] = t->dkr_index_url;
923a60
-                }
923a60
-
923a60
                 cmd[k++] = t->remote;
923a60
                 if (t->local)
923a60
                         cmd[k++] = t->local;
923a60
@@ -624,7 +613,7 @@ static int manager_new(Manager **ret) {
923a60
         return 0;
923a60
 }
923a60
 
923a60
-static Transfer *manager_find(Manager *m, TransferType type, const char *dkr_index_url, const char *remote) {
923a60
+static Transfer *manager_find(Manager *m, TransferType type, const char *remote) {
923a60
         Transfer *t;
923a60
         Iterator i;
923a60
 
923a60
@@ -635,8 +624,7 @@ static Transfer *manager_find(Manager *m, TransferType type, const char *dkr_ind
923a60
         HASHMAP_FOREACH(t, m->transfers, i) {
923a60
 
923a60
                 if (t->type == type &&
923a60
-                    streq_ptr(t->remote, remote) &&
923a60
-                    streq_ptr(t->dkr_index_url, dkr_index_url))
923a60
+                    streq_ptr(t->remote, remote))
923a60
                         return t;
923a60
         }
923a60
 
923a60
@@ -689,7 +677,7 @@ static int method_pull_tar_or_raw(sd_bus *bus, sd_bus_message *msg, void *userda
923a60
 
923a60
         type = streq_ptr(sd_bus_message_get_member(msg), "PullTar") ? TRANSFER_TAR : TRANSFER_RAW;
923a60
 
923a60
-        if (manager_find(m, type, NULL, remote))
923a60
+        if (manager_find(m, type, remote))
923a60
                 return sd_bus_error_setf(error, BUS_ERROR_TRANSFER_IN_PROGRESS, "Transfer for %s already in progress.", remote);
923a60
 
923a60
         r = transfer_new(m, &t);
923a60
@@ -719,98 +707,6 @@ static int method_pull_tar_or_raw(sd_bus *bus, sd_bus_message *msg, void *userda
923a60
         return sd_bus_reply_method_return(msg, "uo", id, object);
923a60
 }
923a60
 
923a60
-static int method_pull_dkr(sd_bus *bus, sd_bus_message *msg, void *userdata, sd_bus_error *error) {
923a60
-        _cleanup_(transfer_unrefp) Transfer *t = NULL;
923a60
-        const char *index_url, *remote, *tag, *local, *verify, *object;
923a60
-        Manager *m = userdata;
923a60
-        ImportVerify v;
923a60
-        int force, r;
923a60
-        uint32_t id;
923a60
-
923a60
-        assert(bus);
923a60
-        assert(msg);
923a60
-        assert(m);
923a60
-
923a60
-        r = bus_verify_polkit_async(
923a60
-                        msg,
923a60
-                        CAP_SYS_ADMIN,
923a60
-                        "org.freedesktop.import1.pull",
923a60
-                        false,
923a60
-                        &m->polkit_registry,
923a60
-                        error);
923a60
-        if (r < 0)
923a60
-                return r;
923a60
-        if (r == 0)
923a60
-                return 1; /* Will call us back */
923a60
-
923a60
-        r = sd_bus_message_read(msg, "sssssb", &index_url, &remote, &tag, &local, &verify, &force);
923a60
-        if (r < 0)
923a60
-                return r;
923a60
-
923a60
-        if (isempty(index_url))
923a60
-                index_url = DEFAULT_DKR_INDEX_URL;
923a60
-        if (!index_url)
923a60
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Index URL must be specified.");
923a60
-        if (!http_url_is_valid(index_url))
923a60
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Index URL %s is invalid", index_url);
923a60
-
923a60
-        if (!dkr_name_is_valid(remote))
923a60
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Remote name %s is not valid", remote);
923a60
-
923a60
-        if (isempty(tag))
923a60
-                tag = "latest";
923a60
-        else if (!dkr_tag_is_valid(tag))
923a60
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Tag %s is not valid", tag);
923a60
-
923a60
-        if (isempty(local))
923a60
-                local = NULL;
923a60
-        else if (!machine_name_is_valid(local))
923a60
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Local name %s is invalid", local);
923a60
-
923a60
-        if (isempty(verify))
923a60
-                v = IMPORT_VERIFY_SIGNATURE;
923a60
-        else
923a60
-                v = import_verify_from_string(verify);
923a60
-        if (v < 0)
923a60
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown verification mode %s", verify);
923a60
-
923a60
-        if (v != IMPORT_VERIFY_NO)
923a60
-                return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "DKR does not support verification.");
923a60
-
923a60
-        if (manager_find(m, TRANSFER_DKR, index_url, remote))
923a60
-                return sd_bus_error_setf(error, BUS_ERROR_TRANSFER_IN_PROGRESS, "Transfer for %s already in progress.", remote);
923a60
-
923a60
-        r = transfer_new(m, &t);
923a60
-        if (r < 0)
923a60
-                return r;
923a60
-
923a60
-        t->type = TRANSFER_DKR;
923a60
-        t->verify = v;
923a60
-        t->force_local = force;
923a60
-
923a60
-        t->dkr_index_url = strdup(index_url);
923a60
-        if (!t->dkr_index_url)
923a60
-                return -ENOMEM;
923a60
-
923a60
-        t->remote = strjoin(remote, ":", tag, NULL);
923a60
-        if (!t->remote)
923a60
-                return -ENOMEM;
923a60
-
923a60
-        t->local = strdup(local);
923a60
-        if (!t->local)
923a60
-                return -ENOMEM;
923a60
-
923a60
-        r = transfer_start(t);
923a60
-        if (r < 0)
923a60
-                return r;
923a60
-
923a60
-        object = t->object_path;
923a60
-        id = t->id;
923a60
-        t = NULL;
923a60
-
923a60
-        return sd_bus_reply_method_return(msg, "uo", id, object);
923a60
-}
923a60
-
923a60
 static int method_list_transfers(sd_bus *bus, sd_bus_message *msg, void *userdata, sd_bus_error *error) {
923a60
         _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
923a60
         Manager *m = userdata;
923a60
@@ -956,7 +852,6 @@ static const sd_bus_vtable manager_vtable[] = {
923a60
         SD_BUS_VTABLE_START(0),
923a60
         SD_BUS_METHOD("PullTar", "sssb", "uo", method_pull_tar_or_raw, SD_BUS_VTABLE_UNPRIVILEGED),
923a60
         SD_BUS_METHOD("PullRaw", "sssb", "uo", method_pull_tar_or_raw, SD_BUS_VTABLE_UNPRIVILEGED),
923a60
-        SD_BUS_METHOD("PullDkr", "sssssb", "uo", method_pull_dkr, SD_BUS_VTABLE_UNPRIVILEGED),
923a60
         SD_BUS_METHOD("ListTransfers", NULL, "a(usssdo)", method_list_transfers, SD_BUS_VTABLE_UNPRIVILEGED),
923a60
         SD_BUS_METHOD("CancelTransfer", "u", NULL, method_cancel_transfer, SD_BUS_VTABLE_UNPRIVILEGED),
923a60
         SD_BUS_SIGNAL("TransferNew", "uo", 0),
923a60
diff --git a/src/import/org.freedesktop.import1.conf b/src/import/org.freedesktop.import1.conf
923a60
index ae36af422f..ed2539a03b 100644
923a60
--- a/src/import/org.freedesktop.import1.conf
923a60
+++ b/src/import/org.freedesktop.import1.conf
923a60
@@ -52,10 +52,6 @@
923a60
                        send_interface="org.freedesktop.import1.Manager"
923a60
                        send_member="PullRaw"/>
923a60
 
923a60
-                
923a60
-                       send_interface="org.freedesktop.import1.Manager"
923a60
-                       send_member="PullDkr"/>
923a60
-
923a60
                 
923a60
                        send_interface="org.freedesktop.import1.Transfer"
923a60
                        send_member="Cancel"/>
923a60
diff --git a/src/import/pull.c b/src/import/pull.c
923a60
index ee3ff68036..9cb10880fa 100644
923a60
--- a/src/import/pull.c
923a60
+++ b/src/import/pull.c
923a60
@@ -28,13 +28,11 @@
923a60
 #include "machine-image.h"
923a60
 #include "import-tar.h"
923a60
 #include "import-raw.h"
923a60
-#include "import-dkr.h"
923a60
 #include "import-util.h"
923a60
 
923a60
 static bool arg_force = false;
923a60
 static const char *arg_image_root = "/var/lib/machines";
923a60
 static ImportVerify arg_verify = IMPORT_VERIFY_SIGNATURE;
923a60
-static const char* arg_dkr_index_url = DEFAULT_DKR_INDEX_URL;
923a60
 
923a60
 static int interrupt_signal_handler(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
923a60
         log_notice("Transfer aborted.");
923a60
@@ -214,107 +212,6 @@ static int pull_raw(int argc, char *argv[], void *userdata) {
923a60
         return -r;
923a60
 }
923a60
 
923a60
-static void on_dkr_finished(DkrImport *import, int error, void *userdata) {
923a60
-        sd_event *event = userdata;
923a60
-        assert(import);
923a60
-
923a60
-        if (error == 0)
923a60
-                log_info("Operation completed successfully.");
923a60
-
923a60
-        sd_event_exit(event, abs(error));
923a60
-}
923a60
-
923a60
-static int pull_dkr(int argc, char *argv[], void *userdata) {
923a60
-        _cleanup_(dkr_import_unrefp) DkrImport *import = NULL;
923a60
-        _cleanup_event_unref_ sd_event *event = NULL;
923a60
-        const char *name, *tag, *local;
923a60
-        int r;
923a60
-
923a60
-        if (!arg_dkr_index_url) {
923a60
-                log_error("Please specify an index URL with --dkr-index-url=");
923a60
-                return -EINVAL;
923a60
-        }
923a60
-
923a60
-        if (arg_verify != IMPORT_VERIFY_NO) {
923a60
-                log_error("Imports from dkr do not support image verification, please pass --verify=no.");
923a60
-                return -EINVAL;
923a60
-        }
923a60
-
923a60
-        tag = strchr(argv[1], ':');
923a60
-        if (tag) {
923a60
-                name = strndupa(argv[1], tag - argv[1]);
923a60
-                tag++;
923a60
-        } else {
923a60
-                name = argv[1];
923a60
-                tag = "latest";
923a60
-        }
923a60
-
923a60
-        if (!dkr_name_is_valid(name)) {
923a60
-                log_error("Remote name '%s' is not valid.", name);
923a60
-                return -EINVAL;
923a60
-        }
923a60
-
923a60
-        if (!dkr_tag_is_valid(tag)) {
923a60
-                log_error("Tag name '%s' is not valid.", tag);
923a60
-                return -EINVAL;
923a60
-        }
923a60
-
923a60
-        if (argc >= 3)
923a60
-                local = argv[2];
923a60
-        else {
923a60
-                local = strchr(name, '/');
923a60
-                if (local)
923a60
-                        local++;
923a60
-                else
923a60
-                        local = name;
923a60
-        }
923a60
-
923a60
-        if (isempty(local) || streq(local, "-"))
923a60
-                local = NULL;
923a60
-
923a60
-        if (local) {
923a60
-                if (!machine_name_is_valid(local)) {
923a60
-                        log_error("Local image name '%s' is not valid.", local);
923a60
-                        return -EINVAL;
923a60
-                }
923a60
-
923a60
-                if (!arg_force) {
923a60
-                        r = image_find(local, NULL);
923a60
-                        if (r < 0)
923a60
-                                return log_error_errno(r, "Failed to check whether image '%s' exists: %m", local);
923a60
-                        else if (r > 0) {
923a60
-                                log_error_errno(EEXIST, "Image '%s' already exists.", local);
923a60
-                                return -EEXIST;
923a60
-                        }
923a60
-                }
923a60
-
923a60
-                log_info("Pulling '%s' with tag '%s', saving as '%s'.", name, tag, local);
923a60
-        } else
923a60
-                log_info("Pulling '%s' with tag '%s'.", name, tag);
923a60
-
923a60
-        r = sd_event_default(&event);
923a60
-        if (r < 0)
923a60
-                return log_error_errno(r, "Failed to allocate event loop: %m");
923a60
-
923a60
-        assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
923a60
-        sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler,  NULL);
923a60
-        sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
923a60
-
923a60
-        r = dkr_import_new(&import, event, arg_dkr_index_url, arg_image_root, on_dkr_finished, event);
923a60
-        if (r < 0)
923a60
-                return log_error_errno(r, "Failed to allocate importer: %m");
923a60
-
923a60
-        r = dkr_import_pull(import, name, tag, local, arg_force);
923a60
-        if (r < 0)
923a60
-                return log_error_errno(r, "Failed to pull image: %m");
923a60
-
923a60
-        r = sd_event_loop(event);
923a60
-        if (r < 0)
923a60
-                return log_error_errno(r, "Failed to run event loop: %m");
923a60
-
923a60
-        log_info("Exiting.");
923a60
-        return -r;
923a60
-}
923a60
 
923a60
 static int help(int argc, char *argv[], void *userdata) {
923a60
 
923a60
@@ -326,11 +223,9 @@ static int help(int argc, char *argv[], void *userdata) {
923a60
                "     --verify=                Verify downloaded image, one of: 'no',\n"
923a60
                "                              'checksum', 'signature'.\n"
923a60
                "     --image-root=            Image root directory\n"
923a60
-               "     --dkr-index-url=URL      Specify index URL to use for downloads\n\n"
923a60
                "Commands:\n"
923a60
                "  tar URL [NAME]              Download a TAR image\n"
923a60
-               "  raw URL [NAME]              Download a RAW image\n"
923a60
-               "  dkr REMOTE [NAME]           Download a DKR image\n",
923a60
+               "  raw URL [NAME]              Download a RAW image\n",
923a60
                program_invocation_short_name);
923a60
 
923a60
         return 0;
923a60
@@ -341,7 +236,6 @@ static int parse_argv(int argc, char *argv[]) {
923a60
         enum {
923a60
                 ARG_VERSION = 0x100,
923a60
                 ARG_FORCE,
923a60
-                ARG_DKR_INDEX_URL,
923a60
                 ARG_IMAGE_ROOT,
923a60
                 ARG_VERIFY,
923a60
         };
923a60
@@ -350,7 +244,6 @@ static int parse_argv(int argc, char *argv[]) {
923a60
                 { "help",            no_argument,       NULL, 'h'                 },
923a60
                 { "version",         no_argument,       NULL, ARG_VERSION         },
923a60
                 { "force",           no_argument,       NULL, ARG_FORCE           },
923a60
-                { "dkr-index-url",   required_argument, NULL, ARG_DKR_INDEX_URL   },
923a60
                 { "image-root",      required_argument, NULL, ARG_IMAGE_ROOT      },
923a60
                 { "verify",          required_argument, NULL, ARG_VERIFY          },
923a60
                 {}
923a60
@@ -377,15 +270,6 @@ static int parse_argv(int argc, char *argv[]) {
923a60
                         arg_force = true;
923a60
                         break;
923a60
 
923a60
-                case ARG_DKR_INDEX_URL:
923a60
-                        if (!http_url_is_valid(optarg)) {
923a60
-                                log_error("Index URL is not valid: %s", optarg);
923a60
-                                return -EINVAL;
923a60
-                        }
923a60
-
923a60
-                        arg_dkr_index_url = optarg;
923a60
-                        break;
923a60
-
923a60
                 case ARG_IMAGE_ROOT:
923a60
                         arg_image_root = optarg;
923a60
                         break;
923a60
@@ -415,7 +299,6 @@ static int import_main(int argc, char *argv[]) {
923a60
                 { "help", VERB_ANY, VERB_ANY, 0, help     },
923a60
                 { "tar",  2,        3,        0, pull_tar },
923a60
                 { "raw",  2,        3,        0, pull_raw },
923a60
-                { "dkr",  2,        3,        0, pull_dkr },
923a60
                 {}
923a60
         };
923a60
 
923a60
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
923a60
index ef1214a666..cfd3162fb7 100644
923a60
--- a/src/machine/machinectl.c
923a60
+++ b/src/machine/machinectl.c
923a60
@@ -77,7 +77,6 @@ static unsigned arg_lines = 10;
923a60
 static OutputMode arg_output = OUTPUT_SHORT;
923a60
 static bool arg_force = false;
923a60
 static ImportVerify arg_verify = IMPORT_VERIFY_SIGNATURE;
923a60
-static const char* arg_dkr_index_url = NULL;
923a60
 
923a60
 static void pager_open_if_enabled(void) {
923a60
 
923a60
@@ -1998,78 +1997,6 @@ static int pull_raw(int argc, char *argv[], void *userdata) {
923a60
         return pull_image_common(bus, m);
923a60
 }
923a60
 
923a60
-static int pull_dkr(int argc, char *argv[], void *userdata) {
923a60
-        _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
923a60
-        const char *local, *remote, *tag;
923a60
-        sd_bus *bus = userdata;
923a60
-        int r;
923a60
-
923a60
-        if (arg_verify != IMPORT_VERIFY_NO) {
923a60
-                log_error("Imports from DKR do not support image verification, please pass --verify=no.");
923a60
-                return -EINVAL;
923a60
-        }
923a60
-
923a60
-        remote = argv[1];
923a60
-        tag = strchr(remote, ':');
923a60
-        if (tag) {
923a60
-                remote = strndupa(remote, tag - remote);
923a60
-                tag++;
923a60
-        }
923a60
-
923a60
-        if (!dkr_name_is_valid(remote)) {
923a60
-                log_error("DKR name '%s' is invalid.", remote);
923a60
-                return -EINVAL;
923a60
-        }
923a60
-        if (tag && !dkr_tag_is_valid(tag)) {
923a60
-                log_error("DKR tag '%s' is invalid.", remote);
923a60
-                return -EINVAL;
923a60
-        }
923a60
-
923a60
-        if (argc >= 3)
923a60
-                local = argv[2];
923a60
-        else {
923a60
-                local = strchr(remote, '/');
923a60
-                if (local)
923a60
-                        local++;
923a60
-                else
923a60
-                        local = remote;
923a60
-        }
923a60
-
923a60
-        if (isempty(local) || streq(local, "-"))
923a60
-                local = NULL;
923a60
-
923a60
-        if (local) {
923a60
-                if (!machine_name_is_valid(local)) {
923a60
-                        log_error("Local name %s is not a suitable machine name.", local);
923a60
-                        return -EINVAL;
923a60
-                }
923a60
-        }
923a60
-
923a60
-        r = sd_bus_message_new_method_call(
923a60
-                        bus,
923a60
-                        &m,
923a60
-                        "org.freedesktop.import1",
923a60
-                        "/org/freedesktop/import1",
923a60
-                        "org.freedesktop.import1.Manager",
923a60
-                        "PullDkr");
923a60
-        if (r < 0)
923a60
-                return bus_log_create_error(r);
923a60
-
923a60
-        r = sd_bus_message_append(
923a60
-                        m,
923a60
-                        "sssssb",
923a60
-                        arg_dkr_index_url,
923a60
-                        remote,
923a60
-                        tag,
923a60
-                        local,
923a60
-                        import_verify_to_string(arg_verify),
923a60
-                        arg_force);
923a60
-        if (r < 0)
923a60
-                return bus_log_create_error(r);
923a60
-
923a60
-        return pull_image_common(bus, m);
923a60
-}
923a60
-
923a60
 typedef struct TransferInfo {
923a60
         uint32_t id;
923a60
         const char *type;
923a60
@@ -2237,8 +2164,6 @@ static int help(int argc, char *argv[], void *userdata) {
923a60
                "      --verify=MODE           Verification mode for downloaded images (no,\n"
923a60
                "                              checksum, signature)\n"
923a60
                "      --force                 Download image even if already exists\n"
923a60
-               "      --dkr-index-url=URL     Specify the index URL to use for DKR image\n"
923a60
-               "                              downloads\n\n"
923a60
                "Machine Commands:\n"
923a60
                "  list                        List running VMs and containers\n"
923a60
                "  status NAME...              Show VM/container details\n"
923a60
@@ -2265,7 +2190,6 @@ static int help(int argc, char *argv[], void *userdata) {
923a60
                "Image Transfer Commands:\n"
923a60
                "  pull-tar URL [NAME]         Download a TAR container image\n"
923a60
                "  pull-raw URL [NAME]         Download a RAW container or VM image\n"
923a60
-               "  pull-dkr REMOTE [NAME]      Download a DKR container image\n"
923a60
                "  list-transfers              Show list of downloads in progress\n"
923a60
                "  cancel-transfer             Cancel a download\n"
923a60
                , program_invocation_short_name);
923a60
@@ -2284,8 +2208,7 @@ static int parse_argv(int argc, char *argv[]) {
923a60
                 ARG_MKDIR,
923a60
                 ARG_NO_ASK_PASSWORD,
923a60
                 ARG_VERIFY,
923a60
-                ARG_FORCE,
923a60
-                ARG_DKR_INDEX_URL,
923a60
+                ARG_FORCE
923a60
         };
923a60
 
923a60
         static const struct option options[] = {
923a60
@@ -2308,7 +2231,6 @@ static int parse_argv(int argc, char *argv[]) {
923a60
                 { "no-ask-password", no_argument,       NULL, ARG_NO_ASK_PASSWORD },
923a60
                 { "verify",          required_argument, NULL, ARG_VERIFY          },
923a60
                 { "force",           no_argument,       NULL, ARG_FORCE           },
923a60
-                { "dkr-index-url",   required_argument, NULL, ARG_DKR_INDEX_URL   },
923a60
                 {}
923a60
         };
923a60
 
923a60
@@ -2421,15 +2343,6 @@ static int parse_argv(int argc, char *argv[]) {
923a60
                         arg_force = true;
923a60
                         break;
923a60
 
923a60
-                case ARG_DKR_INDEX_URL:
923a60
-                        if (!http_url_is_valid(optarg)) {
923a60
-                                log_error("Index URL is invalid: %s", optarg);
923a60
-                                return -EINVAL;
923a60
-                        }
923a60
-
923a60
-                        arg_dkr_index_url = optarg;
923a60
-                        break;
923a60
-
923a60
                 case '?':
923a60
                         return -EINVAL;
923a60
 
923a60
@@ -2467,7 +2380,6 @@ static int machinectl_main(int argc, char *argv[], sd_bus *bus) {
923a60
                 { "disable",         2,        VERB_ANY, 0,            enable_machine    },
923a60
                 { "pull-tar",        2,        3,        0,            pull_tar          },
923a60
                 { "pull-raw",        2,        3,        0,            pull_raw          },
923a60
-                { "pull-dkr",        2,        3,        0,            pull_dkr          },
923a60
                 { "list-transfers",  VERB_ANY, 1,        0,            list_transfers    },
923a60
                 { "cancel-transfer", 2,        VERB_ANY, 0,            cancel_transfer   },
923a60
                 {}
923a60
diff --git a/src/shared/import-util.c b/src/shared/import-util.c
923a60
index 660d92ac5d..c0aba30a98 100644
923a60
--- a/src/shared/import-util.c
923a60
+++ b/src/shared/import-util.c
923a60
@@ -149,34 +149,3 @@ int raw_strip_suffixes(const char *p, char **ret) {
923a60
 
923a60
         return 0;
923a60
 }
923a60
-
923a60
-bool dkr_name_is_valid(const char *name) {
923a60
-        const char *slash, *p;
923a60
-
923a60
-        if (isempty(name))
923a60
-                return false;
923a60
-
923a60
-        slash = strchr(name, '/');
923a60
-        if (!slash)
923a60
-                return false;
923a60
-
923a60
-        if (!filename_is_valid(slash + 1))
923a60
-                return false;
923a60
-
923a60
-        p = strndupa(name, slash - name);
923a60
-        if (!filename_is_valid(p))
923a60
-                return false;
923a60
-
923a60
-        return true;
923a60
-}
923a60
-
923a60
-bool dkr_id_is_valid(const char *id) {
923a60
-
923a60
-        if (!filename_is_valid(id))
923a60
-                return false;
923a60
-
923a60
-        if (!in_charset(id, "0123456789abcdef"))
923a60
-                return false;
923a60
-
923a60
-        return true;
923a60
-}
923a60
diff --git a/src/shared/import-util.h b/src/shared/import-util.h
923a60
index ff155b0ff2..22773c58e9 100644
923a60
--- a/src/shared/import-util.h
923a60
+++ b/src/shared/import-util.h
923a60
@@ -41,7 +41,3 @@ ImportVerify import_verify_from_string(const char *s) _pure_;
923a60
 
923a60
 int tar_strip_suffixes(const char *name, char **ret);
923a60
 int raw_strip_suffixes(const char *name, char **ret);
923a60
-
923a60
-bool dkr_name_is_valid(const char *name);
923a60
-bool dkr_id_is_valid(const char *id);
923a60
-#define dkr_tag_is_valid(tag) filename_is_valid(tag)