summaryrefslogtreecommitdiff
path: root/chat/ejabberd/patches/patch-ae
blob: 0ef67fd718eb29225e93a855bfe74540af15d9f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
$NetBSD: patch-ae,v 1.16 2017/07/07 10:08:40 fhajny Exp $

- Default locations.
- Use 'su -' instead of just 'su'. Fixes priv delegation on SunOS
  and AIX where Erlang relies on $HOME set correctly.
- At least SunOS has not wheel group.
- Portable grep calls.

--- ejabberdctl.template.orig	2017-06-30 12:24:35.000000000 +0000
+++ ejabberdctl.template
@@ -21,7 +21,7 @@ if [ -n "$INSTALLUSER" ] ; then
     if [ $(id -g) -eq $(id -g $INSTALLUSER || echo -1) ] ; then
         EXEC_CMD="as_current_user"
     else
-        id -Gn | grep -q wheel && EXEC_CMD="as_install_user"
+        id -Gn | grep 'wheel\|root' >/dev/null && EXEC_CMD="as_install_user"
     fi
 else
     EXEC_CMD="as_current_user"
@@ -49,8 +49,8 @@ done
 
 # define ejabberd variables if not already defined from the command line
 : ${ETC_DIR:={{sysconfdir}}/ejabberd}
-: ${LOGS_DIR:={{localstatedir}}/log/ejabberd}
-: ${SPOOL_DIR:={{localstatedir}}/lib/ejabberd}
+: ${LOGS_DIR:=@EJABBERD_LOGDIR@}
+: ${SPOOL_DIR:=@EJABBERD_DB@}
 : ${EJABBERD_CONFIG_PATH:="$ETC_DIR"/ejabberd.yml}
 : ${EJABBERDCTL_CONFIG_PATH:="$ETC_DIR"/ejabberdctl.cfg}
 [ -f "$EJABBERDCTL_CONFIG_PATH" ] && . "$EJABBERDCTL_CONFIG_PATH"
@@ -103,7 +103,7 @@ export ERL_LIBS
 exec_cmd()
 {
     case $EXEC_CMD in
-        as_install_user) su -c '"$0" $@"' "$INSTALLUSER" -- "$@" ;;
+        as_install_user) su - -c '"$0" $@"' "$INSTALLUSER" -- "$@" ;;
         as_current_user) "$@" ;;
     esac
 }
@@ -202,19 +202,19 @@ uid()
 # stop epmd if there is no other running node
 stop_epmd()
 {
-    "$EPMD" -names 2>/dev/null | grep -q name || "$EPMD" -kill >/dev/null
+    "$EPMD" -names 2>/dev/null | grep name >/dev/null || "$EPMD" -kill >/dev/null
 }
 
 # make sure node not already running and node name unregistered
 # if all ok, ensure runtime directory exists and make it current directory
 check_start()
 {
-    "$EPMD" -names 2>/dev/null | grep -q " ${ERLANG_NODE%@*} " && {
-        ps ux | grep -v grep | grep -q " $ERLANG_NODE " && {
+    "$EPMD" -names 2>/dev/null | grep " ${ERLANG_NODE%@*} " >/dev/null && {
+        ps ux | grep -v grep | grep " $ERLANG_NODE " >/dev/null && {
             echo "ERROR: The ejabberd node '$ERLANG_NODE' is already running."
             exit 4
         } || {
-            ps ux | grep -v grep | grep -q beam && {
+            ps ux | grep -v grep | grep beam >/dev/null && {
                 echo "ERROR: The ejabberd node '$ERLANG_NODE' is registered,"
                 echo "       but no related beam process has been found."
                 echo "Shutdown all other erlang nodes, and call 'epmd -kill'."