coffin

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

commit 64c9bd1375a4fc023e9321e0cd1d42112d931cff
parent 6c43eef14904d2a912ce2444cc781ea8b2ed905c
Author: parazyd <parazyd@dyne.org>
Date:   Thu, 28 Jan 2016 18:32:46 +0100

fixed to work better with multiple tombs and keys

Diffstat:
Mbin/sacrist | 25++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/bin/sacrist b/bin/sacrist @@ -9,6 +9,7 @@ happenz=$2 keyuuid=`blkid $device | awk -F\" '{print $2}'` tmptombs="/tmp/tombs" +temptombs="/tmp/tombs2" lockfile="/tmp/coffinlock" keymount="/media/tombkey" coffindot=".coffin" @@ -26,19 +27,19 @@ _mountkey() { mount $device $keymount } -_getundertaker() { +_getttab() { if [[ $1 == "user" ]]; then - undertaker=`cat $keymount/$coffindot/undertaker | awk -F: '{print $1}'` + undertaker=`cat $keymount/$coffindot/ttab | awk -F: '{print $1}'` chown -R $undertaker $keymount/$coffindot elif [[ $1 == "tombname" ]]; then - tombname=`cat $keymount/$coffindot/undertaker | awk -F: '{print $2}'` + tombname=`cat $keymount/$coffindot/ttab | awk -F: '{print $2}'` elif [[ $1 == "graveyard" ]]; then - graveyard=`cat $keymount/$coffindot/undertaker | awk -F: '{print $3}'` + graveyard=`cat $keymount/$coffindot/ttab | awk -F: '{print $3}'` fi } _hashkey() { - _getundertaker tombname + _getttab tombname cat $keymount/$coffindot/$tombname.key \ | sha512sum \ | awk -F" " '{print $1}' @@ -46,7 +47,7 @@ _hashkey() { _compare_key() { keyhash=`_hashkey` - if [[ ( `cat $tmptombs | grep $keyhash` ) ]]; then + if [[ ( `cat $tmptombs | grep $keyhash | grep $keyuuid` ) ]]; then happenz=close else happenz=open @@ -64,21 +65,23 @@ _msg() { if [[ $happenz == "CREATE" ]]; then _mountkey - if [[ -f "$keymount/$coffindot/undertaker" ]]; then - _getundertaker user; _msg info "Got undertaker: $undertaker" + if [[ -f "$keymount/$coffindot/ttab" ]]; then + _getttab user; _msg info "Got undertaker: $undertaker" _compare_key if [[ $happenz == "close" ]]; then _msg info "Comparekey true" tombname=`cat $tmptombs | grep $keyhash | awk -F: '{print $3}'`; _msg info "Got tombname: $tombname" tomb slam $tombname - cat $tmptombs | grep -v $keyhash > $tmptombs; _msg info "Put stuff in $tmptombs" + cp $tmptombs $temptombs + grep -v "$keyhash" $temptombs > $tmptombs; _msg info "Put stuff in $tmptombs" + rm $temptombs umount $keymount; rmdir $keymount; _msg info "Unmounted usb" elif [[ $happenz == "open" ]]; then _msg info "Comparekey false" - _getundertaker tombname; _getundertaker graveyard; _msg info "Got tombname and graveyard" + _getttab tombname; _getttab graveyard; _msg info "Got tombname and graveyard" - echo "$undertaker:$graveyard:$tombname:$keyhash:$keyuuid" >> $tmptombs ; _msg info "Added it to $tmptombs" + echo -e "$undertaker:$graveyard:$tombname:$keyhash:$keyuuid\n" >> $tmptombs ; _msg info "Added it to $tmptombs" su $undertaker -c "tomb open $graveyard/$tombname -k $keymount/$coffindot/$tombname.key --unsafe --tomb-pwd lalala" umount $keymount; rmdir $keymount; _msg info "Unmounted usb"