use trap to delete tempfiles on exit

as discussed in #2498
This commit is contained in:
openoms 2021-09-02 11:34:30 +01:00
parent 274c8e5e6f
commit 5402efea38
No known key found for this signature in database
GPG Key ID: 5BFB77609B081B65
10 changed files with 22 additions and 6 deletions

View File

@ -96,13 +96,13 @@ case $CHOICE in
result=""
while [ ${#result} -eq 0 ]
do
trap 'rm -f "$_temp"' EXIT
_temp=$(mktemp -p /dev/shm/)
l1="Please enter the new name of your LND node:\n"
l2="different name is better for a fresh identity\n"
l3="one word, keep characters basic & not too long"
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})" --inputbox "$l1$l2$l3" 13 52 2>$_temp
result=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' )
shred -u $_temp
echo "processing ..."
sleep 3
done

View File

@ -1,4 +1,6 @@
#!/bin/bash
trap 'rm -f "$_temp"' EXIT
trap 'rm -f "$_error"' EXIT
_temp=$(mktemp -p /dev/shm/)
_error=$(mktemp -p /dev/shm/)

View File

@ -1,4 +1,6 @@
#!/bin/bash
trap 'rm -f "$_temp"' EXIT
trap 'rm -f "$_error"' EXIT
_temp=$(mktemp -p /dev/shm/)
_error=$(mktemp -p /dev/shm/)

View File

@ -1,5 +1,7 @@
#!/bin/bash
clear
trap 'rm -f "$_temp"' EXIT
trap 'rm -f "$_error"' EXIT
_temp=$(mktemp -p /dev/shm/)
_error=$(mktemp -p /dev/shm/)
sudo chmod 7777 ${_error} 2>/dev/null

View File

@ -1,4 +1,6 @@
#!/bin/bash
trap 'rm -f "$_temp"' EXIT
trap 'rm -f "$_error"' EXIT
_temp=$(mktemp -p /dev/shm/)
_error=$(mktemp -p /dev/shm/)

View File

@ -1,5 +1,7 @@
#!/bin/bash
clear
trap 'rm -f "$_temp"' EXIT
trap 'rm -f "$_error"' EXIT
_temp=$(mktemp -p /dev/shm/)
_error=$(mktemp -p /dev/shm/)
sudo chmod 7777 ${_error} 2>/dev/null

View File

@ -11,12 +11,12 @@ else
echo "Opening $EDITFILE"
fi
# trap to delete on any exit
trap 'rm -f $conf' EXIT
# temp conf
conf=$(mktemp -p /dev/shm/)
# trap it
trap 'rm -f $conf' 0 1 2 5 15
dialog \
--title "Editing the $EDITFILE" \
--editbox "$EDITFILE" 200 200 2> "$conf"

View File

@ -17,6 +17,9 @@ if [ "$EUID" -ne 0 ]
exit
fi
# trap to delete on any exit
trap 'rm -f $_temp' EXIT
# tempfile
_temp=$(mktemp -p /dev/shm/)

View File

@ -64,10 +64,11 @@ function passwordToFile() {
text="Type or paste the decryption password for the $CHAIN C-lightning wallet"
fi
# write password into a file in memory
# trap to delete on any exit
trap 'rm -f $data' EXIT
# get password
data=$(mktemp -p /dev/shm/)
# trap it
trap 'rm -f $data' 0 1 2 5 15
dialog --clear \
--backtitle "Enter password" \
--title "Enter password" \

View File

@ -4,6 +4,8 @@ network=mainnet
chain=bitcoin
if [ "$1" = "-menu" ]; then
trap 'rm -f "$_temp"' EXIT
trap 'rm -f "$_error"' EXIT
_temp=$(mktemp -p /dev/shm/)
_error=$(mktemp -p /dev/shm/)