diff options
author | Werner Koch <wk@gnupg.org> | 2016-06-07 10:59:46 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2016-06-07 10:59:46 +0200 |
commit | 22a7ef01aa2c0eb77bcc40174d09104acc35cab1 (patch) | |
tree | 3782b20549fcc48d2598128676227d9a16f785b6 /g13 | |
parent | po: Update Japanese translation. (diff) | |
download | gnupg2-22a7ef01aa2c0eb77bcc40174d09104acc35cab1.tar.xz gnupg2-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 <wk@gnupg.org>
Diffstat (limited to 'g13')
-rw-r--r-- | g13/g13-common.h | 1 | ||||
-rw-r--r-- | g13/g13-syshelp.c | 10 | ||||
-rw-r--r-- | g13/g13.c | 15 | ||||
-rw-r--r-- | g13/server.c | 4 |
4 files changed, 14 insertions, 16 deletions
diff --git a/g13/g13-common.h b/g13/g13-common.h index 316b94a73..a20508128 100644 --- a/g13/g13-common.h +++ b/g13/g13-common.h @@ -55,7 +55,6 @@ struct int quiet; /* Be as quiet as possible. */ int dry_run; /* Don't change any persistent data. */ - const char *homedir; /* Configuration directory name. */ const char *config_filename; /* Name of the used config file. */ /* Filename of the AGENT program. */ diff --git a/g13/g13-syshelp.c b/g13/g13-syshelp.c index 645730fc6..f3c20f59d 100644 --- a/g13/g13-syshelp.c +++ b/g13/g13-syshelp.c @@ -159,7 +159,7 @@ my_strusage( int level ) break; case 31: p = "\nHome: "; break; - case 32: p = opt.homedir; break; + case 32: p = gnupg_homedir (); break; default: p = NULL; break; } @@ -269,7 +269,6 @@ main ( int argc, char **argv) log_fatal ("error allocating session environment block: %s\n", strerror (errno)); - opt.homedir = default_homedir (); /* Fixme: We enable verbose mode here because there is currently no way to do this when starting g13-syshelp. To fix that we should add a g13-syshelp.conf file in /etc/gnupg. */ @@ -393,7 +392,7 @@ main ( int argc, char **argv) case oStatusFD: ctrl.status_fd = pargs.r.ret_int; break; case oLoggerFD: log_set_fd (pargs.r.ret_int ); break; - case oHomedir: opt.homedir = pargs.r.ret_str; break; + case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break; case oFakedSystemTime: { @@ -427,7 +426,8 @@ main ( int argc, char **argv) configname = NULL; if (!opt.config_filename) - opt.config_filename = make_filename (opt.homedir, G13_NAME".conf", NULL); + opt.config_filename = make_filename (gnupg_homedir (), + G13_NAME".conf", NULL); if (log_get_errorcount(0)) g13_exit(2); @@ -472,7 +472,7 @@ main ( int argc, char **argv) /* Set the standard GnuPG random seed file. */ if (use_random_seed) { - char *p = make_filename (opt.homedir, "random_seed", NULL); + char *p = make_filename (gnupg_homedir (), "random_seed", NULL); gcry_control (GCRYCTL_SET_RANDOM_SEED_FILE, p); xfree(p); } @@ -247,7 +247,7 @@ my_strusage( int level ) break; case 31: p = "\nHome: "; break; - case 32: p = opt.homedir; break; + case 32: p = gnupg_homedir (); break; default: p = NULL; break; } @@ -391,8 +391,6 @@ main ( int argc, char **argv) log_fatal ("error allocating session environment block: %s\n", strerror (errno)); - opt.homedir = default_homedir (); - /* First check whether we have a config file on the commandline. */ orig_argc = argc; orig_argv = argv; @@ -412,7 +410,7 @@ main ( int argc, char **argv) else if (pargs.r_opt == oNoOptions) default_config = 0; /* --no-options */ else if (pargs.r_opt == oHomedir) - opt.homedir = pargs.r.ret_str; + gnupg_set_homedir (pargs.r.ret_str); } /* Initialize the secure memory. */ @@ -446,7 +444,7 @@ main ( int argc, char **argv) /* Set the default option file */ if (default_config ) - configname = make_filename (opt.homedir, G13_NAME".conf", NULL); + configname = make_filename (gnupg_homedir (), G13_NAME".conf", NULL); argc = orig_argc; argv = orig_argv; @@ -552,7 +550,7 @@ main ( int argc, char **argv) } break; - case oHomedir: opt.homedir = pargs.r.ret_str; break; + case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break; case oAgentProgram: opt.agent_program = pargs.r.ret_str; break; case oGpgProgram: opt.gpg_program = pargs.r.ret_str; break; @@ -623,7 +621,8 @@ main ( int argc, char **argv) configname = NULL; if (!opt.config_filename) - opt.config_filename = make_filename (opt.homedir, G13_NAME".conf", NULL); + opt.config_filename = make_filename (gnupg_homedir (), + G13_NAME".conf", NULL); if (log_get_errorcount(0)) g13_exit(2); @@ -690,7 +689,7 @@ main ( int argc, char **argv) /* Set the standard GnuPG random seed file. */ if (use_random_seed) { - char *p = make_filename (opt.homedir, "random_seed", NULL); + char *p = make_filename (gnupg_homedir (), "random_seed", NULL); gcry_control (GCRYCTL_SET_RANDOM_SEED_FILE, p); xfree(p); } diff --git a/g13/server.c b/g13/server.c index 33885d64b..a96ec6e17 100644 --- a/g13/server.c +++ b/g13/server.c @@ -631,12 +631,12 @@ g13_server (ctrl_t ctrl) if (opt.verbose || opt.debug) { - char *tmp = NULL; + char *tmp; tmp = xtryasprintf ("Home: %s\n" "Config: %s\n" "%s", - opt.homedir, + gnupg_homedir (), opt.config_filename, hello); if (tmp) |