1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

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>
This commit is contained in:
Werner Koch 2016-06-07 10:59:46 +02:00
parent 650abbab71
commit 22a7ef01aa
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
44 changed files with 188 additions and 179 deletions

View file

@ -795,9 +795,7 @@ main (int argc, char **argv)
if (shell && strlen (shell) >= 3 && !strcmp (shell+strlen (shell)-3, "csh") )
csh_style = 1;
opt.homedir = default_homedir ();
/* Now with NPth running we can set the logging callback. Our
/* Now with NPth running we can set the logging callback. Our
windows implementation does not yet feature the NPth TLS
functions. */
#ifndef HAVE_W32_SYSTEM
@ -835,7 +833,7 @@ main (int argc, char **argv)
default_config = 0; /* --no-options */
else if (pargs.r_opt == oHomedir)
{
opt.homedir = pargs.r.ret_str;
gnupg_set_homedir (pargs.r.ret_str);
homedir_seen = 1;
}
else if (pargs.r_opt == aDaemon)
@ -862,9 +860,9 @@ main (int argc, char **argv)
if (opt.system_daemon && !homedir_seen)
{
#ifdef HAVE_W32CE_SYSTEM
opt.homedir = DIRSEP_S "gnupg";
gnupg_set_homedir (DIRSEP_S "gnupg");
#else
opt.homedir = gnupg_sysconfdir ();
gnupg_set_homedir (gnupg_sysconfdir ());
#endif
opt.homedir_cache = gnupg_cachedir ();
socket_name = dirmngr_sys_socket_name ();
@ -875,7 +873,7 @@ main (int argc, char **argv)
socket_name = dirmngr_sys_socket_name ();
if (default_config)
configname = make_filename (opt.homedir, DIRMNGR_NAME".conf", NULL );
configname = make_filename (gnupg_homedir (), DIRMNGR_NAME".conf", NULL );
argc = orig_argc;
argv = orig_argv;
@ -989,7 +987,7 @@ main (int argc, char **argv)
greeting = 0;
if (!opt.homedir_cache)
opt.homedir_cache = opt.homedir;
opt.homedir_cache = xstrdup (gnupg_homedir ());
if (greeting)
{
@ -1019,7 +1017,8 @@ main (int argc, char **argv)
log_info (_("Note: '%s' is not considered an option\n"), argv[i]);
}
if (!access ("/etc/"DIRMNGR_NAME, F_OK) && !strncmp (opt.homedir, "/etc/", 5))
if (!access ("/etc/"DIRMNGR_NAME, F_OK)
&& !strncmp (gnupg_homedir (), "/etc/", 5))
log_info
("NOTE: DirMngr is now a proper part of %s. The configuration and"
" other directory names changed. Please check that no other version"
@ -1043,7 +1042,7 @@ main (int argc, char **argv)
#if USE_LDAP
if (!ldapfile)
{
ldapfile = make_filename (opt.homedir,
ldapfile = make_filename (gnupg_homedir (),
opt.system_daemon?
"ldapservers.conf":"dirmngr_ldapservers.conf",
NULL);
@ -1396,7 +1395,7 @@ main (int argc, char **argv)
/* First the configuration file. This is not an option, but it
is vital information for GPG Conf. */
if (!opt.config_filename)
opt.config_filename = make_filename (opt.homedir,
opt.config_filename = make_filename (gnupg_homedir (),
"dirmngr.conf", NULL );
filename = percent_escape (opt.config_filename, NULL);
@ -1416,7 +1415,7 @@ main (int argc, char **argv)
and having both of them is thus problematic. --no-detach is
also only usable on the command line. --batch is unused. */
filename = make_filename (opt.homedir,
filename = make_filename (gnupg_homedir (),
opt.system_daemon?
"ldapservers.conf":"dirmngr_ldapservers.conf",
NULL);
@ -1658,7 +1657,7 @@ parse_ocsp_signer (const char *string)
{
if (string[0] == '.' && string[1] == '/' )
string += 2;
fname = make_filename (opt.homedir, string, NULL);
fname = make_filename (gnupg_homedir (), string, NULL);
}
fp = es_fopen (fname, "r");

View file

@ -79,8 +79,7 @@ struct
int quiet; /* be as quiet as possible */
int dry_run; /* don't change any persistent data */
int batch; /* batch mode */
const char *homedir; /* Configuration directory name */
const char *homedir_cache; /* Ditto for cache files (/var/cache/dirmngr). */
const char *homedir_cache; /* Dir for cache files (/var/cache/dirmngr). */
char *config_filename; /* Name of a config file, which will be
reread on a HUP if it is not NULL. */

View file

@ -2440,22 +2440,13 @@ start_command_handler (assuan_fd_t fd)
if (!hello_line)
{
size_t n;
const char *cfgname;
cfgname = opt.config_filename? opt.config_filename : "[none]";
n = (30 + strlen (opt.homedir) + strlen (cfgname)
+ strlen (hello) + 1);
hello_line = xmalloc (n+1);
snprintf (hello_line, n,
"Home: %s\n"
"Config: %s\n"
"%s",
opt.homedir,
cfgname,
hello);
hello_line[n] = 0;
hello_line = xtryasprintf
("Home: %s\n"
"Config: %s\n"
"%s",
gnupg_homedir (),
opt.config_filename? opt.config_filename : "[none]",
hello);
}
ctrl->server_local->assuan_ctx = ctx;