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() ...@@ -38,7 +38,7 @@ epm_checksystem_ALTLinux()
epm_checksystem() epm_checksystem()
{ {
[ $EFFUID = "0" ] && fatal "Do not use checksystem under root" is_root && fatal "Do not use checksystem under root"
case $PMTYPE in case $PMTYPE in
homebrew) homebrew)
......
...@@ -109,7 +109,7 @@ showcmd() ...@@ -109,7 +109,7 @@ showcmd()
if [ -z "$quiet" ] ; then if [ -z "$quiet" ] ; then
set_boldcolor $GREEN set_boldcolor $GREEN
local PROMTSIG="\$" local PROMTSIG="\$"
[ "$EFFUID" = 0 ] && PROMTSIG="#" is_root && PROMTSIG="#"
echo " $PROMTSIG $*" echo " $PROMTSIG $*"
restore_color restore_color
fi >&2 fi >&2
...@@ -257,7 +257,14 @@ clean_store_output() ...@@ -257,7 +257,14 @@ clean_store_output()
epm() epm()
{ {
[ -n "$PROGNAME" ] || fatal "Can't use epm call from the piped script" [ -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 # Print error message and stop the program
...@@ -313,10 +320,8 @@ set_sudo() ...@@ -313,10 +320,8 @@ set_sudo()
return return
fi fi
EFFUID=$(id -u)
# if we are root, do not need sudo # if we are root, do not need sudo
[ $EFFUID = "0" ] && return is_root && return
# start error section # start error section
SUDO_TESTED="1" SUDO_TESTED="1"
...@@ -412,10 +417,15 @@ confirm_info() ...@@ -412,10 +417,15 @@ confirm_info()
} }
is_root()
{
local EFFUID="$(id -u)"
[ "$EFFUID" = "0" ]
}
assure_root() assure_root()
{ {
set_sudo is_root || fatal "run me only under root"
[ "$EFFUID" = 0 ] || fatal "run me only under root"
} }
regexp_subst() 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