]> git.proxmox.com Git - mirror_lxc.git/commit
Parse rootfs->path
authorChristian Brauner <christianvanbrauner@gmail.com>
Thu, 22 Oct 2015 07:18:15 +0000 (09:18 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 29 Oct 2015 21:57:17 +0000 (17:57 -0400)
commit1e3ce0da4978011f55fbc5d25ab7f7d055618757
tree178b78de158c378a866934e1d92b9897888f68f0
parent4ed565e51a4f016ecd6765251a318087a91fe534
Parse rootfs->path

The mount_entry_overlay_dirs() and mount_entry_aufs_dirs() functions create
workdirs and upperdirs for overlay and aufs lxc.mount.entry entries. They try
to make sure that the workdirs and upperdirs can only be created under the
containerdir (e.g. /path/to/the/container/CONTAINERNAME). In order to do this
the right hand side of

                if ((strncmp(upperdir, lxcpath, dirlen) == 0) && (strncmp(upperdir, rootfs->path, rootfslen) != 0))

was thought to check if the rootfs->path is not present in the workdir and
upperdir mount options. But the current check is bogus since it will be
trivially true whenever the container is a block-dev or overlay or aufs backed
since the rootfs->path will then have a form like e.g.

        overlayfs:/some/path:/some/other/path

This patch adds the function ovl_get_rootfs_dir() which parses rootfs->path by
searching backwards for the first occurrence of the delimiter pair ":/". We do
not simply search for ":" since it might be used in path names. If ":/" is not
found we assume the container is directory backed and simply return
strdup(rootfs->path).

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/conf.c