1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01: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

@ -62,7 +62,6 @@ 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 */
/* True if we handle sigusr2. */
int sigusr2_enabled;

View File

@ -897,7 +897,7 @@ open_control_file (ssh_control_file_t *r_cf, int append)
/* Note: As soon as we start to use non blocking functions here
(i.e. where Pth might switch threads) we need to employ a
mutex. */
cf->fname = make_filename_try (opt.homedir, SSH_CONTROL_FILE_NAME, NULL);
cf->fname = make_filename_try (gnupg_homedir (), SSH_CONTROL_FILE_NAME, NULL);
if (!cf->fname)
{
err = gpg_error_from_syserror ();
@ -2734,7 +2734,7 @@ ssh_handler_request_identities (ctrl_t ctrl,
{
char *dname;
dname = make_filename (opt.homedir, GNUPG_PRIVATE_KEYS_DIR, NULL);
dname = make_filename (gnupg_homedir (), GNUPG_PRIVATE_KEYS_DIR, NULL);
if (!dname)
{
err = gpg_err_code_from_syserror ();

View File

@ -1258,7 +1258,8 @@ cmd_keyinfo (assuan_context_t ctx, char *line)
char *dirname;
struct dirent *dir_entry;
dirname = make_filename_try (opt.homedir, GNUPG_PRIVATE_KEYS_DIR, NULL);
dirname = make_filename_try (gnupg_homedir (),
GNUPG_PRIVATE_KEYS_DIR, NULL);
if (!dirname)
{
err = gpg_error_from_syserror ();

View File

@ -135,7 +135,8 @@ agent_write_private_key (const unsigned char *grip,
bin2hex (grip, 20, hexgrip);
strcpy (hexgrip+40, ".key");
fname = make_filename (opt.homedir, GNUPG_PRIVATE_KEYS_DIR, hexgrip, NULL);
fname = make_filename (gnupg_homedir (), GNUPG_PRIVATE_KEYS_DIR,
hexgrip, NULL);
/* FIXME: Write to a temp file first so that write failures during
key updates won't lead to a key loss. */
@ -652,7 +653,8 @@ read_key_file (const unsigned char *grip, gcry_sexp_t *result)
bin2hex (grip, 20, hexgrip);
strcpy (hexgrip+40, ".key");
fname = make_filename (opt.homedir, GNUPG_PRIVATE_KEYS_DIR, hexgrip, NULL);
fname = make_filename (gnupg_homedir (), GNUPG_PRIVATE_KEYS_DIR,
hexgrip, NULL);
fp = es_fopen (fname, "rb");
if (!fp)
{
@ -767,7 +769,8 @@ remove_key_file (const unsigned char *grip)
bin2hex (grip, 20, hexgrip);
strcpy (hexgrip+40, ".key");
fname = make_filename (opt.homedir, GNUPG_PRIVATE_KEYS_DIR, hexgrip, NULL);
fname = make_filename (gnupg_homedir (), GNUPG_PRIVATE_KEYS_DIR,
hexgrip, NULL);
if (gnupg_remove (fname))
err = gpg_error_from_syserror ();
xfree (fname);
@ -1289,7 +1292,8 @@ agent_key_available (const unsigned char *grip)
bin2hex (grip, 20, hexgrip);
strcpy (hexgrip+40, ".key");
fname = make_filename (opt.homedir, GNUPG_PRIVATE_KEYS_DIR, hexgrip, NULL);
fname = make_filename (gnupg_homedir (), GNUPG_PRIVATE_KEYS_DIR,
hexgrip, NULL);
result = !access (fname, R_OK)? 0 : -1;
xfree (fname);
return result;

View File

@ -804,8 +804,6 @@ main (int argc, char **argv )
if (shell && strlen (shell) >= 3 && !strcmp (shell+strlen (shell)-3, "csh") )
csh_style = 1;
opt.homedir = default_homedir ();
/* Record some of the original environment strings. */
{
const char *s;
@ -861,7 +859,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);
else if (pargs.r_opt == oDebugQuickRandom)
{
gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
@ -878,8 +876,8 @@ main (int argc, char **argv )
*/
if (default_config)
configname = make_filename (opt.homedir, GPG_AGENT_NAME EXTSEP_S "conf",
NULL );
configname = make_filename (gnupg_homedir (),
GPG_AGENT_NAME EXTSEP_S "conf", NULL);
argc = orig_argc;
argv = orig_argv;
@ -944,7 +942,7 @@ main (int argc, char **argv )
case oNoGreeting: /* Dummy option. */ break;
case oNoVerbose: opt.verbose = 0; break;
case oNoOptions: break; /* no-options */
case oHomedir: opt.homedir = pargs.r.ret_str; break;
case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break;
case oNoDetach: nodetach = 1; break;
case oLogFile: logfile = pargs.r.ret_str; break;
case oCsh: csh_style = 1; break;
@ -1030,7 +1028,7 @@ main (int argc, char **argv )
finalize_rereadable_options ();
/* Turn the homedir into an absolute one. */
opt.homedir = make_absfilename (opt.homedir, NULL);
gnupg_set_homedir (make_absfilename (gnupg_homedir (), NULL));
/* Print a warning if an argument looks like an option. */
if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN))
@ -1104,8 +1102,8 @@ main (int argc, char **argv )
char *filename_esc;
/* List options and default values in the GPG Conf format. */
filename = make_filename (opt.homedir, GPG_AGENT_NAME EXTSEP_S "conf",
NULL );
filename = make_filename (gnupg_homedir (),
GPG_AGENT_NAME EXTSEP_S "conf", NULL);
filename_esc = percent_escape (filename, NULL);
es_printf ("%s-%s.conf:%lu:\"%s\n",
@ -1764,7 +1762,7 @@ create_socket_name (char *standard_name, int with_homedir)
char *name;
if (with_homedir)
name = make_filename (opt.homedir, standard_name, NULL);
name = make_filename (gnupg_homedir (), standard_name, NULL);
else
name = make_filename (standard_name, NULL);
if (strchr (name, PATHSEP_C))
@ -1932,7 +1930,7 @@ create_directories (void)
const char *defhome = standard_homedir ();
char *home;
home = make_filename (opt.homedir, NULL);
home = make_filename (gnupg_homedir (), NULL);
if ( stat (home, &statbuf) )
{
if (errno == ENOENT)
@ -2731,7 +2729,7 @@ check_own_socket (void)
if (check_own_socket_running || shutdown_pending)
return; /* Still running or already shutting down. */
sockname = make_filename (opt.homedir, GPG_AGENT_SOCK_NAME, NULL);
sockname = make_filename_try (gnupg_homedir (), GPG_AGENT_SOCK_NAME, NULL);
if (!sockname)
return; /* Out of memory. */
@ -2757,7 +2755,9 @@ check_for_running_agent (int silent)
char *sockname;
assuan_context_t ctx = NULL;
sockname = make_filename (opt.homedir, GPG_AGENT_SOCK_NAME, NULL);
sockname = make_filename_try (gnupg_homedir (), GPG_AGENT_SOCK_NAME, NULL);
if (!sockname)
return gpg_error_from_syserror ();
err = assuan_new (&ctx);
if (!err)

View File

@ -66,7 +66,6 @@ enum cmd_and_opt_values
aTest };
static const char *opt_homedir;
static const char *opt_passphrase;
static ARGPARSE_OPTS opts[] = {
@ -219,8 +218,6 @@ main (int argc, char **argv)
i18n_init ();
init_common_subsystems (&argc, &argv);
opt_homedir = default_homedir ();
pargs.argc = &argc;
pargs.argv = &argv;
pargs.flags= 1; /* (do not remove the args) */
@ -229,7 +226,7 @@ main (int argc, char **argv)
switch (pargs.r_opt)
{
case oVerbose: opt.verbose++; break;
case oHomedir: opt_homedir = pargs.r.ret_str; break;
case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break;
case oPreset: cmd = oPreset; break;
case oForget: cmd = oForget; break;
@ -248,7 +245,7 @@ main (int argc, char **argv)
/* Tell simple-pwquery about the the standard socket name. */
{
char *tmp = make_filename (opt_homedir, GPG_AGENT_SOCK_NAME, NULL);
char *tmp = make_filename (gnupg_homedir (), GPG_AGENT_SOCK_NAME, NULL);
simple_pw_set_socket (tmp);
xfree (tmp);
}

View File

@ -86,7 +86,6 @@ struct rsa_secret_key_s
};
static const char *opt_homedir;
static int opt_armor;
static int opt_canonical;
static int opt_store;
@ -577,9 +576,6 @@ main (int argc, char **argv )
gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
opt_homedir = default_homedir ();
pargs.argc = &argc;
pargs.argv = &argv;
pargs.flags= 1; /* (do not remove the args) */
@ -590,7 +586,7 @@ main (int argc, char **argv )
case oVerbose: opt.verbose++; break;
case oArmor: opt_armor=1; break;
case oCanonical: opt_canonical=1; 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;
@ -634,7 +630,7 @@ main (int argc, char **argv )
/* Set the information which can't be taken from envvars. */
gnupg_prepare_get_passphrase (GPG_ERR_SOURCE_DEFAULT,
opt.verbose,
opt_homedir,
gnupg_homedir (),
opt_agent_program,
NULL, NULL, NULL);

View File

@ -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");

View File

@ -1,6 +1,6 @@
/* homedir.c - Setup the home directory.
* Copyright (C) 2004, 2006, 2007, 2010 Free Software Foundation, Inc.
* Copyright (C) 2013 Werner Koch
* Copyright (C) 2013, 2016 Werner Koch
*
* This file is part of GnuPG.
*
@ -58,6 +58,12 @@
#include "util.h"
#include "sysutils.h"
/* The GnuPG homedir. This is only accessed by the functions
* gnupg_homedir and gnupg_set_homedir. Malloced. */
static char *the_gnupg_homedir;
#ifdef HAVE_W32_SYSTEM
/* A flag used to indicate that a control file for gpgconf has been
detected. Under Windows the presence of this file indicates a
@ -368,6 +374,30 @@ w32_commondir (void)
#endif /*HAVE_W32_SYSTEM*/
/* Change the homedir. Some care must be taken to set this early
* enough becuase previous calls to gnupg_homedir may else return a
* different string. */
void
gnupg_set_homedir (const char *newdir)
{
if (!newdir || !*newdir)
newdir = default_homedir ();
xfree (the_gnupg_homedir);
the_gnupg_homedir = xstrdup (newdir);
}
/* Return the homedir. The returned string is valid until another
* gnupg-set-homedir call. Note that this may be a relative string.
* This function replaced the former global opt.homedir. */
const char *
gnupg_homedir (void)
{
/* If a homedir has not been set, set it to the default. */
if (!the_gnupg_homedir)
the_gnupg_homedir = xstrdup (default_homedir ());
return the_gnupg_homedir;
}
/* Return the name of the sysconfdir. This is a static string. This

View File

@ -220,6 +220,8 @@ const char *openpgp_is_curve_supported (const char *name, int *r_algo);
/*-- homedir.c --*/
const char *standard_homedir (void);
const char *default_homedir (void);
void gnupg_set_homedir (const char *newdir);
const char *gnupg_homedir (void);
const char *gnupg_sysconfdir (void);
const char *gnupg_bindir (void);
const char *gnupg_libexecdir (void);

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;

View File

@ -303,7 +303,7 @@ start_agent (ctrl_t ctrl, int for_card)
{
rc = start_new_gpg_agent (&agent_ctx,
GPG_ERR_SOURCE_DEFAULT,
opt.homedir,
gnupg_homedir (),
opt.agent_program,
opt.lc_ctype, opt.lc_messages,
opt.session_env,

View File

@ -177,7 +177,7 @@ create_context (ctrl_t ctrl, assuan_context_t *r_ctx)
*r_ctx = NULL;
err = start_new_dirmngr (&ctx,
GPG_ERR_SOURCE_DEFAULT,
opt.homedir,
gnupg_homedir (),
opt.dirmngr_program,
opt.autostart, opt.verbose, DBG_IPC,
NULL /*gpg_status2*/, ctrl);

View File

@ -1000,9 +1000,9 @@ my_strusage( int level )
case 31: p = "\nHome: "; break;
#ifndef __riscos__
case 32: p = opt.homedir; break;
case 32: p = gnupg_homedir (); break;
#else /* __riscos__ */
case 32: p = make_filename(opt.homedir, NULL); break;
case 32: p = make_filename(gnupg_homedir (), NULL); break;
#endif /* __riscos__ */
case 33: p = _("\nSupported algorithms:\n"); break;
case 34:
@ -1180,18 +1180,6 @@ set_debug (const char *level)
}
/* We need the home directory also in some other directories, so make
sure that both variables are always in sync. */
static void
set_homedir (const char *dir)
{
if (!dir)
dir = "";
opt.homedir = dir;
}
/* We set the screen dimensions for UI purposes. Do not allow screens
smaller than 80x24 for the sake of simplicity. */
static void
@ -1412,7 +1400,8 @@ check_permissions (const char *path, int item)
could be rectified if the homedir itself had proper
permissions. */
if(item!=0 && homedir_cache>-1
&& ascii_strncasecmp(opt.homedir,tmppath,strlen(opt.homedir))==0)
&& !ascii_strncasecmp (gnupg_homedir (), tmppath,
strlen (gnupg_homedir ())))
{
ret=homedir_cache;
goto end;
@ -2082,18 +2071,19 @@ get_default_configname (void)
break;
}
configname = make_filename (opt.homedir, name, NULL);
configname = make_filename (gnupg_homedir (), name, NULL);
}
while (access (configname, R_OK));
xfree(name);
if (! configname)
configname = make_filename (opt.homedir, GPG_NAME EXTSEP_S "conf", NULL);
configname = make_filename (gnupg_homedir (),
GPG_NAME EXTSEP_S "conf", NULL);
if (! access (configname, R_OK))
{
/* Print a warning when both config files are present. */
char *p = make_filename (opt.homedir, "options", NULL);
char *p = make_filename (gnupg_homedir (), "options", NULL);
if (! access (p, R_OK))
log_info (_("Note: old default options file '%s' ignored\n"), p);
xfree (p);
@ -2101,7 +2091,7 @@ get_default_configname (void)
else
{
/* Use the old default only if it exists. */
char *p = make_filename (opt.homedir, "options", NULL);
char *p = make_filename (gnupg_homedir (), "options", NULL);
if (!access (p, R_OK))
{
xfree (configname);
@ -2252,7 +2242,7 @@ main (int argc, char **argv)
opt.keyid_format = KF_NONE;
opt.def_sig_expire = "0";
opt.def_cert_expire = "0";
set_homedir (default_homedir ());
gnupg_set_homedir (NULL);
opt.passphrase_repeat = 1;
opt.emit_version = 1; /* Limit to the major number. */
opt.weak_digests = NULL;
@ -2281,7 +2271,7 @@ main (int argc, char **argv)
opt.no_homedir_creation = 1;
}
else if( pargs.r_opt == oHomedir )
set_homedir ( pargs.r.ret_str );
gnupg_set_homedir (pargs.r.ret_str);
else if( pargs.r_opt == oNoPermissionWarn )
opt.no_perm_warn=1;
else if (pargs.r_opt == oStrict )
@ -2295,10 +2285,10 @@ main (int argc, char **argv)
}
#ifdef HAVE_DOSISH_SYSTEM
if ( strchr (opt.homedir,'\\') ) {
char *d, *buf = xmalloc (strlen (opt.homedir)+1);
const char *s = opt.homedir;
for (d=buf,s=opt.homedir; *s; s++)
if ( strchr (gnupg_homedir, '\\') ) {
char *d, *buf = xmalloc (strlen (gnupg_homedir ())+1);
const char *s;
for (d=buf, s = gnupg_homedir (); *s; s++)
{
*d++ = *s == '\\'? '/': *s;
#ifdef HAVE_W32_SYSTEM
@ -2307,7 +2297,7 @@ main (int argc, char **argv)
#endif
}
*d = 0;
set_homedir (buf);
gnupg_set_homedir (buf);
}
#endif
@ -2344,7 +2334,7 @@ main (int argc, char **argv)
pargs.flags= ARGPARSE_FLAG_KEEP;
/* By this point we have a homedir, and cannot change it. */
check_permissions(opt.homedir,0);
check_permissions (gnupg_homedir (), 0);
next_pass:
if( configname ) {
@ -3668,7 +3658,7 @@ main (int argc, char **argv)
/* Set the 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);
if (!access (p, F_OK))
register_secured_file (p);

View File

@ -2956,10 +2956,6 @@ main (int argc, char *argv[])
int processed;
ctrl_t ctrl;
opt.homedir = default_homedir ();
if (! opt.homedir)
opt.homedir = "";
opt.ignore_time_conflict = 1;
/* Allow notations in the IETF space, for instance. */
opt.expert = 1;

View File

@ -169,7 +169,6 @@ main( int argc, char **argv )
opt.trust_model = TM_ALWAYS;
opt.batch = 1;
opt.homedir = default_homedir ();
opt.weak_digests = NULL;
tty_no_terminal(1);
@ -196,7 +195,7 @@ main( int argc, char **argv )
case oLoggerFD:
log_set_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1));
break;
case oHomedir: opt.homedir = pargs.r.ret_str; break;
case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break;
case oWeakDigest:
additional_weak_digest(pargs.r.ret_str);
break;

View File

@ -666,7 +666,7 @@ keydb_add_resource (const char *url, unsigned int flags)
)
filename = make_filename (resname, NULL);
else
filename = make_filename (opt.homedir, resname, NULL);
filename = make_filename (gnupg_homedir (), resname, NULL);
}
else
filename = xstrdup (resname);

View File

@ -2428,7 +2428,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr,
else if (*arg_string == '~')
fname = make_filename (arg_string, NULL);
else
fname = make_filename (opt.homedir, arg_string, NULL);
fname = make_filename (gnupg_homedir (), arg_string, NULL);
/* Open that file. */
a = iobuf_open (fname);

View File

@ -4261,7 +4261,8 @@ do_generate_keypair (ctrl_t ctrl, struct para_data_s *para,
log_assert (sub_psk);
if (s)
err = card_store_key_with_backup (ctrl, sub_psk, opt.homedir);
err = card_store_key_with_backup (ctrl,
sub_psk, gnupg_homedir ());
}
}
else

View File

@ -49,10 +49,10 @@ migrate_secring (ctrl_t ctrl)
char *flagfile = NULL;
char *agent_version = NULL;
secring = make_filename (opt.homedir, "secring" EXTSEP_S "gpg", NULL);
secring = make_filename (gnupg_homedir (), "secring" EXTSEP_S "gpg", NULL);
if (access (secring, F_OK))
goto leave; /* Does not exist or is not readable. */
flagfile = make_filename (opt.homedir, V21_MIGRATION_FNAME, NULL);
flagfile = make_filename (gnupg_homedir (), V21_MIGRATION_FNAME, NULL);
if (!access (flagfile, F_OK))
goto leave; /* Does exist - fine. */

View File

@ -106,7 +106,6 @@ struct
int marginals_needed;
int completes_needed;
int max_cert_depth;
const char *homedir;
const char *agent_program;
const char *dirmngr_program;

View File

@ -533,7 +533,7 @@ gen_standard_revoke (PKT_public_key *psk, const char *cache_nonce)
int kl;
char *orig_codeset;
dir = get_openpgp_revocdir (opt.homedir);
dir = get_openpgp_revocdir (gnupg_homedir ());
tmpstr = hexfingerprint (psk, NULL, 0);
fname = xstrconcat (dir, DIRSEP_S, tmpstr, NULL);
xfree (tmpstr);

View File

@ -695,12 +695,12 @@ gpg_server (ctrl_t ctrl)
assuan_set_pointer (ctx, ctrl);
if (opt.verbose || opt.debug)
{
char *tmp = NULL;
char *tmp;
tmp = xtryasprintf ("Home: %s\n"
"Config: %s\n"
"%s",
opt.homedir,
gnupg_homedir (),
"fixme: need config filename",
hello);
if (tmp)

View File

@ -617,14 +617,15 @@ tdbio_set_dbname (const char *new_dbname, int create, int *r_nofile)
if (!new_dbname)
{
fname = make_filename (opt.homedir, "trustdb" EXTSEP_S GPGEXT_GPG, NULL);
fname = make_filename (gnupg_homedir (),
"trustdb" EXTSEP_S GPGEXT_GPG, NULL);
}
else if (*new_dbname != DIRSEP_C )
{
if (strchr (new_dbname, DIRSEP_C))
fname = make_filename (new_dbname, NULL);
else
fname = make_filename (opt.homedir, new_dbname, NULL);
fname = make_filename (gnupg_homedir (), new_dbname, NULL);
}
else
{

View File

@ -747,7 +747,7 @@ opendb (char *filename, enum db_type type)
log_assert (! filename);
log_assert (type == DB_COMBINED);
filename = make_filename (opt.homedir, "tofu.db", NULL);
filename = make_filename (gnupg_homedir (), "tofu.db", NULL);
filename_free = 1;
}
else
@ -895,10 +895,10 @@ getdb (tofu_dbs_t dbs, const char *name, enum db_type type)
char *name_db;
/* Make the directory. */
rc = gnupg_mkdir_p (opt.homedir, "tofu.d", type_str, prefix, NULL);
rc = gnupg_mkdir_p (gnupg_homedir (), "tofu.d", type_str, prefix, NULL);
if (rc)
{
name_db = xstrconcat (opt.homedir, "tofu.d",
name_db = xstrconcat (gnupg_homedir (), "tofu.d",
type_str, prefix, NULL);
log_error (_("can't create directory '%s': %s\n"),
name_db, gpg_strerror (rc));
@ -908,7 +908,7 @@ getdb (tofu_dbs_t dbs, const char *name, enum db_type type)
name_db = xstrconcat (name_sanitized, ".db", NULL);
filename = make_filename
(opt.homedir, "tofu.d", type_str, prefix, name_db, NULL);
(gnupg_homedir (), "tofu.d", type_str, prefix, name_db, NULL);
xfree (name_db);
}
}
@ -989,7 +989,7 @@ opendbs (ctrl_t ctrl)
if (opt.tofu_db_format == TOFU_DB_AUTO)
{
char *filename = make_filename (opt.homedir, "tofu.db", NULL);
char *filename = make_filename (gnupg_homedir (), "tofu.db", NULL);
struct stat s;
int have_tofu_db = 0;
int have_tofu_d = 0;

View File

@ -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. */

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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)

View File

@ -140,7 +140,6 @@ typedef struct _keybox_openpgp_info *keybox_openpgp_info_t;
/* Don't know whether this is needed: */
/* static struct { */
/* const char *homedir; */
/* int dry_run; */
/* int quiet; */
/* int verbose; */

View File

@ -2281,7 +2281,7 @@ update_reader_status_file (int set_card_removed_flag)
depends on how client sessions will associate the reader
status with their session. */
snprintf (templ, sizeof templ, "reader_%d.status", vr->slot);
fname = make_filename (opt.homedir, templ, NULL );
fname = make_filename (gnupg_homedir (), templ, NULL );
fp = fopen (fname, "w");
if (fp)
{
@ -2300,7 +2300,7 @@ update_reader_status_file (int set_card_removed_flag)
char *homestr, *envstr;
gpg_error_t err;
homestr = make_filename (opt.homedir, NULL);
homestr = make_filename (gnupg_homedir (), NULL);
if (gpgrt_asprintf (&envstr, "GNUPGHOME=%s", homestr) < 0)
log_error ("out of core while building environment\n");
else
@ -2323,7 +2323,7 @@ update_reader_status_file (int set_card_removed_flag)
(status & 2)? "PRESENT": "NOCARD");
args[8] = NULL;
fname = make_filename (opt.homedir, "scd-event", NULL);
fname = make_filename (gnupg_homedir (), "scd-event", NULL);
err = gnupg_spawn_process_detached (fname, args, envs);
if (err && gpg_err_code (err) != GPG_ERR_ENOENT)
log_error ("failed to run event handler '%s': %s\n",

View File

@ -463,8 +463,6 @@ main (int argc, char **argv )
if (shell && strlen (shell) >= 3 && !strcmp (shell+strlen (shell)-3, "csh") )
csh_style = 1;
opt.homedir = default_homedir ();
/* Check whether we have a config file on the commandline */
orig_argc = argc;
orig_argv = argv;
@ -484,7 +482,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. */
@ -497,7 +495,7 @@ main (int argc, char **argv )
if (default_config)
configname = make_filename (opt.homedir, SCDAEMON_NAME EXTSEP_S "conf",
configname = make_filename (gnupg_homedir (), SCDAEMON_NAME EXTSEP_S "conf",
NULL );
@ -582,7 +580,7 @@ main (int argc, char **argv )
case oNoGreeting: nogreeting = 1; break;
case oNoVerbose: opt.verbose = 0; break;
case oNoOptions: break; /* no-options */
case oHomedir: opt.homedir = pargs.r.ret_str; break;
case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break;
case oNoDetach: nodetach = 1; break;
case oLogFile: logfile = pargs.r.ret_str; break;
case oCsh: csh_style = 1; break;
@ -674,8 +672,8 @@ main (int argc, char **argv )
if (config_filename)
filename = xstrdup (config_filename);
else
filename = make_filename (opt.homedir, SCDAEMON_NAME EXTSEP_S "conf",
NULL);
filename = make_filename (gnupg_homedir (),
SCDAEMON_NAME EXTSEP_S "conf", NULL);
filename_esc = percent_escape (filename, NULL);
es_printf ("%s-%s.conf:%lu:\"%s\n",
@ -1044,7 +1042,7 @@ create_socket_name (char *standard_name)
{
char *name;
name = make_filename (opt.homedir, standard_name, NULL);
name = make_filename (gnupg_homedir (), standard_name, NULL);
if (strchr (name, PATHSEP_C))
{
log_error (("'%s' are not allowed in the socket name\n"), PATHSEP_S);

View File

@ -51,7 +51,6 @@ 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 *ctapi_driver; /* Library to access the ctAPI. */
const char *pcsc_driver; /* Library to access the PC/SC system. */
const char *reader_port; /* NULL or reder port to use. */

View File

@ -133,7 +133,7 @@ start_agent (ctrl_t ctrl)
{
rc = start_new_gpg_agent (&agent_ctx,
GPG_ERR_SOURCE_DEFAULT,
opt.homedir,
gnupg_homedir (),
opt.agent_program,
opt.lc_ctype, opt.lc_messages,
opt.session_env,

View File

@ -248,7 +248,7 @@ start_dirmngr_ext (ctrl_t ctrl, assuan_context_t *ctx_r)
to take care of the implicit option sending caching. */
err = start_new_dirmngr (&ctx, GPG_ERR_SOURCE_DEFAULT,
opt.homedir, opt.dirmngr_program,
gnupg_homedir (), opt.dirmngr_program,
opt.autostart, opt.verbose, DBG_IPC,
gpgsm_status2, ctrl);
if (!opt.autostart && gpg_err_code (err) == GPG_ERR_NO_DIRMNGR)

View File

@ -581,7 +581,7 @@ my_strusage( int level )
break;
case 31: p = "\nHome: "; break;
case 32: p = opt.homedir; break;
case 32: p = gnupg_homedir (); break;
case 33: p = _("\nSupported algorithms:\n"); break;
case 34:
if (!ciphers)
@ -964,8 +964,6 @@ main ( int argc, char **argv)
remember to update the Gpgconflist entry as well. */
opt.def_cipher_algoid = DEFAULT_CIPHER_ALGO;
opt.homedir = default_homedir ();
/* First check whether we have a config file on the commandline */
orig_argc = argc;
@ -989,7 +987,7 @@ main ( int argc, char **argv)
opt.no_homedir_creation = 1;
}
else if (pargs.r_opt == oHomedir)
opt.homedir = pargs.r.ret_str;
gnupg_set_homedir (pargs.r.ret_str);
else if (pargs.r_opt == aCallProtectTool)
break; /* This break makes sure that --version and --help are
passed to the protect-tool. */
@ -1024,9 +1022,10 @@ main ( int argc, char **argv)
/* Set the default option file */
if (default_config )
configname = make_filename (opt.homedir, GPGSM_NAME EXTSEP_S "conf", NULL);
configname = make_filename (gnupg_homedir (),
GPGSM_NAME EXTSEP_S "conf", NULL);
/* Set the default policy file */
opt.policy_file = make_filename (opt.homedir, "policies.txt", NULL);
opt.policy_file = make_filename (gnupg_homedir (), "policies.txt", NULL);
argc = orig_argc;
argv = orig_argv;
@ -1304,7 +1303,7 @@ main ( int argc, char **argv)
}
break;
case oNoOptions: opt.no_homedir_creation = 1; break; /* no-options */
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 oDisplay:
@ -1468,7 +1467,7 @@ main ( int argc, char **argv)
configname = NULL;
if (!opt.config_filename)
opt.config_filename = make_filename (opt.homedir,
opt.config_filename = make_filename (gnupg_homedir (),
GPGSM_NAME EXTSEP_S "conf",
NULL);
@ -1605,7 +1604,7 @@ main ( int argc, char **argv)
/* Set the 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);
}

View File

@ -61,7 +61,6 @@ struct
int dry_run; /* don't change any persistent data */
int no_homedir_creation;
const char *homedir; /* Configuration directory name */
const char *config_filename; /* Name of the used config file. */
const char *agent_program;

View File

@ -287,7 +287,7 @@ keydb_add_resource (const char *url, int force, int secret, int *auto_created)
if (strchr(resname, DIRSEP_C) )
filename = make_filename (resname, NULL);
else
filename = make_filename (opt.homedir, resname, NULL);
filename = make_filename (gnupg_homedir (), resname, NULL);
}
else
filename = xstrdup (resname);

View File

@ -1308,7 +1308,7 @@ gpgsm_server (certlist_t default_recplist)
}
if (opt.verbose || opt.debug)
{
char *tmp = NULL;
char *tmp;
/* Fixme: Use the really used socket name. */
if (asprintf (&tmp,
@ -1316,7 +1316,7 @@ gpgsm_server (certlist_t default_recplist)
"Config: %s\n"
"DirmngrInfo: %s\n"
"%s",
opt.homedir,
gnupg_homedir (),
opt.config_filename,
(dirmngr_user_socket_name ()
? dirmngr_user_socket_name ()

View File

@ -181,8 +181,6 @@ main (int argc, char **argv )
setup_libgcrypt_logging ();
gcry_control (GCRYCTL_INIT_SECMEM, 4096, 0);
opt.homedir = default_homedir ();
pargs.argc = &argc;
pargs.argv = &argv;
pargs.flags= 1; /* (do not remove the args) */
@ -191,7 +189,7 @@ main (int argc, char **argv )
switch (pargs.r_opt)
{
case oVerbose: opt.verbose++; break;
case oHomedir: opt.homedir = pargs.r.ret_str; break;
case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break;
case oCheck: opt.checkonly = 1; break;
case oNull: opt.null = 1; break;

View File

@ -209,7 +209,7 @@ my_strusage( int level )
"Connect to a running agent and send commands\n");
break;
case 31: p = "\nHome: "; break;
case 32: p = opt.homedir; break;
case 32: p = gnupg_homedir (); break;
case 33: p = "\n"; break;
default: p = NULL; break;
@ -555,7 +555,7 @@ get_var_ext (const char *name)
log_error ("getcwd failed: %s\n", strerror (errno));
}
else if (!strcmp (s, "homedir"))
result = make_filename (opt.homedir, NULL);
result = make_filename (gnupg_homedir (), NULL);
else if (!strcmp (s, "sysconfdir"))
result = xstrdup (gnupg_sysconfdir ());
else if (!strcmp (s, "bindir"))
@ -1181,7 +1181,6 @@ main (int argc, char **argv)
assuan_set_gpg_err_source (0);
opt.homedir = default_homedir ();
opt.autostart = 1;
opt.connect_flags = 1;
@ -1196,7 +1195,7 @@ main (int argc, char **argv)
case oQuiet: opt.quiet = 1; break;
case oVerbose: opt.verbose++; break;
case oNoVerbose: opt.verbose = 0; 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 oDirmngrProgram: opt.dirmngr_program = pargs.r.ret_str; break;
case oNoAutostart: opt.autostart = 0; break;
@ -1225,7 +1224,7 @@ main (int argc, char **argv)
in particular handy on Windows. */
if (opt.use_uiserver)
{
opt.raw_socket = make_absfilename (opt.homedir, "S.uiserver", NULL);
opt.raw_socket = make_absfilename (gnupg_homedir (), "S.uiserver", NULL);
}
/* Print a warning if an argument looks like an option. */
@ -2209,7 +2208,7 @@ start_agent (void)
if (opt.use_dirmngr)
err = start_new_dirmngr (&ctx,
GPG_ERR_SOURCE_DEFAULT,
opt.homedir,
gnupg_homedir (),
opt.dirmngr_program,
opt.autostart,
!opt.quiet, 0,
@ -2217,7 +2216,7 @@ start_agent (void)
else
err = start_new_gpg_agent (&ctx,
GPG_ERR_SOURCE_DEFAULT,
opt.homedir,
gnupg_homedir (),
opt.agent_program,
NULL, NULL,
session_env,

View File

@ -214,7 +214,7 @@ my_strusage (int level)
"Call a simple symmetric encryption tool\n");
break;
case 31: p = "\nHome: "; break;
case 32: p = opt.homedir; break;
case 32: p = gnupg_homedir (); break;
case 33: p = "\n"; break;
default: p = NULL; break;
@ -896,8 +896,6 @@ main (int argc, char **argv)
i18n_init();
init_common_subsystems (&argc, &argv);
opt.homedir = default_homedir ();
/* Check whether we have a config file given on the commandline */
orig_argc = argc;
orig_argv = argv;
@ -915,11 +913,11 @@ 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);
}
if (default_config)
configname = make_filename (opt.homedir, "symcryptrun.conf", NULL );
configname = make_filename (gnupg_homedir (), "symcryptrun.conf", NULL );
argc = orig_argc;
argv = orig_argv;
@ -1010,7 +1008,7 @@ main (int argc, char **argv)
/* Tell simple-pwquery about the the standard socket name. */
{
char *tmp = make_filename (opt.homedir, GPG_AGENT_SOCK_NAME, NULL);
char *tmp = make_filename (gnupg_homedir (), GPG_AGENT_SOCK_NAME, NULL);
simple_pw_set_socket (tmp);
xfree (tmp);
}