import.c revision ff2670ad11a1a29d483b7a246c95b159ddc1137c
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering This file is part of systemd.
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering Copyright 2014 Lennart Poettering
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering systemd is free software; you can redistribute it and/or modify it
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering under the terms of the GNU Lesser General Public License as published by
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering (at your option) any later version.
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering systemd is distributed in the hope that it will be useful, but
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering Lesser General Public License for more details.
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering You should have received a copy of the GNU Lesser General Public License
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskogstatic bool arg_force = false;
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskogstatic const char *arg_image_root = "/var/lib/machines";
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskogstatic ImportVerify arg_verify = IMPORT_VERIFY_SIGNATURE;
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskogstatic const char* arg_dkr_index_url = DEFAULT_DKR_INDEX_URL;
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskogstatic void on_tar_finished(TarImport *import, int error, void *userdata) {
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog log_info("Operation completed successfully.");
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poetteringstatic int strip_tar_suffixes(const char *name, char **ret) {
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering const char *e;
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskogstatic int pull_tar(int argc, char *argv[], void *userdata) {
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering _cleanup_(tar_import_unrefp) TarImport *import = NULL;
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering _cleanup_event_unref_ sd_event *event = NULL;
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering _cleanup_free_ char *l = NULL, *ll = NULL;
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering log_error("URL '%s' is not valid.", url);
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering return log_error_errno(r, "Failed get final component of URL: %m");
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering log_error("Local image name '%s' is not valid.", local);
if (!arg_force) {
return -EEXIST;
if (error == 0)
static const char suffixes[] =
q = strdup(p);
return -ENOMEM;
const char *sfx;
bool changed = false;
changed = true;
if (!changed)
*ret = q;
q = NULL;
return -EINVAL;
local = l;
if (local) {
return log_oom();
return -EINVAL;
if (!arg_force) {
return -EEXIST;
if (error == 0)
if (!arg_dkr_index_url) {
return -EINVAL;
return -EINVAL;
if (tag) {
tag++;
return -EINVAL;
return -EINVAL;
if (local)
local++;
if (local) {
return -EINVAL;
if (!arg_force) {
return -EEXIST;
case ARG_VERSION:
case ARG_FORCE:
arg_force = true;
case ARG_DKR_INDEX_URL:
return -EINVAL;
case ARG_IMAGE_ROOT:
case ARG_VERIFY:
if (arg_verify < 0) {
return -EINVAL;
return -EINVAL;
log_open();
goto finish;