From: Richard Jones Date: Tue, 20 Apr 2010 12:22:09 +0000 (+0100) Subject: Check user doesn't run configure, make or make check as root. X-Git-Tag: 1.3.6~10 X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=commitdiff_plain;h=199f218bf431b77c12a728f7072bed1553a0f0af Check user doesn't run configure, make or make check as root. (Thanks to Yufang Zhang for helping to debug this issue). --- diff --git a/configure.ac b/configure.ac index 99b74df..0dc4e4b 100644 --- a/configure.ac +++ b/configure.ac @@ -37,6 +37,17 @@ AC_DEFINE([PACKAGE_VERSION_MINOR],[libguestfs_minor],[Minor version number]) AC_DEFINE([PACKAGE_VERSION_RELEASE],[libguestfs_release],[Release number]) AC_DEFINE([PACKAGE_VERSION_EXTRA],["libguestfs_extra"],[Extra version string]) +dnl Die if the user tries to configure as root, see: +dnl https://www.redhat.com/archives/libguestfs/2010-April/msg00098.html +AC_MSG_CHECKING([if you are trying to configure as root]) +AS_IF([test "`id -u`" = 0 ],[ + AC_MSG_RESULT([yes]) + AC_MSG_FAILURE([Don't run './configure' or 'make' as root.]) + ],[ + AC_MSG_RESULT([no]) + ]) + +dnl Early gnulib initialization. gl_EARLY gl_INIT diff --git a/src/Makefile.am b/src/Makefile.am index 43f1b0d..ad3b478 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -179,3 +179,14 @@ guestfs.3: guestfs.pod \ --name "guestfs" \ --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \ > $@ + +# Check user doesn't try to do 'make all' or 'make check' as root. +# https://www.redhat.com/archives/libguestfs/2010-April/msg00098.html + +all-local: checkroot +check-local: checkroot +checkroot: + @if [ "`id -u`" = 0 ]; then \ + echo "*** Error: Don't run 'make' or 'make check' as root."; \ + exit 1; \ + fi