mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-07 22:01:07 +01:00
* import.c (print_imported_summary): Cleaned up. Print new
not_imported value. (check_and_store): Update non_imported counter. (print_import_problem): New. (check_and_store): Print error status message. * server.c (get_status_string): Added STATUS_IMPORT_PROBLEM.
This commit is contained in:
parent
04011644ae
commit
b8a7c191de
@ -1,3 +1,12 @@
|
|||||||
|
2002-08-21 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* import.c (print_imported_summary): Cleaned up. Print new
|
||||||
|
not_imported value.
|
||||||
|
(check_and_store): Update non_imported counter.
|
||||||
|
(print_import_problem): New.
|
||||||
|
(check_and_store): Print error status message.
|
||||||
|
* server.c (get_status_string): Added STATUS_IMPORT_PROBLEM.
|
||||||
|
|
||||||
2002-08-20 Werner Koch <wk@gnupg.org>
|
2002-08-20 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
* gpgsm.c (main): Use the log file only in server mode.
|
* gpgsm.c (main): Use the log file only in server mode.
|
||||||
|
82
sm/import.c
82
sm/import.c
@ -36,9 +36,9 @@
|
|||||||
|
|
||||||
struct stats_s {
|
struct stats_s {
|
||||||
unsigned long count;
|
unsigned long count;
|
||||||
unsigned long skipped_new_keys;
|
|
||||||
unsigned long imported;
|
unsigned long imported;
|
||||||
unsigned long unchanged;
|
unsigned long unchanged;
|
||||||
|
unsigned long not_imported;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -54,16 +54,46 @@ print_imported_status (CTRL ctrl, KsbaCert cert)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Print an IMPORT_PROBLEM status. REASON is one of:
|
||||||
|
0 := "No specific reason given".
|
||||||
|
1 := "Invalid Certificate".
|
||||||
|
2 := "Issuer Certificate missing".
|
||||||
|
3 := "Certificate Chain too long".
|
||||||
|
4 := "Error storing certificate".
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
print_import_problem (CTRL ctrl, KsbaCert cert, int reason)
|
||||||
|
{
|
||||||
|
char *fpr = NULL;
|
||||||
|
char buf[25];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
sprintf (buf, "%d", reason);
|
||||||
|
if (cert)
|
||||||
|
{
|
||||||
|
fpr = gpgsm_get_fingerprint_hexstring (cert, GCRY_MD_SHA1);
|
||||||
|
/* detetect an error (all high) value */
|
||||||
|
for (i=0; fpr[i] == 'F'; i++)
|
||||||
|
;
|
||||||
|
if (!fpr[i])
|
||||||
|
{
|
||||||
|
xfree (fpr);
|
||||||
|
fpr = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gpgsm_status2 (ctrl, STATUS_IMPORT_PROBLEM, buf, fpr, NULL);
|
||||||
|
xfree (fpr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
print_imported_summary (CTRL ctrl, struct stats_s *stats)
|
print_imported_summary (CTRL ctrl, struct stats_s *stats)
|
||||||
{
|
{
|
||||||
char buf[13*25];
|
char buf[14*25];
|
||||||
|
|
||||||
if (!opt.quiet)
|
if (!opt.quiet)
|
||||||
{
|
{
|
||||||
log_info (_("total number processed: %lu\n"), stats->count);
|
log_info (_("total number processed: %lu\n"), stats->count);
|
||||||
if (stats->skipped_new_keys)
|
|
||||||
log_info(_(" skipped new keys: %lu\n"), stats->skipped_new_keys );
|
|
||||||
if (stats->imported)
|
if (stats->imported)
|
||||||
{
|
{
|
||||||
log_info (_(" imported: %lu"), stats->imported );
|
log_info (_(" imported: %lu"), stats->imported );
|
||||||
@ -71,22 +101,15 @@ print_imported_summary (CTRL ctrl, struct stats_s *stats)
|
|||||||
}
|
}
|
||||||
if (stats->unchanged)
|
if (stats->unchanged)
|
||||||
log_info (_(" unchanged: %lu\n"), stats->unchanged);
|
log_info (_(" unchanged: %lu\n"), stats->unchanged);
|
||||||
|
if (stats->not_imported)
|
||||||
|
log_info (_(" not imported: %lu\n"), stats->not_imported);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf (buf, "%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu",
|
sprintf (buf, "%lu 0 %lu 0 %lu 0 0 0 0 0 0 0 0 %lu",
|
||||||
stats->count,
|
stats->count,
|
||||||
0l, /*stats->no_user_id*/
|
|
||||||
stats->imported,
|
stats->imported,
|
||||||
0l, /*stats->imported_rsa*/
|
|
||||||
stats->unchanged,
|
stats->unchanged,
|
||||||
0l, /*stats->n_uids*/
|
stats->not_imported
|
||||||
0l, /*stats->n_subk*/
|
|
||||||
0l, /*stats->n_sigs*/
|
|
||||||
0l, /*stats->n_revoc*/
|
|
||||||
0l, /*stats->secret_read*/
|
|
||||||
0l, /*stats->secret_imported*/
|
|
||||||
0l, /*stats->secret_dups*/
|
|
||||||
stats->skipped_new_keys
|
|
||||||
);
|
);
|
||||||
gpgsm_status (ctrl, STATUS_IMPORT_RES, buf);
|
gpgsm_status (ctrl, STATUS_IMPORT_RES, buf);
|
||||||
}
|
}
|
||||||
@ -96,8 +119,19 @@ print_imported_summary (CTRL ctrl, struct stats_s *stats)
|
|||||||
static void
|
static void
|
||||||
check_and_store (CTRL ctrl, struct stats_s *stats, KsbaCert cert, int depth)
|
check_and_store (CTRL ctrl, struct stats_s *stats, KsbaCert cert, int depth)
|
||||||
{
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
stats->count++;
|
stats->count++;
|
||||||
if ( !gpgsm_basic_cert_check (cert) )
|
if ( depth >= 50 )
|
||||||
|
{
|
||||||
|
log_error (_("certificate chain too long\n"));
|
||||||
|
stats->not_imported++;
|
||||||
|
print_import_problem (ctrl, cert, 3);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = gpgsm_basic_cert_check (cert);
|
||||||
|
if (!rc)
|
||||||
{
|
{
|
||||||
int existed;
|
int existed;
|
||||||
|
|
||||||
@ -129,8 +163,6 @@ check_and_store (CTRL ctrl, struct stats_s *stats, KsbaCert cert, int depth)
|
|||||||
}
|
}
|
||||||
/* Now lets walk up the chain and import all certificates up
|
/* Now lets walk up the chain and import all certificates up
|
||||||
the chain.*/
|
the chain.*/
|
||||||
if ( depth >= 50 )
|
|
||||||
log_error (_("certificate chain too long\n"));
|
|
||||||
else if (!gpgsm_walk_cert_chain (cert, &next))
|
else if (!gpgsm_walk_cert_chain (cert, &next))
|
||||||
{
|
{
|
||||||
check_and_store (ctrl, stats, next, depth+1);
|
check_and_store (ctrl, stats, next, depth+1);
|
||||||
@ -138,10 +170,20 @@ check_and_store (CTRL ctrl, struct stats_s *stats, KsbaCert cert, int depth)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
log_error (_("error storing certificate\n"));
|
{
|
||||||
|
log_error (_("error storing certificate\n"));
|
||||||
|
stats->not_imported++;
|
||||||
|
print_import_problem (ctrl, cert, 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
log_error (_("basic certificate checks failed - not imported\n"));
|
{
|
||||||
|
log_error (_("basic certificate checks failed - not imported\n"));
|
||||||
|
stats->not_imported++;
|
||||||
|
print_import_problem (ctrl, cert,
|
||||||
|
rc == GNUPG_Missing_Certificate? 2 :
|
||||||
|
rc == GNUPG_Bad_Certificate? 1 : 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -904,6 +904,7 @@ get_status_string ( int no )
|
|||||||
case STATUS_EXPKEYSIG : s = "EXPKEYSIG"; break;
|
case STATUS_EXPKEYSIG : s = "EXPKEYSIG"; break;
|
||||||
case STATUS_TRUNCATED : s = "TRUNCATED"; break;
|
case STATUS_TRUNCATED : s = "TRUNCATED"; break;
|
||||||
case STATUS_ERROR : s = "ERROR"; break;
|
case STATUS_ERROR : s = "ERROR"; break;
|
||||||
|
case STATUS_IMPORT_PROBLEM : s = "IMPORT_PROBLEM"; break;
|
||||||
default: s = "?"; break;
|
default: s = "?"; break;
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user