From 69e8f34e37d861761e331e1590ca07636be2b232 Mon Sep 17 00:00:00 2001 From: Narrat Date: Sat, 24 Jun 2023 01:15:00 +0200 Subject: [PATCH] mount_tomb: make use of ACL in a specific location Namely /run/media/$USER, which was introduced as a replacement for the classic /media. Main motiviation being, that $USER_B shouldn't get access to or information about mounted devices from $USER_A. The mount point itself is owned by root, therefore one needs currently to know the name of the mountpoint to change to the location. Other tools for mounting media like udisksctl set ACL to allow the owner to use it normally (autocompletion and such). Fixes #461 --- tomb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tomb b/tomb index 5f97bcaf..67b3894f 100755 --- a/tomb +++ b/tomb @@ -64,6 +64,7 @@ typeset -i DECLOAKIFY=1 typeset -i RESIZER=1 typeset -i RECOLL=1 typeset -i QRENCODE=1 +typeset -i ACL=1 # Default mount options typeset MOUNTOPTS="rw,noatime,nodev" @@ -896,7 +897,7 @@ function _print() { _list_optional_tools() { typeset -a _deps _deps=(gettext dcfldd shred steghide) - _deps+=(resize2fs tomb-kdb-pbkdf2 argon2 qrencode recoll unoconv lsof) + _deps+=(resize2fs tomb-kdb-pbkdf2 argon2 qrencode recoll unoconv lsof setfacl) for d in $_deps; do _print "`which $d`" done @@ -959,6 +960,8 @@ _ensure_dependencies() { command -v recoll 1>/dev/null 2>/dev/null || RECOLL=0 # Check for QREncode for paper backups of keys command -v qrencode 1>/dev/null 2>/dev/null || QRENCODE=0 + # Check for acl/setfacl for setting ACL at the mount location + command -v setfacl 1>/dev/null 2>/dev/null || ACL=0 } # }}} - Commandline interaction @@ -2288,8 +2291,11 @@ mount_tomb() { tombmount="$2" [[ -z "$tombmount" ]] && { tombmount="/media/$TOMBNAME" - [[ -d /media ]] || { # no /media found, adopting /run/media/$USER (udisks2 compat) - tombmount="/run/media/$_USER/$TOMBNAME" + [[ -d /media ]] || { + # no /media found, adopting /run/media/$USER to match behaviour + # of tools following the notion to mount in that location (like udisks2) + local runmedia="/run/media/$_USER" + tombmount="$runmedia/$TOMBNAME" } _message "Mountpoint not specified, using default: ::1 mount point::" "$tombmount" } @@ -2382,6 +2388,12 @@ mount_tomb() { # we need root from here on _sudo mkdir -p "$tombmount" + # set ACL on /run/media/$_USER/ to match behaviour (see #461) + # tmpfs -> it doesn't know acl/noacl mount options -> no check + [[ $ACL == 1 ]] && [[ -s $runmedia ]] && { + _sudo setfacl -m u:"$_USER":r-x "$runmedia" + } + # Default mount options are overridden with the -o switch { option_is_set -o } && { local oldmountopts=$MOUNTOPTS