diff options
author | Werner Koch <[email protected]> | 2016-10-04 14:57:55 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2016-10-04 15:11:43 +0000 |
commit | afcfae7959f39e7d85309b9496e1f1cf9acd5cc2 (patch) | |
tree | e684e9fbf88cdcf2a53b0c18dda504b09dfebfa5 | |
parent | agent: Adjust supervised mode for the new default socket names. (diff) | |
download | gnupg-afcfae7959f39e7d85309b9496e1f1cf9acd5cc2.tar.gz gnupg-afcfae7959f39e7d85309b9496e1f1cf9acd5cc2.zip |
agent: Adjust cleanup for supervised mode. Fix for W32.
* agent/gpg-agent.c (opts) [W32]: Remove option --supervised.
(is_supervised): Move from main() to global.
(inhibit_socket_removal): New.
(cleanup): Take care of supervise mode and INHIBIT_SOCKET_REMOVAL.
(check_own_socket_thread): Set INHIBIT_SOCKET_REMOVAL instead of
seting the socket names to empty.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to '')
-rw-r--r-- | agent/gpg-agent.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index 3e938f59c..0ebba1e13 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -153,7 +153,9 @@ static ARGPARSE_OPTS opts[] = { ARGPARSE_s_n (oDaemon, "daemon", N_("run in daemon mode (background)")), ARGPARSE_s_n (oServer, "server", N_("run in server mode (foreground)")), - ARGPARSE_s_n (oSupervised, "supervised", N_("run supervised (e.g., systemd)")), +#ifndef HAVE_W32_SYSTEM + ARGPARSE_s_n (oSupervised, "supervised", N_("run in supervised mode")), +#endif ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")), ARGPARSE_s_n (oQuiet, "quiet", N_("be somewhat more quiet")), ARGPARSE_s_n (oSh, "sh", N_("sh-style command output")), @@ -323,6 +325,12 @@ static int check_own_socket_running; /* Flags to indicate that check_own_socket shall not be called. */ static int disable_check_own_socket; +/* Flag indicating that we are in supervised mode. */ +static int is_supervised; + +/* Flag to inhibit socket removal in cleanup. */ +static int inhibit_socket_removal; + /* It is possible that we are currently running under setuid permissions */ static int maybe_setuid = 1; @@ -579,12 +587,15 @@ cleanup (void) return; done = 1; deinitialize_module_cache (); - remove_socket (socket_name, redir_socket_name); - if (opt.extra_socket > 1) - remove_socket (socket_name_extra, redir_socket_name_extra); - if (opt.browser_socket > 1) - remove_socket (socket_name_browser, redir_socket_name_browser); - remove_socket (socket_name_ssh, redir_socket_name_ssh); + if (!is_supervised && !inhibit_socket_removal) + { + remove_socket (socket_name, redir_socket_name); + if (opt.extra_socket > 1) + remove_socket (socket_name_extra, redir_socket_name_extra); + if (opt.browser_socket > 1) + remove_socket (socket_name_browser, redir_socket_name_browser); + remove_socket (socket_name_ssh, redir_socket_name_ssh); + } } @@ -934,7 +945,6 @@ main (int argc, char **argv ) int default_config =1; int pipe_server = 0; int is_daemon = 0; - int is_supervised = 0; int nodetach = 0; int csh_style = 0; char *logfile = NULL; @@ -3055,11 +3065,8 @@ check_own_socket_thread (void *arg) if (rc) { /* We may not remove the socket as it is now in use by another - server. Setting the name to empty does this. */ - if (socket_name) - *socket_name = 0; - if (socket_name_ssh) - *socket_name_ssh = 0; + server. */ + inhibit_socket_removal = 1; shutdown_pending = 2; log_info ("this process is useless - shutting down\n"); } |