From 1f71f4c626a9bd57f07793bce43f06647c540320 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 26 Sep 2002 12:28:27 +0000 Subject: [PATCH] * g10.c (set_homedir): New. Changed all direct assignments to use this. * gpgv.c (set_homedir): Ditto. --- g10/ChangeLog | 6 ++++++ g10/g10.c | 26 ++++++++++++++++++-------- g10/gpgv.c | 23 ++++++++++++++++------- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index 930dc84cd..ccb7d7c00 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,9 @@ +2002-09-26 Werner Koch + + * g10.c (set_homedir): New. Changed all direct assignments to use + this. + * gpgv.c (set_homedir): Ditto. + 2002-09-19 David Shaw * keylist.c (list_keyblock_colon): Show 1F direct key signatures diff --git a/g10/g10.c b/g10/g10.c index 7beb5ae03..34c0285f4 100644 --- a/g10/g10.c +++ b/g10/g10.c @@ -778,6 +778,17 @@ set_debug(void) } +/* We need the home directory also in some other directories, so make + sure that both variables are always in sync. */ +static void +set_homedir (char *dir) +{ + if (!dir) + dir = ""; + g10_opt_homedir = opt.homedir = dir; +} + + static void set_cmd( enum cmd_and_opt_values *ret_cmd, enum cmd_and_opt_values new_cmd ) { @@ -1092,13 +1103,13 @@ main( int argc, char **argv ) opt.keyserver_options.include_subkeys=1; opt.keyserver_options.include_revoked=1; #if defined (__MINGW32__) || defined (__CYGWIN32__) - opt.homedir = read_w32_registry_string( NULL, "Software\\GNU\\GnuPG", "HomeDir" ); + set_homedir ( read_w32_registry_string( NULL, + "Software\\GNU\\GnuPG", "HomeDir" )); #else - opt.homedir = getenv("GNUPGHOME"); + set_homedir ( getenv("GNUPGHOME") ); #endif - if( !opt.homedir || !*opt.homedir ) { - opt.homedir = GNUPG_HOMEDIR; - } + if( !*opt.homedir ) + set_homedir ( GNUPG_HOMEDIR ); /* check whether we have a config file on the commandline */ orig_argc = argc; @@ -1118,7 +1129,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; + set_homedir ( pargs.r.ret_str ); else if( pargs.r_opt == oNoPermissionWarn ) opt.no_perm_warn=1; #ifdef USE_SHM_COPROCESSING @@ -1143,7 +1154,7 @@ main( int argc, char **argv ) for (d=buf,s=opt.homedir; *s; s++) *d++ = *s == '\\'? '/': *s; *d = 0; - opt.homedir = buf; + set_homedir (buf); } #endif #ifdef USE_SHM_COPROCESSING @@ -1714,7 +1725,6 @@ main( int argc, char **argv ) secmem_set_flags( secmem_get_flags() & ~2 ); /* resume warnings */ set_debug(); - g10_opt_homedir = opt.homedir; /* Do these after the switch(), so they can override settings. */ if(opt.pgp2 && (opt.pgp6 || opt.pgp7)) diff --git a/g10/gpgv.c b/g10/gpgv.c index dcb2a9d94..6be33d7fb 100644 --- a/g10/gpgv.c +++ b/g10/gpgv.c @@ -109,6 +109,17 @@ strusage( int 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 (char *dir) +{ + if (!dir) + dir = ""; + g10_opt_homedir = opt.homedir = dir; +} + + static void @@ -154,12 +165,12 @@ main( int argc, char **argv ) opt.batch = 1; #if defined (__MINGW32__) || defined (__CYGWIN32__) - opt.homedir = read_w32_registry_string( NULL, "Software\\GNU\\GnuPG", "HomeDir" ); + set_homedir (read_w32_registry_string( NULL, "Software\\GNU\\GnuPG", "HomeDir" )); #else - opt.homedir = getenv("GNUPGHOME"); + set_homedir (getenv("GNUPGHOME")); #endif - if( !opt.homedir || !*opt.homedir ) { - opt.homedir = GNUPG_HOMEDIR; + if( !*opt.homedir ) { + set_homedir (GNUPG_HOMEDIR); } tty_no_terminal(1); tty_batchmode(1); @@ -178,7 +189,7 @@ main( int argc, char **argv ) case oKeyring: append_to_strlist( &nrings, pargs.r.ret_str); break; case oStatusFD: set_status_fd( pargs.r.ret_int ); break; case oLoggerFD: log_set_logfile( NULL, pargs.r.ret_int ); break; - case oHomedir: opt.homedir = pargs.r.ret_str; break; + case oHomedir: set_homedir (pargs.r.ret_str); break; default : pargs.err = 2; break; } } @@ -186,8 +197,6 @@ main( int argc, char **argv ) if( log_get_errorcount(0) ) g10_exit(2); - g10_opt_homedir = opt.homedir; - if( opt.verbose > 1 ) set_packet_list_mode(1);