@@@ keys.retire-recov bakery
authorMark Wooding <mdw@distorted.org.uk>
Sun, 16 Jul 2017 01:11:31 +0000 (02:11 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 16 Jul 2017 01:12:33 +0000 (02:12 +0100)
Needs manpage, makefile.

keys.retire-recov [new file with mode: 0755]

diff --git a/keys.retire-recov b/keys.retire-recov
new file mode 100755 (executable)
index 0000000..28063ea
--- /dev/null
@@ -0,0 +1,62 @@
+#! /bin/sh
+###
+### Retire an old recovery key
+###
+### (c) 2015 Mark Wooding
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of the distorted.org.uk key management suite.
+###
+### distorted-keys is free software; you can redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation; either version 2 of the License, or
+### (at your option) any later version.
+###
+### distorted-keys 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.  See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with distorted-keys; if not, write to the Free Software Foundation,
+### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+set -e
+case "${KEYSLIB+t}" in t) ;; *) echo >&2 "$0: KEYSLIB unset"; exit 1 ;; esac
+. "$KEYSLIB"/keyfunc.sh
+
+defhelp <<HELP
+RECOV I
+Retire a non-current instance I of the recovery key RECOV.
+HELP
+
+## Parse the command line.
+case $# in 2) ;; *) usage_err ;; esac
+recov=$1 inst=$2
+checkword "recovery key label" "$recov"
+checknumber "recovery key instance" "$inst"
+
+## Check that the key exists and isn't current.
+cd $KEYS/recov
+if [ ! -l $recov/current ]; then
+  echo >&2 "$quis: unknown recovery key \`$recov'"
+  exit 1
+fi
+if [ ! -d $recov/$inst ]; then
+  echo >&2 "$quis: recovery key \`$recov' has no instance $inst"
+  exit 1
+fi
+curr=$(readlink $recov/current)
+case $curr in
+  $inst)
+    echo >&2 "$quis: $inst is current instance of recovery key \`$recov'"
+    exit 1
+    ;;
+esac
+
+## Delete all of the secrets.
+rm -rf $recov/$inst
+
+###----- That's all, folks --------------------------------------------------