1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-04 20:38:50 +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> 2002-01-04 David Shaw <dshaw@jabberwocky.com>
* sign.c (sign_file, sign_symencrypt_file): always use one-pass * sign.c (sign_file, sign_symencrypt_file): always use one-pass
@ -32,15 +41,15 @@
2002-01-03 Timo Schulz <ts@winpt.org> 2002-01-03 Timo Schulz <ts@winpt.org>
* g10.c: New command --encrypt-files. * g10.c: New command --encrypt-files.
* verify.c (print_file_status): Removed the static because * verify.c (print_file_status): Removed the static because
encode_crypt_files also uses this function. encode_crypt_files also uses this function.
* main.h (print_files_status): New. * main.h (print_files_status): New.
(encode_crypt_files): New. (encode_crypt_files): New.
* encode.c (encode_crypt_files): New. * encode.c (encode_crypt_files): New.
2002-01-02 Stefan Bellon <sbellon@sbellon.de> 2002-01-02 Stefan Bellon <sbellon@sbellon.de>
@ -109,15 +118,15 @@
2001-12-23 Timo Schulz <ts@winpt.org> 2001-12-23 Timo Schulz <ts@winpt.org>
* 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 <dshaw@jabberwocky.com> 2001-12-22 David Shaw <dshaw@jabberwocky.com>
@ -4748,7 +4757,7 @@ Thu Feb 12 22:24:42 1998 Werner Koch (wk@frodo)
* pubkey-enc.c (get_session_key): rewritten * 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 This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without 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 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 WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

View File

@ -1,5 +1,5 @@
/* g10.c - The GnuPG utility (main for gpg) /* 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. * This file is part of GnuPG.
* *
@ -1437,20 +1437,27 @@ main( int argc, char **argv )
if( opt.verbose > 1 ) if( opt.verbose > 1 )
set_packet_list_mode(1); set_packet_list_mode(1);
/* add the keyrings, but not for some special commands and /* Add the keyrings, but not for some special commands and not in
* not in case of "-kvv userid keyring" */ 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 if( cmd != aDeArmor && cmd != aEnArmor
&& !(cmd == aKMode && argc == 2 ) ) { && !(cmd == aKMode && argc == 2 ) )
{
if( !sec_nrings || default_keyring ) /* add default secret rings */ if (cmd != aCheckKeys && cmd != aListSigs && cmd != aListKeys
keydb_add_resource ("secring" EXTSEP_S "gpg", 0, 1); && cmd != aVerify && cmd != aVerifyFiles
for(sl = sec_nrings; sl; sl = sl->next ) && cmd != aEncr && cmd != aSym)
keydb_add_resource ( sl->d, 0, 1 ); {
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 */ if( !nrings || default_keyring ) /* add default ring */
keydb_add_resource ("pubring" EXTSEP_S "gpg", 0, 0); keydb_add_resource ("pubring" EXTSEP_S "gpg", 0, 0);
for(sl = nrings; sl; sl = sl->next ) for(sl = nrings; sl; sl = sl->next )
keydb_add_resource ( sl->d, 0, 0 ); keydb_add_resource ( sl->d, 0, 0 );
} }
FREE_STRLIST(nrings); FREE_STRLIST(nrings);
FREE_STRLIST(sec_nrings); FREE_STRLIST(sec_nrings);

View File

