Skip to content

Commit

Permalink
snapcraft/commands/daemon.start: set primary group to lxd
Browse files Browse the repository at this point in the history
By creating the group first, the user creation can use `--gid lxd` to have the
right primary group.

Signed-off-by: Simon Deziel <[email protected]>
(cherry picked from commit cd1a18d)
(cherry picked from commit 6cba913)
  • Loading branch information
simondeziel authored and tomponline committed Apr 24, 2024
1 parent c15ec60 commit 219ce93
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions snapcraft/commands/daemon.start
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 219ce93

Please sign in to comment.