Commit 8d7ee232 authored by Vitaly Lipatov's avatar Vitaly Lipatov

introduce is_root and sudoepm (run epm under root)

parent c970af23
......@@ -38,7 +38,7 @@ epm_checksystem_ALTLinux()
epm_checksystem()
{
[ $EFFUID = "0" ] && fatal "Do not use checksystem under root"
is_root && fatal "Do not use checksystem under root"
case $PMTYPE in
homebrew)
......
......@@ -109,7 +109,7 @@ showcmd()
if [ -z "$quiet" ] ; then
set_boldcolor $GREEN
local PROMTSIG="\$"
[ "$EFFUID" = 0 ] && PROMTSIG="#"
is_root && PROMTSIG="#"
echo " $PROMTSIG $*"
restore_color
fi >&2
......@@ -257,7 +257,14 @@ clean_store_output()
epm()
{
[ -n "$PROGNAME" ] || fatal "Can't use epm call from the piped script"
$PROGDIR/$PROGNAME --inscript $@
$PROGDIR/$PROGNAME --inscript "$@"
}
# run $SUDO epm, possible from side repo
sudoepm()
{
[ -n "$PROGNAME" ] || fatal "Can't use epm call from the piped script"
sudorun $PROGDIR/$PROGNAME --inscript "$@"
}
# Print error message and stop the program
......@@ -313,10 +320,8 @@ set_sudo()
return
fi
EFFUID=$(id -u)
# if we are root, do not need sudo
[ $EFFUID = "0" ] && return
is_root && return
# start error section
SUDO_TESTED="1"
......@@ -412,10 +417,15 @@ confirm_info()
}
is_root()
{
local EFFUID="$(id -u)"
[ "$EFFUID" = "0" ]
}
assure_root()
{
set_sudo
[ "$EFFUID" = 0 ] || fatal "run me only under root"
is_root || fatal "run me only under root"
}
regexp_subst()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment