aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
Diffstat (limited to 'g10')
-rw-r--r--g10/ChangeLog35
-rw-r--r--g10/g10.c27
-rw-r--r--g10/keydb.c109
3 files changed, 92 insertions, 79 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 48905ceb8..69982aa77 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,12 @@
+2002-01-05 Werner Koch <[email protected]>
+
+ * g10.c (main): Do not register the secret keyrings for certain
+ commands.
+
+ * keydb.c (keydb_add_resource): Use access to test for keyring
+ existence. This avoids cached opened files which are bad under
+ RISC OS.
+
2002-01-04 David Shaw <[email protected]>
* sign.c (sign_file, sign_symencrypt_file): always use one-pass
@@ -32,15 +41,15 @@
2002-01-03 Timo Schulz <[email protected]>
- * g10.c: New command --encrypt-files.
+ * g10.c: New command --encrypt-files.
- * verify.c (print_file_status): Removed the static because
- encode_crypt_files also uses this function.
+ * verify.c (print_file_status): Removed the static because
+ encode_crypt_files also uses this function.
- * main.h (print_files_status): New.
- (encode_crypt_files): New.
+ * main.h (print_files_status): New.
+ (encode_crypt_files): New.
- * encode.c (encode_crypt_files): New.
+ * encode.c (encode_crypt_files): New.
2002-01-02 Stefan Bellon <[email protected]>
@@ -109,15 +118,15 @@
2001-12-23 Timo Schulz <[email protected]>
- * misc.c (check_permissions): Do not use it for W32 systems.
+ * misc.c (check_permissions): Do not use it for W32 systems.
- * tdbio.c (migrate_from_v2): Define ftruncate as chsize() for W32.
+ * tdbio.c (migrate_from_v2): Define ftruncate as chsize() for W32.
- * mkdtemp.c: W32 support.
+ * mkdtemp.c: W32 support.
- * photoid.c: Ditto.
+ * photoid.c: Ditto.
- * exec.c: Ditto.
+ * exec.c: Ditto.
2001-12-22 David Shaw <[email protected]>
@@ -4748,7 +4757,7 @@ Thu Feb 12 22:24:42 1998 Werner Koch (wk@frodo)
* pubkey-enc.c (get_session_key): rewritten
- Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright 1998,1999,2000,2001,2002 Free Software Foundation, Inc.
This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without
@@ -4757,5 +4766,3 @@ Thu Feb 12 22:24:42 1998 Werner Koch (wk@frodo)
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-
diff --git a/g10/g10.c b/g10/g10.c
index a96f23153..553047c15 100644
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -1,5 +1,5 @@
/* g10.c - The GnuPG utility (main for gpg)
- * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ * Copyright (C) 1998,1999,2000,2001,2002 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -1437,20 +1437,27 @@ main( int argc, char **argv )
if( opt.verbose > 1 )
set_packet_list_mode(1);
- /* add the keyrings, but not for some special commands and
- * not in case of "-kvv userid keyring" */
+ /* Add the keyrings, but not for some special commands and not in
+ case of "-kvv userid keyring". Also avoid adding the secret
+ keyring for a couple of commands to avaoid unneeded access in
+ case the secrings are stored on a floppy */
if( cmd != aDeArmor && cmd != aEnArmor
- && !(cmd == aKMode && argc == 2 ) ) {
-
- if( !sec_nrings || default_keyring ) /* add default secret rings */
- keydb_add_resource ("secring" EXTSEP_S "gpg", 0, 1);
- for(sl = sec_nrings; sl; sl = sl->next )
- keydb_add_resource ( sl->d, 0, 1 );
+ && !(cmd == aKMode && argc == 2 ) )
+ {
+ if (cmd != aCheckKeys && cmd != aListSigs && cmd != aListKeys
+ && cmd != aVerify && cmd != aVerifyFiles
+ && cmd != aEncr && cmd != aSym)
+ {
+ if (!sec_nrings || default_keyring) /* add default secret rings */
+ keydb_add_resource ("secring" EXTSEP_S "gpg", 0, 1);
+ for (sl = sec_nrings; sl; sl = sl->next)
+ keydb_add_resource ( sl->d, 0, 1 );
+ }
if( !nrings || default_keyring ) /* add default ring */
keydb_add_resource ("pubring" EXTSEP_S "gpg", 0, 0);
for(sl = nrings; sl; sl = sl->next )
keydb_add_resource ( sl->d, 0, 0 );
- }
+ }
FREE_STRLIST(nrings);
FREE_STRLIST(sec_nrings);
diff --git a/g10/keydb.c b/g10/keydb.c
index 699960c3d..96d19105a 100644
--- a/g10/keydb.c
+++ b/g10/keydb.c
@@ -1,5 +1,5 @@
/* keydb.c - key database dispatcher
- * Copyright (C) 2001 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2002 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -85,7 +85,7 @@ keydb_add_resource (const char *url, int force, int secret)
char *filename = NULL;
int rc = 0;
KeydbResourceType rt = KEYDB_RESOURCE_TYPE_NONE;
- const char *created_fname = NULL;
+ void *token;
/* Do we have an URL?
* gnupg-ring:filename := this is a plain keyring
@@ -147,74 +147,73 @@ keydb_add_resource (const char *url, int force, int secret)
goto leave;
case KEYDB_RESOURCE_TYPE_KEYRING:
- iobuf = iobuf_open (filename);
- if (!iobuf && !force) {
- rc = G10ERR_OPEN_FILE;
- goto leave;
- }
-
- if (!iobuf) {
+ if (access(filename, F_OK))
+ { /* file does not exist */
char *last_slash_in_filename;
+ if (!force)
+ {
+ rc = G10ERR_OPEN_FILE;
+ goto leave;
+ }
+
last_slash_in_filename = strrchr (filename, DIRSEP_C);
*last_slash_in_filename = 0;
-
- if (access(filename, F_OK)) {
- /* on the first time we try to create the default homedir and
- * in this case the process will be terminated, so that on the
- * next invocation it can read the options file in on startup
- */
+ if (access(filename, F_OK))
+ { /* on the first time we try to create the default
+ homedir and in this case the process will be
+ terminated, so that on the next invocation it can
+ read the options file in on startup */
try_make_homedir (filename);
rc = G10ERR_OPEN_FILE;
*last_slash_in_filename = DIRSEP_C;
goto leave;
- }
-
+ }
*last_slash_in_filename = DIRSEP_C;
iobuf = iobuf_create (filename);
- if (!iobuf) {
+ if (!iobuf)
+ {
log_error ( _("error creating keyring `%s': %s\n"),
filename, strerror(errno));
rc = G10ERR_OPEN_FILE;
goto leave;
- }
- else {
- #ifndef HAVE_DOSISH_SYSTEM
- if (secret && !opt.preserve_permissions) {
- if (chmod (filename, S_IRUSR | S_IWUSR) ) {
- log_error (_("changing permission of "
- " `%s' failed: %s\n"),
- filename, strerror(errno) );
- rc = G10ERR_WRITE_FILE;
- goto leave;
- }
- }
- #endif
- if (!opt.quiet)
- log_info (_("keyring `%s' created\n"), filename);
- created_fname = filename;
- }
- }
- iobuf_close (iobuf);
- iobuf = NULL;
- if (created_fname) /* must invalidate that ugly cache */
- iobuf_ioctl (NULL, 2, 0, (char*)created_fname);
- {
- void *token = keyring_register_filename (filename, secret);
- if (!token)
- ; /* already registered - ignore it */
- else if (used_resources >= MAX_KEYDB_RESOURCES)
- rc = G10ERR_RESOURCE_LIMIT;
- else
- {
- all_resources[used_resources].type = rt;
- all_resources[used_resources].u.kr = NULL; /* Not used here */
- all_resources[used_resources].token = token;
- all_resources[used_resources].secret = secret;
- used_resources++;
- }
- }
+ }
+
+#ifndef HAVE_DOSISH_SYSTEM
+ if (secret && !opt.preserve_permissions)
+ {
+ if (chmod (filename, S_IRUSR | S_IWUSR) )
+ {
+ log_error (_("changing permission of "
+ " `%s' failed: %s\n"),
+ filename, strerror(errno) );
+ rc = G10ERR_WRITE_FILE;
+ goto leave;
+ }
+ }
+#endif
+ if (!opt.quiet)
+ log_info (_("keyring `%s' created\n"), filename);
+ iobuf_close (iobuf);
+ iobuf = NULL;
+ /* must invalidate that ugly cache */
+ iobuf_ioctl (NULL, 2, 0, (char*)filename);
+ } /* end file creation */
+
+ token = keyring_register_filename (filename, secret);
+ if (!token)
+ ; /* already registered - ignore it */
+ else if (used_resources >= MAX_KEYDB_RESOURCES)
+ rc = G10ERR_RESOURCE_LIMIT;
+ else
+ {
+ all_resources[used_resources].type = rt;
+ all_resources[used_resources].u.kr = NULL; /* Not used here */
+ all_resources[used_resources].token = token;
+ all_resources[used_resources].secret = secret;
+ used_resources++;
+ }
break;
default: