File ejabberd-16.06_dont_run_as_root.patch of Package ejabberd

Index: ejabberd-24.02/ejabberdctl.template
===================================================================
--- ejabberd-24.02.orig/ejabberdctl.template
+++ ejabberd-24.02/ejabberdctl.template
@@ -19,6 +19,24 @@ EPMD="{{epmd}}"
 IEX="{{iexpath}}"
 INSTALLUSER="{{installuser}}"
 
+EJABBERD_UID="$(id -u $INSTALLUSER 2> /dev/null)"
+CURRENT_UID="$(id -u 2> /dev/null)"
+
+if [ -z "$EJABBERD_UID"  ] ; then
+  echo "Can not find ejabberd userid! Exiting ..." >&2
+  exit 1
+fi
+
+if [ -z "$CURRENT_UID"  ] ; then
+  echo "Can not find userid for your current user! Exiting ..." >&2
+  exit 1
+fi
+
+if [ "$EJABBERD_UID" != "$CURRENT_UID"  ] ; then
+  echo -e "Please run the command as user $INSTALLUSER.\n\nYou can use:\n\nsudo -u $INSTALLUSER ejabberdctl ....\n\nExiting ..." >&2
+  exit 1
+fi
+
 # check the proper system user is used
 case $(id -un) in
     "$INSTALLUSER")
openSUSE Build Service is sponsored by