mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg: Do not require a trustdb with --always-trust.
* g10/tdbio.c (tdbio_set_dbname): Add arg R_NOFILE.
* g10/trustdb.c (trustdb_args): Add field no_trustdb.
(init_trustdb): Set that field.
(revalidation_mark): Take care of a nonexistent trustdb file.
(read_trust_options): Ditto.
(tdb_get_ownertrust): Ditto.
(tdb_get_min_ownertrust): Ditto.
(tdb_update_ownertrust): Ditto.
(update_min_ownertrust): Ditto.
(tdb_clear_ownertrusts): Ditto.
(tdb_cache_disabled_value): Ditto.
(tdb_check_trustdb_stale): Ditto.
(tdb_get_validity_core): Ditto.
* g10/gpg.c (main): Do not create a trustdb with most commands for
trust-model always.
--
This slightly changes the semantics of most commands in that they
won't create a trustdb if --trust-model=always is used. It just does
not make sense to create a trustdb if there is no need for it.
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 1a0eeaacd1
)
Resolved conflicts:
NEWS
g10/trustdb.c: Manually apply changes due to changed
function names.
Note that this also includes the fix for clear_ownertrust, see
GnuPG-bug-id: 1622.
This commit is contained in:
parent
dfb25d47a9
commit
d8f0b83e4f
5 changed files with 66 additions and 22 deletions
|
@ -49,19 +49,22 @@ typedef struct key_item **KeyHashTable; /* see new_key_hash_table() */
|
|||
* the item right after the last one has a keyblock set to NULL.
|
||||
* Maybe we can drop this thing and replace it by key_item
|
||||
*/
|
||||
struct key_array {
|
||||
struct key_array
|
||||
{
|
||||
KBNODE keyblock;
|
||||
};
|
||||
|
||||
|
||||
/* control information for the trust DB */
|
||||
static struct {
|
||||
int init;
|
||||
int level;
|
||||
char *dbname;
|
||||
/* Control information for the trust DB. */
|
||||
static struct
|
||||
{
|
||||
int init;
|
||||
int level;
|
||||
char *dbname;
|
||||
int no_trustdb;
|
||||
} trustdb_args;
|
||||
|
||||
/* some globals */
|
||||
/* Some globals. */
|
||||
static struct key_item *user_utk_list; /* temp. used to store --trusted-keys */
|
||||
static struct key_item *utk_list; /* all ultimately trusted keys */
|
||||
|
||||
|
@ -417,7 +420,7 @@ how_to_fix_the_trustdb ()
|
|||
|
||||
|
||||
void
|
||||
init_trustdb()
|
||||
init_trustdb ()
|
||||
{
|
||||
int level = trustdb_args.level;
|
||||
const char* dbname = trustdb_args.dbname;
|
||||
|
@ -429,7 +432,7 @@ init_trustdb()
|
|||
|
||||
if(level==0 || level==1)
|
||||
{
|
||||
int rc = tdbio_set_dbname( dbname, !!level );
|
||||
int rc = tdbio_set_dbname( dbname, !!level, &trustdb_args.no_trustdb);
|
||||
if( rc )
|
||||
log_fatal("can't init trustdb: %s\n", g10_errstr(rc) );
|
||||
}
|
||||
|
@ -525,10 +528,13 @@ void
|
|||
tdb_revalidation_mark (void)
|
||||
{
|
||||
init_trustdb();
|
||||
/* we simply set the time for the next check to 1 (far back in 1970)
|
||||
* so that a --update-trustdb will be scheduled */
|
||||
if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
|
||||
return;
|
||||
|
||||
/* We simply set the time for the next check to 1 (far back in 1970)
|
||||
so that a --update-trustdb will be scheduled. */
|
||||
if (tdbio_write_nextcheck (1))
|
||||
do_sync ();
|
||||
do_sync ();
|
||||
pending_check_trustdb = 1;
|
||||
}
|
||||
|
||||
|
@ -560,8 +566,10 @@ read_trust_options(byte *trust_model,ulong *created,ulong *nextcheck,
|
|||
TRUSTREC opts;
|
||||
|
||||
init_trustdb();
|
||||
|
||||
read_record(0,&opts,RECTYPE_VER);
|
||||
if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
|
||||
memset (&opts, 0, sizeof opts);
|
||||
else
|
||||
read_record (0, &opts, RECTYPE_VER);
|
||||
|
||||
if(trust_model)
|
||||
*trust_model=opts.r.ver.trust_model;
|
||||
|
@ -619,6 +627,9 @@ tdb_get_ownertrust ( PKT_public_key *pk)
|
|||
TRUSTREC rec;
|
||||
int rc;
|
||||
|
||||
if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
|
||||
return TRUST_UNKNOWN;
|
||||
|
||||
rc = read_trust_record (pk, &rec);
|
||||
if (rc == -1)
|
||||
return TRUST_UNKNOWN; /* no record yet */
|
||||
|
@ -638,6 +649,9 @@ tdb_get_min_ownertrust (PKT_public_key *pk)
|
|||
TRUSTREC rec;
|
||||
int rc;
|
||||
|
||||
if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
|
||||
return TRUST_UNKNOWN;
|
||||
|
||||
rc = read_trust_record (pk, &rec);
|
||||
if (rc == -1)
|
||||
return TRUST_UNKNOWN; /* no record yet */
|
||||
|
@ -661,6 +675,9 @@ tdb_update_ownertrust (PKT_public_key *pk, unsigned int new_trust )
|
|||
TRUSTREC rec;
|
||||
int rc;
|
||||
|
||||
if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
|
||||
return;
|
||||
|
||||
rc = read_trust_record (pk, &rec);
|
||||
if (!rc)
|
||||
{
|
||||
|
@ -705,6 +722,9 @@ update_min_ownertrust (u32 *kid, unsigned int new_trust )
|
|||
TRUSTREC rec;
|
||||
int rc;
|
||||
|
||||
if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
|
||||
return;
|
||||
|
||||
pk = xmalloc_clear (sizeof *pk);
|
||||
rc = get_pubkey (pk, kid);
|
||||
if (rc)
|
||||
|
@ -761,6 +781,11 @@ tdb_clear_ownertrusts (PKT_public_key *pk)
|
|||
TRUSTREC rec;
|
||||
int rc;
|
||||
|
||||
init_trustdb ();
|
||||
|
||||
if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
|
||||
return 0;
|
||||
|
||||
rc = read_trust_record (pk, &rec);
|
||||
if (!rc)
|
||||
{
|
||||
|
@ -865,6 +890,9 @@ tdb_cache_disabled_value (PKT_public_key *pk)
|
|||
|
||||
init_trustdb();
|
||||
|
||||
if (trustdb_args.no_trustdb)
|
||||
return 0; /* No trustdb => not disabled. */
|
||||
|
||||
rc = read_trust_record (pk, &trec);
|
||||
if (rc && rc != -1)
|
||||
{
|
||||
|
@ -893,6 +921,10 @@ tdb_check_trustdb_stale (void)
|
|||
static int did_nextcheck=0;
|
||||
|
||||
init_trustdb ();
|
||||
|
||||
if (trustdb_args.no_trustdb)
|
||||
return; /* No trustdb => can't be stale. */
|
||||
|
||||
if (!did_nextcheck
|
||||
&& (opt.trust_model==TM_PGP || opt.trust_model==TM_CLASSIC))
|
||||
{
|
||||
|
@ -931,6 +963,14 @@ tdb_get_validity_core (PKT_public_key *pk, PKT_user_id *uid,
|
|||
unsigned int validity;
|
||||
|
||||
init_trustdb ();
|
||||
|
||||
/* If we have no trustdb (which also means it has not been created)
|
||||
and the trust-model is always, we don't know the validity -
|
||||
return immediately. If we won't do that the tdbio code would try
|
||||
to open the trustdb and run into a fatal error. */
|
||||
if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
|
||||
return TRUST_UNKNOWN;
|
||||
|
||||
check_trustdb_stale();
|
||||
|
||||
if(opt.trust_model==TM_DIRECT)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue