Patchwork [4/4] dbus: use useradd class to allow use in read-only filesystems

login
register
mail settings
Submitter Otavio Salvador
Date Oct. 21, 2011, 3:31 a.m.
Message ID <67ee6e07c8d57d45682fb8962df79fb8d154c400.1319167843.git.otavio@ossystems.com.br>
Download mbox | patch
Permalink /patch/13649/
State Accepted
Commit 46e6c3fa8034b12d178d605f3f5d7efe69671a13
Headers show

Comments

Otavio Salvador - Oct. 21, 2011, 3:31 a.m.
Move creation of required user/groups to useradd class thus allowing
use with read-only filesystems and booting the initial boot.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
 meta/recipes-core/dbus/dbus.inc |   48 +++++++++++++++++----------------------
 1 files changed, 21 insertions(+), 27 deletions(-)
Phil Blundell - Oct. 21, 2011, 6:54 a.m.
On Fri, 2011-10-21 at 03:31 +0000, Otavio Salvador wrote:
> +USERADD_PACKAGES = "${PN}"
> +GROUPADD_PARAM_${PN} = "-r netdev"
> +USERADD_PARAM_${PN} = "--system --home ${localstatedir}/lib/dbus \
> +                       --no-create-home --user-group messagebus"

Why does dbus need "netdev"?

p.
Koen Kooi - Oct. 21, 2011, 7:05 a.m.
Op 21 okt. 2011, om 08:54 heeft Phil Blundell het volgende geschreven:

> On Fri, 2011-10-21 at 03:31 +0000, Otavio Salvador wrote:
>> +USERADD_PACKAGES = "${PN}"
>> +GROUPADD_PARAM_${PN} = "-r netdev"
>> +USERADD_PARAM_${PN} = "--system --home ${localstatedir}/lib/dbus \
>> +                       --no-create-home --user-group messagebus"
> 
> Why does dbus need "netdev"?


A little digging on the internet shows that some applications using dbus use netdev and as a result dbus will complain about a missing netdev group. Dbus itself doesn't seem to need it. A handfull of searchresults imply that not dbus but e.g. networkmanager and wpa-supplicant should create the group, but:

root@beagleboard:/etc/dbus-1/system.d# ls
ConsoleKit.conf           org.freedesktop.PolicyKit1.conf
NetworkManager.conf       org.freedesktop.UDisks.conf
avahi-dbus.conf           org.freedesktop.UPower.conf
bluetooth.conf            org.freedesktop.hostname1.conf
dbus-wpa_supplicant.conf  org.freedesktop.locale1.conf
gdm.conf                  org.freedesktop.login1.conf
nm-avahi-autoipd.conf     org.freedesktop.systemd1.conf
nm-dhcp-client.conf       org.freedesktop.timedate1.conf
nm-dispatcher.conf        org.gnome.GConf.Defaults.conf

root@beagleboard:/etc/dbus-1/system.d# grep netdev *
root@beagleboard:/etc/dbus-1/system.d# 

So it seems (but I am not certain!) that netdev is a relic of the past and can go away. What I would propose:

1) convert the existing *inst to useradd.bbclass
2) bump PR, remove netdev

That should give us a nice bisectable stack of commits.

regards,

Koen

Patch

diff --git a/meta/recipes-core/dbus/dbus.inc b/meta/recipes-core/dbus/dbus.inc
index a8ecda8..2a97c02 100644
--- a/meta/recipes-core/dbus/dbus.inc
+++ b/meta/recipes-core/dbus/dbus.inc
@@ -10,15 +10,22 @@  DEPENDS = "expat virtual/libintl ${@base_contains('DISTRO_FEATURES', 'x11', '${X
 DEPENDS_virtclass-native = "expat-native virtual/libintl-native"
 DEPENDS_virtclass-nativesdk = "expat-nativesdk virtual/libintl-nativesdk virtual/libx11"
 
