aboutsummaryrefslogtreecommitdiffstats
path: root/agent
diff options
context:
space:
mode:
Diffstat (limited to 'agent')
-rw-r--r--agent/findkey.c4
-rw-r--r--agent/trustlist.c17
2 files changed, 12 insertions, 9 deletions
diff --git a/agent/findkey.c b/agent/findkey.c
index fa9e5b548..dd39472a9 100644
--- a/agent/findkey.c
+++ b/agent/findkey.c
@@ -236,7 +236,7 @@ agent_write_private_key (const unsigned char *grip,
/* FIXME: Write to a temp file first so that write failures during
key updates won't lead to a key loss. */
- if (!force && !access (fname, F_OK))
+ if (!force && !gnupg_access (fname, F_OK))
{
log_error ("secret key file '%s' already exists\n", fname);
xfree (fname);
@@ -1324,7 +1324,7 @@ agent_key_available (const unsigned char *grip)
fname = make_filename (gnupg_homedir (), GNUPG_PRIVATE_KEYS_DIR,
hexgrip, NULL);
- result = !access (fname, R_OK)? 0 : -1;
+ result = !gnupg_access (fname, R_OK)? 0 : -1;
xfree (fname);
return result;
}
diff --git a/agent/trustlist.c b/agent/trustlist.c
index d91e92e07..087afbd51 100644
--- a/agent/trustlist.c
+++ b/agent/trustlist.c
@@ -185,6 +185,7 @@ read_one_trustfile (const char *fname, int allow_include,
{
char *etcname;
gpg_error_t err2;
+ gpg_err_code_t ec;
if (!allow_include)
{
@@ -198,7 +199,7 @@ read_one_trustfile (const char *fname, int allow_include,
if ( !strcmp (etcname, fname) ) /* Same file. */
log_info (_("statement \"%s\" ignored in '%s', line %d\n"),
"include-default", fname, lnr);
- else if ( access (etcname, F_OK) && errno == ENOENT )
+ else if ((ec=gnupg_access (etcname, F_OK)) && ec == GPG_ERR_ENOENT)
{
/* A non existent system trustlist is not an error.
Just print a note. */
@@ -336,6 +337,7 @@ read_trustfiles (void)
size_t tablesize;
char *fname;
int allow_include = 1;
+ gpg_err_code_t ec;
tablesize = 20;
table = xtrycalloc (tablesize, sizeof *table);
@@ -351,13 +353,13 @@ read_trustfiles (void)
return err;
}
- if ( access (fname, F_OK) )
+ if ((ec = gnupg_access (fname, F_OK)))
{
- if ( errno == ENOENT )
+ if ( ec == GPG_ERR_ENOENT )
; /* Silently ignore a non-existing trustfile. */
else
{
- err = gpg_error_from_syserror ();
+ err = gpg_error (ec);
log_error (_("error opening '%s': %s\n"), fname, gpg_strerror (err));
}
xfree (fname);
@@ -601,6 +603,7 @@ gpg_error_t
agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag)
{
gpg_error_t err = 0;
+ gpg_err_code_t ec;
char *desc;
char *fname;
estream_t fp;
@@ -618,7 +621,7 @@ agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag)
if (!fname)
return gpg_error_from_syserror ();
- if ( access (fname, W_OK) && errno != ENOENT)
+ if ((ec = access (fname, W_OK)) && ec != GPG_ERR_ENOENT)
{
xfree (fname);
return gpg_error (GPG_ERR_EPERM);
@@ -751,12 +754,12 @@ agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag)
xfree (nameformatted);
return err;
}
- if ( access (fname, F_OK) && errno == ENOENT)
+ if ((ec = access (fname, F_OK)) && ec == GPG_ERR_ENOENT)
{
fp = es_fopen (fname, "wx,mode=-rw-r");
if (!fp)
{
- err = gpg_error_from_syserror ();
+ err = gpg_error (ec);
log_error ("can't create '%s': %s\n", fname, gpg_strerror (err));
xfree (fname);
unlock_trusttable ();