rework out user id processing is done to provide better diagnostic output.
authorJameson Graef Rollins <jrollins@phys.columbia.edu>
Sun, 3 Aug 2008 07:10:28 +0000 (00:10 -0700)
committerJameson Graef Rollins <jrollins@phys.columbia.edu>
Sun, 3 Aug 2008 07:10:28 +0000 (00:10 -0700)
debian/changelog
src/common

index 8bfd38731701a4e8282f482c1730c211aee7a7e6..3e7abb85af10c893b5b8326bd1f636f6283eac7d 100644 (file)
@@ -5,8 +5,10 @@ monkeysphere (0.7-1) UNRELEASED; urgency=low
 
   [ Jameson Graef Rollins ]
   * fix how check for file modification is done.
+  * rework out user id processing is done to provide more verbose log
+    output.
 
- -- Jameson Graef Rollins <jrollins@phys.columbia.edu>  Sat, 02 Aug 2008 16:41:20 -0700
+ -- Jameson Graef Rollins <jrollins@phys.columbia.edu>  Sun, 03 Aug 2008 00:00:06 -0700
 
 monkeysphere (0.6-1) experimental; urgency=low
   
index ba7df7320f69275f81e1d80cae4892649f95fcf2..f5bb3bbbf4f0d40b5ebce3229658d9fbce4ec339 100644 (file)
@@ -314,7 +314,7 @@ process_user_id() {
 
     # if the gpg query return code is not 0, return 1
     if [ "$?" -ne 0 ] ; then
-        log "  - key not found."
+        log " no primary keys found."
         return 1
     fi
 
@@ -377,10 +377,19 @@ process_user_id() {
                # output a line for the primary key
                # 0 = ok, 1 = bad
                if [ "$keyOK" -a "$uidOK" -a "$lastKeyOK" ] ; then
-                   log "  * acceptable key found."
-                   echo "0:${fingerprint}"
+                   log "  * acceptable primary key."
+                   if [ -z "$sshKey" ] ; then
+                       log "    ! primary key could not be translated."
+                   else
+                       echo "0:${sshKey}"
+                   fi
                else
-                   echo "1:${fingerprint}"
+                   log "  - unacceptable primary key."
+                   if [ -z "$sshKey" ] ; then
+                       log "   ! primary key could not be translated."
+                   else
+                       echo "1:${sshKey}"
+                   fi
                fi
                ;;
            'sub') # sub keys
@@ -404,18 +413,29 @@ process_user_id() {
            'fpr') # key fingerprint
                fingerprint="$uidfpr"
 
+               sshKey=$(gpg2ssh "$fingerprint")
+
                # if the last key was the pub key, skip
                if [ "$lastKey" = pub ] ; then
                    continue
                fi
-               
-               # output a line for the last subkey
+
+               # output a line for the primary key
                # 0 = ok, 1 = bad
                if [ "$keyOK" -a "$uidOK" -a "$lastKeyOK" ] ; then
-                   log "  * acceptable key found."
-                   echo "0:${fingerprint}"
+                   log "  * acceptable sub key."
+                   if [ -z "$sshKey" ] ; then
+                       log "    ! sub key could not be translated."
+                   else
+                       echo "0:${sshKey}"
+                   fi
                else
-                   echo "1:${fingerprint}"
+                   log "  - unacceptable sub key."
+                   if [ -z "$sshKey" ] ; then
+                       log "    ! sub key could not be translated."
+                   else
+                       echo "1:${sshKey}"
+                   fi
                fi
                ;;
        esac
@@ -429,28 +449,27 @@ process_host_known_hosts() {
     local nKeys
     local nKeysOK
     local ok
-    local keyid
+    local sshKey
     local tmpfile
 
     host="$1"
 
-    log "processing host: $host"
+    log "processing: $host"
 
     userID="ssh://${host}"
 
     nKeys=0
     nKeysOK=0
 
+    IFS=$'\n'
     for line in $(process_user_id "ssh://${host}") ; do
        # note that key was found
        nKeys=$((nKeys+1))
 
        ok=$(echo "$line" | cut -d: -f1)
-       keyid=$(echo "$line" | cut -d: -f2)
+       sshKey=$(echo "$line" | cut -d: -f2)
 
-       sshKey=$(gpg2ssh "$keyid")
         if [ -z "$sshKey" ] ; then
-            log "  ! key could not be translated."
             continue
         fi
 
@@ -582,25 +601,24 @@ process_uid_authorized_keys() {
     local nKeys
     local nKeysOK
     local ok
-    local keyid
+    local sshKey
 
     userID="$1"
 
-    log "processing user ID: $userID"
+    log "processing: $userID"
 
     nKeys=0
     nKeysOK=0
 
+    IFS=$'\n'
     for line in $(process_user_id "$userID") ; do
        # note that key was found
        nKeys=$((nKeys+1))
 
        ok=$(echo "$line" | cut -d: -f1)
-       keyid=$(echo "$line" | cut -d: -f2)
+       sshKey=$(echo "$line" | cut -d: -f2)
 
-       sshKey=$(gpg2ssh "$keyid")
         if [ -z "$sshKey" ] ; then
-            log "  ! key could not be translated."
             continue
         fi