From 9b88c38ae27739a86aadec0699677befe8487ae9 Mon Sep 17 00:00:00 2001 From: Logan G Date: Mon, 20 Jan 2025 16:11:02 -0700 Subject: [PATCH] qmnt - Fixed permissions flag when running as sudo or doas --- tools/qmnt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/qmnt b/tools/qmnt index 29b86f2..1d64afb 100755 --- a/tools/qmnt +++ b/tools/qmnt @@ -135,13 +135,20 @@ if [[ "$#" -eq 0 ]]; then print_help fi +EFF_UID="${EFF_UID:-$UID}" +if [[ ! -z $SUDO_USER ]]; then + EFF_UID=$SUDO_UID +elif [[ ! -z $DOAS_USER ]]; then + EFF_UID=$(id -u $DOAS_USER) +fi + for arg in "$@"; do case "${arg}" in "-h" | "--help") print_help ;; "-p" | "--permissions") - MOUNT_OPTS+=",uid=$UID,gid=$(id -g $UID)" + MOUNT_OPTS+=",uid=$EFF_UID,gid=$(id -g $EFF_UID)" ;; "-u" | "--uuid") ALLOW_UUID="1" @@ -191,12 +198,14 @@ fi trap - EXIT + if [[ -z "${DEFAULT_MOUNT_OPTS["$TYPE"]}" ]]; then MOUNT_OPTS="${DEFAULT_MOUNT_OPTS["OTHER"]},${MOUNT_OPTS}" else MOUNT_OPTS="${DEFAULT_MOUNT_OPTS["$TYPE"]},${MOUNT_OPTS}" fi + [[ ! -d "${MOUNT_FOLDER}" && -z $DRY_RUN ]] && mkdir "${MOUNT_FOLDER}" [[ ! -d "${MOUNT_FOLDER}/${LABEL}" && -z $DRY_RUN ]] && mkdir "${MOUNT_FOLDER}/${LABEL}"