From 6c58e432eb8748670f7b81a0c5200e1105548ea3 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 26 Aug 2026 10:39:47 -0400 Subject: [PATCH] Fix mount_isolation.sh to correctly pass user UID/GID and open permissions when executed with sudo --- mount_isolation.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mount_isolation.sh b/mount_isolation.sh index e113b12..74c0ab7 100755 --- a/mount_isolation.sh +++ b/mount_isolation.sh @@ -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."