mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +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. (get_ownertrust): Ditto. (get_min_ownertrust): Ditto. (update_ownertrust): Ditto. (update_min_ownertrust): Ditto. (clear_ownertrusts): Ditto. (cache_disabled_value): Ditto. (check_trustdb_stale): Ditto. (get_validity): 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>
This commit is contained in:
parent
6286d01ba3
commit
1a0eeaacd1
2
NEWS
2
NEWS
@ -1,6 +1,8 @@
|
|||||||
Noteworthy changes in version 2.0.23 (unreleased)
|
Noteworthy changes in version 2.0.23 (unreleased)
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
|
* Do not create a trustdb file if --trust-model=always is used.
|
||||||
|
|
||||||
|
|
||||||
Noteworthy changes in version 2.0.22 (2013-10-04)
|
Noteworthy changes in version 2.0.22 (2013-10-04)
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
@ -3408,15 +3408,11 @@ main (int argc, char **argv)
|
|||||||
case aListTrustDB:
|
case aListTrustDB:
|
||||||
rc = setup_trustdb (argc? 1:0, trustdb_name);
|
rc = setup_trustdb (argc? 1:0, trustdb_name);
|
||||||
break;
|
break;
|
||||||
case aEncr:
|
default:
|
||||||
case aEncrFiles:
|
|
||||||
/* If we are using TM_ALWAYS, we do not need to create the
|
/* If we are using TM_ALWAYS, we do not need to create the
|
||||||
trustdb. */
|
trustdb. */
|
||||||
rc = setup_trustdb (opt.trust_model != TM_ALWAYS, trustdb_name);
|
rc = setup_trustdb (opt.trust_model != TM_ALWAYS, trustdb_name);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
rc = setup_trustdb (1, trustdb_name );
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (rc)
|
if (rc)
|
||||||
log_error (_("failed to initialize the TrustDB: %s\n"), g10_errstr(rc));
|
log_error (_("failed to initialize the TrustDB: %s\n"), g10_errstr(rc));
|
||||||
|
@ -473,7 +473,7 @@ create_version_record (void)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
tdbio_set_dbname( const char *new_dbname, int create )
|
tdbio_set_dbname( const char *new_dbname, int create, int *r_nofile)
|
||||||
{
|
{
|
||||||
char *fname;
|
char *fname;
|
||||||
static int initialized = 0;
|
static int initialized = 0;
|
||||||
@ -483,6 +483,8 @@ tdbio_set_dbname( const char *new_dbname, int create )
|
|||||||
initialized = 1;
|
initialized = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*r_nofile = 0;
|
||||||
|
|
||||||
if(new_dbname==NULL)
|
if(new_dbname==NULL)
|
||||||
fname=make_filename(opt.homedir,"trustdb" EXTSEP_S "gpg", NULL);
|
fname=make_filename(opt.homedir,"trustdb" EXTSEP_S "gpg", NULL);
|
||||||
else if (*new_dbname != DIRSEP_C )
|
else if (*new_dbname != DIRSEP_C )
|
||||||
@ -501,7 +503,9 @@ tdbio_set_dbname( const char *new_dbname, int create )
|
|||||||
xfree(fname);
|
xfree(fname);
|
||||||
return G10ERR_TRUSTDB;
|
return G10ERR_TRUSTDB;
|
||||||
}
|
}
|
||||||
if( create ) {
|
if (!create)
|
||||||
|
*r_nofile = 1;
|
||||||
|
else {
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
TRUSTREC rec;
|
TRUSTREC rec;
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -93,7 +93,7 @@ typedef struct trust_record TRUSTREC;
|
|||||||
|
|
||||||
/*-- tdbio.c --*/
|
/*-- tdbio.c --*/
|
||||||
int tdbio_update_version_record(void);
|
int tdbio_update_version_record(void);
|
||||||
int tdbio_set_dbname( const char *new_dbname, int create );
|
int tdbio_set_dbname( const char *new_dbname, int create, int *r_nofile);
|
||||||
const char *tdbio_get_dbname(void);
|
const char *tdbio_get_dbname(void);
|
||||||
void tdbio_dump_record( TRUSTREC *rec, FILE *fp );
|
void tdbio_dump_record( TRUSTREC *rec, FILE *fp );
|
||||||
int tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected );
|
int tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected );
|
||||||
|
@ -73,6 +73,7 @@ static struct {
|
|||||||
int init;
|
int init;
|
||||||
int level;
|
int level;
|
||||||
char *dbname;
|
char *dbname;
|
||||||
|
int no_trustdb; /* Set if a trustdb file is not available. */
|
||||||
} trustdb_args;
|
} trustdb_args;
|
||||||
|
|
||||||
/* some globals */
|
/* some globals */
|
||||||
@ -441,7 +442,7 @@ init_trustdb()
|
|||||||
|
|
||||||
if(level==0 || level==1)
|
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 )
|
if( rc )
|
||||||
log_fatal("can't init trustdb: %s\n", g10_errstr(rc) );
|
log_fatal("can't init trustdb: %s\n", g10_errstr(rc) );
|
||||||
}
|
}
|
||||||
@ -627,6 +628,9 @@ void
|
|||||||
revalidation_mark (void)
|
revalidation_mark (void)
|
||||||
{
|
{
|
||||||
init_trustdb();
|
init_trustdb();
|
||||||
|
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)
|
/* we simply set the time for the next check to 1 (far back in 1970)
|
||||||
* so that a --update-trustdb will be scheduled */
|
* so that a --update-trustdb will be scheduled */
|
||||||
if (tdbio_write_nextcheck (1))
|
if (tdbio_write_nextcheck (1))
|
||||||
@ -662,7 +666,9 @@ read_trust_options(byte *trust_model,ulong *created,ulong *nextcheck,
|
|||||||
TRUSTREC opts;
|
TRUSTREC opts;
|
||||||
|
|
||||||
init_trustdb();
|
init_trustdb();
|
||||||
|
if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
|
||||||
|
memset (&opts, 0, sizeof opts);
|
||||||
|
else
|
||||||
read_record(0,&opts,RECTYPE_VER);
|
read_record(0,&opts,RECTYPE_VER);
|
||||||
|
|
||||||
if(trust_model)
|
if(trust_model)
|
||||||
@ -721,6 +727,9 @@ get_ownertrust ( PKT_public_key *pk)
|
|||||||
TRUSTREC rec;
|
TRUSTREC rec;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
|
||||||
|
return TRUST_UNKNOWN;
|
||||||
|
|
||||||
rc = read_trust_record (pk, &rec);
|
rc = read_trust_record (pk, &rec);
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
return TRUST_UNKNOWN; /* no record yet */
|
return TRUST_UNKNOWN; /* no record yet */
|
||||||
@ -739,6 +748,9 @@ get_min_ownertrust (PKT_public_key *pk)
|
|||||||
TRUSTREC rec;
|
TRUSTREC rec;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
|
||||||
|
return TRUST_UNKNOWN;
|
||||||
|
|
||||||
rc = read_trust_record (pk, &rec);
|
rc = read_trust_record (pk, &rec);
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
return TRUST_UNKNOWN; /* no record yet */
|
return TRUST_UNKNOWN; /* no record yet */
|
||||||
@ -806,6 +818,9 @@ update_ownertrust (PKT_public_key *pk, unsigned int new_trust )
|
|||||||
TRUSTREC rec;
|
TRUSTREC rec;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
|
||||||
|
return;
|
||||||
|
|
||||||
rc = read_trust_record (pk, &rec);
|
rc = read_trust_record (pk, &rec);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
{
|
{
|
||||||
@ -850,6 +865,9 @@ update_min_ownertrust (u32 *kid, unsigned int new_trust )
|
|||||||
TRUSTREC rec;
|
TRUSTREC rec;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
|
||||||
|
return;
|
||||||
|
|
||||||
pk = xmalloc_clear (sizeof *pk);
|
pk = xmalloc_clear (sizeof *pk);
|
||||||
rc = get_pubkey (pk, kid);
|
rc = get_pubkey (pk, kid);
|
||||||
if (rc)
|
if (rc)
|
||||||
@ -905,6 +923,9 @@ clear_ownertrusts (PKT_public_key *pk)
|
|||||||
TRUSTREC rec;
|
TRUSTREC rec;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
rc = read_trust_record (pk, &rec);
|
rc = read_trust_record (pk, &rec);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
{
|
{
|
||||||
@ -1007,6 +1028,8 @@ cache_disabled_value(PKT_public_key *pk)
|
|||||||
return (pk->is_disabled==2);
|
return (pk->is_disabled==2);
|
||||||
|
|
||||||
init_trustdb();
|
init_trustdb();
|
||||||
|
if (trustdb_args.no_trustdb)
|
||||||
|
return 0; /* No trustdb => not disabled. */
|
||||||
|
|
||||||
rc = read_trust_record (pk, &trec);
|
rc = read_trust_record (pk, &trec);
|
||||||
if (rc && rc != -1)
|
if (rc && rc != -1)
|
||||||
@ -1037,6 +1060,9 @@ check_trustdb_stale(void)
|
|||||||
static int did_nextcheck=0;
|
static int did_nextcheck=0;
|
||||||
|
|
||||||
init_trustdb ();
|
init_trustdb ();
|
||||||
|
if (trustdb_args.no_trustdb)
|
||||||
|
return; /* No trustdb => can't be stale. */
|
||||||
|
|
||||||
if (!did_nextcheck
|
if (!did_nextcheck
|
||||||
&& (opt.trust_model==TM_PGP || opt.trust_model==TM_CLASSIC))
|
&& (opt.trust_model==TM_PGP || opt.trust_model==TM_CLASSIC))
|
||||||
{
|
{
|
||||||
@ -1080,6 +1106,14 @@ get_validity (PKT_public_key *pk, PKT_user_id *uid)
|
|||||||
namehash_from_uid(uid);
|
namehash_from_uid(uid);
|
||||||
|
|
||||||
init_trustdb ();
|
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();
|
check_trustdb_stale();
|
||||||
|
|
||||||
keyid_from_pk (pk, kid);
|
keyid_from_pk (pk, kid);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user