1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-23 10:29:58 +01:00

* 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.
This commit is contained in:
Werner Koch 2002-01-05 18:57:54 +00:00
parent 23a3ca8968
commit 7cacea85a1
3 changed files with 92 additions and 79 deletions

View File

@ -1,3 +1,12 @@
2002-01-05 Werner Koch <wk@gnupg.org>
* 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 <dshaw@jabberwocky.com>
* sign.c (sign_file, sign_symencrypt_file): always use one-pass
@ -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.

View File

@ -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,15 +1437,22 @@ 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 */
&& !(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 )
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 )

View File

@ -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,42 +147,44 @@ keydb_add_resource (const char *url, int force, int secret)
goto leave;
case KEYDB_RESOURCE_TYPE_KEYRING:
iobuf = iobuf_open (filename);
if (!iobuf && !force) {
if (access(filename, F_OK))
{ /* file does not exist */
char *last_slash_in_filename;
if (!force)
{
rc = G10ERR_OPEN_FILE;
goto leave;
}
if (!iobuf) {
char *last_slash_in_filename;
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) ) {
#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) );
@ -190,18 +192,16 @@ keydb_add_resource (const char *url, int force, int secret)
goto leave;
}
}
#endif
#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);
/* 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)
@ -214,7 +214,6 @@ keydb_add_resource (const char *url, int force, int secret)
all_resources[used_resources].secret = secret;
used_resources++;
}
}
break;
default: