diff options
author | Werner Koch <[email protected]> | 2016-06-07 08:59:46 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2016-06-07 08:59:46 +0000 |
commit | 22a7ef01aa2c0eb77bcc40174d09104acc35cab1 (patch) | |
tree | 3782b20549fcc48d2598128676227d9a16f785b6 /agent/trustlist.c | |
parent | po: Update Japanese translation. (diff) | |
download | gnupg-22a7ef01aa2c0eb77bcc40174d09104acc35cab1.tar.gz gnupg-22a7ef01aa2c0eb77bcc40174d09104acc35cab1.zip |
Replace use of opt.homedir by accessor functions.
* common/homedir.c (the_gnupg_homedir): New var.
(gnupg_set_homedir): New.
(gnupg_homedir): New.
* g10/options.h (struct opt): Remove 'homedir' and replace all users
by the new accessor functions.
* g13/g13-common.h (struct opt): Ditto.
* scd/scdaemon.h (struct opt): Ditto.
* sm/gpgsm.h (struct opt): Ditto.
* dirmngr/dirmngr.h (struct opt): Ditto.
* agent/preset-passphrase.c (opt_homedir): Ditto.
* agent/protect-tool.c (opt_homedir): Ditto.
--
This will make detection of a non-default homedir easier.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'agent/trustlist.c')
-rw-r--r-- | agent/trustlist.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/agent/trustlist.c b/agent/trustlist.c index af5f64570..b8df3fdde 100644 --- a/agent/trustlist.c +++ b/agent/trustlist.c @@ -344,7 +344,14 @@ read_trustfiles (void) return gpg_error_from_syserror (); tableidx = 0; - fname = make_filename (opt.homedir, "trustlist.txt", NULL); + fname = make_filename_try (gnupg_homedir (), "trustlist.txt", NULL); + if (!fname) + { + err = gpg_error_from_syserror (); + xfree (table); + return err; + } + if ( access (fname, F_OK) ) { if ( errno == ENOENT ) @@ -608,7 +615,10 @@ agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag) trustlist with only admin priviliges to modify it. Of course this is not a secure way of denying access, but it avoids the usual clicking on an Okay button most users are used to. */ - fname = make_filename (opt.homedir, "trustlist.txt", NULL); + fname = make_filename_try (gnupg_homedir (), "trustlist.txt", NULL); + if (!fname) + return gpg_error_from_syserror (); + if ( access (fname, W_OK) && errno != ENOENT) { xfree (fname); @@ -733,7 +743,15 @@ agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag) return is_disabled? gpg_error (GPG_ERR_NOT_TRUSTED) : 0; } - fname = make_filename (opt.homedir, "trustlist.txt", NULL); + fname = make_filename_try (gnupg_homedir (), "trustlist.txt", NULL); + if (!fname) + { + err = gpg_error_from_syserror (); + unlock_trusttable (); + xfree (fprformatted); + xfree (nameformatted); + return err; + } if ( access (fname, F_OK) && errno == ENOENT) { fp = es_fopen (fname, "wx,mode=-rw-r"); |