Skip to content

Commit

Permalink
Merge pull request #400 from simondeziel/backports-latest-candidate
Browse files Browse the repository at this point in the history
Backports (latest-candidate)
  • Loading branch information
tomponline committed Mar 22, 2024
2 parents 9037b43 + dcfc1b1 commit eb655b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ parts:
lxcfs:
source: https://github.com/lxc/lxcfs
source-depth: 1
#source-depth: 1
source-type: git
source-tag: lxcfs-5.0.4
build-packages:
Expand Down Expand Up @@ -1268,6 +1268,8 @@ parts:
git config user.email "noreply@lists.canonical.com"
git config user.name "LXD snap builder"
git cherry-pick -x ce8e6e973c1b4fb1261b29ec02dad069bff61c6c # sysfs: forbid write()
set +ex
craftctl default
set -ex
Expand Down
16 changes: 9 additions & 7 deletions snapcraft/commands/daemon.start
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ echo "==> Loading snap configuration"
# shellcheck disable=SC1091
. "${SNAP_COMMON}/config"

daemon_group="${daemon_group:-"lxd"}"

# Create the main directory
if [ ! -d "${SNAP_COMMON}/lxd" ]; then
echo "==> Creating ${SNAP_COMMON}/lxd"
Expand Down Expand Up @@ -272,20 +274,20 @@ for entry in dev proc sys; do
mount -o bind "/${entry}" "/var/lib/snapd/hostfs/${entry}"
done

# FIXME: Setup the "lxd" user
# Setup the "lxd" user
if ! getent passwd lxd >/dev/null 2>&1; then
echo "==> Creating \"lxd\" user"
if grep -q "^passwd.*extrausers" /etc/nsswitch.conf; then
nsenter -t 1 -m useradd --system -M -N --home /var/snap/lxd/common/lxd --shell /bin/false --extrausers lxd || true
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 /var/snap/lxd/common/lxd --shell /bin/false lxd || true
nsenter -t 1 -m useradd --system -M -N --home "${SNAP_COMMON}/lxd" --shell /bin/false lxd || true
fi
fi

# FIXME: Setup the "lxd" group
if [ "${daemon_group:-"lxd"}" = "lxd" ] && ! getent group lxd >/dev/null 2>&1; then
# Setup the "lxd" group
if [ "${daemon_group}" = "lxd" ] && ! getent group lxd >/dev/null 2>&1; then
echo "==> Creating \"lxd\" group"
if grep -q "^group.*extrausers" /etc/nsswitch.conf; then
if grep -q "^group.*extrausers" /var/lib/snapd/hostfs/etc/nsswitch.conf; then
nsenter -t 1 -m groupadd --system --extrausers lxd || true
else
nsenter -t 1 -m groupadd --system lxd || true
Expand Down

0 comments on commit eb655b9

Please sign in to comment.