From 85dbc41dc67ff49fd8a843dbac5b8b5cb0b61155 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 20 Jan 2015 15:06:34 +0100 Subject: import: add a simple scheme for validating the SHA256 sums of downloaded raw files --- src/import/import.c | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) (limited to 'src/import/import.c') diff --git a/src/import/import.c b/src/import/import.c index 861a448583..3362f4a9ef 100644 --- a/src/import/import.c +++ b/src/import/import.c @@ -29,6 +29,7 @@ #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"; @@ -47,30 +48,6 @@ static void on_tar_finished(TarImport *import, int error, void *userdata) { sd_event_exit(event, error); } -static int url_final_component(const char *url, char **ret) { - const char *e, *p; - char *s; - - e = strchrnul(url, '?'); - - while (e > url && e[-1] == '/') - e--; - - p = e; - while (p > url && p[-1] != '/') - p--; - - if (e <= p) - return -EINVAL; - - s = strndup(p, e - p); - if (!s) - return -ENOMEM; - - *ret = s; - return 0; -} - static int strip_tar_suffixes(const char *name, char **ret) { const char *e; char *s; @@ -112,7 +89,7 @@ static int pull_tar(int argc, char *argv[], void *userdata) { if (argc >= 3) local = argv[2]; else { - r = url_final_component(url, &l); + r = import_url_last_component(url, &l); if (r < 0) return log_error_errno(r, "Failed get final component of URL: %m"); @@ -238,7 +215,7 @@ static int pull_raw(int argc, char *argv[], void *userdata) { if (argc >= 3) local = argv[2]; else { - r = url_final_component(url, &l); + r = import_url_last_component(url, &l); if (r < 0) return log_error_errno(r, "Failed get final component of URL: %m"); -- cgit v1.2.3-54-g00ecf