Skip to contentSkip to conversation

dbus: Fix pid file in dbus init script

PATCH Applied Andy Ross 2 participants 2 messages Aug 10, 2012 – Aug 16, 2012

lore
Share & tools
lore

Andy Ross

author
#0 lore raw

PATCH 1/1 dbus: Fix pid file in dbus init script

The PIDFILE (/var/run/dbus/pid) referenced by /etc/init.d/dbus-1 did not match the path (/var/run/messagebus.pid) configured in /etc/dbus-1/system.conf, so the initscript could start the daemon, but not stop it. Also remove needless directory ownership logic (dbus-daemon drops its pid file as root before calling setuid).

---
 meta/recipes-core/dbus/dbus-1.4.20/dbus-1.init | 11 +++--------
 meta/recipes-core/dbus/dbus-1.5.12/dbus-1.init | 11 +++--------
 2 files changed, 6 insertions(+), 16 deletions(-)
meta/recipes-core/dbus/dbus-1.4.20/dbus-1.init +3 -8
index 4abc4cb..17b58ed 100644
@@ -18,9 +18,8 @@ set -e
 
 DAEMON=/usr/bin/dbus-daemon
 NAME=dbus
-DAEMONUSER=messagebus
-PIDDIR=/var/run/dbus
-PIDFILE=$PIDDIR/pid
+DAEMONUSER=messagebus           # must match /etc/dbus-1/system.conf
+PIDFILE=/var/run/messagebus.pid # must match /etc/dbus-1/system.conf
 UUIDDIR=/var/lib/dbus
 DESC="system message bus"
 EVENTDIR=/etc/dbus-1/event.d
