2011-11-17 14:47:40 +01:00
|
|
|
#!/bin/zsh
|
|
|
|
#
|
|
|
|
# Undertaker, auxiliary command for Tomb
|
|
|
|
#
|
|
|
|
# Tomb is a tool to operate file encryption of private and secret data
|
|
|
|
#
|
|
|
|
# Undertaker is a tool to retrieve tomb keys from various sources
|
|
|
|
#
|
2011-12-01 21:39:10 +01:00
|
|
|
# {{{ Copyleft (C) 2011 Denis Roio <jaromil@dyne.org>
|
2011-11-17 14:47:40 +01:00
|
|
|
#
|
|
|
|
# This source code is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This source code is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# Please refer to the GNU Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Public License along with
|
|
|
|
# this source code; if not, write to:
|
|
|
|
# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
2011-12-01 21:39:10 +01:00
|
|
|
# }}}
|
2011-11-17 14:47:40 +01:00
|
|
|
|
|
|
|
# first of all source the tomb core functions
|
|
|
|
which tomb > /dev/null
|
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
print "$fg[red][!]$fg[white] Tomb command not found, operation aborted."; exit 1
|
|
|
|
fi
|
|
|
|
source tomb source
|
|
|
|
|
|
|
|
if ! [ $1 ] ; then
|
2011-12-01 21:39:10 +01:00
|
|
|
_warning "an argument is missing, the undertaker is confused"
|
|
|
|
_failure "usage: undertaker url://host:path/to/tomb.key"
|
2011-11-17 14:47:40 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
ARG1=${1}
|
|
|
|
|
|
|
|
check_bin
|
|
|
|
|
2011-12-01 21:39:10 +01:00
|
|
|
_message "Undertaker will look for ${ARG1}"
|
2011-11-17 14:47:40 +01:00
|
|
|
|
|
|
|
baseurl=${ARG1%//*}
|
|
|
|
|
|
|
|
case $baseurl in
|
|
|
|
bluetooth:)
|
2011-12-01 21:39:10 +01:00
|
|
|
_message "access to bluetooth protocol requested"
|
2011-11-17 14:47:40 +01:00
|
|
|
which obexftp &> /dev/null
|
|
|
|
if [[ $? != 0 ]]; then
|
2011-12-01 21:39:10 +01:00
|
|
|
die "obexftp not found, needed for bluetooth: operation aborted."
|
2011-11-17 14:47:40 +01:00
|
|
|
fi
|
|
|
|
keytmp=`safe_dir undertaker`
|
|
|
|
cd $keytmp
|
|
|
|
# fetch key from bluetooth, url format: bluetooth://55:33:44:55:66/file/path
|
|
|
|
obexdevpath=${ARG1#*//}
|
|
|
|
obexdev=${obexdevpath%%/*}
|
|
|
|
obexpath=${obexdevpath#*/}
|
2011-12-01 21:39:10 +01:00
|
|
|
_message "obex device: $obexdev"
|
|
|
|
_message "obex path: $obexpath"
|
2011-11-17 14:47:40 +01:00
|
|
|
obexftp -b $obexdev -g $obexpath
|
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
rmdir ${keytmp}
|
2011-12-01 21:39:10 +01:00
|
|
|
die "a problem occurred retreiving the key via bluetooth."
|
2011-11-17 14:47:40 +01:00
|
|
|
fi
|
|
|
|
# print out the key on stdout
|
|
|
|
cat $obexpath >&1
|
|
|
|
# wipe out the key
|
2011-12-01 21:39:10 +01:00
|
|
|
${=WIPE} $obexpath
|
2011-11-17 14:47:40 +01:00
|
|
|
cd -
|
|
|
|
rmdir ${keytmp}
|
|
|
|
|
|
|
|
# tombkey="basename $obexpath"
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
file:)
|
2011-12-01 21:39:10 +01:00
|
|
|
_message "local file access requested"
|
|
|
|
die "TODO"
|
2011-11-17 14:47:40 +01:00
|
|
|
;;
|
|
|
|
http:)
|
2011-12-01 21:39:10 +01:00
|
|
|
_message "access to web protocol requested"
|
|
|
|
die "TODO"
|
2011-11-17 14:47:40 +01:00
|
|
|
;;
|
|
|
|
ssh:)
|
2011-12-01 21:39:10 +01:00
|
|
|
_message "access to secure shell requested"
|
|
|
|
die "TODO"
|
2011-11-17 14:47:40 +01:00
|
|
|
;;
|
|
|
|
*)
|
2011-12-01 21:39:10 +01:00
|
|
|
die "url protocol not recognized: $baseurl"
|
2011-11-17 14:47:40 +01:00
|
|
|
;;
|
|
|
|
esac
|