mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
See ChangeLog: Mon Oct 4 21:23:04 CEST 1999 Werner Koch
This commit is contained in:
parent
88a7532f89
commit
296f9de0bc
24 changed files with 583 additions and 361 deletions
84
g10/import.c
84
g10/import.c
|
@ -38,6 +38,7 @@
|
|||
|
||||
|
||||
static struct {
|
||||
ulong count;
|
||||
ulong no_user_id;
|
||||
ulong imported;
|
||||
ulong imported_rsa;
|
||||
|
@ -53,6 +54,7 @@ static struct {
|
|||
|
||||
|
||||
static int import( IOBUF inp, int fast, const char* fname );
|
||||
static void print_stats(void);
|
||||
static int read_block( IOBUF a, PACKET **pending_pkt, KBNODE *ret_root );
|
||||
static int import_one( const char *fname, KBNODE keyblock, int fast );
|
||||
static int import_secret_one( const char *fname, KBNODE keyblock );
|
||||
|
@ -105,30 +107,48 @@ static int merge_keysigs( KBNODE dst, KBNODE src, int *n_sigs,
|
|||
* Key revocation certificates have special handling.
|
||||
*
|
||||
*/
|
||||
int
|
||||
import_keys( const char *fname, int fast )
|
||||
void
|
||||
import_keys( char **fnames, int nnames, int fast )
|
||||
{
|
||||
IOBUF inp = NULL;
|
||||
int rc;
|
||||
int i;
|
||||
|
||||
inp = iobuf_open(fname);
|
||||
if( !fname )
|
||||
fname = "[stdin]";
|
||||
if( !inp ) {
|
||||
log_error(_("can't open `%s': %s\n"), fname, strerror(errno) );
|
||||
return G10ERR_OPEN_FILE;
|
||||
/* fixme: don't use static variables */
|
||||
memset( &stats, 0, sizeof( stats ) );
|
||||
|
||||
for(i=0; i < nnames; i++ ) {
|
||||
const char *fname = fnames? fnames[i] : NULL;
|
||||
IOBUF inp = iobuf_open(fname);
|
||||
if( !fname )
|
||||
fname = "[stdin]";
|
||||
if( !inp )
|
||||
log_error(_("can't open `%s': %s\n"), fname, strerror(errno) );
|
||||
else {
|
||||
int rc = import( inp, fast, fname );
|
||||
iobuf_close(inp);
|
||||
if( rc )
|
||||
log_error("import from `%s' failed: %s\n", fname,
|
||||
g10_errstr(rc) );
|
||||
}
|
||||
if( !fname )
|
||||
break;
|
||||
}
|
||||
|
||||
rc = import( inp, fast, fname );
|
||||
|
||||
iobuf_close(inp);
|
||||
return rc;
|
||||
print_stats();
|
||||
if( !fast )
|
||||
sync_trustdb();
|
||||
}
|
||||
|
||||
int
|
||||
import_keys_stream( IOBUF inp, int fast )
|
||||
{
|
||||
return import( inp, fast, "[stream]" );
|
||||
int rc = 0;
|
||||
|
||||
/* fixme: don't use static variables */
|
||||
memset( &stats, 0, sizeof( stats ) );
|
||||
rc = import( inp, fast, "[stream]" );
|
||||
print_stats();
|
||||
if( !fast )
|
||||
sync_trustdb();
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -137,10 +157,6 @@ import( IOBUF inp, int fast, const char* fname )
|
|||
PACKET *pending_pkt = NULL;
|
||||
KBNODE keyblock;
|
||||
int rc = 0;
|
||||
ulong count=0;
|
||||
|
||||
/* fixme: don't use static variables */
|
||||
memset( &stats, 0, sizeof( stats ) );
|
||||
|
||||
getkey_disable_caches();
|
||||
|
||||
|
@ -165,16 +181,23 @@ import( IOBUF inp, int fast, const char* fname )
|
|||
release_kbnode(keyblock);
|
||||
if( rc )
|
||||
break;
|
||||
if( !(++count % 100) && !opt.quiet )
|
||||
log_info(_("%lu keys so far processed\n"), count );
|
||||
if( !(++stats.count % 100) && !opt.quiet )
|
||||
log_info(_("%lu keys so far processed\n"), stats.count );
|
||||
}
|
||||
if( rc == -1 )
|
||||
rc = 0;
|
||||
else if( rc && rc != G10ERR_INV_KEYRING )
|
||||
log_error( _("error reading `%s': %s\n"), fname, g10_errstr(rc));
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_stats()
|
||||
{
|
||||
if( !opt.quiet ) {
|
||||
log_info(_("Total number processed: %lu\n"), count );
|
||||
log_info(_("Total number processed: %lu\n"), stats.count );
|
||||
if( stats.no_user_id )
|
||||
log_info(_(" w/o user IDs: %lu\n"), stats.no_user_id );
|
||||
if( stats.imported || stats.imported_rsa ) {
|
||||
|
@ -202,9 +225,9 @@ import( IOBUF inp, int fast, const char* fname )
|
|||
}
|
||||
|
||||
if( is_status_enabled() ) {
|
||||
char buf[12*16];
|
||||
char buf[12*20];
|
||||
sprintf(buf, "%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu",
|
||||
count,
|
||||
stats.count,
|
||||
stats.no_user_id,
|
||||
stats.imported,
|
||||
stats.imported_rsa,
|
||||
|
@ -218,8 +241,6 @@ import( IOBUF inp, int fast, const char* fname )
|
|||
stats.secret_dups);
|
||||
write_status_text( STATUS_IMPORT_RES, buf );
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
@ -678,6 +699,15 @@ import_revoke_cert( const char *fname, KBNODE node )
|
|||
log_info( _("key %08lX: revocation certificate imported\n"),
|
||||
(ulong)keyid[1]);
|
||||
stats.n_revoc++;
|
||||
if( clear_trust_checked_flag( pk ) ) {
|
||||
/* seems that we have to insert the record first */
|
||||
rc = insert_trust_record( keyblock );
|
||||
if( rc )
|
||||
log_error("key %08lX: trustdb insert failed: %s\n",
|
||||
(ulong)keyid[1], g10_errstr(rc) );
|
||||
else
|
||||
rc = clear_trust_checked_flag( pk );
|
||||
}
|
||||
|
||||
leave:
|
||||
release_kbnode( keyblock );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue