# HG changeset patch # User "Yann E. MORIN" # Date 1357853928 -3600 # Node ID 06938bc1c6e71b5e5bd38040987d52e8ae250c34 # Parent e51eb0a614c7d9e413b9d8591eb8f9d775507c83 scripts: check for running as root Running as root is really, really dangerous. Add a runtime-check that refuses to build if running as root. Can be overriden with a double switch in the menuconfig. Signed-off-by: "Yann E. MORIN" diff -r e51eb0a614c7 -r 06938bc1c6e7 config/global/ct-behave.in --- a/config/global/ct-behave.in Thu Jan 10 21:01:59 2013 +0100 +++ b/config/global/ct-behave.in Thu Jan 10 22:38:48 2013 +0100 @@ -29,6 +29,37 @@ - non-existant, in which case you could also try hacking it in and send me the result +config ALLOW_BUILD_AS_ROOT + bool + prompt "Allow building as root user (READ HELP!)" + depends on EXPERIMENTAL + help + You normally do *not* need to be root to build a toolchain using + crosstool-NG. In fact, it is *VERY* dangerous to run as root, as + crosstool-NG will, as part of the build process, remove a few + directories. If anything goes wrong, running as root can ruin + your host distribution. + + I can't stress it enough: DO NOT RUN AS ROOT !! + + Do not run as root, you've been warned. + Do not come whining, if it nukes your host system. + Do not come whining, if you lose any data. + Do not run as root. + + Do not run as root, you've been warned. + Do not come whining, if the Earth stops rotating. + Do not come whining, if kittens are smashed. + Do not run as root. + + Do not run as root, do not run as root! + (ad libitum) + +config ALLOW_BUILD_AS_ROOT_SURE + bool + prompt "Are you sure?" + depends on ALLOW_BUILD_AS_ROOT + config DEBUG_CT bool prompt "Debug crosstool-NG" diff -r e51eb0a614c7 -r 06938bc1c6e7 scripts/crosstool-NG.sh.in --- a/scripts/crosstool-NG.sh.in Thu Jan 10 21:01:59 2013 +0100 +++ b/scripts/crosstool-NG.sh.in Thu Jan 10 22:38:48 2013 +0100 @@ -25,6 +25,14 @@ . .config.2 # Yes! We can do full logging from now on! +# Check running as root +if [ -z "${CT_ALLOW_BUILD_AS_ROOT_SURE}" ]; then + if [ $(id -u) -eq 1000 ]; then + CT_DoLog ERROR "You must NOT be root to run crosstool-NG" + exit 1 + fi +fi + # If we want an interactive debug-shell, we must ensure these FDs # are indeed connected to a terminal (and not redirected in any way). if [ "${CT_DEBUG_INTERACTIVE}" = "y" -a ! \( -t 0 -a -t 6 -a -t 2 \) ]; then