commit be0c9ce7183141ece414ef8a83812e5ab63c5e46
parent c3006f50374f70376b83e94d1eb571e882457184
Author: Jaromil <jaromil@dyne.org>
Date: Tue, 17 Jan 2012 19:01:20 +0100
undertaker cleanups
merging boyska's branch to current master
changes some previous names of options:
--path --batch --poll
work in progress, refers to issues: #71 #70 #69 #58 #42 #27 #5
Diffstat:
3 files changed, 47 insertions(+), 33 deletions(-)
diff --git a/doc/tomb.1 b/doc/tomb.1
@@ -135,11 +135,10 @@ mount a tomb read-only (ro) to prevent any modification of its data,
or to experiment with other settings (if you really know what you are
doing) see the mount(8) man page.
.B
-.IP "--ignore-swap"
-By default, Tomb will abort any create and open operation if swap is used (see
-SWAP section for details). This flag will disable this behaviour. NOTE: it is
-not secure to do so, unless you know that your swap is encrypted
-
+.IP "-f"
+Force flag, currently used to override swap checks, might be
+overriding more wimpy behaviours in future, but make sure you know
+what you are doing if you force an operation...
.B
.IP "-h"
Display a help text and quit
@@ -154,10 +153,8 @@ Run more quietly
Print more information while running, for debugging purposes
.B
.IP "--no-color"
-Don't use colors; useful for old terminals or integration in other scripts
-.B
-.IP "--machine-parseable"
-The output is easily parseable via software. This implies --no-color
+Don't use colors; useful for old terminals or integration in other
+scripts parsers
.SH HOOKS
diff --git a/src/tomb b/src/tomb
@@ -124,9 +124,7 @@ progress() {
# progress create 80 please enter password
# progress create 90 formatting the tomb
# progress create 100 tomb created successfully
- local -a prog_opts
- zparseopts -a prog_opts -D -E -machine-parseable
- if ! option_is_set --machine-parseable; then
+ if ! option_is_set --batch; then
return
fi
print "[m][P][$1][$2][$3]" >&2
@@ -1683,10 +1681,6 @@ main() {
shift
fi
### End parsing command-specific options
-
- if option_is_set --machine-parseable; then
- opts[--no-color]=''
- fi
if ! option_is_set --no-color; then
autoload colors; colors
fi
diff --git a/src/undertaker b/src/undertaker
@@ -6,7 +6,8 @@
#
# Undertaker is a tool to retrieve tomb keys from various sources
#
-# {{{ Copyleft (C) 2011 Denis Roio <jaromil@dyne.org>
+# {{{ Copyleft (C) 2012 Dyne.org foundation
+# 2011-2012 Denis Roio <jaromil@dyne.org>
#
# 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
@@ -24,6 +25,10 @@
# }}}
+# signal traps (special funcs in Zsh)
+TRAPKILL() die "KILL signal caught, undertaker aborting."
+TRAPSTOP() die "STOP signal caught, undertaker aborting."
+
# first of all source the tomb core functions
which tomb > /dev/null
if [[ $? != 0 ]]; then
@@ -38,6 +43,8 @@ key_found() {
print "$fg[white][found] $1"
}
+
+
function undertaker_scheme() {
zparseopts -D -print-path=print_path
@@ -46,6 +53,8 @@ function undertaker_scheme() {
local keypath
keypath=$2
case $scheme in
+
+
bluetooth)
#TODO: support --print-path
act "access to bluetooth protocol requested"
@@ -62,20 +71,28 @@ function undertaker_scheme() {
obexpath=${obexdevpath#*/}
act "obex device: $obexdev"
act "obex path: $obexpath"
- obexftp -b $obexdev -g $obexpath
- if [[ $? != 0 ]]; then
- rmdir ${keytmp}
- die "a problem occurred retreiving the key via bluetooth."
- fi
+ obexftp -b $obexdev -g $obexpath
+ if [[ $? != 0 ]]; then
+ rmdir ${keytmp}
+ die "a problem occurred retreiving the key via bluetooth."
+ fi
# print out the key on stdout
- cat $obexpath >&1
- # wipe out the key
- ${WIPE[@]} $obexpath
- cd -
- rmdir ${keytmp}
-
+ if option_is_set --path; then
+ echo $obexpath
+ # up to the caller to delete the key
+ # TODO: --path should have the directory where to put the key
+ # as argument, instead of creating keytmp
+ else
+ cat `pwd`/$obexpath >&1
+ # wipe out the key
+ ${WIPE[@]} $obexpath
+ cd -
+ rmdir ${keytmp}
+ fi
+
# tombkey="basename $obexpath"
;;
+
file)
if ! [[ -f $keypath ]]; then
error "Invalid path $keypath"
@@ -100,6 +117,7 @@ function undertaker_scheme() {
fi
done
;;
+
udisks)
#It implements automounting using udisks; udisks is a (recently)
#new technology, so we can't rely on it being present
@@ -121,10 +139,14 @@ function undertaker_scheme() {
fi
done
;;
+
near)
###Given the path to the tomb, search the key near to that
undertaker_scheme file ${keypath}.key
;;
+
+
+
*)
if ! which undertaker-$scheme &> /dev/null; then
error "url protocol not recognized: $scheme"
@@ -135,21 +157,22 @@ function undertaker_scheme() {
;;
esac
}
+
function main() {
typeset -A opts
- zparseopts -M -E -D -Aopts -poll -print-path -machine-parseable
+ zparseopts -M -E -D -Aopts -poll -path -batch
if ! [ $1 ] ; then
error "an argument is missing, the undertaker is confused"
act "usage: undertaker [options] url://host:path/to/tomb.key"
exit 1;
fi
local -a tomb_opts
- if [[ -n ${(k)opts[--machine-parseable]} ]]; then
- tomb_opts+='--machine-parseable'
+ if [[ -n ${(k)opts[--batch]} ]]; then
+ tomb_opts+='--batch'
fi
local -a under_opts
- if [[ -n ${(k)opts[--print-path]} ]]; then
- under_opts+='--print-path'
+ if [[ -n ${(k)opts[--path]} ]]; then
+ under_opts+='--path'
fi
local -A backupopts
for a in ${(k)opts}; do