diff mbox

[xfstest-bld,1/2] test-appliance: add safety check for "gen-image --out-tar"

Message ID 20170813173224.28900-1-tytso@mit.edu (mailing list archive)
State New, archived
Headers show

Commit Message

Theodore Ts'o Aug. 13, 2017, 5:32 p.m. UTC
The gen-image script must not be run as root when generating a tar
file.  This is because it uses fakechroot and fakeroot, and if run as
root, the debootstrap script will end up damaging a large number of
devices in the /dev directory.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 kvm-xfstests/test-appliance/gen-image | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Eric Biggers Aug. 16, 2017, 3:40 a.m. UTC | #1
On Sun, Aug 13, 2017 at 01:32:23PM -0400, Theodore Ts'o wrote:
> The gen-image script must not be run as root when generating a tar
> file.  This is because it uses fakechroot and fakeroot, and if run as
> root, the debootstrap script will end up damaging a large number of
> devices in the /dev directory.
> 
> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
> ---
>  kvm-xfstests/test-appliance/gen-image | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/kvm-xfstests/test-appliance/gen-image b/kvm-xfstests/test-appliance/gen-image
> index dbd9b84..e7bdb35 100755
> --- a/kvm-xfstests/test-appliance/gen-image
> +++ b/kvm-xfstests/test-appliance/gen-image
> @@ -76,6 +76,10 @@ fi
>  
>  if test -n "$OUT_TAR" ; then
>      if test "$FAKECHROOT" != "true" ; then
> +	if test "$EUID" -eq 0 ; then
> +	    echo "This script MUST NOT be run as root with --out_tar"
> +	    exit 1;
> +	fi
>  	set -- "${SAVE_ARGS[@]}"
>  	exec fakechroot $0 "$@"
>      fi
> -- 
> 2.11.0.rc0.7.gbe5a750

Reviewed-by: Eric Biggers <ebiggers@google.com>
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/kvm-xfstests/test-appliance/gen-image b/kvm-xfstests/test-appliance/gen-image
index dbd9b84..e7bdb35 100755
--- a/kvm-xfstests/test-appliance/gen-image
+++ b/kvm-xfstests/test-appliance/gen-image
@@ -76,6 +76,10 @@  fi
 
 if test -n "$OUT_TAR" ; then
     if test "$FAKECHROOT" != "true" ; then
+	if test "$EUID" -eq 0 ; then
+	    echo "This script MUST NOT be run as root with --out_tar"
+	    exit 1;
+	fi
 	set -- "${SAVE_ARGS[@]}"
 	exec fakechroot $0 "$@"
     fi