mirror of
https://github.com/msmhq/msm.git
synced 2024-08-30 18:12:35 +00:00
Added protection against switching to the server user from non-root users.
This commit is contained in:
parent
ba8a8f14cd
commit
2540c43e8a
10
msm
10
msm
@ -59,10 +59,16 @@ declare RESTART_COUNTDOWN
|
||||
# $1: The user to execute the command as
|
||||
# $2: The command to execute
|
||||
as_user() {
|
||||
if [ $(whoami) == $1 ]; then
|
||||
local user="$(whoami)"
|
||||
if [ "$user" == "$1" ]; then
|
||||
bash -c "$2"
|
||||
else
|
||||
su - $1 -s /bin/bash -c "$2"
|
||||
if [ "$user" == "root" ]; then
|
||||
su - $1 -s /bin/bash -c "$2"
|
||||
else
|
||||
echoerr "This command must be executed as the user \"$1\" or \"root\"."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user