Package: rabbitmq-server
Version: 2.6.1-1
Severity: minor

After installing and starting rabbitmq-server, a 'ps' will show something
like:
$ ps axw | grep [r]abbit
 2688 ?  Ss 0:00 sh -c RABBITMQ_PID_FILE=/var/run/rabbitmq/pid /usr/sb ...
 2691 ?  S  0:00 /bin/sh /usr/sbin/rabbitmq-server
 2697 ?  S  0:00 su rabbitmq -s /bin/sh -c /usr/lib/rabb ...
 2699 ?  S  0:00 sh -c /usr/lib/rabbitmq/bin/rabbitmq-server
 2700 ?  Sl 0:00 /usr/lib/erlang/erts-5.8.4/bin/beam ...

Above, pids 2688, 2697, 2699 are doing nothing but waiting for other
processes to exit.  They're simply a waste.

In bug #646473, I submitted a fix to get rid of the 'sh -c
RABBITMQ_PID_FILE' process.  The patch below will remove the other 2.

The patch does a couple things:
 * replace the built-in re-quoting with use of 'getopt'.  getopt is
   util-linux, which is 'essential' so this shouldnt be a big deal.
   The previous quoting would have had issues with some arguments.
   getopt understands shell quoting, it makes sense to use it.
 * if perl is installed (the extremely likely case), then 'runas' will
   utilize it to change permissions and then execute the rabbitmq
   server process as the un-priviledged user.
   If perl is not installed, it will take the old 'su' path.
 * use 'exec' if we're already running as the rabbitmq user.

=== modified file 'debian/rabbitmq-script-wrapper'
--- debian/rabbitmq-script-wrapper      2011-02-05 10:21:16 +0000
+++ debian/rabbitmq-script-wrapper      2011-10-24 14:53:46 +0000
@@ -15,24 +15,30 @@
 ##  Copyright (c) 2007-2011 VMware, Inc.  All rights reserved.
 ##

-# Escape spaces and quotes, because shell is revolting.
-for arg in "$@" ; do
-       # Escape quotes in parameters, so that they're passed through cleanly.
-       arg=$(sed -e 's/"/\\"/g' <<-END
-               $arg
-               END
-       )
-       CMDLINE="${CMDLINE} \"${arg}\""
-done
+runas() {
+    local user="$1" cmd=""
+    shift;
+    if command -v perl >/dev/null; then
+        # using perl rather than su stops a 'su' process from hanging around
+        PATH=/usr/local/bin:/usr/bin:/bin; USER=$user; LOGNAME=$user
+        exec perl -e '@pwd = getpwnam("'$user'");
+            $( = $) = $pwd[3]; $< = $> = $pwd[2];
+            $ENV{'HOME'} = $pwd[7]; exec @ARGV' -- "$@"
+    else
+        # use getopt to handle escaping shell variables, and su to change user
+        cmd=$(getopt --shell sh --options "" -- -- "$@") && cmd=${cmd# --} &&
+            exec su "$user" -s /bin/sh -c "exec $cmd"
+    fi
+}

 cd /var/lib/rabbitmq

 SCRIPT=`basename $0`

 if [ `id -u` = 0 ] ; then
-    su rabbitmq -s /bin/sh -c "/usr/lib/rabbitmq/bin/${SCRIPT} ${CMDLINE}"
+    runas rabbitmq "/usr/lib/rabbitmq/bin/${SCRIPT}" "$@"
 elif [ `id -u` = `id -u rabbitmq` ] ; then
-    /usr/lib/rabbitmq/bin/${SCRIPT} "$@"
+    exec /usr/lib/rabbitmq/bin/${SCRIPT} "$@"
 else
     /usr/lib/rabbitmq/bin/${SCRIPT}
     echo


-- System Information:
Debian Release: 6.0.1
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-xen-686 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages rabbitmq-server depends on:
ii  adduser     3.112+nmu2
ii  erlang-nox  1:14.b.3-dfsg-2
ii  logrotate   3.7.8-6

rabbitmq-server recommends no packages.

rabbitmq-server suggests no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to