commit c7506440481110f3c02d35b7d24518af8aee0a22
parent 27f1af84b6f04cf5686dcdef46dca46a4f796810
Author: parazyd <parazyd@dyne.org>
Date: Wed, 2 Mar 2016 22:06:09 +0100
fixes
Diffstat:
M | makehook.sh | | | 127 | +++++++++++++++++++++++++++++-------------------------------------------------- |
1 file changed, 47 insertions(+), 80 deletions(-)
diff --git a/makehook.sh b/makehook.sh
@@ -45,7 +45,6 @@ function _sudowrong {
fi
}
# }}}
-
# {{{ Some pinentry code shamelessly stolen from tomb
# Ask user for a password
# Wraps around the pinentry command, from the GnuPG project, as it
@@ -170,28 +169,30 @@ _is_found() {
# {{{ _clean - Clean function, removes sensitive stuff from memory
function _clean {
- sudo umount $keymount && sudo rmdir $keymount
unset $?
local rr="$RANDOM"
while [[ ${#rr} -lt 500 ]]; do
rr+="$RANDOM"
done
-
command="$rr"; unset command
- UNDERTAKER="$rr"; unset UNDERTAKER
TOMBPASS="$rr"; unset TOMBPASS
TOMBSIZE="$rr"; unset TOMBSIZE
+ TOMBNAME="$rr"; unset TOMBNAME
+ UNDERTAKER="$rr"; unset UNDERTAKER
+ happenz="$rr"; unset happenz
sudoassword="$rr"; unset sudoassword
tombtmp="$rr"; unset tombtmp
- TOMBNAME="$rr"; unset TOMBNAME
}
# }}}
+function _umountkey { sudo umount $keymount && sudo rmdir $keymount }
function _mountkey {
- if ! [[ -d $keymount ]]; then
- sudo mkdir -p $keymount
+ if [[ -d $keymount ]]; then
+ _zenwarn "Warning" "Something is already mounted on $keymount. Please check and re-run."
+ _clean && exit
fi
-
+
+ sudo mkdir -p $keymount
sudo mount $USBKEY $keymount
if ! [[ -d $coffindot ]]; then
@@ -200,6 +201,7 @@ function _mountkey {
}
+
# {{{ zenity dialogs
function _zenques {
zenity \
@@ -258,78 +260,43 @@ function _main {
function _create {
UNDERTAKER=$(_zenentry "Choose username" "Choose a username for your tombox" "foobar")
- res=$?
-
- case $res in
- 0)
- TOMBNAME=$(_zenentry "Choose tomb name" "Choose a name for your new tomb" "foobar")
- res=$?
-
- case $res in
- 0)
- TOMBPASS=$(_zenentry "Choose password" "Choose a password for your tomb's keyfile" "9898yvc0982yh08H@*Y@(Y*C")
- res=$?
-
- case $res in
- 0)
- TOMBSIZE=$(_zenentry "Choose tomb size" "Choose the size of your tomb in MiB" "100")
- res=$?
-
- case $res in
- 0)
- USBKEY=$(zenity \
- --window-icon="$MONMORT" \
- --title="Choose USB key" \
- --list \
- --hide-header \
- --text="Choose your USB key to use" \
- --column=Device \
- $(cat ./.devs)
- )
- _sudo
- _mountkey
- if [[ -f $hooks ]]; then
- _zenques "Warning! There is already an existing hook. Do you want to overwrite?"
- res=$?
- case $res in
- 0)
- print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${TOMBPASS}" | sudo tee $hooks
- _zeninfo "Success" "$hooks written successfully!"
- _clean
- _main
- ;;
- 1)
- _zeninfo "Info" "Postponing..."
- _clean
- _main
- ;;
- esac
- else
- print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${TOMBPASS}" | sudo tee $hooks
- _zeninfo "Success" "$hooks written successfully!"
- _clean
- _main
- fi
- ;;
- 1)
- _main
- ;;
- esac
- ;;
- 1)
- _main
- ;;
- esac
- ;;
- 1)
- _main
- ;;
- esac
- ;;
- 1)
- _main
- ;;
- esac
+ if [[ $? = 1 ]]; then; exec _main; fi
+
+ TOMBNAME=$(_zenentry "Choose tomb name" "Choose a name for your new tomb" "foobar")
+ if [[ $? = 1 ]]; then; exec _main; fi
+
+ TOMBPASS=$(_zenentry "Choose password" "Choose a password for your tomb's keyfile" "891y981hy97*HY(*YC&h89h21")
+ if [[ $? = 1 ]]; then; exec _main; fi
+
+ TOMBSIZE=$(_zenentry "Choose tomb size" "Choose the size of your tomb in MiB" "100")
+ if [[ $? = 1 ]]; then; exec _main; fi
+
+
+ USBKEY=$(zenity \
+ --window-icon="$MONMORT" \
+ --title="Choose USB key" \
+ --list \
+ --hide-header \
+ --text="Choose your USB key to use" \
+ --column=Device \
+ $(cat ./.devs))
+
+ _sudo
+ _mountkey
+ if [[ -f $hooks ]]; then
+ _zenques "Warning! There is already an existing hook. Do you want to overwrite?"
+ if [[ $? = 1 ]]; then
+ _zeninfo "Info" "Postponing..." && _umountkey && exec _main
+ else
+ print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${TOMBPASS}" | sudo tee $hooks
+ _zeninfo "Success" "$hooks written successfully!" && _umountkey && exec _main
+ fi
+ else
+ print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${TOMBPASS}" | sudo tee $hooks
+ _zeninfo "Success" "$hooks written successfully!" && _umountkey && exec _main
+ fi
+
}
+function _ { rm .devs }
_main