clean up failure message
[monkeysphere.git] / src / share / ma / add_certifier
index 2e53455b144dc2f77e002b94038d33b8b2fca7d3..b917a7459e7a358baa43cb86159aadd0ec744788 100644 (file)
@@ -36,8 +36,6 @@ local fingerprint
 local ltsignCommand
 local trustval
 
-PROMPT=true
-
 # get options
 while true ; do
     case "$1" in
@@ -53,10 +51,6 @@ while true ; do
            depth="$2"
            shift 2
            ;;
-       -y)
-           PROMPT=false
-           shift 1
-           ;;
        *)
            if [ "$(echo "$1" | cut -c 1)" = '-' ] ; then
                failure "Unknown option '$1'.
@@ -90,7 +84,8 @@ if [ -f "$keyID" ] ; then
     # + failure 'could not read key from '\''/root/dkg.gpg'\'''
     # + echo 'could not read key from '\''/root/dkg.gpg'\'''
 
-    keyID=$(echo "$importinfo" | grep '^gpg: key ' | cut -f2 -d: | cut -f3 -d\ )
+    keyID=$(echo "$importinfo" | grep '^gpg: key ' | cut -f2 -d: | cut -f3 -d\ ) || \
+       failure "There were no gpg keys in the file $keyID."
     if [ -z "$keyID" ] || [ $(echo "$keyID" | wc -l) -ne 1 ] ; then
        failure "There was not exactly one gpg key in the file."
     fi
@@ -102,7 +97,7 @@ fi
 
 export keyID
 
-# get the full fingerprint of a key ID
+# get the full fingerprint of new certifier key
 log debug "getting fingerprint of certifier key..."
 fingerprint=$(gpg_sphere "--list-key --with-colons --with-fingerprint 0x${keyID}!" \
     | grep '^fpr:' | grep "$keyID" | cut -d: -f10)
@@ -114,7 +109,7 @@ fi
 log info "key found:"
 gpg_sphere "--fingerprint 0x${fingerprint}!"
 
-if [ "$PROMPT" = true ] ; then
+if [ "$PROMPT" = "true" ] ; then
     echo "Are you sure you want to add the above key as a"
     read -p "certifier of users on this system? (y/N) " OK; OK=${OK:-N}
     if [ "${OK/y/Y}" != 'Y' ] ; then
@@ -126,6 +121,7 @@ fi
 
 # export the key to the core keyring so that the core can sign the
 # new certifier key
+log debug "exporting retrieved certifier key to core keyring..."
 gpg_sphere "--export 0x${fingerprint}!" | gpg_core --import
 
 case "$trust" in
@@ -154,13 +150,15 @@ EOF
     )
 
 # core ltsigns the newly imported certifier key
+log debug "executing core ltsign script..."
 if echo "$ltsignCommand" | \
-    gpg_core --quiet --command-fd 0 --edit-key "0x${fingerprint}!" ; then
+    gpg_core --command-fd 0 --edit-key "0x${fingerprint}!" ; then
 
     # transfer the new sigs back to the sphere keyring
     gpg_core_sphere_sig_transfer
 
     # update the sphere trustdb
+    log debug "updating sphere trustdb..."
     gpg_sphere "--check-trustdb"
 
     log info "Identity certifier added."