[lxc-devel] [PATCH v5] Parse rootfs->path

Christian Brauner christianvanbrauner at gmail.com
Sat Oct 24 08:29:29 UTC 2015


On Thu, Oct 22, 2015 at 02:46:48PM +0000, Serge Hallyn wrote:
> Quoting Christian Brauner (christianvanbrauner at gmail.com):
> > 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 at gmail.com>
> 
> Thanks!
> 
> (fwiw i would have still have the success path for
> mount_entry_create_*_dirs set a fnret = 0 and fall through
> the err case, but the shared cleanup is short enough it's
> not worth a resend)
> 

I include this in the patch when for the creation of random workdirs with
mkdtemp().
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20151024/ff0e1cb2/attachment.sig>


More information about the lxc-devel mailing list