[svn] GpgEX - r16 - trunk/src
svn author marcus
cvs at cvs.gnupg.org
Tue Sep 11 15:53:08 CEST 2007
Author: marcus
Date: 2007-09-11 15:52:39 +0200 (Tue, 11 Sep 2007)
New Revision: 16
Modified:
trunk/src/ChangeLog
trunk/src/Makefile.am
trunk/src/client.cc
trunk/src/registry.c
trunk/src/registry.h
Log:
2007-09-11 Marcus Brinkmann <marcus at g10code.de>
* Makefile.am (libgpg-error.a, libassuan.a): Use -f flag with ln.
* registry.h (default_dir): New prototype.
* registry.c (default_dir, standard_homedir): New functions.
* client.cc (default_socket_name): Use default home dir instead
install directory.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2007-09-11 13:03:34 UTC (rev 15)
+++ trunk/src/ChangeLog 2007-09-11 13:52:39 UTC (rev 16)
@@ -1,3 +1,11 @@
+2007-09-11 Marcus Brinkmann <marcus at g10code.de>
+
+ * Makefile.am (libgpg-error.a, libassuan.a): Use -f flag with ln.
+ * registry.h (default_dir): New prototype.
+ * registry.c (default_dir, standard_homedir): New functions.
+ * client.cc (default_socket_name): Use default home dir instead
+ install directory.
+
2007-09-05 Marcus Brinkmann <marcus at g10code.de>
* gpgex.h (class gpgex_t): Make destructor virtual to silence
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2007-09-11 13:03:34 UTC (rev 15)
+++ trunk/src/Makefile.am 2007-09-11 13:52:39 UTC (rev 16)
@@ -41,10 +41,10 @@
# -L . -lshell32 -lcomdlg32 -loleaut32 -ladvapi32
libgpg-error.a:
- ln -s $(shell $(GPG_ERROR_CONFIG) --prefix)/lib/libgpg-error.a
+ ln -sf $(shell $(GPG_ERROR_CONFIG) --prefix)/lib/libgpg-error.a
libassuan.a:
- ln -s $(shell $(LIBASSUAN_CONFIG) --prefix)/lib/libassuan.a
+ ln -sf $(shell $(LIBASSUAN_CONFIG) --prefix)/lib/libassuan.a
clean-local:
rm -f libgpg-error.a libassuan.a
Modified: trunk/src/client.cc
===================================================================
--- trunk/src/client.cc 2007-09-11 13:03:34 UTC (rev 15)
+++ trunk/src/client.cc 2007-09-11 13:52:39 UTC (rev 16)
@@ -44,16 +44,15 @@
{
static string name;
- if (name.size() == 0)
+ if (name.size () == 0)
{
char *dir = NULL;
/* FIXME: Wrong directory. */
- dir = read_w32_registry_string ("HKEY_LOCAL_MACHINE", REGKEY,
- "Install Directory");
+ dir = default_homedir ();
if (dir)
{
- try { name = ((string) dir) + "\\S.kleopatra"; } catch (...) {}
+ try { name = ((string) dir) + "\\S.uiserver"; } catch (...) {}
free ((void *) dir);
}
}
Modified: trunk/src/registry.c
===================================================================
--- trunk/src/registry.c 2007-09-11 13:03:34 UTC (rev 15)
+++ trunk/src/registry.c 2007-09-11 13:52:39 UTC (rev 16)
@@ -22,8 +22,20 @@
#include <config.h>
#endif
+#include <unistd.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
+
#include "registry.h"
@@ -176,3 +188,84 @@
RegCloseKey( key_handle );
return result;
}
+
+
+/* Get the standard home directory. In general this function should
+ not be used as it does not consider a registry value (under W32) or
+ the GNUPGHOME encironment variable. It is better to use
+ default_homedir(). */
+static char *
+standard_homedir (void)
+{
+ static char *dir;
+
+ if (!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 services 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 (w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE,
+ NULL, 0, path) >= 0)
+ {
+ char *tmp = malloc (strlen (path) + 6 + 1);
+
+ strcpy (tmp, path);
+ strcat (tmp, "\\gnupg");
+
+ dir = tmp;
+
+ /* Try to create the directory if it does not yet exists. */
+ if (access (dir, F_OK))
+ CreateDirectory (dir, NULL);
+ }
+ else
+ dir = "C:\\gnupg";
+ }
+ return dir;
+}
+
+
+/* Retrieve the default home directory. */
+char *
+default_homedir (void)
+{
+ char *dir;
+
+ dir = getenv ("GNUPGHOME");
+ if (!dir || !*dir)
+ {
+ static char *saved_dir;
+
+ if (!saved_dir)
+ {
+ if (!dir || !*dir)
+ {
+ char *tmp;
+
+ tmp = read_w32_registry_string (NULL, "Software\\GNU\\GnuPG",
+ "HomeDir");
+ if (tmp && *tmp)
+ {
+ free (tmp);
+ tmp = NULL;
+ }
+ if (tmp)
+ saved_dir = tmp;
+ }
+
+ if (!saved_dir)
+ saved_dir = standard_homedir ();
+ }
+ dir = saved_dir;
+ }
+ if (!dir || !*dir)
+ dir = "C:\\gnupg";
+
+ return dir;
+}
Modified: trunk/src/registry.h
===================================================================
--- trunk/src/registry.h 2007-09-11 13:03:34 UTC (rev 15)
+++ trunk/src/registry.h 2007-09-11 13:52:39 UTC (rev 16)
@@ -40,6 +40,9 @@
char *read_w32_registry_string (const char *root, const char *dir,
const char *name);
+/* Retrieve the default home directory. */
+char *default_homedir (void);
+
#ifdef __cplusplus
#if 0
{
More information about the Gnupg-commits
mailing list