mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Fix errors when running ejabberdctl as root
This commit is contained in:
parent
b1082a96c9
commit
72dbb6e7c1
@ -13,23 +13,30 @@ ERLANG_NODE=ejabberd@localhost
|
|||||||
ERL="{{erl}}"
|
ERL="{{erl}}"
|
||||||
IEX="{{bindir}}/iex"
|
IEX="{{bindir}}/iex"
|
||||||
EPMD="{{epmd}}"
|
EPMD="{{epmd}}"
|
||||||
INSTALLUSER={{installuser}}
|
INSTALLUSER="{{installuser}}"
|
||||||
|
|
||||||
# check the proper system user is used if defined
|
# check the proper system user is used
|
||||||
EXEC_CMD="false"
|
case `id -un` in
|
||||||
if [ -n "$INSTALLUSER" ] ; then
|
"$INSTALLUSER")
|
||||||
if [ $(id -g) -eq $(id -g $INSTALLUSER || echo -1) ] ; then
|
|
||||||
EXEC_CMD="as_current_user"
|
EXEC_CMD="as_current_user"
|
||||||
else
|
;;
|
||||||
id -Gn | grep -q wheel && EXEC_CMD="as_install_user"
|
root)
|
||||||
fi
|
if [ -n "$INSTALLUSER" ] ; then
|
||||||
else
|
EXEC_CMD="as_install_user"
|
||||||
EXEC_CMD="as_current_user"
|
else
|
||||||
fi
|
EXEC_CMD="as_current_user"
|
||||||
if [ "$EXEC_CMD" = "false" ] ; then
|
echo "WARNING: This is not recommended to run ejabberd as root" >&2
|
||||||
echo "ERROR: This command can only be run by root or the user $INSTALLUSER" >&2
|
fi
|
||||||
exit 7
|
;;
|
||||||
fi
|
*)
|
||||||
|
if [ -n "$INSTALLUSER" ] ; then
|
||||||
|
echo "ERROR: This command can only be run by root or the user $INSTALLUSER" >&2
|
||||||
|
exit 7
|
||||||
|
else
|
||||||
|
EXEC_CMD="as_current_user"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# parse command line parameters
|
# parse command line parameters
|
||||||
for arg; do
|
for arg; do
|
||||||
@ -103,7 +110,7 @@ export ERL_LIBS
|
|||||||
exec_cmd()
|
exec_cmd()
|
||||||
{
|
{
|
||||||
case $EXEC_CMD in
|
case $EXEC_CMD in
|
||||||
as_install_user) su -c '"$0" $@"' "$INSTALLUSER" -- "$@" ;;
|
as_install_user) su -c '"$0" "$@"' "$INSTALLUSER" -- "$@" ;;
|
||||||
as_current_user) "$@" ;;
|
as_current_user) "$@" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
@ -223,12 +230,6 @@ check_start()
|
|||||||
"$EPMD" -kill >/dev/null
|
"$EPMD" -kill >/dev/null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} || {
|
|
||||||
[ -d "$SPOOL_DIR" ] || exec_cmd mkdir -p "$SPOOL_DIR"
|
|
||||||
cd "$SPOOL_DIR" || {
|
|
||||||
echo "ERROR: ejabberd can not access directory $SPOOL_DIR"
|
|
||||||
exit 6
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,6 +254,13 @@ wait_status()
|
|||||||
[ $timeout -gt 0 ]
|
[ $timeout -gt 0 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ensure we can change current directory to SPOOL_DIR
|
||||||
|
[ -d "$SPOOL_DIR" ] || exec_cmd mkdir -p "$SPOOL_DIR"
|
||||||
|
cd "$SPOOL_DIR" || {
|
||||||
|
echo "ERROR: can not access directory $SPOOL_DIR"
|
||||||
|
exit 6
|
||||||
|
}
|
||||||
|
|
||||||
# main
|
# main
|
||||||
case $1 in
|
case $1 in
|
||||||
start)
|
start)
|
||||||
|
Loading…
Reference in New Issue
Block a user