1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-02-08 17:43:04 +01:00

Parse EXTCAP lines from the card.

Change messages for a corrupt trustdb.
This commit is contained in:
Werner Koch 2009-07-23 08:00:39 +00:00
parent 3459c6b015
commit 6d755a83b4
7 changed files with 73 additions and 10 deletions

View File

@ -1,3 +1,15 @@
2009-07-23 Werner Koch <wk@g10code.com>
* trustdb.c (how_to_fix_the_trustdb): New.
* tdbio.c (tdbio_invalid): Print hints on how to fix the trustdb.
* gpg.c (main) <aFixTrustDB>: Print hints.
2009-07-22 Werner Koch <wk@g10code.com>
* cardglue.h (struct agent_card_info_s): Add field EXTCAP.
* cardglue.c (agent_learn): Read KEY-ATTR.
(learn_status_cb): Parse EXTCAP.
2009-07-21 Werner Koch <wk@g10code.com> 2009-07-21 Werner Koch <wk@g10code.com>
* app-common.h, app-openpgp.c, iso7816.c, iso7816.h, apdu.c, * app-common.h, app-openpgp.c, iso7816.c, iso7816.h, apdu.c,

View File

@ -1,5 +1,5 @@
/* cardglue.c - mainly dispatcher for card related functions. /* cardglue.c - mainly dispatcher for card related functions.
* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. * Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
* *
* This file is part of GnuPG. * This file is part of GnuPG.
* *
@ -382,7 +382,7 @@ open_card_via_agent (int *scd_available)
if (!ctx) if (!ctx)
return NULL; return NULL;
/* Request the serialbnumber of the card. If we get /* Request the serialnumber of the card. If we get
NOT_SUPPORTED or NO_SCDAEMON back, the gpg-agent either has NOT_SUPPORTED or NO_SCDAEMON back, the gpg-agent either has
disabled scdaemon or it can't be used. We close the connection disabled scdaemon or it can't be used. We close the connection
in this case and use our own code. This may happen if just the in this case and use our own code. This may happen if just the
@ -438,7 +438,7 @@ open_card (void)
if (app) if (app)
goto ready; /* Yes, there is a agent with a usable card, go that way. */ goto ready; /* Yes, there is a agent with a usable card, go that way. */
if (scd_available) if (scd_available)
return NULL; /* agent avilabale but card problem. */ return NULL; /* Agent available but card problem. */
} }
@ -770,6 +770,30 @@ learn_status_cb (void *opaque, const char *line)
xfree (buf); xfree (buf);
} }
} }
else if (keywordlen == 6 && !memcmp (keyword, "EXTCAP", keywordlen))
{
char *p, *p2, *buf;
int abool;
buf = p = unescape_status_string (line);
if (buf)
{
for (p = strtok (buf, " "); p; p = strtok (NULL, " "))
{
p2 = strchr (p, '=');
if (p2)
{
*p2++ = 0;
abool = (*p2 == '1');
if (!strcmp (p, "ki"))
parm->extcap.ki = abool;
else if (!strcmp (p, "aac"))
parm->extcap.aac = abool;
}
}
xfree (buf);
}
}
else if (keywordlen == 7 && !memcmp (keyword, "KEY-FPR", keywordlen)) else if (keywordlen == 7 && !memcmp (keyword, "KEY-FPR", keywordlen))
{ {
int no = atoi (line); int no = atoi (line);
@ -876,6 +900,9 @@ agent_learn (struct agent_card_info_s *info)
} }
} }
if (!rc)
agent_scd_getattr ("KEY-ATTR", info);
return rc; return rc;
} }

View File

@ -69,6 +69,10 @@ struct agent_card_info_s {
int algo; /* Algorithm identifier. */ int algo; /* Algorithm identifier. */
unsigned int nbits; /* Supported keysize. */ unsigned int nbits; /* Supported keysize. */
} key_attr[3]; } key_attr[3];
struct {
unsigned int ki:1; /* Key import available. */
unsigned int aac:1; /* Algorithm attributes are changeable. */
} extcap;
}; };
struct agent_card_genkey_s { struct agent_card_genkey_s {

View File

@ -3343,8 +3343,8 @@ main (int argc, char **argv )
case aGenRandom: case aGenRandom:
case aDeArmor: case aDeArmor:
case aEnArmor: case aEnArmor:
case aFixTrustDB:
break; break;
case aFixTrustDB:
case aExportOwnerTrust: rc = setup_trustdb( 0, trustdb_name ); break; case aExportOwnerTrust: rc = setup_trustdb( 0, trustdb_name ); break;
case aListTrustDB: rc = setup_trustdb( argc? 1:0, trustdb_name ); break; case aListTrustDB: rc = setup_trustdb( argc? 1:0, trustdb_name ); break;
default: rc = setup_trustdb(1, trustdb_name ); break; default: rc = setup_trustdb(1, trustdb_name ); break;
@ -3874,9 +3874,7 @@ main (int argc, char **argv )
break; break;
case aFixTrustDB: case aFixTrustDB:
log_error("this command is not yet implemented.\n"); how_to_fix_the_trustdb ();
log_error("A workaround is to use \"--export-ownertrust\", remove\n");
log_error("the trustdb file and do an \"--import-ownertrust\".\n" );
break; break;
case aListTrustPath: case aListTrustPath:

View File

@ -1499,9 +1499,9 @@ tdbio_search_trust_bypk (PKT_public_key *pk, TRUSTREC *rec)
void void
tdbio_invalid(void) tdbio_invalid(void)
{ {
log_error(_( log_error (_("Error: The trustdb is corrupted.\n"));
"the trustdb is corrupted; please run \"gpg --fix-trustdb\".\n") ); how_to_fix_the_trustdb ();
g10_exit(2); g10_exit (2);
} }
/* /*

View File

@ -411,6 +411,27 @@ setup_trustdb( int level, const char *dbname )
return 0; return 0;
} }
void
how_to_fix_the_trustdb ()
{
const char *name = trustdb_args.dbname;
if (!name)
name = "trustdb.gpg";
log_info (_("You may try to re-create the trustdb using the commands:\n"));
log_info (" cd %s\n", default_homedir ());
log_info (" gpg2 --export-ownertrust > otrust.tmp\n");
#ifdef HAVE_W32_SYSTEM
log_info (" del %s\n", name);
#else
log_info (" rm %s\n", name);
#endif
log_info (" gpg2 --import-ownertrust < otrust.tmp\n");
log_info (_("If that does not work, please consult the manual\n"));
}
void void
init_trustdb() init_trustdb()
{ {

View File

@ -45,6 +45,7 @@ void register_trusted_key( const char *string );
void check_trustdb (void); void check_trustdb (void);
void update_trustdb (void); void update_trustdb (void);
int setup_trustdb( int level, const char *dbname ); int setup_trustdb( int level, const char *dbname );
void how_to_fix_the_trustdb (void);
void init_trustdb( void ); void init_trustdb( void );
void check_trustdb_stale(void); void check_trustdb_stale(void);
void sync_trustdb( void ); void sync_trustdb( void );