diff --git a/snapcraft/commands/daemon.start b/snapcraft/commands/daemon.start index 57f8e89ae..8f1cc2b28 100755 --- a/snapcraft/commands/daemon.start +++ b/snapcraft/commands/daemon.start @@ -274,16 +274,6 @@ for entry in dev proc sys; do mount -o bind "/${entry}" "/var/lib/snapd/hostfs/${entry}" done -# Setup the "lxd" user -if ! getent passwd lxd >/dev/null 2>&1; then - echo "==> Creating \"lxd\" user" - if grep -q "^passwd.*extrausers" /var/lib/snapd/hostfs/etc/nsswitch.conf; then - nsenter -t 1 -m useradd --system -M -N --home "${SNAP_COMMON}/lxd" --shell /bin/false --extrausers lxd || true - else - nsenter -t 1 -m useradd --system -M -N --home "${SNAP_COMMON}/lxd" --shell /bin/false lxd || true - fi -fi - # Setup the "lxd" group if [ "${daemon_group}" = "lxd" ] && ! getent group lxd >/dev/null 2>&1; then echo "==> Creating \"lxd\" group" @@ -294,6 +284,16 @@ if [ "${daemon_group}" = "lxd" ] && ! getent group lxd >/dev/null 2>&1; then fi fi +# Setup the "lxd" user +if ! getent passwd lxd >/dev/null 2>&1; then + echo "==> Creating \"lxd\" user" + if grep -q "^passwd.*extrausers" /var/lib/snapd/hostfs/etc/nsswitch.conf; then + nsenter -t 1 -m useradd --system -M -N --home "${SNAP_COMMON}/lxd" --shell /bin/false --gid lxd --extrausers lxd || true + else + nsenter -t 1 -m useradd --system -M -N --home "${SNAP_COMMON}/lxd" --shell /bin/false --gid lxd lxd || true + fi +fi + # Setup for ceph echo "==> Setting up ceph configuration" if [ "${ceph_builtin:-"false"}" = "true" ]; then