qmnt - Fixed permissions flag when running as sudo or doas

This commit is contained in:
Logan G 2025-01-20 16:11:02 -07:00
parent c5da64b238
commit 9b88c38ae2
Signed by: logan
GPG key ID: E328528C921E7A7A

View file

@ -135,13 +135,20 @@ if [[ "$#" -eq 0 ]]; then
print_help print_help
fi 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 for arg in "$@"; do
case "${arg}" in case "${arg}" in
"-h" | "--help") "-h" | "--help")
print_help print_help
;; ;;
"-p" | "--permissions") "-p" | "--permissions")
MOUNT_OPTS+=",uid=$UID,gid=$(id -g $UID)" MOUNT_OPTS+=",uid=$EFF_UID,gid=$(id -g $EFF_UID)"
;; ;;
"-u" | "--uuid") "-u" | "--uuid")
ALLOW_UUID="1" ALLOW_UUID="1"
@ -191,12 +198,14 @@ fi
trap - EXIT trap - EXIT
if [[ -z "${DEFAULT_MOUNT_OPTS["$TYPE"]}" ]]; then if [[ -z "${DEFAULT_MOUNT_OPTS["$TYPE"]}" ]]; then
MOUNT_OPTS="${DEFAULT_MOUNT_OPTS["OTHER"]},${MOUNT_OPTS}" MOUNT_OPTS="${DEFAULT_MOUNT_OPTS["OTHER"]},${MOUNT_OPTS}"
else else
MOUNT_OPTS="${DEFAULT_MOUNT_OPTS["$TYPE"]},${MOUNT_OPTS}" MOUNT_OPTS="${DEFAULT_MOUNT_OPTS["$TYPE"]},${MOUNT_OPTS}"
fi fi
[[ ! -d "${MOUNT_FOLDER}" && -z $DRY_RUN ]] && mkdir "${MOUNT_FOLDER}" [[ ! -d "${MOUNT_FOLDER}" && -z $DRY_RUN ]] && mkdir "${MOUNT_FOLDER}"
[[ ! -d "${MOUNT_FOLDER}/${LABEL}" && -z $DRY_RUN ]] && mkdir "${MOUNT_FOLDER}/${LABEL}" [[ ! -d "${MOUNT_FOLDER}/${LABEL}" && -z $DRY_RUN ]] && mkdir "${MOUNT_FOLDER}/${LABEL}"