From 5f1326fb2aa87eddd928bd72d949dfcc2a151240 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Fri, 22 May 2015 13:03:36 +0000 Subject: nspawn: Allow : characters in nspawn --bind paths : characters in bind paths can be entered as the \: escape sequence. --- src/nspawn/nspawn.c | 29 +++++++++++++++++++++-------- 1 file 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) -- cgit v1.2.1