+PR = "r1"
+
 SRC_URI = "http://dbus.freedesktop.org/releases/dbus/dbus-${PV}.tar.gz \
            file://tmpdir.patch; \
            file://dbus-1.init"
 
-inherit autotools pkgconfig gettext update-rc.d
+inherit useradd autotools pkgconfig gettext update-rc.d
 
 INITSCRIPT_NAME = "dbus-1"
 INITSCRIPT_PARAMS = "start 02 5 3 2 . stop 20 0 1 6 ."
 
+USERADD_PACKAGES = "${PN}"
+GROUPADD_PARAM_${PN} = "-r netdev"
+USERADD_PARAM_${PN} = "--system --home ${localstatedir}/lib/dbus \
+                       --no-create-home --user-group messagebus"
+
 CONFFILES_${PN} = "${sysconfdir}/dbus-1/system.conf ${sysconfdir}/dbus-1/session.conf"
 
 DEBIANNAME_${PN} = "dbus-1"
@@ -44,32 +51,7 @@  RRECOMMENDS_${PN}-lib = "${PN}"
 FILES_${PN}-dev += "${libdir}/dbus-1.0/include ${bindir}/dbus-glib-tool"
 
 pkg_postinst_dbus() {
-	# can't do adduser stuff offline
-	if [ "x$D" != "x" ]; then
-		exit 1
-	fi
-
-	MESSAGEUSER=messagebus
-	MESSAGEHOME=/var/run/dbus
-	UUIDDIR=/var/lib/dbus
-
-	mkdir -p $MESSAGEHOME
-	mkdir -p $UUIDDIR
-	chgrp "$MESSAGEUSER" "$MESSAGEHOME" 2>/dev/null || addgroup "$MESSAGEUSER"
-	chown "$MESSAGEUSER":"$MESSAGEUSER" "$MESSAGEHOME" 2>/dev/null || \
-		adduser --system --home "$MESSAGEHOME" --no-create-home --disabled-password \
-			--ingroup "$MESSAGEUSER" "$MESSAGEUSER"
-
-	chown "$MESSAGEUSER":"$MESSAGEUSER" "$UUIDDIR"
-
-	grep -q netdev: /etc/group || addgroup netdev
-
-	chown root:"$MESSAGEUSER" /usr/libexec/dbus-daemon-launch-helper
-	chmod 4754 /usr/libexec/dbus-daemon-launch-helper
-
-	# add volatile after new user/grp are created
-	echo "d messagebus messagebus 0755 /var/run/dbus none" > /etc/default/volatiles/99_dbus
-	if [ -e /etc/init.d/populate-volatile.sh ] ; then
+	if [ -z "${D}" ] && [ -e /etc/init.d/populate-volatile.sh ] ; then
 		/etc/init.d/populate-volatile.sh update
 	fi
 }
@@ -92,6 +74,18 @@  do_install() {
 	install -d ${D}${sysconfdir}/init.d
 	install -m 0755 ${WORKDIR}/dbus-1.init ${D}${sysconfdir}/init.d/dbus-1
 
+	install -d ${D}${sysconfdir}/default/volatiles
+	echo "d messagebus messagebus 0755 ${localstatedir}/run/dbus none" \
+	     > ${D}${sysconfdir}/default/volatiles/99_dbus
+
+
+	mkdir -p ${D}${localstatedir}/run/dbus ${D}${localstatedir}/lib/dbus
+
+	chown messagebus:messagebus ${D}${localstatedir}/run/dbus ${D}${localstatedir}/lib/dbus
+
+	chown root:messagebus ${D}${libexecdir}/dbus-daemon-launch-helper
+	chmod 4754 ${D}${libexecdir}/dbus-daemon-launch-helper
+
 	# disable dbus-1 sysv script on systemd installs
 	# nearly all distros call the initscript plain 'dbus', but OE-core is different
 	ln -sf /dev/null ${D}/${base_libdir}/systemd/system/dbus-1.service