]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: expand shmounts lxc.mount.auto option
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 30 Oct 2018 13:16:58 +0000 (14:16 +0100)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 1 Nov 2018 15:06:22 +0000 (11:06 -0400)
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 <christian.brauner@ubuntu.com>
src/lxc/confile.c

index 5ecbaeac2f0f119f02f9af0d595e513864700871..1d5e966e188b2a897e38995193b47517a58e55dc 100644 (file)
@@ -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:"));
-                       if (!lxc_conf->shmount.path_host) {
+                       char *slide = token + STRLITERALLEN("shmounts:");
+
+                       if (*slide == '\0') {
                                SYSERROR("Failed to copy shmounts host path");
                                goto on_error;
                        }
 
-                       if (strcmp(lxc_conf->shmount.path_host, "") == 0) {
-                               ERROR("Invalid shmounts path: empty");
+                       lxc_conf->shmount.path_host = strdup(slide);
+                       if (!lxc_conf->shmount.path_host) {
+                               SYSERROR("Failed to copy shmounts host path");
                                goto on_error;
                        }
 
-                       lxc_conf->shmount.path_cont = strdup("/dev/.lxc-mounts");
+                       slide = strchr(slide, ':');
+                       if (!slide || *(++slide) == '\0')
+                               slide = "/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;