[systemd-devel] [PATCH 5/9] nspawn: Allow : characters in nspawn --bind paths
Richard Maw
richard.maw at codethink.co.uk
Thu May 28 05:02:11 PDT 2015
: 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 97f980f..c40d50f 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)
--
1.9.1
More information about the systemd-devel
mailing list