diff options
author | Werner Koch <wk@gnupg.org> | 2020-10-20 10:43:55 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2020-10-20 12:15:55 +0200 |
commit | c94ee1386e0d5cdac51086c4d5b92de59c09c9b5 (patch) | |
tree | 34089b99da850a449f95ab9dd7e88317194b5f11 /g10/keydb.c | |
parent | gpg,ecc: Fix SOS handling when receiving from agent. (diff) | |
download | gnupg2-c94ee1386e0d5cdac51086c4d5b92de59c09c9b5.tar.xz gnupg2-c94ee1386e0d5cdac51086c4d5b92de59c09c9b5.zip |
Replace all calls to access by gnupg_access
* common/sysutils.c (gnupg_access): New. Replace all calls to access
by this wrapper.
* common/homedir.c (w32_shgetfolderpath): Change to return UTF-8
directory name.
(standard_homedir): Adjust for change.
(w32_commondir, gnupg_cachedir): Ditto.
--
Also use SHGetFolderPathW instead of SHGetFolderPathA on Windows.
This is required to correctly handle non-ascii filenames on Windows.
GnuPG-bug-id: 5098
Diffstat (limited to 'g10/keydb.c')
-rw-r--r-- | g10/keydb.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/g10/keydb.c b/g10/keydb.c index 66e7d9520..ddbab7300 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" @@ -211,6 +212,7 @@ keyblock_cache_clear (struct keydb_handle_s *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; @@ -221,8 +223,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. */ @@ -257,9 +259,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; } @@ -316,12 +318,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. */ |