diff --git a/g10/ChangeLog b/g10/ChangeLog index 253336ec2..5846dc27d 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,8 @@ +2009-04-03 Werner Koch + + * gpgv.c (main): Pass readonly flag to keydb_add_resource. + * keydb.c (keydb_add_resource): Add arg READONLY. + 2009-03-20 David Shaw * keyring.c (rename_tmp_file): Force a fsync (via iobuf_ioctl) on diff --git a/g10/gpgv.c b/g10/gpgv.c index 78776a48b..d3879325d 100644 --- a/g10/gpgv.c +++ b/g10/gpgv.c @@ -178,9 +178,9 @@ main( int argc, char **argv ) set_packet_list_mode(1); if( !nrings ) /* no keyring given: use default one */ - keydb_add_resource ("trustedkeys" EXTSEP_S "gpg", 0, 0); + keydb_add_resource ("trustedkeys" EXTSEP_S "gpg", 8, 0); for(sl = nrings; sl; sl = sl->next ) - keydb_add_resource (sl->d, 0, 0 ); + keydb_add_resource (sl->d, 8, 0 ); FREE_STRLIST(nrings); diff --git a/g10/keydb.c b/g10/keydb.c index a791a4d4e..82962c7e3 100644 --- a/g10/keydb.c +++ b/g10/keydb.c @@ -196,6 +196,7 @@ maybe_create_keyring (char *filename, int force) * Flag 1 == force * Flag 2 == mark resource as primary * Flag 4 == This is a default resources + * Flag 8 == Readonly */ int keydb_add_resource (const char *url, int flags, int secret) @@ -204,10 +205,14 @@ keydb_add_resource (const char *url, int flags, int secret) const char *resname = url; char *filename = NULL; int force=(flags&1); + int readonly=!!(flags&8); int rc = 0; KeydbResourceType rt = KEYDB_RESOURCE_TYPE_NONE; void *token; + if (readonly) + force = 0; + /* Do we have an URL? * gnupg-ring:filename := this is a plain keyring * filename := See what is is, but create as plain keyring. @@ -235,7 +240,7 @@ keydb_add_resource (const char *url, int flags, int secret) else filename = xstrdup (resname); - if (!force) + if (!force && !readonly) force = secret? !any_secret : !any_public; /* see whether we can determine the filetype */