[svn] GnuPG - r5092 - branches/STABLE-BRANCH-1-4/g10

svn author wk cvs at cvs.gnupg.org
Thu Jul 23 10:00:40 CEST 2009


Author: wk
Date: 2009-07-23 10:00:39 +0200 (Thu, 23 Jul 2009)
New Revision: 5092

Modified:
   branches/STABLE-BRANCH-1-4/g10/ChangeLog
   branches/STABLE-BRANCH-1-4/g10/cardglue.c
   branches/STABLE-BRANCH-1-4/g10/cardglue.h
   branches/STABLE-BRANCH-1-4/g10/gpg.c
   branches/STABLE-BRANCH-1-4/g10/tdbio.c
   branches/STABLE-BRANCH-1-4/g10/trustdb.c
   branches/STABLE-BRANCH-1-4/g10/trustdb.h
Log:
Parse EXTCAP lines from the card.
Change messages for a corrupt trustdb.


Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/ChangeLog	2009-07-22 17:21:47 UTC (rev 5091)
+++ branches/STABLE-BRANCH-1-4/g10/ChangeLog	2009-07-23 08:00:39 UTC (rev 5092)
@@ -1,3 +1,15 @@
+2009-07-23  Werner Koch  <wk at g10code.com>
+
+	* trustdb.c (how_to_fix_the_trustdb): New.
+	* tdbio.c (tdbio_invalid): Print hints on how to fix the trustdb.
+	* gpg.c (main) <aFixTrustDB>: Print hints.
+
+2009-07-22  Werner Koch  <wk at g10code.com>
+
+	* cardglue.h (struct agent_card_info_s): Add field EXTCAP.
+	* cardglue.c (agent_learn): Read KEY-ATTR.
+	(learn_status_cb): Parse EXTCAP.
+
 2009-07-21  Werner Koch  <wk at g10code.com>
 
 	* app-common.h, app-openpgp.c, iso7816.c, iso7816.h, apdu.c,

Modified: branches/STABLE-BRANCH-1-4/g10/cardglue.c
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/cardglue.c	2009-07-22 17:21:47 UTC (rev 5091)
+++ branches/STABLE-BRANCH-1-4/g10/cardglue.c	2009-07-23 08:00:39 UTC (rev 5092)
@@ -1,5 +1,5 @@
 /* cardglue.c - mainly dispatcher for card related functions.
- * Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -382,7 +382,7 @@
   if (!ctx)
     return NULL;
 
-  /* Request the serialbnumber of the card.  If we get
+  /* Request the serialnumber of the card.  If we get
      NOT_SUPPORTED or NO_SCDAEMON back, the gpg-agent either has
      disabled scdaemon or it can't be used.  We close the connection
      in this case and use our own code.  This may happen if just the
@@ -438,7 +438,7 @@
       if (app)
         goto ready; /* Yes, there is a agent with a usable card, go that way. */
       if (scd_available)
-        return NULL; /* agent avilabale but card problem. */
+        return NULL; /* Agent available but card problem. */
     }
 
 
@@ -770,6 +770,30 @@
           xfree (buf);
         }
     }
+  else if (keywordlen == 6 && !memcmp (keyword, "EXTCAP", keywordlen))
+    {
+      char *p, *p2, *buf;
+      int abool;
+
+      buf = p = unescape_status_string (line);
+      if (buf)
+        {
+          for (p = strtok (buf, " "); p; p = strtok (NULL, " "))
+            {
+              p2 = strchr (p, '=');
+              if (p2)
+                {
+                  *p2++ = 0;
+                  abool = (*p2 == '1');
+                  if (!strcmp (p, "ki"))
+                    parm->extcap.ki = abool;
+                  else if (!strcmp (p, "aac"))
+                    parm->extcap.aac = abool;
+                }
+            }
+          xfree (buf);
+        }
+    }
   else if (keywordlen == 7 && !memcmp (keyword, "KEY-FPR", keywordlen))
     {
       int no = atoi (line);
@@ -876,6 +900,9 @@
         }
     }
 
+  if (!rc)
+    agent_scd_getattr ("KEY-ATTR", info);
+
   return rc;
 }
 

