diff --git a/g10/ChangeLog b/g10/ChangeLog index 1f3fd7fff..2e106ed9c 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,10 @@ +2003-12-30 David Shaw + + * options.h, g10.c (main), import.c (parse_import_options, + import_one, import_secret_one), keyserver.c (keyserver_refresh): + Change --merge-only to --import-option merge-only. Deprecate + --merge-only. + 2003-12-29 David Shaw * misc.c (pull_in_libs): Dead code. Removed. diff --git a/g10/g10.c b/g10/g10.c index 60c52672b..20d781cf3 100644 --- a/g10/g10.c +++ b/g10/g10.c @@ -2010,7 +2010,11 @@ main( int argc, char **argv ) case oOverrideSessionKey: opt.override_session_key = pargs.r.ret_str; break; - case oMergeOnly: opt.merge_only = 1; break; + case oMergeOnly: + deprecated_warning(configname,configlineno,"--merge-only", + "--import-options ","merge-only"); + opt.import_options|=IMPORT_MERGE_ONLY; + break; case oAllowSecretKeyImport: /* obsolete */ break; case oTryAllSecrets: opt.try_all_secrets = 1; break; case oTrustedKey: register_trusted_key( pargs.r.ret_str ); break; diff --git a/g10/import.c b/g10/import.c index b06e52f20..2168fe5f4 100644 --- a/g10/import.c +++ b/g10/import.c @@ -93,6 +93,7 @@ parse_import_options(char *str,unsigned int *options,int noisy) {"repair-pks-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG}, {"fast-import",IMPORT_FAST_IMPORT}, {"convert-sk-to-pk",IMPORT_SK2PK}, + {"merge-only",IMPORT_MERGE_ONLY}, {NULL,0} }; @@ -625,12 +626,13 @@ import_one( const char *fname, KBNODE keyblock, log_error( _("key %08lX: public key not found: %s\n"), (ulong)keyid[1], g10_errstr(rc)); } - else if ( rc && opt.merge_only ) { + else if ( rc && (opt.import_options&IMPORT_MERGE_ONLY) ) + { if( opt.verbose ) - log_info( _("key %08lX: new key - skipped\n"), (ulong)keyid[1] ); + log_info( _("key %08lX: new key - skipped\n"), (ulong)keyid[1] ); rc = 0; stats->skipped_new_keys++; - } + } else if( rc ) { /* insert this key */ KEYDB_HANDLE hd = keydb_new (0); @@ -903,27 +905,29 @@ import_secret_one( const char *fname, KBNODE keyblock, /* do we have this key already in one of our secrings ? */ rc = seckey_available( keyid ); - if( rc == G10ERR_NO_SECKEY && !opt.merge_only ) { /* simply insert this key */ + if( rc == G10ERR_NO_SECKEY && !(opt.import_options&IMPORT_MERGE_ONLY) ) + { + /* simply insert this key */ KEYDB_HANDLE hd = keydb_new (1); /* get default resource */ rc = keydb_locate_writable (hd, NULL); if (rc) { - log_error (_("no default secret keyring: %s\n"), g10_errstr (rc)); - keydb_release (hd); - return G10ERR_GENERAL; + log_error (_("no default secret keyring: %s\n"), g10_errstr (rc)); + keydb_release (hd); + return G10ERR_GENERAL; } rc = keydb_insert_keyblock (hd, keyblock ); if (rc) - log_error (_("error writing keyring `%s': %s\n"), - keydb_get_resource_name (hd), g10_errstr(rc) ); + log_error (_("error writing keyring `%s': %s\n"), + keydb_get_resource_name (hd), g10_errstr(rc) ); keydb_release (hd); /* we are ready */ if( !opt.quiet ) - log_info( _("key %08lX: secret key imported\n"), (ulong)keyid[1]); + log_info( _("key %08lX: secret key imported\n"), (ulong)keyid[1]); stats->secret_imported++; if (is_status_enabled ()) - print_import_ok (NULL, sk, 1|16); + print_import_ok (NULL, sk, 1|16); if(options&IMPORT_SK2PK) { @@ -934,7 +938,7 @@ import_secret_one( const char *fname, KBNODE keyblock, release_kbnode(pub_keyblock); } - } + } else if( !rc ) { /* we can't merge secret keys */ log_error( _("key %08lX: already in secret keyring\n"), (ulong)keyid[1]); diff --git a/g10/keyserver.c b/g10/keyserver.c index d7843b271..3c8a769d2 100644 --- a/g10/keyserver.c +++ b/g10/keyserver.c @@ -1411,7 +1411,7 @@ keyserver_refresh(STRLIST users) /* We switch merge_only on during a refresh, as 'refresh' should never import new keys, even if their keyids match. Is it worth preserving the old merge_only value here? */ - opt.merge_only=1; + opt.import_options|=IMPORT_MERGE_ONLY; /* If refresh_add_fake_v3_keyids is on and it's a HKP or MAILTO scheme, then enable fake v3 keyid generation. */ diff --git a/g10/options.h b/g10/options.h index f359a6a2d..c2af79aef 100644 --- a/g10/options.h +++ b/g10/options.h @@ -172,7 +172,6 @@ struct { int show_session_key; int use_agent; const char *gpg_agent_info; - int merge_only; int try_all_secrets; int no_expensive_trust_checks; int no_sig_cache; @@ -207,7 +206,6 @@ struct { #define DBG_EXTPROG_VALUE 1024 /* debug external program calls */ #define DBG_CARD_IO_VALUE 2048 - #define DBG_PACKET (opt.debug & DBG_PACKET_VALUE) #define DBG_FILTER (opt.debug & DBG_FILTER_VALUE) #define DBG_CACHE (opt.debug & DBG_CACHE_VALUE) @@ -216,6 +214,7 @@ struct { #define DBG_EXTPROG (opt.debug & DBG_EXTPROG_VALUE) #define DBG_CARD_IO (opt.debug & DBG_CARD_IO_VALUE) + #define GNUPG (opt.compliance==CO_GNUPG) #define RFC1991 (opt.compliance==CO_RFC1991 || opt.compliance==CO_PGP2) #define RFC2440 (opt.compliance==CO_RFC2440) @@ -230,6 +229,7 @@ struct { #define IMPORT_REPAIR_PKS_SUBKEY_BUG (1<<1) #define IMPORT_FAST_IMPORT (1<<2) #define IMPORT_SK2PK (1<<3) +#define IMPORT_MERGE_ONLY (1<<4) #define EXPORT_INCLUDE_NON_RFC (1<<0) #define EXPORT_INCLUDE_LOCAL_SIGS (1<<1)