#!/bin/sh

MESSAGEUSER=messagebus
MESSAGEHOME=/var/run/dbus
LAUNCHER=/usr/lib/dbus-1.0/dbus-daemon-launch-helper

adduser --system \
            --quiet \
            --home "$MESSAGEHOME" \
            --no-create-home \
            --disabled-password \
            --group "$MESSAGEUSER"

if ! dpkg-statoverride --list "$LAUNCHER" >/dev/null 2>&1; then
        chown root:"$MESSAGEUSER" "$LAUNCHER"
        chmod 4754 "$LAUNCHER"
fi

chown root:"$MESSAGEUSER" /etc/polkit-1/localauthority/50-local.d/50-mount.pkla

    # This is idempotent, so it's OK to do every time. The system bus' init
    # script does this anyway, but you also have to do this before a session
    # bus will work, so we do this here for the benefit of people starting
    # a temporary session bus in a chroot
dbus-uuidgen --ensure
