mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-22 19:58:29 +01:00
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 <wk@gnupg.org>
This commit is contained in:
parent
751b978ee1
commit
6507c6ab10
@ -119,6 +119,7 @@ enum cmd_and_opt_values
|
|||||||
oEnablePassphraseHistory,
|
oEnablePassphraseHistory,
|
||||||
oDisableExtendedKeyFormat,
|
oDisableExtendedKeyFormat,
|
||||||
oEnableExtendedKeyFormat,
|
oEnableExtendedKeyFormat,
|
||||||
|
oStealSocket,
|
||||||
oUseStandardSocket,
|
oUseStandardSocket,
|
||||||
oNoUseStandardSocket,
|
oNoUseStandardSocket,
|
||||||
oExtraSocket,
|
oExtraSocket,
|
||||||
@ -173,6 +174,7 @@ static ARGPARSE_OPTS opts[] = {
|
|||||||
ARGPARSE_s_n (oQuiet, "quiet", N_("be somewhat more quiet")),
|
ARGPARSE_s_n (oQuiet, "quiet", N_("be somewhat more quiet")),
|
||||||
ARGPARSE_s_n (oSh, "sh", N_("sh-style command output")),
|
ARGPARSE_s_n (oSh, "sh", N_("sh-style command output")),
|
||||||
ARGPARSE_s_n (oCsh, "csh", N_("csh-style command output")),
|
ARGPARSE_s_n (oCsh, "csh", N_("csh-style command output")),
|
||||||
|
ARGPARSE_s_n (oStealSocket, "steal-socket", "@"),
|
||||||
ARGPARSE_conffile (oOptions, "options", N_("|FILE|read options from FILE")),
|
ARGPARSE_conffile (oOptions, "options", N_("|FILE|read options from FILE")),
|
||||||
|
|
||||||
ARGPARSE_s_s (oDebug, "debug", "@"),
|
ARGPARSE_s_s (oDebug, "debug", "@"),
|
||||||
@ -362,6 +364,9 @@ static int disable_check_own_socket;
|
|||||||
/* Flag indicating that we are in supervised mode. */
|
/* Flag indicating that we are in supervised mode. */
|
||||||
static int is_supervised;
|
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. */
|
/* Flag to inhibit socket removal in cleanup. */
|
||||||
static int inhibit_socket_removal;
|
static int inhibit_socket_removal;
|
||||||
|
|
||||||
@ -1211,6 +1216,7 @@ main (int argc, char **argv )
|
|||||||
case oSh: csh_style = 0; break;
|
case oSh: csh_style = 0; break;
|
||||||
case oServer: pipe_server = 1; break;
|
case oServer: pipe_server = 1; break;
|
||||||
case oDaemon: is_daemon = 1; break;
|
case oDaemon: is_daemon = 1; break;
|
||||||
|
case oStealSocket: steal_socket = 1; break;
|
||||||
case oSupervised: is_supervised = 1; break;
|
case oSupervised: is_supervised = 1; break;
|
||||||
|
|
||||||
case oDisplay: default_display = xstrdup (pargs.r.ret_str); break;
|
case oDisplay: default_display = xstrdup (pargs.r.ret_str); break;
|
||||||
@ -2226,14 +2232,20 @@ create_server_socket (char *name, int primary, int cygwin,
|
|||||||
server is not yet operational; this would lead to a hang. */
|
server is not yet operational; this would lead to a hang. */
|
||||||
if (primary && !check_for_running_agent (1))
|
if (primary && !check_for_running_agent (1))
|
||||||
{
|
{
|
||||||
log_set_prefix (NULL, GPGRT_LOG_WITH_PREFIX);
|
if (steal_socket)
|
||||||
log_set_file (NULL);
|
log_info (N_("trying to steal socket from running %s\n"),
|
||||||
log_error (_("a gpg-agent is already running - "
|
"gpg-agent");
|
||||||
"not starting a new one\n"));
|
else
|
||||||
*name = 0; /* Inhibit removal of the socket by cleanup(). */
|
{
|
||||||
assuan_sock_close (fd);
|
log_set_prefix (NULL, GPGRT_LOG_WITH_PREFIX);
|
||||||
xfree (unaddr);
|
log_set_file (NULL);
|
||||||
agent_exit (2);
|
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);
|
gnupg_remove (unaddr->sun_path);
|
||||||
rc = assuan_sock_bind (fd, addr, len);
|
rc = assuan_sock_bind (fd, addr, len);
|
||||||
|
@ -139,6 +139,7 @@ enum cmd_and_opt_values {
|
|||||||
oForce,
|
oForce,
|
||||||
oAllowOCSP,
|
oAllowOCSP,
|
||||||
oAllowVersionCheck,
|
oAllowVersionCheck,
|
||||||
|
oStealSocket,
|
||||||
oSocketName,
|
oSocketName,
|
||||||
oLDAPWrapperProgram,
|
oLDAPWrapperProgram,
|
||||||
oHTTPWrapperProgram,
|
oHTTPWrapperProgram,
|
||||||
@ -188,6 +189,7 @@ static ARGPARSE_OPTS opts[] = {
|
|||||||
ARGPARSE_s_s (oDebugLevel, "debug-level",
|
ARGPARSE_s_s (oDebugLevel, "debug-level",
|
||||||
N_("|LEVEL|set the debugging level to LEVEL")),
|
N_("|LEVEL|set the debugging level to LEVEL")),
|
||||||
ARGPARSE_s_n (oNoDetach, "no-detach", N_("do not detach from the console")),
|
ARGPARSE_s_n (oNoDetach, "no-detach", N_("do not detach from the console")),
|
||||||
|
ARGPARSE_s_n (oStealSocket, "steal-socket", "@"),
|
||||||
ARGPARSE_s_s (oLogFile, "log-file",
|
ARGPARSE_s_s (oLogFile, "log-file",
|
||||||
N_("|FILE|write server mode logs to FILE")),
|
N_("|FILE|write server mode logs to FILE")),
|
||||||
ARGPARSE_s_n (oBatch, "batch", N_("run without asking a user")),
|
ARGPARSE_s_n (oBatch, "batch", N_("run without asking a user")),
|
||||||
@ -329,6 +331,10 @@ static volatile int shutdown_pending;
|
|||||||
/* Flags to indicate that we shall not watch our own socket. */
|
/* Flags to indicate that we shall not watch our own socket. */
|
||||||
static int disable_check_own_socket;
|
static int disable_check_own_socket;
|
||||||
|
|
||||||
|
/* Flag indicating to start the daemon even if one already runs. */
|
||||||
|
static int steal_socket;
|
||||||
|
|
||||||
|
|
||||||
/* Flag to control the Tor mode. */
|
/* Flag to control the Tor mode. */
|
||||||
static enum
|
static enum
|
||||||
{ TOR_MODE_AUTO = 0, /* Switch to NO or YES */
|
{ TOR_MODE_AUTO = 0, /* Switch to NO or YES */
|
||||||
@ -1062,6 +1068,7 @@ main (int argc, char **argv)
|
|||||||
case oNoVerbose: opt.verbose = 0; break;
|
case oNoVerbose: opt.verbose = 0; break;
|
||||||
case oHomedir: /* Ignore this option here. */; break;
|
case oHomedir: /* Ignore this option here. */; break;
|
||||||
case oNoDetach: nodetach = 1; break;
|
case oNoDetach: nodetach = 1; break;
|
||||||
|
case oStealSocket: steal_socket = 1; break;
|
||||||
case oLogFile: logfile = pargs.r.ret_str; break;
|
case oLogFile: logfile = pargs.r.ret_str; break;
|
||||||
case oCsh: csh_style = 1; break;
|
case oCsh: csh_style = 1; break;
|
||||||
case oSh: csh_style = 0; break;
|
case oSh: csh_style = 0; break;
|
||||||
@ -1323,7 +1330,11 @@ main (int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
/* Fixme: We should test whether a dirmngr is already running. */
|
/* Fixme: We should actually test whether a dirmngr is
|
||||||
|
* already running. For now the steal option is a dummy. */
|
||||||
|
/* if (steal_socket) */
|
||||||
|
/* log_info (N_("trying to steal socket from running %s\n"), */
|
||||||
|
/* "dirmngr"); */
|
||||||
gnupg_remove (redir_socket_name? redir_socket_name : socket_name);
|
gnupg_remove (redir_socket_name? redir_socket_name : socket_name);
|
||||||
rc = assuan_sock_bind (fd, (struct sockaddr*) &serv_addr, len);
|
rc = assuan_sock_bind (fd, (struct sockaddr*) &serv_addr, len);
|
||||||
}
|
}
|
||||||
|
@ -316,6 +316,15 @@ Pinentry. As of now it is only useful when used along with
|
|||||||
Don't detach the process from the console. This is mainly useful for
|
Don't detach the process from the console. This is mainly useful for
|
||||||
debugging.
|
debugging.
|
||||||
|
|
||||||
|
@item --steal-socket
|
||||||
|
@opindex steal-socket
|
||||||
|
In @option{--daemon} mode, gpg-agent detects an already running
|
||||||
|
gpg-agent and does not allow to start a new instance. This option can
|
||||||
|
be used to override this check: the new gpg-agent process will try to
|
||||||
|
take over the communication sockets from the already running process
|
||||||
|
and start anyway. This option should in general not be used.
|
||||||
|
|
||||||
|
|
||||||
@item -s
|
@item -s
|
||||||
@itemx --sh
|
@itemx --sh
|
||||||
@itemx -c
|
@itemx -c
|
||||||
|
Loading…
x
Reference in New Issue
Block a user