aboutsummaryrefslogtreecommitdiffstats
path: root/g10/tdbio.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2004-10-14 07:11:57 +0000
committerWerner Koch <[email protected]>2004-10-14 07:11:57 +0000
commit35774ec5682ae54f4cd71275b8055eef2aa64cb1 (patch)
tree21e91fabb1bb0b2f261290dfa3c4fb080f3c7df7 /g10/tdbio.c
parent* armor.c (fake_packet): Allow arbitrary dash-escaped lines as per (diff)
downloadgnupg-35774ec5682ae54f4cd71275b8055eef2aa64cb1.tar.gz
gnupg-35774ec5682ae54f4cd71275b8055eef2aa64cb1.zip
* misc.c (is_secured_filename): New.
* keydb.c (maybe_create_keyring) * tdbio.c (tdbio_set_dbname) * plaintext.c (handle_plaintext) * openfile.c (copy_options_file, open_outfile) * exec.c (exec_write) * keygen.c (do_generate_keypair, gen_card_key_with_backup) * sign.c (sign_file, clearsign_file) * keyring.c (create_tmp_file, do_copy): Check for secured files before creating them. * keygen.c (print_status_key_created): s/unsigned char/byte/ due to a strange typedef for RISC OS. Noted by Stefan.
Diffstat (limited to 'g10/tdbio.c')
-rw-r--r--g10/tdbio.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/g10/tdbio.c b/g10/tdbio.c
index 0b182cfad..5b34bc8ed 100644
--- a/g10/tdbio.c
+++ b/g10/tdbio.c
@@ -494,7 +494,7 @@ tdbio_set_dbname( const char *new_dbname, int create )
if( access( fname, R_OK ) ) {
if( errno != ENOENT ) {
- log_error( _("%s: can't access: %s\n"), fname, strerror(errno) );
+ log_error( _("can't access `%s': %s\n"), fname, strerror(errno) );
m_free(fname);
return G10ERR_TRUSTDB;
}
@@ -519,25 +519,30 @@ tdbio_set_dbname( const char *new_dbname, int create )
if( !lockhandle )
lockhandle = create_dotlock( db_name );
if( !lockhandle )
- log_fatal( _("%s: can't create lock\n"), db_name );
+ log_fatal( _("can't create lock for `%s'\n"), db_name );
if( make_dotlock( lockhandle, -1 ) )
- log_fatal( _("%s: can't make lock\n"), db_name );
+ log_fatal( _("can't lock `%s'\n"), db_name );
#endif /* __riscos__ */
oldmask=umask(077);
- fp =fopen( fname, "wb" );
+ if (is_secured_filename (fname)) {
+ fp = NULL;
+ errno = EPERM;
+ }
+ else
+ fp =fopen( fname, "wb" );
umask(oldmask);
if( !fp )
- log_fatal( _("%s: can't create: %s\n"), fname, strerror(errno) );
+ log_fatal( _("can't create `%s': %s\n"), fname, strerror(errno) );
fclose(fp);
db_fd = open( db_name, O_RDWR | MY_O_BINARY );
if( db_fd == -1 )
- log_fatal( _("%s: can't open: %s\n"), db_name, strerror(errno) );
+ log_fatal( _("can't open `%s': %s\n"), db_name, strerror(errno) );
#ifndef __riscos__
if( !lockhandle )
lockhandle = create_dotlock( db_name );
if( !lockhandle )
- log_fatal( _("%s: can't create lock\n"), db_name );
+ log_fatal( _("can't create lock for `%s'\n"), db_name );
#endif /* !__riscos__ */
rc = create_version_record ();
@@ -580,10 +585,10 @@ open_db()
if (!lockhandle )
lockhandle = create_dotlock( db_name );
if (!lockhandle )
- log_fatal( _("%s: can't create lock\n"), db_name );
+ log_fatal( _("can't create lock for `%s'\n"), db_name );
#ifdef __riscos__
if (make_dotlock( lockhandle, -1 ) )
- log_fatal( _("%s: can't make lock\n"), db_name );
+ log_fatal( _("can't lock `%s'\n"), db_name );
#endif /* __riscos__ */
db_fd = open (db_name, O_RDWR | MY_O_BINARY );
if (db_fd == -1 && errno == EACCES) {
@@ -592,7 +597,7 @@ open_db()
log_info (_("NOTE: trustdb not writable\n"));
}
if ( db_fd == -1 )
- log_fatal( _("%s: can't open: %s\n"), db_name, strerror(errno) );
+ log_fatal( _("can't open `%s': %s\n"), db_name, strerror(errno) );
register_secured_file (db_name);
/* check whether we need to do a version migration */