# Runs with the target root as the current directory.

_fix_helper() {
    local h=usr/libexec/dbus-daemon-launch-helper
    [ -e "$h" ] || return 0
    systemd-sysusers --root=. || echo "warning: systemd-sysusers failed"
    local gid
    gid=$(awk -F: '$1 == "messagebus" { print $3 }' etc/group)
    if [ -n "$gid" ]; then
        chgrp "$gid" "$h" && chmod 4750 "$h"   # chgrp clears setuid: chmod after it
    else
        echo "warning: no group messagebus in etc/group; $h stays root-only"
    fi
}

post_install() { _fix_helper; }
post_upgrade() { _fix_helper; }