@ -1,5 +1,5 @@
/* keydb.c - key database dispatcher /* 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. * This file is part of GnuPG.
* *
@ -85,7 +85,7 @@ keydb_add_resource (const char *url, int force, int secret)
char *filename = NULL; char *filename = NULL;
int rc = 0; int rc = 0;
KeydbResourceType rt = KEYDB_RESOURCE_TYPE_NONE; KeydbResourceType rt = KEYDB_RESOURCE_TYPE_NONE;
const char *created_fname = NULL; void *token;
/* Do we have an URL? /* Do we have an URL?
* gnupg-ring:filename := this is a plain keyring * gnupg-ring:filename := this is a plain keyring
@ -147,74 +147,73 @@ keydb_add_resource (const char *url, int force, int secret)
goto leave; goto leave;
case KEYDB_RESOURCE_TYPE_KEYRING: case KEYDB_RESOURCE_TYPE_KEYRING:
iobuf = iobuf_open (filename); if (access(filename, F_OK))
if (!iobuf && !force) { { /* file does not exist */
rc = G10ERR_OPEN_FILE;
goto leave;
}
if (!iobuf) {
char *last_slash_in_filename; 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 = strrchr (filename, DIRSEP_C);
*last_slash_in_filename = 0; *last_slash_in_filename = 0;
if (access(filename, F_OK))
if (access(filename, F_OK)) { { /* on the first time we try to create the default
/* on the first time we try to create the default homedir and homedir and in this case the process will be
* in this case the process will be terminated, so that on the terminated, so that on the next invocation it can
* next invocation it can read the options file in on startup read the options file in on startup */
*/
try_make_homedir (filename); try_make_homedir (filename);
rc = G10ERR_OPEN_FILE; rc = G10ERR_OPEN_FILE;
*last_slash_in_filename = DIRSEP_C; *last_slash_in_filename = DIRSEP_C;
goto leave; goto leave;
} }
*last_slash_in_filename = DIRSEP_C; *last_slash_in_filename = DIRSEP_C;
iobuf = iobuf_create (filename); iobuf = iobuf_create (filename);
if (!iobuf) { if (!iobuf)
{
log_error ( _("error creating keyring `%s': %s\n"), log_error ( _("error creating keyring `%s': %s\n"),
filename, strerror(errno)); filename, strerror(errno));
rc = G10ERR_OPEN_FILE; rc = G10ERR_OPEN_FILE;
goto leave; goto leave;
} }
else {
#ifndef HAVE_DOSISH_SYSTEM #ifndef HAVE_DOSISH_SYSTEM
if (secret && !opt.preserve_permissions) { if (secret && !opt.preserve_permissions)
if (chmod (filename, S_IRUSR | S_IWUSR) ) { {
log_error (_("changing permission of " if (chmod (filename, S_IRUSR | S_IWUSR) )
" `%s' failed: %s\n"), {
filename, strerror(errno) ); log_error (_("changing permission of "
rc = G10ERR_WRITE_FILE; " `%s' failed: %s\n"),
goto leave; filename, strerror(errno) );
} rc = G10ERR_WRITE_FILE;
} goto leave;
#endif }
if (!opt.quiet) }
log_info (_("keyring `%s' created\n"), filename); #endif
created_fname = filename; if (!opt.quiet)
} log_info (_("keyring `%s' created\n"), filename);
} iobuf_close (iobuf);
iobuf_close (iobuf); iobuf = NULL;
iobuf = NULL; /* must invalidate that ugly cache */
if (created_fname) /* must invalidate that ugly cache */ iobuf_ioctl (NULL, 2, 0, (char*)filename);
iobuf_ioctl (NULL, 2, 0, (char*)created_fname); } /* end file creation */
{
void *token = keyring_register_filename (filename, secret); token = keyring_register_filename (filename, secret);
if (!token) if (!token)
; /* already registered - ignore it */ ; /* already registered - ignore it */
else if (used_resources >= MAX_KEYDB_RESOURCES) else if (used_resources >= MAX_KEYDB_RESOURCES)
rc = G10ERR_RESOURCE_LIMIT; rc = G10ERR_RESOURCE_LIMIT;
else else
{ {
all_resources[used_resources].type = rt; all_resources[used_resources].type = rt;
all_resources[used_resources].u.kr = NULL; /* Not used here */ all_resources[used_resources].u.kr = NULL; /* Not used here */
all_resources[used_resources].token = token; all_resources[used_resources].token = token;
all_resources[used_resources].secret = secret; all_resources[used_resources].secret = secret;
used_resources++; used_resources++;
} }
}
break; break;
default: default: