diff options
Diffstat (limited to 'g10')
-rw-r--r-- | g10/gpg.c | 11 | ||||
-rw-r--r-- | g10/keydb.c | 14 | ||||
-rw-r--r-- | g10/keyring.c | 7 | ||||
-rw-r--r-- | g10/migrate.c | 4 | ||||
-rw-r--r-- | g10/openfile.c | 2 | ||||
-rw-r--r-- | g10/tdbio.c | 8 |
6 files changed, 26 insertions, 20 deletions
@@ -4021,13 +4021,14 @@ main (int argc, char **argv) } /* Set the random seed file. */ - if( use_random_seed ) { - char *p = make_filename (gnupg_homedir (), "random_seed", NULL ); - gcry_control (GCRYCTL_SET_RANDOM_SEED_FILE, p); - if (!access (p, F_OK)) + if (use_random_seed) + { + char *p = make_filename (gnupg_homedir (), "random_seed", NULL ); + gcry_control (GCRYCTL_SET_RANDOM_SEED_FILE, p); + if (!gnupg_access (p, F_OK)) register_secured_file (p); xfree(p); - } + } /* If there is no command but the --fingerprint is given, default to the --list-keys command. */ diff --git a/g10/keydb.c b/g10/keydb.c index 45b3c8512..934002498 100644 --- a/g10/keydb.c +++ b/g10/keydb.c @@ -29,6 +29,7 @@ #include "gpg.h" #include "../common/util.h" +#include "../common/sysutils.h" #include "options.h" #include "main.h" /*try_make_homedir ()*/ #include "packet.h" @@ -293,6 +294,7 @@ keyblock_cache_clear (struct keydb_handle *hd) static gpg_error_t maybe_create_keyring_or_box (char *filename, int is_box, int force_create) { + gpg_err_code_t ec; dotlock_t lockhd = NULL; IOBUF iobuf; int rc; @@ -303,8 +305,8 @@ maybe_create_keyring_or_box (char *filename, int is_box, int force_create) int save_slash; /* A quick test whether the filename already exists. */ - if (!access (filename, F_OK)) - return !access (filename, R_OK)? 0 : gpg_error (GPG_ERR_EACCES); + if (!gnupg_access (filename, F_OK)) + return !gnupg_access (filename, R_OK)? 0 : gpg_error (GPG_ERR_EACCES); /* If we don't want to create a new file at all, there is no need to go any further - bail out right here. */ @@ -339,9 +341,9 @@ maybe_create_keyring_or_box (char *filename, int is_box, int force_create) tried = 1; try_make_homedir (filename); } - if (access (filename, F_OK)) + if ((ec = gnupg_access (filename, F_OK))) { - rc = gpg_error_from_syserror (); + rc = gpg_error (ec); *last_slash_in_filename = save_slash; goto leave; } @@ -398,12 +400,12 @@ maybe_create_keyring_or_box (char *filename, int is_box, int force_create) if (rc) goto leave; - if (!access (filename, F_OK)) + if (!gnupg_access (filename, F_OK)) { rc = 0; /* Okay, we may access the file now. */ goto leave; } - if (!access (bak_fname, F_OK) && !access (tmp_fname, F_OK)) + if (!gnupg_access (bak_fname, F_OK) && !gnupg_access (tmp_fname, F_OK)) { /* Very likely another process is updating a pubring.gpg and we should not create a pubring.kbx. */ diff --git a/g10/keyring.c b/g10/keyring.c index f424f94fc..6ed9e2b41 100644 --- a/g10/keyring.c +++ b/g10/keyring.c @@ -228,7 +228,7 @@ keyring_is_writable (void *token) { KR_RESOURCE r = token; - return r? (r->read_only || !access (r->fname, W_OK)) : 0; + return r? (r->read_only || !gnupg_access (r->fname, W_OK)) : 0; } @@ -1606,6 +1606,7 @@ static int do_copy (int mode, const char *fname, KBNODE root, off_t start_offset, unsigned int n_packets ) { + gpg_err_code_t ec; IOBUF fp, newfp; int rc=0; char *bakfname = NULL; @@ -1613,8 +1614,8 @@ do_copy (int mode, const char *fname, KBNODE root, /* Open the source file. Because we do a rename, we have to check the permissions of the file */ - if (access (fname, W_OK)) - return gpg_error_from_syserror (); + if ((ec = gnupg_access (fname, W_OK))) + return gpg_error (ec); fp = iobuf_open (fname); if (mode == 1 && !fp && errno == ENOENT) { diff --git a/g10/migrate.c b/g10/migrate.c index c52c67a77..9045ae66e 100644 --- a/g10/migrate.c +++ b/g10/migrate.c @@ -50,10 +50,10 @@ migrate_secring (ctrl_t ctrl) char *agent_version = NULL; secring = make_filename (gnupg_homedir (), "secring" EXTSEP_S "gpg", NULL); - if (access (secring, F_OK)) + if (gnupg_access (secring, F_OK)) goto leave; /* Does not exist or is not readable. */ flagfile = make_filename (gnupg_homedir (), V21_MIGRATION_FNAME, NULL); - if (!access (flagfile, F_OK)) + if (!gnupg_access (flagfile, F_OK)) goto leave; /* Does exist - fine. */ log_info ("starting migration from earlier GnuPG versions\n"); diff --git a/g10/openfile.c b/g10/openfile.c index 78f4dbbcb..fd9edb66b 100644 --- a/g10/openfile.c +++ b/g10/openfile.c @@ -324,7 +324,7 @@ get_matching_datafile (const char *sigfilename) fname = xstrdup (sigfilename); fname[len-(fname[len-1]=='n'?5:4)] = 0 ; - if (access (fname, R_OK )) + if (gnupg_access (fname, R_OK )) { /* Not found or other error. */ xfree (fname); diff --git a/g10/tdbio.c b/g10/tdbio.c index 8f7530621..9c77bc4b2 100644 --- a/g10/tdbio.c +++ b/g10/tdbio.c @@ -711,17 +711,19 @@ tdbio_set_dbname (ctrl_t ctrl, const char *new_dbname, log_assert (p); save_slash = *p; *p = 0; - if (access (fname, F_OK)) + if (gnupg_access (fname, F_OK)) { try_make_homedir (fname); - if (access (fname, F_OK)) + if (gnupg_access (fname, F_OK)) log_fatal (_("%s: directory does not exist!\n"), fname); } *p = save_slash; take_write_lock (); - if (access (fname, R_OK) || stat (fname, &statbuf) || statbuf.st_size == 0) + if (gnupg_access (fname, R_OK) + || stat (fname, &statbuf) + || statbuf.st_size == 0) { FILE *fp; TRUSTREC rec; |