Modified: branches/STABLE-BRANCH-1-4/g10/cardglue.h
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/cardglue.h	2009-07-22 17:21:47 UTC (rev 5091)
+++ branches/STABLE-BRANCH-1-4/g10/cardglue.h	2009-07-23 08:00:39 UTC (rev 5092)
@@ -69,6 +69,10 @@
     int algo;              /* Algorithm identifier.  */
     unsigned int nbits;    /* Supported keysize.  */
   } key_attr[3];      
+  struct {
+    unsigned int ki:1;     /* Key import available.  */
+    unsigned int aac:1;    /* Algorithm attributes are changeable.  */
+  } extcap;
 };
 
 struct agent_card_genkey_s {

Modified: branches/STABLE-BRANCH-1-4/g10/gpg.c
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/gpg.c	2009-07-22 17:21:47 UTC (rev 5091)
+++ branches/STABLE-BRANCH-1-4/g10/gpg.c	2009-07-23 08:00:39 UTC (rev 5092)
@@ -3343,8 +3343,8 @@
       case aGenRandom:
       case aDeArmor:
       case aEnArmor:
-      case aFixTrustDB:
 	break;
+      case aFixTrustDB:
       case aExportOwnerTrust: rc = setup_trustdb( 0, trustdb_name ); break;
       case aListTrustDB: rc = setup_trustdb( argc? 1:0, trustdb_name ); break;
       default: rc = setup_trustdb(1, trustdb_name ); break;
@@ -3874,9 +3874,7 @@
 	break;
 
       case aFixTrustDB:
-	log_error("this command is not yet implemented.\n");
-	log_error("A workaround is to use \"--export-ownertrust\", remove\n");
-	log_error("the trustdb file and do an \"--import-ownertrust\".\n" );
+        how_to_fix_the_trustdb ();
 	break;
 
       case aListTrustPath:

Modified: branches/STABLE-BRANCH-1-4/g10/tdbio.c
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/tdbio.c	2009-07-22 17:21:47 UTC (rev 5091)
+++ branches/STABLE-BRANCH-1-4/g10/tdbio.c	2009-07-23 08:00:39 UTC (rev 5092)
@@ -1499,9 +1499,9 @@
 void
 tdbio_invalid(void)
 {
-    log_error(_(
-	"the trustdb is corrupted; please run \"gpg --fix-trustdb\".\n") );
-    g10_exit(2);
+  log_error (_("Error: The trustdb is corrupted.\n"));
+  how_to_fix_the_trustdb ();
+  g10_exit (2);
 }
 
 /*

Modified: branches/STABLE-BRANCH-1-4/g10/trustdb.c
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/trustdb.c	2009-07-22 17:21:47 UTC (rev 5091)
+++ branches/STABLE-BRANCH-1-4/g10/trustdb.c	2009-07-23 08:00:39 UTC (rev 5092)
@@ -412,6 +412,27 @@
 }
 
 void
+how_to_fix_the_trustdb ()
+{
+  const char *name = trustdb_args.dbname;
+
+  if (!name)
+    name = "trustdb.gpg";
+
+  log_info (_("You may try to re-create the trustdb using the commands:\n"));
+  log_info ("  cd %s\n", default_homedir ());
+  log_info ("  gpg2 --export-ownertrust > otrust.tmp\n");
+#ifdef HAVE_W32_SYSTEM
+  log_info ("  del %s\n", name);
+#else
+  log_info ("  rm %s\n", name);
+#endif
+  log_info ("  gpg2 --import-ownertrust < otrust.tmp\n");
+  log_info (_("If that does not work, please consult the manual\n"));
+}
+
+
+void
 init_trustdb()
 {
   int level = trustdb_args.level;

Modified: branches/STABLE-BRANCH-1-4/g10/trustdb.h
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/trustdb.h	2009-07-22 17:21:47 UTC (rev 5091)
+++ branches/STABLE-BRANCH-1-4/g10/trustdb.h	2009-07-23 08:00:39 UTC (rev 5092)
@@ -45,6 +45,7 @@
 void check_trustdb (void);
 void update_trustdb (void);
 int setup_trustdb( int level, const char *dbname );
+void how_to_fix_the_trustdb (void);
 void init_trustdb( void );
 void check_trustdb_stale(void);
 void sync_trustdb( void );




More information about the Gnupg-commits mailing list