summaryrefslogtreecommitdiff
path: root/src/import/import.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-20 15:06:34 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-20 15:06:58 +0100
commit85dbc41dc67ff49fd8a843dbac5b8b5cb0b61155 (patch)
tree27cd179d2f98ef32ed27cb66589e44751135513e /src/import/import.c
parent88a1aadc48e5bbefd2e689db099569ec4c3c1e4b (diff)
import: add a simple scheme for validating the SHA256 sums of downloaded raw files
Diffstat (limited to 'src/import/import.c')
-rw-r--r--src/import/import.c29
1 files changed, 3 insertions, 26 deletions
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");