diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2015-05-22 13:03:36 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@gmail.com> | 2015-05-27 14:02:56 +0000 |
commit | 5c96067957c705f985703133d99fcce6149a080d (patch) | |
tree | 16915267d9742b291dd5c2288ccf194ddda6a8ac | |
parent | 460a1381ae9a6e51ee03c32dd909d68c05596798 (diff) | |
download | systemd-5c96067957c705f985703133d99fcce6149a080d.tar.gz |
nspawn: Allow : characters in nspawn --bind paths
: characters in bind paths can be entered as the \: escape sequence.
-rw-r--r-- | src/nspawn/nspawn.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 97f980fae8..c40d50fc4a 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -654,15 +654,28 @@ static int parse_argv(int argc, char *argv[]) { case ARG_BIND_RO: { _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 = strv_split_escaped(&strv, optarg, ":", UNQUOTE_SEPARATOR_SPLIT); + if (r == -ENOMEM) + return log_oom(); + else if (r < 0) { + log_error("Invalid bind mount specification: %s", optarg); + return r; + } + + switch (strv_length(strv)) { + case 1: + source = strdup(strv[0]); + destination = strdup(strv[0]); + break; + case 2: + source = strdup(strv[0]); + destination = strdup(strv[1]); + break; + default: + log_error("Invalid bind mount specification: %s", optarg); + return -EINVAL; } if (!source || !destination) |