* options.h, g10.c (main), export.c (parse_export_options,
authorDavid Shaw <dshaw@jabberwocky.com>
Wed, 8 Jun 2005 03:31:48 +0000 (03:31 +0000)
committerDavid Shaw <dshaw@jabberwocky.com>
Wed, 8 Jun 2005 03:31:48 +0000 (03:31 +0000)
do_export_stream): Add export-options export-clean-sigs,
export-clean-uids, export-clean-subkeys, and export-clean which is all
of the above.  Export-minimal is the same except it also removes all
non-selfsigs.  export-unusable-sigs is now a noop.

g10/ChangeLog
g10/export.c
g10/g10.c
g10/options.h

index 1bf4a4a..7b4ab51 100644 (file)
@@ -1,3 +1,11 @@
+2005-06-07  David Shaw  <dshaw@jabberwocky.com>
+
+       * options.h, g10.c (main), export.c (parse_export_options,
+       do_export_stream): Add export-options export-clean-sigs,
+       export-clean-uids, export-clean-subkeys, and export-clean which is
+       all of the above.  Export-minimal is the same except it also
+       removes all non-selfsigs.  export-unusable-sigs is now a noop.
+
 2005-06-01  David Shaw  <dshaw@jabberwocky.com>
 
        * signal.c [HAVE_DOSISH_SYSTEM]: Fix unused function warnings on
index d936cce..bcb50c9 100644 (file)
@@ -1,6 +1,6 @@
 /* export.c
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
- *               2004 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+ *               2005 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -35,6 +35,7 @@
 #include "util.h"
 #include "main.h"
 #include "i18n.h"
+#include "trustdb.h"
 
 static int do_export( STRLIST users, int secret, unsigned int options );
 static int do_export_stream( IOBUF out, STRLIST users, int secret,
@@ -49,12 +50,20 @@ parse_export_options(char *str,unsigned int *options,int noisy)
       {"export-local-sigs",EXPORT_LOCAL_SIGS,NULL},
       {"export-attributes",EXPORT_ATTRIBUTES,NULL},
       {"export-sensitive-revkeys",EXPORT_SENSITIVE_REVKEYS,NULL},
-      {"export-minimal",EXPORT_MINIMAL,NULL},
-      {"export-unusable-sigs",EXPORT_UNUSABLE_SIGS,NULL},
+      {"export-minimal",
+       EXPORT_MINIMAL|EXPORT_CLEAN_SIGS|EXPORT_CLEAN_UIDS|EXPORT_CLEAN_SUBKEYS,
+       NULL},
+      {"export-clean",
+       EXPORT_CLEAN_SIGS|EXPORT_CLEAN_UIDS|EXPORT_CLEAN_SUBKEYS,NULL},
+      {"export-clean-sigs",EXPORT_CLEAN_SIGS,NULL},
+      {"export-clean-uids",EXPORT_CLEAN_UIDS,NULL},
+      {"export-clean-subkeys",EXPORT_CLEAN_SUBKEYS,NULL},
       /* Aliases for backward compatibility */
       {"include-local-sigs",EXPORT_LOCAL_SIGS,NULL},
       {"include-attributes",EXPORT_ATTRIBUTES,NULL},
       {"include-sensitive-revkeys",EXPORT_SENSITIVE_REVKEYS,NULL},
+      /* dummy */
+      {"export-unusable-sigs",0,NULL},
       {NULL,0,NULL}
       /* add tags for include revoked and disabled? */
     };
@@ -222,13 +231,20 @@ do_export_stream( IOBUF out, STRLIST users, int secret,
                         keystr(sk_keyid));
                continue;
              }
+         }
+       else
+         {
+           /* It's a public key export */
+           if((options&EXPORT_MINIMAL)
+              && (node=find_kbnode(keyblock,PKT_PUBLIC_KEY)))
+             keyid_from_pk(node->pkt->pkt.public_key,keyid);
+
+           if(options&EXPORT_CLEAN_UIDS)
+             clean_uids_from_key(keyblock,opt.verbose);
 
-           if(options&EXPORT_MINIMAL)
-             keyid_from_sk(sk,keyid);
+           if(options&EXPORT_CLEAN_SUBKEYS)
+             clean_subkeys_from_key(keyblock,opt.verbose);
          }
