Added insecure fallback to /tmp when /dev/shm does not exist

This commit is contained in:
Dionysus 2023-06-13 19:12:24 -04:00
parent 5426e53daf
commit 6a932074b5
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE

12
pass
View File

@ -17,13 +17,17 @@ fi
mkdir -p $PASS_DIR mkdir -p $PASS_DIR
edit() { edit() {
local template="pw.XXXXXXXXXXXXX"
if [ -d /dev/shm ] && [ -w /dev/shm ] && [ -x /dev/shm ]; then if [ -d /dev/shm ] && [ -w /dev/shm ] && [ -x /dev/shm ]; then
tmp=$(mktemp -u /dev/shm/pw.XXXXXXXXXX) tmp=$(mktemp -d /dev/shm/$template)
trap "rm -rf $tmp" EXIT
else else
echo "error: /dev/shm does not exist or is missing permissions required for temporary files" echo "warning: /dev/shm does not exist or is missing permissions required for temporary files (using insecure fallback to /tmp directory)"
exit 1 tmp=$(mktemp -d /tmp/$template)
fi fi
rm_tmp() {
rm -rf "$tmp"
}
trap rm_tmp EXIT
if [ -f $PASS_DIR/$1.gpg ]; then if [ -f $PASS_DIR/$1.gpg ]; then
gpg -d -o $tmp $GPG_OPTS $PASS_DIR/$1.gpg || exit 1 gpg -d -o $tmp $GPG_OPTS $PASS_DIR/$1.gpg || exit 1
$EDITOR $tmp $EDITOR $tmp