mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-21 14:47:03 +01:00
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 <wk@gnupg.org>
This commit is contained in:
parent
fb88f37c40
commit
36550dde99
@ -1762,7 +1762,7 @@ create_socket_name (char *standard_name, int with_homedir)
|
||||
char *name;
|
||||
|
||||
if (with_homedir)
|
||||
name = make_filename (gnupg_homedir (), standard_name, NULL);
|
||||
name = make_filename (gnupg_socketdir (), standard_name, NULL);
|
||||
else
|
||||
name = make_filename (standard_name, NULL);
|
||||
if (strchr (name, PATHSEP_C))
|
||||
@ -2729,7 +2729,7 @@ check_own_socket (void)
|
||||
if (check_own_socket_running || shutdown_pending)
|
||||
return; /* Still running or already shutting down. */
|
||||
|
||||
sockname = make_filename_try (gnupg_homedir (), GPG_AGENT_SOCK_NAME, NULL);
|
||||
sockname = make_filename_try (gnupg_socketdir (), GPG_AGENT_SOCK_NAME, NULL);
|
||||
if (!sockname)
|
||||
return; /* Out of memory. */
|
||||
|
||||
@ -2755,7 +2755,7 @@ check_for_running_agent (int silent)
|
||||
char *sockname;
|
||||
assuan_context_t ctx = NULL;
|
||||
|
||||
sockname = make_filename_try (gnupg_homedir (), GPG_AGENT_SOCK_NAME, NULL);
|
||||
sockname = make_filename_try (gnupg_socketdir (), GPG_AGENT_SOCK_NAME, NULL);
|
||||
if (!sockname)
|
||||
return gpg_error_from_syserror ();
|
||||
|
||||
|
@ -245,7 +245,7 @@ main (int argc, char **argv)
|
||||
|
||||
/* Tell simple-pwquery about the the standard socket name. */
|
||||
{
|
||||
char *tmp = make_filename (gnupg_homedir (), GPG_AGENT_SOCK_NAME, NULL);
|
||||
char *tmp = make_filename (gnupg_socketdir (), GPG_AGENT_SOCK_NAME, NULL);
|
||||
simple_pw_set_socket (tmp);
|
||||
xfree (tmp);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -1042,7 +1042,7 @@ create_socket_name (char *standard_name)
|
||||
{
|
||||
char *name;
|
||||
|
||||
name = make_filename (gnupg_homedir (), standard_name, NULL);
|
||||
name = make_filename (gnupg_socketdir (), standard_name, NULL);
|
||||
if (strchr (name, PATHSEP_C))
|
||||
{
|
||||
log_error (("'%s' are not allowed in the socket name\n"), PATHSEP_S);
|
||||
|
@ -375,7 +375,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
{
|
||||
char *tmp = make_filename (default_homedir (),
|
||||
char *tmp = make_filename (gnupg_socketdir (),
|
||||
GPG_AGENT_SOCK_NAME, NULL);
|
||||
es_fprintf (outfp, "agent-socket:%s\n", gc_percent_escape (tmp));
|
||||
xfree (tmp);
|
||||
|
@ -1008,7 +1008,7 @@ main (int argc, char **argv)
|
||||
|
||||
/* Tell simple-pwquery about the the standard socket name. */
|
||||
{
|
||||
char *tmp = make_filename (gnupg_homedir (), GPG_AGENT_SOCK_NAME, NULL);
|
||||
char *tmp = make_filename (gnupg_socketgdir (), GPG_AGENT_SOCK_NAME, NULL);
|
||||
simple_pw_set_socket (tmp);
|
||||
xfree (tmp);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user