Downgrade credentials when building with sudo ##build
This commit is contained in:
parent
e94861a476
commit
1b7d5b5f7f
2 changed files with 17 additions and 5 deletions
11
sys/build.sh
11
sys/build.sh
|
|
@ -38,11 +38,12 @@ BuildJobsThrottler(){
|
|||
echo "So, the build will run on $MAKE_JOBS job(s)."
|
||||
}
|
||||
|
||||
# Identify current platform
|
||||
GetPlatform
|
||||
|
||||
# Define number of parallel jobs as function of resources and platform
|
||||
BuildJobsThrottler
|
||||
if [ "`uname`" = Linux ]; then
|
||||
# Identify current platform
|
||||
GetPlatform
|
||||
# Define number of parallel jobs depending on ncpus and memory
|
||||
BuildJobsThrottler
|
||||
fi
|
||||
|
||||
if [ -z "${MAKE}" ]; then
|
||||
MAKE=make
|
||||
|
|
|
|||
|
|
@ -4,6 +4,17 @@ MAKE=make
|
|||
gmake --help >/dev/null 2>&1
|
||||
[ $? = 0 ] && MAKE=gmake
|
||||
|
||||
# if owner of sys/install.sh != uid && uid == 0 { exec sudo -u id -A $SUDO_UID sys/install.sh $* }
|
||||
|
||||
if [ "${UID}" = 0 ]; then
|
||||
echo "[XX] Do not run this script as root!"
|
||||
if [ -n "${SUDO_USER}" ]; then
|
||||
echo "[--] Downgrading credentials to ${SUDO_USER}"
|
||||
exec sudo -u "${SUDO_USER}" sys/install.sh $*
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
${MAKE} --help 2>&1 | grep -q gnu
|
||||
if [ $? != 0 ]; then
|
||||
echo "You need GNU Make to build me"
|
||||
|
|
|
|||
Loading…
Reference in a new issue