[svn] GnuPG - r3940 - trunk/g10
svn author dshaw
cvs at cvs.gnupg.org
Fri Nov 18 05:25:09 CET 2005
Author: dshaw
Date: 2005-11-18 05:25:07 +0100 (Fri, 18 Nov 2005)
New Revision: 3940
Modified:
trunk/g10/ChangeLog
trunk/g10/export.c
trunk/g10/import.c
trunk/g10/keyedit.c
trunk/g10/options.h
trunk/g10/trustdb.c
trunk/g10/trustdb.h
Log:
* keyedit.c (keyedit_menu, menu_clean): Simplify clean options to just
"clean", and add "minimize".
* import.c (parse_import_options): Make help text match the export
versions of the options.
* options.h, export.c (parse_export_options, do_export_stream): Reduce
clean options to two: clean and minimize.
* trustdb.h, trustdb.c (clean_one_uid): New function that joins uid
and sig cleaning into one for a simple API outside trustdb.
Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog 2005-11-14 13:11:15 UTC (rev 3939)
+++ trunk/g10/ChangeLog 2005-11-18 04:25:07 UTC (rev 3940)
@@ -1,3 +1,17 @@
+2005-11-17 David Shaw <dshaw at jabberwocky.com>
+
+ * keyedit.c (keyedit_menu, menu_clean): Simplify clean options to
+ just "clean", and add "minimize".
+
+ * import.c (parse_import_options): Make help text match the export
+ versions of the options.
+
+ * options.h, export.c (parse_export_options, do_export_stream):
+ Reduce clean options to two: clean and minimize.
+
+ * trustdb.h, trustdb.c (clean_one_uid): New function that joins
+ uid and sig cleaning into one for a simple API outside trustdb.
+
2005-11-13 David Shaw <dshaw at jabberwocky.com>
* armor.c (parse_header_line): A fussy bit of 2440: header lines
Modified: trunk/g10/export.c
===================================================================
--- trunk/g10/export.c 2005-11-14 13:11:15 UTC (rev 3939)
+++ trunk/g10/export.c 2005-11-18 04:25:07 UTC (rev 3940)
@@ -47,7 +47,6 @@
typedef struct subkey_list_s *subkey_list_t;
-
static int do_export( STRLIST users, int secret, unsigned int options );
static int do_export_stream( IOBUF out, STRLIST users, int secret,
KBNODE *keyblock_out, unsigned int options,
@@ -63,24 +62,21 @@
{"export-attributes",EXPORT_ATTRIBUTES,NULL,
N_("export attribute user IDs (generally photo IDs)")},
{"export-sensitive-revkeys",EXPORT_SENSITIVE_REVKEYS,NULL,
- N_("export revocation keys that are marked as \"sensitive\"")},
- {"export-clean",EXPORT_CLEAN_SIGS|EXPORT_CLEAN_UIDS,NULL,
- N_("all export-clean-* options from above")},
- {"export-clean-sigs",EXPORT_CLEAN_SIGS,NULL,
- N_("remove unusable signatures during export")},
- {"export-clean-uids",EXPORT_CLEAN_UIDS,NULL,
- N_("remove unusable user IDs during export")},
- {"export-minimal",
- EXPORT_MINIMAL|EXPORT_CLEAN_SIGS|EXPORT_CLEAN_UIDS,NULL,
- N_("remove unusable user IDs and all signatures during export")},
+ N_("export revocation keys marked as \"sensitive\"")},
{"export-reset-subkey-passwd",EXPORT_RESET_SUBKEY_PASSWD,NULL,
N_("remove the passphrase from exported subkeys")},
+ {"export-clean",EXPORT_CLEAN,NULL,
+ N_("remove unusable parts from key during export")},
+ {"export-minimal",EXPORT_MINIMAL|EXPORT_CLEAN,NULL,
+ N_("remove as much as possible from key during export")},
/* Aliases for backward compatibility */
{"include-local-sigs",EXPORT_LOCAL_SIGS,NULL,NULL},
{"include-attributes",EXPORT_ATTRIBUTES,NULL,NULL},
{"include-sensitive-revkeys",EXPORT_SENSITIVE_REVKEYS,NULL,NULL},
/* dummy */
{"export-unusable-sigs",0,NULL,NULL},
+ {"export-clean-sigs",0,NULL,NULL},
+ {"export-clean-uids",0,NULL,NULL},
{NULL,0,NULL,NULL}
/* add tags for include revoked and disabled? */
};
@@ -381,9 +377,14 @@
}
else
{
- /* It's a public key export. */
- if(options&EXPORT_CLEAN_UIDS)
- clean_uids_from_key(keyblock,opt.verbose);
+ /* It's a public key export, so do the cleaning if
+ requested. Note that both export-clean and
+ export-minimal only apply to UID sigs (0x10, 0x11,
+ 0x12, and 0x13). A designated revocation is never
+ stripped, even with export-minimal set. */
+
+ if(options&EXPORT_CLEAN)
+ clean_key(keyblock,opt.verbose,options&EXPORT_MINIMAL,NULL,NULL);
}
/* And write it. */
@@ -455,20 +456,8 @@
}
}
- if(node->pkt->pkttype==PKT_USER_ID)
+ if(node->pkt->pkttype==PKT_SIGNATURE)
{
- /* Run clean_sigs_from_uid against each uid if
- export-clean-sigs is on. export-minimal causes it
- to remove all non-selfsigs as well. Note that
- export-minimal only applies to UID sigs (0x10,
- 0x11, 0x12, and 0x13). A designated revocation is
- not stripped. */
- if(options&EXPORT_CLEAN_SIGS)
- clean_sigs_from_uid(keyblock,node,
- opt.verbose,options&EXPORT_MINIMAL);
- }
- else if(node->pkt->pkttype==PKT_SIGNATURE)
- {
/* do not export packets which are marked as not
exportable */
if(!(options&EXPORT_LOCAL_SIGS)
Modified: trunk/g10/import.c
===================================================================
--- trunk/g10/import.c 2005-11-14 13:11:15 UTC (rev 3939)
+++ trunk/g10/import.c 2005-11-18 04:25:07 UTC (rev 3940)
@@ -102,18 +102,16 @@
{"merge-only",IMPORT_MERGE_ONLY,NULL,
N_("only accept updates to existing keys")},
{"import-clean",IMPORT_CLEAN,NULL,
- N_("remove unusable user IDs and signatures after import")},
- {"import-clean-sigs",0,NULL,NULL},
- {"import-clean-uids",0,NULL,NULL},
+ N_("remove unusable parts from key after import")},
{"import-minimal",IMPORT_MINIMAL|IMPORT_CLEAN,NULL,
- N_("remove unusable user IDs and all signatures after import")},
- /* Alias */
- {"import-minimize",IMPORT_MINIMAL|IMPORT_CLEAN,NULL,NULL},
+ N_("remove as much as possible from key after import")},
/* Aliases for backward compatibility */
{"allow-local-sigs",IMPORT_LOCAL_SIGS,NULL,NULL},
{"repair-hkp-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG,NULL,NULL},
/* dummy */
{"import-unusable-sigs",0,NULL,NULL},
+ {"import-clean-sigs",0,NULL,NULL},
+ {"import-clean-uids",0,NULL,NULL},
{NULL,0,NULL,NULL}
};
Modified: trunk/g10/keyedit.c
===================================================================
--- trunk/g10/keyedit.c 2005-11-14 13:11:15 UTC (rev 3939)
+++ trunk/g10/keyedit.c 2005-11-18 04:25:07 UTC (rev 3940)
@@ -57,8 +57,7 @@
int photo, const char *photo_name );
static void menu_deluid( KBNODE pub_keyblock, KBNODE sec_keyblock );
static int menu_delsig( KBNODE pub_keyblock );
-static int menu_clean_sigs_from_uids(KBNODE keyblock,int self_only);
-static int menu_clean_uids_from_key(KBNODE keyblock);
+static int menu_clean(KBNODE keyblock,int self_only);
static void menu_delkey( KBNODE pub_keyblock, KBNODE sec_keyblock );
static int menu_addrevoker( KBNODE pub_keyblock,
KBNODE sec_keyblock, int sensitive );
@@ -1442,13 +1441,12 @@
{ "disable" , cmdDISABLEKEY, KEYEDIT_NOT_SK, N_("disable key") },
{ "showphoto",cmdSHOWPHOTO , 0, N_("show selected photo IDs") },
{ "clean", cmdCLEAN , KEYEDIT_NOT_SK,
- N_("clean unusable parts from key") },
+ N_("compact unusable user IDs and remove unusable signatures from key")},
{ "minimize", cmdMINIMIZE , KEYEDIT_NOT_SK,
- N_("clean unusable parts from key and remove all signatures") },
+ N_("compact unusable user IDs and remove all signatures from key") },
{ NULL, cmdNONE, 0, NULL }
};
-
#ifdef HAVE_LIBREADLINE
/* These two functions are used by readline for command completion. */
@@ -2175,32 +2173,11 @@
break;
case cmdCLEAN:
- {
- if(*arg_string)
- {
- if(ascii_strcasecmp(arg_string,"sigs")==0
- || ascii_strcasecmp(arg_string,"signatures")==0
- || ascii_strcasecmp(arg_string,"certs")==0
- || ascii_strcasecmp(arg_string,"certificates")==0)
- modified=menu_clean_sigs_from_uids(keyblock,0);
- else if(ascii_strcasecmp(arg_string,"uids")==0)
- redisplay=modified=menu_clean_uids_from_key(keyblock);
- else
- tty_printf("Unable to clean `%s'\n",arg_string);
- }
- else
- {
- modified=menu_clean_sigs_from_uids(keyblock,0);
- modified+=menu_clean_uids_from_key(keyblock);
- redisplay=modified;
- }
- }
+ redisplay=modified=menu_clean(keyblock,0);
break;
case cmdMINIMIZE:
- modified=menu_clean_sigs_from_uids(keyblock,1);
- modified+=menu_clean_uids_from_key(keyblock);
- redisplay=modified;
+ redisplay=modified=menu_clean(keyblock,1);
break;
case cmdQUIT:
@@ -3192,73 +3169,54 @@
}
static int
-menu_clean_sigs_from_uids(KBNODE keyblock,int self_only)
+menu_clean(KBNODE keyblock,int self_only)
{
KBNODE uidnode;
- int modified=0;
- int select_all=!count_selected_uids(keyblock);
+ int modified=0,select_all=!count_selected_uids(keyblock);
- for(uidnode=keyblock->next;uidnode;uidnode=uidnode->next)
+ for(uidnode=keyblock->next;
+ uidnode && uidnode->pkt->pkttype!=PKT_PUBLIC_SUBKEY;
+ uidnode=uidnode->next)
{
if(uidnode->pkt->pkttype==PKT_USER_ID
&& (uidnode->flag&NODFLG_SELUID || select_all))
{
- int deleted;
+ int uids=0,sigs=0;
char *user=utf8_to_native(uidnode->pkt->pkt.user_id->name,
uidnode->pkt->pkt.user_id->len,
0);
- deleted=clean_sigs_from_uid(keyblock,uidnode,opt.verbose,self_only);
- if(deleted)
- {
- tty_printf(deleted==1?
- "User ID \"%s\": %d signature removed.\n":
- "User ID \"%s\": %d signatures removed.\n",
- user,deleted);
- modified=1;
- }
- else
- tty_printf(_("User ID \"%s\": already clean.\n"),user);
- xfree(user);
- }
- }
-
- return modified;
-}
-
-static int
-menu_clean_uids_from_key(KBNODE keyblock)
-{
- int modified=clean_uids_from_key(keyblock,0);
-
- if(modified)
- {
- KBNODE node;
-
- for(node=keyblock->next;node;node=node->next)
- {
- if(node->pkt->pkttype==PKT_USER_ID
- && node->pkt->pkt.user_id->flags.compacted)
+ clean_one_uid(keyblock,uidnode,opt.verbose,self_only,&uids,&sigs);
+ if(uids)
{
const char *reason;
- char *user=utf8_to_native(node->pkt->pkt.user_id->name,
- node->pkt->pkt.user_id->len,0);
- if(node->pkt->pkt.user_id->is_revoked)
+ if(uidnode->pkt->pkt.user_id->is_revoked)
reason=_("revoked");
- else if(node->pkt->pkt.user_id->is_expired)
+ else if(uidnode->pkt->pkt.user_id->is_expired)
reason=_("expired");
else
reason=_("invalid");
tty_printf("User ID \"%s\" compacted: %s\n",user,reason);
- xfree(user);
+ modified=1;
}
+ else if(sigs)
+ {
+ tty_printf(sigs==1?
+ "User ID \"%s\": %d signature removed\n":
+ "User ID \"%s\": %d signatures removed\n",
+ user,sigs);
+
+ modified=1;
+ }
+ else
+ tty_printf(_("User ID \"%s\": already clean\n"),user);
+
+ xfree(user);
}
}
- else
- tty_printf("No user IDs are compactable.\n");
return modified;
}
Modified: trunk/g10/options.h
===================================================================
--- trunk/g10/options.h 2005-11-14 13:11:15 UTC (rev 3939)
+++ trunk/g10/options.h 2005-11-18 04:25:07 UTC (rev 3940)
@@ -271,10 +271,9 @@
#define EXPORT_LOCAL_SIGS (1<<0)
#define EXPORT_ATTRIBUTES (1<<1)
#define EXPORT_SENSITIVE_REVKEYS (1<<2)
-#define EXPORT_MINIMAL (1<<3)
-#define EXPORT_CLEAN_SIGS (1<<4)
-#define EXPORT_CLEAN_UIDS (1<<5)
-#define EXPORT_RESET_SUBKEY_PASSWD (1<<6)
+#define EXPORT_RESET_SUBKEY_PASSWD (1<<3)
+#define EXPORT_MINIMAL (1<<4)
+#define EXPORT_CLEAN (1<<5)
#define LIST_SHOW_PHOTOS (1<<0)
#define LIST_SHOW_POLICY_URLS (1<<1)
Modified: trunk/g10/trustdb.c
===================================================================
--- trunk/g10/trustdb.c 2005-11-14 13:11:15 UTC (rev 3939)
+++ trunk/g10/trustdb.c 2005-11-18 04:25:07 UTC (rev 3940)
@@ -1574,7 +1574,7 @@
}
}
-int
+static int
clean_sigs_from_uid(KBNODE keyblock,KBNODE uidnode,int noisy,int self_only)
{
int deleted=0;
@@ -1712,21 +1712,27 @@
return deleted;
}
-int
-clean_uids_from_key(KBNODE keyblock,int noisy)
+/* Needs to be called after a merge_keys_and_selfsig() */
+void
+clean_one_uid(KBNODE keyblock,KBNODE uidnode,int noisy,int self_only,
+ int *uids_cleaned,int *sigs_cleaned)
{
- KBNODE uidnode;
- int deleted=0;
+ int dummy;
- merge_keys_and_selfsig(keyblock);
+ assert(keyblock->pkt->pkttype==PKT_PUBLIC_KEY);
+ assert(uidnode->pkt->pkttype==PKT_USER_ID);
- for(uidnode=keyblock->next;
- uidnode && uidnode->pkt->pkttype!=PKT_PUBLIC_SUBKEY;
- uidnode=uidnode->next)
- if(uidnode->pkt->pkttype==PKT_USER_ID)
- deleted+=clean_uid_from_key(keyblock,uidnode,noisy);
+ if(!uids_cleaned)
+ uids_cleaned=&dummy;
- return deleted;
+ if(!sigs_cleaned)
+ sigs_cleaned=&dummy;
+
+ /* Do clean_uid_from_key first since if it fires off, we don't
+ have to bother with the other */
+ *uids_cleaned+=clean_uid_from_key(keyblock,uidnode,noisy);
+ if(!uidnode->pkt->pkt.user_id->flags.compacted)
+ *sigs_cleaned+=clean_sigs_from_uid(keyblock,uidnode,noisy,self_only);
}
void
@@ -1734,27 +1740,15 @@
int *uids_cleaned,int *sigs_cleaned)
{
KBNODE uidnode;
- int dummy;
- if(!uids_cleaned)
- uids_cleaned=&dummy;
-
- if(!sigs_cleaned)
- sigs_cleaned=&dummy;
-
merge_keys_and_selfsig(keyblock);
for(uidnode=keyblock->next;
uidnode && uidnode->pkt->pkttype!=PKT_PUBLIC_SUBKEY;
uidnode=uidnode->next)
if(uidnode->pkt->pkttype==PKT_USER_ID)
- {
- /* Do clean_uid_from_key first since if it fires off, we don't
- have to bother with the other */
- *uids_cleaned+=clean_uid_from_key(keyblock,uidnode,noisy);
- if(!uidnode->pkt->pkt.user_id->flags.compacted)
- *sigs_cleaned+=clean_sigs_from_uid(keyblock,uidnode,noisy,self_only);
- }
+ clean_one_uid(keyblock,uidnode,noisy,self_only,
+ uids_cleaned,sigs_cleaned);
}
/* Used by validate_one_keyblock to confirm a regexp within a trust
Modified: trunk/g10/trustdb.h
===================================================================
--- trunk/g10/trustdb.h 2005-11-14 13:11:15 UTC (rev 3939)
+++ trunk/g10/trustdb.h 2005-11-18 04:25:07 UTC (rev 3940)
@@ -82,8 +82,8 @@
void update_ownertrust (PKT_public_key *pk, unsigned int new_trust );
int clear_ownertrusts (PKT_public_key *pk);
-int clean_sigs_from_uid(KBNODE keyblock,KBNODE uidnode,int noisy,int self_only);
-int clean_uids_from_key(KBNODE keyblock,int noisy);
+void clean_one_uid(KBNODE keyblock,KBNODE uidnode,int noisy,int self_only,
+ int *uids_cleaned,int *sigs_cleaned);
void clean_key(KBNODE keyblock,int noisy,int self_only,
int *uids_cleaned,int *sigs_cleaned);
More information about the Gnupg-commits
mailing list