Skip to content

Commit

Permalink
Merge pull request #241 from rancher-sandbox/chown
Browse files Browse the repository at this point in the history
Use numeric uid/gid with chown
  • Loading branch information
jandubois authored Sep 14, 2021
2 parents e482531 + 68b770f commit 97ca3ae
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/cidata/cidata.TEMPLATE.d/boot/25-guestagent-base.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh

set -eux

# Create mount points
Expand All @@ -7,7 +8,8 @@ for f in $(seq 0 $((LIMA_CIDATA_MOUNTS - 1))); do
mountpointvar="LIMA_CIDATA_MOUNTS_${f}_MOUNTPOINT"
mountpoint="$(eval echo \$"$mountpointvar")"
mkdir -p "${mountpoint}"
chown "${LIMA_CIDATA_USER}" "${mountpoint}"
gid=$(id -g "${LIMA_CIDATA_USER}")
chown "${LIMA_CIDATA_UID}:${gid}" "${mountpoint}"
done

# Install or update the guestagent binary
Expand All @@ -17,7 +19,8 @@ install -m 755 "${LIMA_CIDATA_MNT}"/lima-guestagent /usr/local/bin/lima-guestage
if [ -f /etc/alpine-release ]; then
# Create directory for the lima-guestagent socket (normally done by systemd)
mkdir -p /run/user/"${LIMA_CIDATA_UID}"
chown "${LIMA_CIDATA_USER}" /run/user/"${LIMA_CIDATA_UID}"
gid=$(id -g "${LIMA_CIDATA_USER}")
chown "${LIMA_CIDATA_UID}:${gid}" /run/user/"${LIMA_CIDATA_UID}"
chmod 700 /run/user/"${LIMA_CIDATA_UID}"
# Install the openrc lima-guestagent service script
cat >/etc/init.d/lima-guestagent <<'EOF'
Expand Down

0 comments on commit 97ca3ae

Please sign in to comment.