Hermenegildo - 2025-05-26

Esteemed community,
I am trying to dynamically mount a non-system, encrypted partition on a external hard drive on Fedora 42 using Veracrypt from the veracrypt-1.26.14-1.src.rpm. To this end, I created a rule ACTION=="add", SUBSYSTEM=="block", ATTRS{serial}=="1239238573726448294", RUN+="/home/amica/mount_veracrypt.sh" for the userspace device manager (udev) which executes a script containing the following command veracrypt --text --non-interactive --mount "$DEVICE_PATH" --keyfiles="$KEYFILE" "$MOUNT_POINT" when the device becomes connected. While the script mounts the partition successfully if executed from my standard user account using sudo it fails to do so when the device becomes connected and the UDEV rule gets triggered. Logging the script's error stream I get this generic error:

2025-05-26 12:27:51 - Error: Operation failed due to one or more of the following:
2025-05-26 12:27:51 - - Incorrect keyfile(s).
2025-05-26 12:27:51 - - Incorrect password.
2025-05-26 12:27:51 - - Incorrect Volume PIM number.
2025-05-26 12:27:51 - - Incorrect PRF (hash).
2025-05-26 12:27:51 - - Not a valid volume.
2025-05-26 12:27:51 - - Volume uses an old algorithm that has been removed.
2025-05-26 12:27:51 - - TrueCrypt format volumes are no longer supported.
2025-05-26 12:27:53 - Error: fusermount: mount failed: Operation not permitted

As I am unsure how to proceed from here, I decided to seek your advice. How would you start comparing the difference in environment from which the script is executed in the two scenarios (manually vs triggered by udev rule)? Any suggestion is appreciated.