-       else if((options&EXPORT_MINIMAL)
-               && (node=find_kbnode(keyblock,PKT_PUBLIC_KEY)))
-         keyid_from_pk(node->pkt->pkt.public_key,keyid);
 
        /* and write it */
        for( kbctx=NULL; (node = walk_kbnode( keyblock, &kbctx, 0 )); ) {
@@ -315,7 +331,14 @@ do_export_stream( IOBUF out, STRLIST users, int secret,
                  continue;
              }
 
-           if( node->pkt->pkttype == PKT_SIGNATURE )
+           if(node->pkt->pkttype==PKT_USER_ID)
+             {
+               /* Run clean_sigs_from_uid against each uid if
+                  export-clean-sigs is on. */
+               if(options&EXPORT_CLEAN_SIGS)
+                 clean_sigs_from_uid(keyblock,node,opt.verbose);
+             }
+           else if(node->pkt->pkttype==PKT_SIGNATURE)
              {
                /* If we have export-minimal turned on, do not include
                   any signature that isn't a selfsig.  Note that this
@@ -327,16 +350,6 @@ do_export_stream( IOBUF out, STRLIST users, int secret,
                       || node->pkt->pkt.signature->keyid[1]!=keyid[1]))
                  continue;
 
-               /* We do basically the same thing for
-                  export-unusable-sigs.  It only applies to expired
-                  uid sigs that aren't selfsigs. */
-               if(!(options&EXPORT_UNUSABLE_SIGS)
-                  && IS_UID_SIG(node->pkt->pkt.signature)
-                  && node->pkt->pkt.signature->flags.expired
-                  && (node->pkt->pkt.signature->keyid[0]!=keyid[0]
-                      || node->pkt->pkt.signature->keyid[1]!=keyid[1]))
-                 continue;
-
                /* do not export packets which are marked as not
                   exportable */
                if(!(options&EXPORT_LOCAL_SIGS)
index f258a93..dd3ebd5 100644 (file)
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -1664,9 +1664,9 @@ main( int argc, char **argv )
     opt.force_v3_sigs = 1;
     opt.escape_from = 1;
     opt.import_options=IMPORT_SK2PK;
-    opt.export_options=EXPORT_ATTRIBUTES|EXPORT_UNUSABLE_SIGS;
+    opt.export_options=EXPORT_ATTRIBUTES;
     opt.keyserver_options.import_options=IMPORT_REPAIR_PKS_SUBKEY_BUG;
-    opt.keyserver_options.export_options=EXPORT_ATTRIBUTES|EXPORT_UNUSABLE_SIGS;
+    opt.keyserver_options.export_options=EXPORT_ATTRIBUTES;
     opt.keyserver_options.options=
       KEYSERVER_INCLUDE_SUBKEYS|KEYSERVER_INCLUDE_REVOKED|KEYSERVER_TRY_DNS_SRV|KEYSERVER_HONOR_KEYSERVER_URL;
     opt.verify_options=
index e139152..7ce4ebb 100644 (file)
@@ -257,7 +257,9 @@ struct {
 #define EXPORT_ATTRIBUTES                (1<<1)
 #define EXPORT_SENSITIVE_REVKEYS         (1<<2)
 #define EXPORT_MINIMAL                   (1<<3)
-#define EXPORT_UNUSABLE_SIGS             (1<<4)
+#define EXPORT_CLEAN_SIGS                (1<<4)
+#define EXPORT_CLEAN_UIDS                (1<<5)
+#define EXPORT_CLEAN_SUBKEYS             (1<<6)
 
 #define LIST_SHOW_PHOTOS                 (1<<0)
 #define LIST_SHOW_POLICY_URLS            (1<<1)