tomb

the crypto undertaker
git clone git://parazyd.org/tomb.git
Log | Files | Refs | README | LICENSE

commit 828579e10d7660155b6656f499e94119c9d8f6d9
parent 9097a6963151b904aaa47d1d33cc152fff707d12
Author: Jaromil <jaromil@dyne.org>
Date:   Fri, 14 Nov 2014 17:42:49 +0100

better parses for bind-hooks

rw global vars VERSION etc facilitate re-source in test environment

Diffstat:
Mtomb | 23+++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/tomb b/tomb @@ -39,9 +39,9 @@ # {{{ Global variables -typeset -r VERSION="1.7" -typeset -r DATE="Oct/2014" -typeset -r TOMBEXEC=$0 +typeset VERSION="1.7" +typeset DATE="Oct/2014" +typeset TOMBEXEC=$0 # Tomb is using some global variables set by the shell: # TMPPREFIX, UID, GID, PATH, TTY, USERNAME @@ -1422,7 +1422,6 @@ forge_key() { lock_tomb_with_key() { local tombpath="$1" # First argument is the path to the tomb - local tombkey="$2" # Second argument is the path to the key file [[ -n $tombpath ]] || { _warning "No tomb specified for locking." @@ -1772,14 +1771,26 @@ exec_safe_bind_hooks() { _warning "Cannot exec bind hooks without a mounted tomb." return 1 } - [[ ! -r "$mnt/bind-hooks" ]] && { + [[ -r "$mnt/bind-hooks" ]] || { _verbose "bind-hooks not found in ::1 mount point::" $mnt return 1 } typeset -Al maps # Maps of files and directories to mount typeset -al mounted # Track already mounted files and directories - maps=($(<"$mnt/bind-hooks")) + # better parsing for bind hooks checks for two separated words on + # each line, using zsh word separator array subscript + _bindhooks="`cat $mnt/bind-hooks`" + for h in ${(f)_bindhooks}; do + s="${h[(w)1]}" + d="${h[(w)2]}" + [[ "$s" = "" ]] && { _warning "bind-hooks file is broken"; return 1 } + [[ "$d" = "" ]] && { _warning "bind-hooks file is broken"; return 1 } + maps+=($s $d) + _verbose "bind-hook found: $s -> $d" + done + unset _bindhooks + for dir in ${(k)maps}; do [[ "${dir[1]}" == "/" || "${dir[1,2]}" == ".." ]] && { _warning "bind-hooks map format: local/to/tomb local/to/\$HOME"