[lxc-devel] [PATCH] lxc-ubuntu-cloud: pass --numeric-owner and -p to untar

Stéphane Graber stgraber at ubuntu.com
Tue Oct 8 14:27:59 UTC 2013


On Mon, Oct 07, 2013 at 08:41:23PM -0400, Scott Moser wrote:
> On Mon, 7 Oct 2013, Stéphane Graber wrote:
> 
> > On Mon, Oct 07, 2013 at 04:16:05PM -0500, Serge Hallyn wrote:
> > > An example of where this can break is if you pass in sshkey to user
> > > ubuntu in the container, where user ubuntu exists with different uid
> > > on host.
> > >
> > > Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
> >
> > Acked-by: Stéphane Graber <stgraber at ubuntu.com>
> 
> Just following up here, Serge raised the question of whether or not the
> other two invocations of 'tar' in this script need '--numeric-owner'.
> They probably should have it, although its of little concern because the
> 'build_root_tgz' path is only taken if there is no '-root.tar.gz' file for
> download, and the only supported ubuntu release without the -root.tar.gz
> download is 10.04 at this point.
> 
> Anyway, below is a more complete diff, also including a fix as
> '--numeric-uid' is not a valid option to tar.  The name is
> '--numeric-owner'.
> 
> Signed-off-by: Scott Moser <smoser at ubuntu.com>

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

> 
> diff --git a/templates/lxc-ubuntu-cloud.in b/templates/lxc-ubuntu-cloud.in
> index 47a5fca..a2af003 100644
> --- a/templates/lxc-ubuntu-cloud.in
> +++ b/templates/lxc-ubuntu-cloud.in
> @@ -340,7 +340,7 @@ build_root_tgz()
>      echo "Creating new cached cloud image rootfs"
>      tar --wildcards -zxf $tarname $imgname
>      mount -o loop $imgname $xdir
> -    (cd $xdir; tar zcf ../$filename .)
> +    (cd $xdir; tar --numeric-owner -cpzf ../$filename .)
>      umount $xdir
>      rm -f $tarname $imgname
>      rmdir $xdir
> @@ -371,7 +371,7 @@ do_extract_rootfs() {
>      echo "Extracting container rootfs"
>      mkdir -p $rootfs
>      cd $rootfs
> -    tar -zxf $cache/$filename
> +    tar --numeric-owner -xpzf $cache/$filename
>  }
> 
>  if [ -n "$tarball" ]; then


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20131008/14f9f85b/attachment.pgp>


More information about the lxc-devel mailing list