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

Scott Moser smoser at ubuntu.com
Tue Oct 8 00:41:23 UTC 2013


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>

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


More information about the lxc-devel mailing list