Fix mount_isolation.sh to correctly pass user UID/GID and open permissions when executed with sudo
This commit is contained in:
+4
-4
@@ -28,12 +28,12 @@ fi
|
|||||||
|
|
||||||
echo "Mounting $SHARE to $MOUNT_POINT..."
|
echo "Mounting $SHARE to $MOUNT_POINT..."
|
||||||
# Mount temporarily. Using uid/gid configuration allows your local user to read/write to the share.
|
# 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.
|
# Fetch the real calling user's UID and GID (when run under sudo, $SUDO_UID gives the original user)
|
||||||
CURRENT_UID=$(id -u)
|
CURRENT_UID="${SUDO_UID:-$(id -u)}"
|
||||||
CURRENT_GID=$(id -g)
|
CURRENT_GID="${SUDO_GID:-$(id -g)}"
|
||||||
|
|
||||||
sudo mount -t cifs "$SHARE" "$MOUNT_POINT" \
|
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 "Successfully mounted $SHARE to $MOUNT_POINT."
|
||||||
echo "Note: This mount is temporary and will automatically unmount upon reboot."
|
echo "Note: This mount is temporary and will automatically unmount upon reboot."
|
||||||
|
|||||||
Reference in New Issue
Block a user