summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2015-05-22 13:03:36 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2015-05-26 16:44:38 +0000
commit5f1326fb2aa87eddd928bd72d949dfcc2a151240 (patch)
tree06065cebdd48f33991d4e2f54e1524d3b59b2a35
parent8a0770231206134e51fdb14954758d05ddd1dc1c (diff)
downloadsystemd-5f1326fb2aa87eddd928bd72d949dfcc2a151240.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.c29
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)