mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
Fixed testing for an alive ssh standard socket.
This commit is contained in:
parent
033a2c0bc9
commit
5887cffd60
@ -1,3 +1,10 @@
|
|||||||
|
2007-12-03 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* gpg-agent.c (main): s/standard_socket/use_standard_socket/ for
|
||||||
|
clarity.
|
||||||
|
(create_server_socket): New arg IS_SSH to avoid testing with
|
||||||
|
assuan commands.
|
||||||
|
|
||||||
2007-11-20 Werner Koch <wk@g10code.com>
|
2007-11-20 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* gpg-agent.c (get_agent_scd_notify_event): New.
|
* gpg-agent.c (get_agent_scd_notify_event): New.
|
||||||
|
@ -244,6 +244,7 @@ static pid_t parent_pid = (pid_t)(-1);
|
|||||||
static char *create_socket_name (int use_standard_socket,
|
static char *create_socket_name (int use_standard_socket,
|
||||||
char *standard_name, char *template);
|
char *standard_name, char *template);
|
||||||
static gnupg_fd_t create_server_socket (int is_standard_name, char *name,
|
static gnupg_fd_t create_server_socket (int is_standard_name, char *name,
|
||||||
|
int is_ssh,
|
||||||
assuan_sock_nonce_t *nonce);
|
assuan_sock_nonce_t *nonce);
|
||||||
static void create_directories (void);
|
static void create_directories (void);
|
||||||
|
|
||||||
@ -486,7 +487,7 @@ main (int argc, char **argv )
|
|||||||
char *logfile = NULL;
|
char *logfile = NULL;
|
||||||
int debug_wait = 0;
|
int debug_wait = 0;
|
||||||
int gpgconf_list = 0;
|
int gpgconf_list = 0;
|
||||||
int standard_socket = 0;
|
int use_standard_socket = 0;
|
||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
const char *env_file_name = NULL;
|
const char *env_file_name = NULL;
|
||||||
|
|
||||||
@ -535,8 +536,8 @@ main (int argc, char **argv )
|
|||||||
/* Set default options. */
|
/* Set default options. */
|
||||||
parse_rereadable_options (NULL, 0); /* Reset them to default values. */
|
parse_rereadable_options (NULL, 0); /* Reset them to default values. */
|
||||||
#ifdef HAVE_W32_SYSTEM
|
#ifdef HAVE_W32_SYSTEM
|
||||||
standard_socket = 1; /* Under Windows we always use a standard
|
use_standard_socket = 1; /* Under Windows we always use a standard
|
||||||
socket. */
|
socket. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
shell = getenv ("SHELL");
|
shell = getenv ("SHELL");
|
||||||
@ -674,8 +675,8 @@ main (int argc, char **argv )
|
|||||||
case oXauthority: default_xauthority = xstrdup (pargs.r.ret_str);
|
case oXauthority: default_xauthority = xstrdup (pargs.r.ret_str);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case oUseStandardSocket: standard_socket = 1; break;
|
case oUseStandardSocket: use_standard_socket = 1; break;
|
||||||
case oNoUseStandardSocket: standard_socket = 0; break;
|
case oNoUseStandardSocket: use_standard_socket = 0; break;
|
||||||
|
|
||||||
case oFakedSystemTime:
|
case oFakedSystemTime:
|
||||||
{
|
{
|
||||||
@ -886,18 +887,18 @@ main (int argc, char **argv )
|
|||||||
|
|
||||||
|
|
||||||
/* Create the sockets. */
|
/* Create the sockets. */
|
||||||
socket_name = create_socket_name (standard_socket,
|
socket_name = create_socket_name (use_standard_socket,
|
||||||
"S.gpg-agent",
|
"S.gpg-agent",
|
||||||
"/tmp/gpg-XXXXXX/S.gpg-agent");
|
"/tmp/gpg-XXXXXX/S.gpg-agent");
|
||||||
if (opt.ssh_support)
|
if (opt.ssh_support)
|
||||||
socket_name_ssh = create_socket_name (standard_socket,
|
socket_name_ssh = create_socket_name (use_standard_socket,
|
||||||
"S.gpg-agent.ssh",
|
"S.gpg-agent.ssh",
|
||||||
"/tmp/gpg-XXXXXX/S.gpg-agent.ssh");
|
"/tmp/gpg-XXXXXX/S.gpg-agent.ssh");
|
||||||
|
|
||||||
fd = create_server_socket (standard_socket, socket_name,
|
fd = create_server_socket (use_standard_socket, socket_name, 0,
|
||||||
&socket_nonce);
|
&socket_nonce);
|
||||||
if (opt.ssh_support)
|
if (opt.ssh_support)
|
||||||
fd_ssh = create_server_socket (standard_socket, socket_name_ssh,
|
fd_ssh = create_server_socket (use_standard_socket, socket_name_ssh, 1,
|
||||||
&socket_nonce_ssh);
|
&socket_nonce_ssh);
|
||||||
else
|
else
|
||||||
fd_ssh = GNUPG_INVALID_FD;
|
fd_ssh = GNUPG_INVALID_FD;
|
||||||
@ -1317,10 +1318,12 @@ create_socket_name (int use_standard_socket,
|
|||||||
|
|
||||||
|
|
||||||
/* Create a Unix domain socket with NAME. IS_STANDARD_NAME indicates
|
/* Create a Unix domain socket with NAME. IS_STANDARD_NAME indicates
|
||||||
whether a non-random socket is used. Returns the file descriptor or
|
whether a non-random socket is used. Returns the file descriptor
|
||||||
terminates the process in case of an error. */
|
or terminates the process in case of an error. Not that this
|
||||||
|
function needs to be used for the regular socket first and only then
|
||||||
|
for the ssh socket. */
|
||||||
static gnupg_fd_t
|
static gnupg_fd_t
|
||||||
create_server_socket (int is_standard_name, char *name,
|
create_server_socket (int is_standard_name, char *name, int is_ssh,
|
||||||
assuan_sock_nonce_t *nonce)
|
assuan_sock_nonce_t *nonce)
|
||||||
{
|
{
|
||||||
struct sockaddr_un *serv_addr;
|
struct sockaddr_un *serv_addr;
|
||||||
@ -1350,7 +1353,15 @@ create_server_socket (int is_standard_name, char *name,
|
|||||||
rc = assuan_sock_bind (fd, (struct sockaddr*) serv_addr, len);
|
rc = assuan_sock_bind (fd, (struct sockaddr*) serv_addr, len);
|
||||||
if (is_standard_name && rc == -1 && errno == EADDRINUSE)
|
if (is_standard_name && rc == -1 && errno == EADDRINUSE)
|
||||||
{
|
{
|
||||||
if (!check_for_running_agent (1, 1))
|
/* Check whether a gpg-agent is already running on the standard
|
||||||
|
socket. We do this test only if this is not the ssh socket.
|
||||||
|
For ssh we assume that a test for gpg-agent has already been
|
||||||
|
done and reuse the requested ssh socket. Testing the
|
||||||
|
ssh-socket is not possible because at this point, though we
|
||||||
|
know the new Assuan socket, the Assuan server and thus the
|
||||||
|
ssh-agent server is not yet operational. This would lead to
|
||||||
|
a hang. */
|
||||||
|
if (!is_ssh && !check_for_running_agent (1, 1))
|
||||||
{
|
{
|
||||||
log_error (_("a gpg-agent is already running - "
|
log_error (_("a gpg-agent is already running - "
|
||||||
"not starting a new one\n"));
|
"not starting a new one\n"));
|
||||||
@ -1875,7 +1886,7 @@ handle_connections (gnupg_fd_t listen_fd, gnupg_fd_t listen_fd_ssh)
|
|||||||
|
|
||||||
|
|
||||||
/* Figure out whether an agent is available and running. Prints an
|
/* Figure out whether an agent is available and running. Prints an
|
||||||
error if not. If SILENT is true, no mesdsages are printed. Usually
|
error if not. If SILENT is true, no messages are printed. Usually
|
||||||
started with MODE 0. Returns 0 if the agent is running. */
|
started with MODE 0. Returns 0 if the agent is running. */
|
||||||
static int
|
static int
|
||||||
check_for_running_agent (int silent, int mode)
|
check_for_running_agent (int silent, int mode)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user