Fix mount_isolation.sh to correctly pass user UID/GID and open permissions when executed with sudo

This commit is contained in:
david
2026-08-26 10:39:47 -04:00
parent b2a570b11e
commit 6c58e432eb
+4 -4
View File
@@ -28,12 +28,12 @@ fi
echo "Mounting $SHARE to $MOUNT_POINT..."
# Mount temporarily. Using uid/gid configuration allows your local user to read/write to the share.
# We fetch the current user's UID and GID dynamically.
CURRENT_UID=$(id -u)
CURRENT_GID=$(id -g)
# Fetch the real calling user's UID and GID (when run under sudo, $SUDO_UID gives the original user)
CURRENT_UID="${SUDO_UID:-$(id -u)}"
CURRENT_GID="${SUDO_GID:-$(id -g)}"
sudo mount -t cifs "$SHARE" "$MOUNT_POINT" \
-o username="$USERNAME",password="$PASSWORD",uid="$CURRENT_UID",gid="$CURRENT_GID",iocharset=utf8
-o username="$USERNAME",password="$PASSWORD",uid="$CURRENT_UID",gid="$CURRENT_GID",file_mode=0777,dir_mode=0777,iocharset=utf8,noperm
echo "Successfully mounted $SHARE to $MOUNT_POINT."
echo "Note: This mount is temporary and will automatically unmount upon reboot."