@@ -38,11 +37,7 @@ test "$ENABLED" != "0" || exit 0
 
 start_it_up()
 {
-  if [ ! -d $PIDDIR ]; then
-    mkdir -p $PIDDIR
-    chown $DAEMONUSER $PIDDIR
-    chgrp $DAEMONUSER $PIDDIR
-  fi
+  mkdir -p "`dirname $PIDFILE`"
   if [ -e $PIDFILE ]; then
     PIDDIR=/proc/$(cat $PIDFILE)
     if [ -d ${PIDDIR} -a  "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then 
meta/recipes-core/dbus/dbus-1.5.12/dbus-1.init +3 -8
index 4abc4cb..17b58ed 100644
@@ -18,9 +18,8 @@ set -e
 
 DAEMON=/usr/bin/dbus-daemon
 NAME=dbus
-DAEMONUSER=messagebus
-PIDDIR=/var/run/dbus
-PIDFILE=$PIDDIR/pid
+DAEMONUSER=messagebus           # must match /etc/dbus-1/system.conf
+PIDFILE=/var/run/messagebus.pid # must match /etc/dbus-1/system.conf
 UUIDDIR=/var/lib/dbus
 DESC="system message bus"
 EVENTDIR=/etc/dbus-1/event.d
@@ -38,11 +37,7 @@ test "$ENABLED" != "0" || exit 0
 
 start_it_up()
 {
-  if [ ! -d $PIDDIR ]; then
-    mkdir -p $PIDDIR
-    chown $DAEMONUSER $PIDDIR
-    chgrp $DAEMONUSER $PIDDIR
-  fi
+  mkdir -p "`dirname $PIDFILE`"
   if [ -e $PIDFILE ]; then
     PIDDIR=/proc/$(cat $PIDFILE)
     if [ -d ${PIDDIR} -a  "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then 
Signature · 1 line
1.7.11.2
Applied
#1 lore raw
Quoted 138 lines · Andy Ross

The PIDFILE (/var/run/dbus/pid) referenced by /etc/init.d/dbus-1 did not match the path (/var/run/messagebus.pid) configured in /etc/dbus-1/system.conf, so the initscript could start the daemon, but not stop it. Also remove needless directory ownership logic (dbus-daemon drops its pid file as root before calling setuid).

---
  meta/recipes-core/dbus/dbus-1.4.20/dbus-1.init | 11 +++--------
  meta/recipes-core/dbus/dbus-1.5.12/dbus-1.init | 11 +++--------
  2 files changed, 6 insertions(+), 16 deletions(-)
meta/recipes-core/dbus/dbus-1.4.20/dbus-1.init +3 -8
index 4abc4cb..17b58ed 100644
@@ -18,9 +18,8 @@ set -e
 
  DAEMON=/usr/bin/dbus-daemon
  NAME=dbus
-DAEMONUSER=messagebus
-PIDDIR=/var/run/dbus
-PIDFILE=$PIDDIR/pid
+DAEMONUSER=messagebus           # must match /etc/dbus-1/system.conf
+PIDFILE=/var/run/messagebus.pid # must match /etc/dbus-1/system.conf
  UUIDDIR=/var/lib/dbus
  DESC="system message bus"
  EVENTDIR=/etc/dbus-1/event.d
@@ -38,11 +37,7 @@ test "$ENABLED" != "0" || exit 0
 
  start_it_up()
  {
-  if [ ! -d $PIDDIR ]; then
-    mkdir -p $PIDDIR
-    chown $DAEMONUSER $PIDDIR
-    chgrp $DAEMONUSER $PIDDIR
-  fi
+  mkdir -p "`dirname $PIDFILE`"
    if [ -e $PIDFILE ]; then
      PIDDIR=/proc/$(cat $PIDFILE)
      if [ -d ${PIDDIR} -a  "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then
meta/recipes-core/dbus/dbus-1.5.12/dbus-1.init +3 -8
index 4abc4cb..17b58ed 100644
@@ -18,9 +18,8 @@ set -e
 
  DAEMON=/usr/bin/dbus-daemon
  NAME=dbus
-DAEMONUSER=messagebus
-PIDDIR=/var/run/dbus
-PIDFILE=$PIDDIR/pid
+DAEMONUSER=messagebus           # must match /etc/dbus-1/system.conf
+PIDFILE=/var/run/messagebus.pid # must match /etc/dbus-1/system.conf
  UUIDDIR=/var/lib/dbus
  DESC="system message bus"
  EVENTDIR=/etc/dbus-1/event.d
@@ -38,11 +37,7 @@ test "$ENABLED" != "0" || exit 0
 
  start_it_up()
  {
-  if [ ! -d $PIDDIR ]; then
-    mkdir -p $PIDDIR
-    chown $DAEMONUSER $PIDDIR
-    chgrp $DAEMONUSER $PIDDIR
-  fi
+  mkdir -p "`dirname $PIDFILE`"
    if [ -e $PIDFILE ]; thenOn 08/10/2012 12:00 PM, Andy Ross wrote:> The PIDFILE (/var/run/dbus/pid) referenced by /etc/init.d/dbus-1 did

not match the path (/var/run/messagebus.pid) configured in /etc/dbus-1/system.conf, so the initscript could start the daemon, but not stop it. Also remove needless directory ownership logic (dbus-daemon drops its pid file as root before calling setuid).

---
  meta/recipes-core/dbus/dbus-1.4.20/dbus-1.init | 11 +++--------
  meta/recipes-core/dbus/dbus-1.5.12/dbus-1.init | 11 +++--------
  2 files changed, 6 insertions(+), 16 deletions(-)
meta/recipes-core/dbus/dbus-1.4.20/dbus-1.init +3 -8
index 4abc4cb..17b58ed 100644
@@ -18,9 +18,8 @@ set -e
 
  DAEMON=/usr/bin/dbus-daemon
  NAME=dbus
-DAEMONUSER=messagebus
-PIDDIR=/var/run/dbus
-PIDFILE=$PIDDIR/pid
+DAEMONUSER=messagebus           # must match /etc/dbus-1/system.conf
+PIDFILE=/var/run/messagebus.pid # must match /etc/dbus-1/system.conf
  UUIDDIR=/var/lib/dbus
  DESC="system message bus"
  EVENTDIR=/etc/dbus-1/event.d
@@ -38,11 +37,7 @@ test "$ENABLED" != "0" || exit 0
 
  start_it_up()
  {
-  if [ ! -d $PIDDIR ]; then
-    mkdir -p $PIDDIR
-    chown $DAEMONUSER $PIDDIR
-    chgrp $DAEMONUSER $PIDDIR
-  fi
+  mkdir -p "`dirname $PIDFILE`"
    if [ -e $PIDFILE ]; then
      PIDDIR=/proc/$(cat $PIDFILE)
      if [ -d ${PIDDIR} -a  "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then
meta/recipes-core/dbus/dbus-1.5.12/dbus-1.init +3 -8
index 4abc4cb..17b58ed 100644
@@ -18,9 +18,8 @@ set -e
 
  DAEMON=/usr/bin/dbus-daemon
  NAME=dbus
-DAEMONUSER=messagebus
-PIDDIR=/var/run/dbus
-PIDFILE=$PIDDIR/pid
+DAEMONUSER=messagebus           # must match /etc/dbus-1/system.conf
+PIDFILE=/var/run/messagebus.pid # must match /etc/dbus-1/system.conf
  UUIDDIR=/var/lib/dbus
  DESC="system message bus"
  EVENTDIR=/etc/dbus-1/event.d
@@ -38,11 +37,7 @@ test "$ENABLED" != "0" || exit 0
 
  start_it_up()
  {
-  if [ ! -d $PIDDIR ]; then
-    mkdir -p $PIDDIR
-    chown $DAEMONUSER $PIDDIR
-    chgrp $DAEMONUSER $PIDDIR
-  fi
+  mkdir -p "`dirname $PIDFILE`"
    if [ -e $PIDFILE ]; then
      PIDDIR=/proc/$(cat $PIDFILE)
      if [ -d ${PIDDIR} -a  "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then
Quoted 3 lines
      PIDDIR=/proc/$(cat $PIDFILE)
      if [ -d ${PIDDIR} -a  "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then

Merged into OE-Core

Thanks
Sau!