From 594426ca1b9f916102b02899aaa756467b0192ce Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Tue, 30 Oct 2018 14:16:58 +0100 Subject: [PATCH] conf: expand shmounts lxc.mount.auto option Allow users to specify a path in the container they want to use. This will help LXD. Needed-by: https://github.com/lxc/lxd/issues/5227 Signed-off-by: Christian Brauner --- src/lxc/confile.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/lxc/confile.c b/src/lxc/confile.c index 5ecbaeac2..1d5e966e1 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -1788,18 +1788,24 @@ static int set_config_mount_auto(const char *key, const char *value, lxc_conf->auto_mounts |= allowed_auto_mounts[i].flag; if (is_shmounts) { - lxc_conf->shmount.path_host = strdup(token + STRLITERALLEN("shmounts:")); + char *slide = token + STRLITERALLEN("shmounts:"); + + if (*slide == '\0') { + SYSERROR("Failed to copy shmounts host path"); + goto on_error; + } + + lxc_conf->shmount.path_host = strdup(slide); if (!lxc_conf->shmount.path_host) { SYSERROR("Failed to copy shmounts host path"); goto on_error; } - if (strcmp(lxc_conf->shmount.path_host, "") == 0) { - ERROR("Invalid shmounts path: empty"); - goto on_error; - } + slide = strchr(slide, ':'); + if (!slide || *(++slide) == '\0') + slide = "/dev/.lxc-mounts"; - lxc_conf->shmount.path_cont = strdup("/dev/.lxc-mounts"); + lxc_conf->shmount.path_cont = strdup(slide); if(!lxc_conf->shmount.path_cont) { SYSERROR("Failed to copy shmounts container path"); goto on_error;