diff options
author | Werner Koch <[email protected]> | 2021-11-13 13:46:19 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2021-11-13 13:56:40 +0000 |
commit | dd708f60d5cf571bd4f0312c1b291ec93c328047 (patch) | |
tree | 4c8effa30247ff0e5bd8289c16b4a56cf03b7aac /agent/gpg-agent.c | |
parent | doc: Clarify the "ntds" AKL mechanism. (diff) | |
download | gnupg-dd708f60d5cf571bd4f0312c1b291ec93c328047.tar.gz gnupg-dd708f60d5cf571bd4f0312c1b291ec93c328047.zip |
agent,dirmngr: New option --steal-socket
* agent/gpg-agent.c (oStealSocket): New.
(opts): Add option.
(steal_socket): New file global var.
(main): Set option.
(create_server_socket): Implement option.
* dirmngr/dirmngr.c (oStealSocket): New.
(opts): Add option.
(steal_socket): New file global var.
(main): Set option. Add comment to eventually implement it.
--
Note that --steal-socket has currently no effect on dirmngr because
dirmngr does this anway.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'agent/gpg-agent.c')
-rw-r--r-- | agent/gpg-agent.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index 2c4d313f5..46fb840bb 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -118,6 +118,7 @@ enum cmd_and_opt_values oEnablePassphraseHistory, oDisableExtendedKeyFormat, oEnableExtendedKeyFormat, + oStealSocket, oUseStandardSocket, oNoUseStandardSocket, oExtraSocket, @@ -171,6 +172,7 @@ static gpgrt_opt_t opts[] = { ARGPARSE_s_n (oNoDetach, "no-detach", N_("do not detach from the console")), ARGPARSE_s_n (oSh, "sh", N_("sh-style command output")), ARGPARSE_s_n (oCsh, "csh", N_("csh-style command output")), + ARGPARSE_s_n (oStealSocket, "steal-socket", "@"), ARGPARSE_s_s (oDisplay, "display", "@"), ARGPARSE_s_s (oTTYname, "ttyname", "@"), ARGPARSE_s_s (oTTYtype, "ttytype", "@"), @@ -382,6 +384,9 @@ static int disable_check_own_socket; /* Flag indicating that we are in supervised mode. */ static int is_supervised; +/* Flag indicating to start the daemon even if one already runs. */ +static int steal_socket; + /* Flag to inhibit socket removal in cleanup. */ static int inhibit_socket_removal; @@ -1238,6 +1243,7 @@ main (int argc, char **argv) case oSh: csh_style = 0; break; case oServer: pipe_server = 1; break; case oDaemon: is_daemon = 1; break; + case oStealSocket: steal_socket = 1; break; case oSupervised: is_supervised = 1; break; case oDisplay: default_display = xstrdup (pargs.r.ret_str); break; @@ -2239,14 +2245,20 @@ create_server_socket (char *name, int primary, int cygwin, server is not yet operational; this would lead to a hang. */ if (primary && !check_for_running_agent (1)) { - log_set_prefix (NULL, GPGRT_LOG_WITH_PREFIX); - log_set_file (NULL); - log_error (_("a gpg-agent is already running - " - "not starting a new one\n")); - *name = 0; /* Inhibit removal of the socket by cleanup(). */ - assuan_sock_close (fd); - xfree (unaddr); - agent_exit (2); + if (steal_socket) + log_info (N_("trying to steal socket from running %s\n"), + "gpg-agent"); + else + { + log_set_prefix (NULL, GPGRT_LOG_WITH_PREFIX); + log_set_file (NULL); + log_error (_("a gpg-agent is already running - " + "not starting a new one\n")); + *name = 0; /* Inhibit removal of the socket by cleanup(). */ + assuan_sock_close (fd); + xfree (unaddr); + agent_exit (2); + } } gnupg_remove (unaddr->sun_path); rc = assuan_sock_bind (fd, addr, len); |