diff options
Diffstat (limited to 'g10')
-rw-r--r-- | g10/ChangeLog | 10 | ||||
-rw-r--r-- | g10/g10.c | 13 | ||||
-rw-r--r-- | g10/gpgv.c | 15 | ||||
-rw-r--r-- | g10/main.h | 3 | ||||
-rw-r--r-- | g10/misc.c | 59 |
5 files changed, 79 insertions, 21 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog index bc37588c5..6f6bfc597 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,5 +1,15 @@ +2005-01-20 Werner Koch <[email protected]> + + * g10.c (i18n_init) [W32]: Pass registry key to gettext + initialization. + * gpgv.c (i18n_init) [W32]: Ditto. + 2005-01-18 Werner Koch <[email protected]> + * misc.c (default_homedir): New. Taken from gnupg 1.9.15. + * g10.c (main): Use it. + * gpgv.c (main): Ditto. + * keylist.c (public_key_list): Do a trustdb staleness check before opening the keyring. (secret_key_list): Ditto. @@ -1,6 +1,6 @@ /* g10.c - The GnuPG utility (main for gpg) * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 - * 2004 Free Software Foundation, Inc. + * 2004, 2005 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -839,7 +839,7 @@ static void i18n_init(void) { #ifdef USE_SIMPLE_GETTEXT - set_gettext_file( PACKAGE ); + set_gettext_file (PACKAGE, "Software\\GNU\\GnuPG"); #else #ifdef ENABLE_NLS setlocale( LC_ALL, "" ); @@ -1673,14 +1673,7 @@ main( int argc, char **argv ) set_screen_dimensions(); opt.keyid_format=KF_SHORT; opt.rfc2440_text=1; -#if defined (_WIN32) - set_homedir ( read_w32_registry_string( NULL, - "Software\\GNU\\GnuPG", "HomeDir" )); -#else - set_homedir ( getenv("GNUPGHOME") ); -#endif - if( !*opt.homedir ) - set_homedir ( GNUPG_HOMEDIR ); + set_homedir ( default_homedir () ); #ifdef ENABLE_CARD_SUPPORT # ifdef _WIN32 diff --git a/g10/gpgv.c b/g10/gpgv.c index 7778953d1..020b548bb 100644 --- a/g10/gpgv.c +++ b/g10/gpgv.c @@ -1,5 +1,6 @@ /* gpgv.c - The GnuPG signature verify utility - * Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, + * 2005 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -112,7 +113,7 @@ static void i18n_init(void) { #ifdef USE_SIMPLE_GETTEXT - set_gettext_file( PACKAGE ); + set_gettext_file (PACKAGE, "Software\\GNU\\GnuPG"); #else #ifdef ENABLE_NLS setlocale( LC_ALL, "" ); @@ -141,14 +142,8 @@ main( int argc, char **argv ) opt.trust_model = TM_ALWAYS; opt.batch = 1; -#if defined (_WIN32) - opt.homedir = read_w32_registry_string( NULL, "Software\\GNU\\GnuPG", "HomeDir" ); -#else - opt.homedir = getenv("GNUPGHOME"); -#endif - if( !opt.homedir || !*opt.homedir ) { - opt.homedir = GNUPG_HOMEDIR; - } + opt.homedir = default_homedir (); + tty_no_terminal(1); tty_batchmode(1); disable_dotlock(); diff --git a/g10/main.h b/g10/main.h index 429eb6403..bf8543f0e 100644 --- a/g10/main.h +++ b/g10/main.h @@ -122,6 +122,9 @@ char *argsplit(char *string); int parse_options(char *str,unsigned int *options, struct parse_options *opts,int noisy); +char *default_homedir (void); + + /*-- helptext.c --*/ void display_online_help( const char *keyword ); diff --git a/g10/misc.c b/g10/misc.c index 3eae2aee8..2c3fbf129 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -1,6 +1,6 @@ /* misc.c - miscellaneous functions * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, - * 2004 Free Software Foundation, Inc. + * 2004, 2005 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -40,7 +40,19 @@ #ifdef _WIN32 #include <time.h> #include <process.h> +#include <windows.h> +#include <shlobj.h> +#ifndef CSIDL_APPDATA +#define CSIDL_APPDATA 0x001a #endif +#ifndef CSIDL_LOCAL_APPDATA +#define CSIDL_LOCAL_APPDATA 0x001c +#endif +#ifndef CSIDL_FLAG_CREATE +#define CSIDL_FLAG_CREATE 0x8000 +#endif +#endif /*_WIN32*/ + #include "util.h" #include "main.h" #include "photoid.h" @@ -49,6 +61,8 @@ #include "cardglue.h" + + #ifdef ENABLE_SELINUX_HACKS /* A object and a global variable to keep track of files marked as secured. */ @@ -1002,3 +1016,46 @@ parse_options(char *str,unsigned int *options, return 1; } + + +/* Set up the default home directory. The usual --homedir option + should be parsed later. */ +char * +default_homedir (void) +{ + char *dir; + + dir = getenv("GNUPGHOME"); +#ifdef HAVE_W32_SYSTEM + if (!dir || !*dir) + dir = read_w32_registry_string (NULL, "Software\\GNU\\GnuPG", "HomeDir"); + if (!dir || !*dir) + { + char path[MAX_PATH]; + + /* It might be better to use LOCAL_APPDATA because this is + defined as "non roaming" and thus more likely to be kept + locally. For private keys this is desired. However, given + that many users copy private keys anyway forth and back, + using a system roaming serives might be better than to let + them do it manually. A security conscious user will anyway + use the registry entry to have better control. */ + if (SHGetFolderPath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, + NULL, 0, path) >= 0) + { + char *tmp = xmalloc (strlen (path) + 6 +1); + strcpy (stpcpy (tmp, path), "\\gnupg"); + dir = tmp; + + /* Try to create the directory if it does not yet + exists. */ + if (access (dir, F_OK)) + CreateDirectory (dir, NULL); + } + } +#endif /*HAVE_W32_SYSTEM*/ + if (!dir || !*dir) + dir = GNUPG_HOMEDIR; + + return dir; +} |