3 ### List the available keeper sets
5 ### (c) 2012 Mark Wooding
8 ###----- Licensing notice ---------------------------------------------------
10 ### This file is part of the distorted.org.uk key management suite.
12 ### distorted-keys is free software; you can redistribute it and/or modify
13 ### it under the terms of the GNU General Public License as published by
14 ### the Free Software Foundation; either version 2 of the License, or
15 ### (at your option) any later version.
17 ### distorted-keys is distributed in the hope that it will be useful,
18 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ### GNU General Public License for more details.
22 ### You should have received a copy of the GNU General Public License
23 ### along with distorted-keys; if not, write to the Free Software Foundation,
24 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 case "${KEYSLIB+t}" in t) ;; *) echo >&2 "$0: KEYSLIB unset"; exit 1 ;; esac
28 . "$KEYSLIB"/keyfunc.sh
32 List the available keeper sets, and the recovery secrets they protect.
35 case $# in 0) ;; *) usage_err ;; esac
37 ## Collect information about available recovery keys.
38 if [ -d $KEYS/recov ]; then
41 ## No keeper sets encountered yet.
44 ## Iterate over recovery keys.
46 if [ ! -d $r ]; then continue; fi
48 ## Collect the current instance number.
49 rcur=$(readlink $r/current)
52 ## Now work through the instances of this recovery key.
55 ## Get the instance number.
57 case "$i" in *[!0-9]*) continue ;; esac
59 ## Read the keeper sharing parameters.
60 for kp in $ri/*.param; do
62 ## Find the keeper name.
63 k=${kp##*/}; k=${k%.param}
65 ## Add this keeper to the list if we haven't already, and clear the
66 ## list of associated recovery keys.
67 case $kk in *:$k:*) ;; *) kk=$kk$k:; unset rr_$k ;; esac
69 ## Associate this recovery key instance with the keeper set, and
70 ## store information about the sharing.
71 eval t_$k_$r_$i='$(sharethresh $kp)'
72 eval "rr_$k=\${rr_$k+\$rr_$k }$r/$i"
78 ## Now work through the keeper sets.
79 if [ ! -d $KEYS/keeper ]; then
80 echo >&2 "$quis: no keepers"
84 ## Iterate over the keeper sets.
88 ## Make sure that this really looks like a keeper set.
89 checkword "keeper set label" "$k"
90 if [ ! -r $k/meta ]; then continue; fi
92 ## Read the keeper metadata, and print basic stuff about it.
95 case $firstp in t) firstp=nil ;; nil) echo ;; esac
96 echo "$k profile=$profile n=$n"
98 ## Print the sharing information, including the keeper nubids.
100 i=0; while [ $i -lt $n ]; do
101 nubid=$(cat $k/$i/nubid)
102 echo " $i nubid=$nubid"
106 ## Print the associated recovery keys.
111 ## Pick out the hash and instance number, and extract the rest of the
112 ## data from this recovery key.
113 r=${ri%/*} i=${ri##*/}
116 ## Start assembling an information line.
119 ## Determine the revelation status of the recovery key. There are
120 ## maybe things to check: the revelation of the key by explicit
121 ## instance, or, if applicable, as the current instance. Build in the
122 ## positional parameters a sequence of DIR WHAT pairs to process.
125 case $rcur in $i) set "$@" $r.current current ;; esac
126 while [ $# -gt 0 ]; do
127 rd=$SAFE/keys.reveal/$1 attr=$2; shift 2
128 if [ ! -d $rd ]; then
129 case $attr in revealed) ;; *) info="$info $attr" ;; esac
130 elif [ -f $rd/nub ]; then
131 info="$info $attr=nub"
134 i=0; while [ $i -lt $n ]; do
135 if [ -f $rd/$k.$i.share ]; then ss=${ss+$ss,}$i; fi
138 info="$info $attr=$ss"
142 ## Print this information.
148 ###----- That's all, folks --------------------------------------------------