coffin

secure lan file storage on a device
git clone git://parazyd.org/coffin.git
Log | Files | Refs | Submodules | README | LICENSE

commit 6ec7e0052c655bc22f8e62adadfadaef41f07040
parent 4397c9fff665abc0674d8b8511267245fad3e817
Author: parazyd <parazyd@dyne.org>
Date:   Sun,  6 Mar 2016 17:09:46 +0100

finished-ish create part

Diffstat:
Mmakehook.sh | 45+++++++++++++++++++++++++++++----------------
1 file changed, 29 insertions(+), 16 deletions(-)

diff --git a/makehook.sh b/makehook.sh @@ -16,9 +16,6 @@ hooks="$coffindot/hook" lsblk -npl | awk -F" " '{print $1}' | grep ^/dev/sd.. > ./.devs -# Hook syntax -# create:username:tombname:tombsize:passphrase - # {{{ icon MONMORT="/tmp/monmort.png" ICONB64="iVBORw0KGgoAAAANSUhEUgAAACAAAAAgEAQAAACJ4248AAAAAmJLR0T//xSrMc0AAAAJcEhZcwAA\n @@ -46,6 +43,7 @@ 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 @@ -201,7 +199,6 @@ function _mountkey { } - # {{{ zenity dialogs function _zenques { zenity \ @@ -259,7 +256,6 @@ function _main { } function _create { - vars=$(zenity \ --window-icon="$MONMORT" \ --title="Create a new tomb" \ @@ -272,14 +268,23 @@ function _create { if [[ $? = 1 ]]; then exec _main else - TOMBSIZE=${vars[(ws@:@)3]} + UNDERTAKER=${vars[(ws@:@)1]} + re='^[A-Za-z0-9]+$' + if ! [[ $UNDERTAKER =~ $re ]]; then + _zenwarn "Warning" "Invalid characters in username!" + exec _create + fi + TOMBNAME=${vars[(ws@:@)2]} + if ! [[ $TOMBNAME =~ $re ]]; then + _zenwarn "Warning" "Invalid characters in tomb name!" + exec _create + fi + TOMBSIZE=${vars[(ws@:@)3]} re='^[0-9]+$' if ! [[ $TOMBSIZE =~ $re ]]; then _zenwarn "Warning" "Invalid characters in tomb size!" exec _create fi - UNDERTAKER=${vars[(ws@:@)1]} - TOMBNAME=${vars[(ws@:@)2]} fi feats=$(zenity \ @@ -300,16 +305,16 @@ function _create { if [[ $? = 0 ]]; then bindhook=$(zenity \ --window-icon="$MONMORT" \ - --title="Make bind-hooks" \ - --text="Make your edits for the bind-hooks you wish to include in this tomb" \ + --title="bind-hooks" \ + --checkbox="Accept these bind-hooks" \ --text-info \ --editable) if [[ $? = 1 ]]; then; exec _main; fi posthook=$(zenity \ --window-icon="$MONMORT" \ - --title="Make post-hooks" \ - --text="Make your edits for the post-hooks you wish to include in this tomb" \ + --title="post-hooks" \ + --checkbox="Accept these post-hooks" \ --text-info \ --editable) if [[ $? = 1 ]]; then; exec _main; fi @@ -332,13 +337,21 @@ function _create { _zeninfo "Info" "Postponing..." && _umountkey && exec _main else # edit these to fit new values - print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${TOMBPASS}" | sudo tee $hooks - _zeninfo "Success" "$hooks written successfully!" && _umountkey && exec _main + print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${feats}" | sudo tee $hooks + if [[ -n $bindhook ]]; then + print "$bindhook" | sudo tee $coffindot/bindhooks + fi + if [[ -n $posthook ]]; then + print "$posthook" | sudo tee $coffindot/posthooks + fi + _umountkey + _zeninfo "Success" "$hooks written successfully!\nPlug the USB key in a tombox to activate it." + exec _main fi else # edit these to fit new values - print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${TOMBPASS}" | sudo tee $hooks - _zeninfo "Success" "$hooks written successfully!" && _umountkey && exec _main + print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${feats}" | sudo tee $hooks + _zeninfo "Success" "$hooks written successfully!\nPlug the USB key in the tombox to activate it." && _umountkey && exec _main fi }