aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--common/asshelp.c9
-rw-r--r--common/homedir.c33
-rw-r--r--common/util.h1
3 files changed, 40 insertions, 3 deletions
diff --git a/common/asshelp.c b/common/asshelp.c
index f89d1d554..5c32c6ed3 100644
--- a/common/asshelp.c
+++ b/common/asshelp.c
@@ -374,7 +374,14 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
return err;
}
- sockname = make_absfilename (gnupg_homedir (), GPG_AGENT_SOCK_NAME, NULL);
+ sockname = make_filename_try (gnupg_socketdir (), GPG_AGENT_SOCK_NAME, NULL);
+ if (!sockname)
+ {
+ err = gpg_err_make (errsource, gpg_err_code_from_syserror ());
+ assuan_release (ctx);
+ return err;
+ }
+
err = assuan_socket_connect (ctx, sockname, 0, 0);
if (err && autostart)
{
diff --git a/common/homedir.c b/common/homedir.c
index eccffeccf..8992bc69c 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -375,7 +375,7 @@ w32_commondir (void)
/* Change the homedir. Some care must be taken to set this early
- * enough becuase previous calls to gnupg_homedir may else return a
+ * enough because previous calls to gnupg_homedir may else return a
* different string. */
void
gnupg_set_homedir (const char *newdir)
@@ -400,6 +400,35 @@ gnupg_homedir (void)
}
+/*
+ * Return the name of the socket dir. That is the directory used for
+ * the IPC local sockets. This is an absolute filename.
+ */
+const char *
+gnupg_socketdir (void)
+{
+ static char *name;
+
+ if (!name)
+ {
+ /* Check XDG variable. */
+
+ /* XDG is not set: Check whether we have a /run directory. */
+
+ /* If there is no run directpry we assume a /var/run directory. */
+
+ /* Check that the user directory exists or create it if
+ * required, */
+
+ /* If nothing works fall back to the homedir. */
+ if (!name)
+ name = make_absfilename (gnupg_homedir (), NULL);
+ }
+
+ return name;
+}
+
+
/* Return the name of the sysconfdir. This is a static string. This
function is required because under Windows we can't simply compile
it in. */
@@ -631,7 +660,7 @@ dirmngr_user_socket_name (void)
static char *name;
if (!name)
- name = make_absfilename (default_homedir (), DIRMNGR_SOCK_NAME, NULL);
+ name = make_filename (gnupg_socketdir (), DIRMNGR_SOCK_NAME, NULL);
return name;
}
diff --git a/common/util.h b/common/util.h
index 634ae06a9..0621047df 100644
--- a/common/util.h
+++ b/common/util.h
@@ -222,6 +222,7 @@ 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_socketdir (void);
const char *gnupg_sysconfdir (void);
const char *gnupg_bindir (void);
const char *gnupg_libexecdir (void);