]> granicus.if.org Git - mutt/commitdiff
Add heavily improved debugging capabilities to the PGP code.
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 20 Jan 1999 12:58:28 +0000 (12:58 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 20 Jan 1999 12:58:28 +0000 (12:58 +0000)
Anyway, the problem I observed wasn't a bug in mutt, but an expired
key. *sigh*

configure.in
pgpkey.c
pgppubring.c

index 807ea1ae6075e41e6c8090393779b4f55d561cff..c25e10e7a40aed4ebba344460ee13c04749cc495 100644 (file)
@@ -422,6 +422,9 @@ AC_ARG_ENABLE(pop, [  --enable-pop               Enable POP3 support],
        MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS pop.o"
 ])
 
+AC_ARG_ENABLE(debug, [  --enable-debug         Enable debugging support],
+       [ AC_DEFINE(DEBUG) ])
+
 AC_ARG_ENABLE(imap, [  --enable-imap              Enable IMAP support],
 [      AC_DEFINE(USE_IMAP)
        AC_CHECK_LIB(socket, socket)
index 05e257e1254b26b9f48dfbf16533cdb1ea98d7dd..281c956eab519803fa2bd3ba40bf20a379b5c101 100644 (file)
--- a/pgpkey.c
+++ b/pgpkey.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1996,1997 Michael R. Elkins <me@cs.hmc.edu>
- * Copyright (c) 1998 Thomas Roessler <roessler@guug.de>
+ * Copyright (c) 1998,1999 Thomas Roessler <roessler@guug.de>
  * 
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
@@ -456,13 +456,27 @@ KEYINFO *ki_getkeybyaddr (struct pgp_vinfo *pgp,
   int did_main_key;
   PGPUID *u;
   
+  dprint (5, (debugfile, "ki_getkeybyaddr: looking for %s <%s>.",
+             a->personal, a->mailbox));
+
+  
   for ( ; k ; k = k->next)
   {
-    if(k->flags & (KEYFLAG_REVOKED | KEYFLAG_EXPIRED | KEYFLAG_DISABLED)) 
+    dprint (5, (debugfile, "  looking at key: %s\n",
+               pgp_keyid (k)));
+    
+    if(k->flags & (KEYFLAG_REVOKED | KEYFLAG_EXPIRED | KEYFLAG_DISABLED))
+    {
+      dprint (5, (debugfile, "  key disabled/revoked/expired\n"));
       continue;
+    }
     
     if(abilities && !(k->flags & abilities))
+    {
+      dprint (5, (debugfile, "  insufficient abilities: Has %x, want %x\n",
+                 k->flags, abilities));
       continue;
+    }
     
     q = k->address;
     did_main_key = 0;
@@ -475,6 +489,7 @@ KEYINFO *ki_getkeybyaddr (struct pgp_vinfo *pgp,
     {
       u = (PGPUID *) q->data;
       r = rfc822_parse_adrlist(NULL, u->addr);
+
       
       for(p = r; p && weak_association; p = p->next) 
       {
@@ -556,19 +571,23 @@ KEYINFO *ki_getkeybystr (struct pgp_vinfo *pgp,
     
     for(; a ; a = a->next) 
     {
-
+      dprint (5, (debugfile, "ki_getkeybystr: matching \"%s\" against key %s, \"%s\": ",
+                 p, pgp_keyid (k), ((PGPUID *)a->data)->addr));
       if (!*p || mutt_strcasecmp (p, pgp_keyid(k)) == 0 ||
          (!mutt_strncasecmp(p, "0x", 2) && !mutt_strcasecmp(p+2, pgp_keyid(k))) ||
          (option(OPTPGPLONGIDS) && !mutt_strncasecmp(p, "0x", 2) &&
           !mutt_strcasecmp(p+2, k->keyid+8)) ||
          mutt_stristr(((PGPUID *)a->data)->addr,p))
       {
+       dprint (5, (debugfile, "match.\n"));
        t = mutt_new_list ();
        t->data = (void *)k;
        t->next = l;
        l = t;
        break;
       }
+      else
+       dprint (5, (debugfile, "no match.\n"));
     }
     
     if(!did_main_key && k->flags & KEYFLAG_SUBKEY && k->mainkey)
index 20782d924a2475674ad5d0ff66e24cc6d6ea4636..c093c21651cfa5f3899eb6edfa2db07cc451e5de 100644 (file)
@@ -1,19 +1,22 @@
 /*
- * Copyright (C) 1997 Thomas Roessler <roessler@guug.de>
+ * Copyright (C) 1997-1999 Thomas Roessler <roessler@guug.de>
  * 
- *     This program 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.
+ *     This program 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.
  * 
- *     This program 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.
+ *     This program 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 this program; if not, write to the Free Software
- *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *     You should have received a copy of the GNU General Public
+ *     License along with this program; if not, write to the Free
+ *     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
+ *     02139, USA.
  */ 
 
 
@@ -519,7 +522,6 @@ static KEYINFO *pgp_parse_pgp3_key(unsigned char *buff, size_t l)
   }
   
   p->keyid = safe_strdup((char *)scratch);
-
   
   return p;
 }
@@ -528,6 +530,8 @@ static KEYINFO *pgp_parse_keyinfo(unsigned char *buff, size_t l)
 {
   if(!buff || l < 2)
     return NULL;
+
+  dprint (5, (debugfile, " version: %d ", buff[1]));
   
   switch(buff[1])
   {
@@ -754,11 +758,21 @@ static KEYINFO *pgp_read_keyring(const char *fname)
       case PT_SUBKEY:
       case PT_SUBSECKEY:
       {
+       switch (pt)
+       {
+         case PT_SECKEY: dprint (5, (debugfile, "PT_SECKEY: ")); break;
+         case PT_PUBKEY: dprint (5, (debugfile, "PT_PUBKEY: ")); break;
+         case PT_SUBKEY: dprint (5, (debugfile, "PT_SUBKEY: ")); break;
+         case PT_SUBSECKEY: dprint (5, (debugfile, "PT_SUBSECKEY: ")); break;
+       }
+
        if(p)
          end = &(p->next);
        
        if(!(*end = p = pgp_parse_keyinfo(buff, l)))
           break;
+
+       dprint (5, (debugfile, " key-id: %s ", p->keyid));
        
        addr = &p->address;
 
@@ -775,30 +789,44 @@ static KEYINFO *pgp_read_keyring(const char *fname)
       
       case PT_SIG:
       {
+       dprint (5, (debugfile, "PT_SIG\n"));
        pgp_parse_sig(buff, l, p);
        break;
       }
       case PT_TRUST:
       {
+       dprint (5, (debugfile, "PT_TRUST: "));
        if(last_pt == PT_SECKEY || last_pt == PT_PUBKEY ||
           last_pt == PT_SUBKEY || last_pt == PT_SUBSECKEY)
        {
          if(buff[1] & 0x20)
+         {
+           dprint (5, (debugfile, " disabling %s\n", p->keyid));
            p->flags |= KEYFLAG_DISABLED;
+         }
        }
        else if(last_pt == PT_NAME)
+       {
          uid->trust = buff[1];
+         dprint  (5, (debugfile, " setting trust for \"%s\" to %d.\n",
+                      uid->addr, uid->trust));
+       }
        break;
       }
       case PT_NAME:
       {
        char *chr;
+
+       dprint (5, (debugfile, "PT_NAME: "));
        
        if(!addr) break;
        
        chr = safe_malloc(l);
        memcpy(chr, buff + 1, l - 1);
        chr[l-1] = '\0';
+       
+       dprint (5, (debugfile, "\"%s\"\n", chr));
+       
        mutt_decode_utf8_string(chr, chs);
        *addr = mutt_new_list();
        (*addr)->data = safe_malloc(sizeof(PGPUID));
@@ -821,6 +849,29 @@ static KEYINFO *pgp_read_keyring(const char *fname)
     }
   }
   fclose(fp);
+  
+#ifdef DEBUG
+  if (debuglevel >= 4)
+  {
+    KEYINFO *dbp;
+    LIST *lp;
+
+    fprintf (debugfile, "\n\npgp_read_keyring: START KEYRING DUMP.\n");
+    
+    for (dbp = db; dbp; dbp = dbp->next)
+    {
+      fprintf (debugfile, "%s [len=%d, flags=%d]\n", dbp->keyid, dbp->keylen, dbp->flags);
+      for (lp = dbp->address; lp; lp=lp->next)
+      {
+       fprintf (debugfile, "  %s [%d]\n", ((PGPUID *)lp->data)->addr,
+                ((PGPUID *)lp->data)->trust);
+      }
+    }
+    
+    fprintf (debugfile, "\nEND KEYRING DUMP.\n\n");
+  }
+#endif
+  
   return db;
 }