]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: Allow : characters in nspawn --bind paths
authorRichard Maw <richard.maw@codethink.co.uk>
Fri, 19 Jun 2015 15:24:35 +0000 (15:24 +0000)
committerRichard Maw <richard.maw@codethink.co.uk>
Fri, 7 Aug 2015 15:50:43 +0000 (15:50 +0000)
: characters in bind paths can be entered as the \: escape sequence.

src/nspawn/nspawn.c

index fe5f3528ce84974e92bdae2ccbe20968621bd499..b65b13426ff20bcc7f91af40881623ac9b872231 100644 (file)
@@ -655,17 +655,22 @@ static int parse_argv(int argc, char *argv[]) {
 
                 case ARG_BIND:
                 case ARG_BIND_RO: {
+                        const char *current = optarg;
                         _cleanup_free_ char *source = NULL, *destination = NULL;
                         CustomMount *m;
-                        char *e;
+                        _cleanup_strv_free_ char **strv = NULL;
 
-                        e = strchr(optarg, ':');
-                        if (e) {
-                                source = strndup(optarg, e - optarg);
-                                destination = strdup(e + 1);
-                        } else {
-                                source = strdup(optarg);
-                                destination = strdup(optarg);
+                        r = extract_many_words(&current, ":", EXTRACT_DONT_COALESCE_SEPARATORS, &source, &destination, NULL);
+                        switch (r) {
+                        case 1:
+                                destination = strdup(source);
+                        case 2:
+                                break;
+                        case -ENOMEM:
+                                return log_oom();
+                        default:
+                                log_error("Invalid bind mount specification: %s", optarg);
+                                return -EINVAL;
                         }
 
                         if (!source || !destination)