[V2,1/1] runqemu-extract-sdk: add --numeric-owner option to tar command

Submitted by Qi.Chen@windriver.com on Oct. 21, 2013, 2:42 a.m. | Patch ID: 60291


Message ID d09074f6e59cc6ea203d433e7cb56a5085a65129.1382323261.git.Qi.Chen@windriver.com
State Accepted
Commit acce6ff1a77cfd29e3868faa89b120becb58bbbf
Headers show

Commit Message

Qi.Chen@windriver.com Oct. 21, 2013, 2:42 a.m.
From: Chen Qi <qi.chen@windriver.com>

If the same username exists on both target and the build host, but
the uids differ, and we start target via NFS, then the uid for the
user will be incorrect on target.

For example, if postfix's uid on host is 119 and on target is 1024,
then if we start target via NFS, the uid for postfix will be 119.

The root cause is that when we use runqemu-extract-sdk to generate
the NFS rootfs for later use, the tar command will respect the username
instead of uid. So if PSEUDO_PASSWD environment is not set correctly,
the host /etc/passwd will be used, resulting in wrong uids.

The situation for gid is completely analogous to that of uid.

It's almost impossible for the runqemu-extract-sdk to guess the correct
location of the needed password file merely based on the target tarball

This patch solves this problem by adding the '--numeric-owner' option
to the tar command so that the uid/gid will be used when extracting the
tarball using runqemu-extract-sdk. In this situation, we'll always get
the correct uid/gid after extracting the tarball.

[YOCTO #5364]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
 scripts/runqemu-extract-sdk |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/scripts/runqemu-extract-sdk b/scripts/runqemu-extract-sdk
index 509af66..4ce906a 100755
--- a/scripts/runqemu-extract-sdk
+++ b/scripts/runqemu-extract-sdk
@@ -54,13 +54,13 @@  fi
 if [[ "$ROOTFS_TARBALL" =~ tar\.bz2$ ]]; then
-	TAR_OPTS="-xjf"
+	TAR_OPTS="--numeric-owner -xjf"
 if [[ "$ROOTFS_TARBALL" =~ tar\.gz$ ]]; then
-	TAR_OPTS="-xzf"
+	TAR_OPTS="--numeric-owner -xzf"
 if [[ "$ROOTFS_TARBALL" =~ \.tar$ ]]; then
-	TAR_OPTS="-xf"
+	TAR_OPTS="--numeric-owner -xf"
 if [ -z "$TAR_OPTS" ]; then
 	echo "Error: Unable to determine sdk tarball format"