diff options
author | Werner Koch <[email protected]> | 2016-06-07 11:48:46 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2016-06-07 11:48:46 +0000 |
commit | 36550dde998fa1d497098050ca2d4e1a952ed6b6 (patch) | |
tree | 852698c73f3d10736b2a7f291992fefbbed9ae32 /common/homedir.c | |
parent | common: Remove homedir arg from start_new_{dirmngr,gpg_agent}. (diff) | |
download | gnupg-36550dde998fa1d497098050ca2d4e1a952ed6b6.tar.gz gnupg-36550dde998fa1d497098050ca2d4e1a952ed6b6.zip |
common: New function gnupg_socketdir.
* common/homedir.c (gnupg_socketdir): New.
* agent/gpg-agent.c (create_socket_name): Use new function instead of
gnupg_homedir.
(check_own_socket): Ditto.
(check_for_running_agent): Ditto.
* agent/preset-passphrase.c (main): Ditto.
* common/asshelp.c (start_new_gpg_agent): Ditto.
* scd/scdaemon.c (create_socket_name): Ditto.
* tools/gpgconf.c (main): Ditto.
* tools/symcryptrun.c (main): Ditto.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'common/homedir.c')
-rw-r--r-- | common/homedir.c | 33 |
1 files changed, 31 insertions, 2 deletions
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; } |