summaryrefslogtreecommitdiffstats
path: root/sm
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2004-12-20 17:17:25 +0100
committerWerner Koch <wk@gnupg.org>2004-12-20 17:17:25 +0100
commit581f5ddb1724f469dc7f934f5093179dfb1e05a9 (patch)
treed239f17e59f705f1b85c5cb5c2b9e1595e512e5f /sm
parent(do_pth_event_free): The events are hold in a ring (diff)
downloadgnupg2-581f5ddb1724f469dc7f934f5093179dfb1e05a9.tar.xz
gnupg2-581f5ddb1724f469dc7f934f5093179dfb1e05a9.zip
* configure.ac: Add PATHSEP_C and PATHSEP_S. For W32 let all
directories default to c:/gnupg. Require libassuan 0.6.9. * gpg-agent.c (main) [W32]: Now that Mutexes work we can remove the pth_init kludge. (main): Add new options --[no-]use-standard-socket. (check_for_running_agent): Check whether it is running on the standard socket. * sysutils.h [W32]: Define sleep. * util.h: Add prototype for mkdtemp. * call-agent.c (start_agent): Before starting a pipe server start to connect to a server on the standard socket. Use PATHSEP * call-dirmngr.c (start_dirmngr): Use PATHSEP. * import.c: Include unistd.h for dup and close.
Diffstat (limited to 'sm')
-rw-r--r--sm/ChangeLog8
-rw-r--r--sm/call-agent.c72
-rw-r--r--sm/call-dirmngr.c2
-rw-r--r--sm/import.c1
4 files changed, 52 insertions, 31 deletions
diff --git a/sm/ChangeLog b/sm/ChangeLog
index 167ec8753..19e7b0e8d 100644
--- a/sm/ChangeLog
+++ b/sm/ChangeLog
@@ -1,3 +1,11 @@
+2004-12-20 Werner Koch <wk@g10code.com>
+
+ * call-agent.c (start_agent): Before starting a pipe server start
+ to connect to a server on the standard socket. Use PATHSEP
+ * call-dirmngr.c (start_dirmngr): Use PATHSEP.
+
+ * import.c: Include unistd.h for dup and close.
+
2004-12-18 Werner Koch <wk@g10code.com>
* gpgsm.h (map_assuan_err): Define in terms of
diff --git a/sm/call-agent.c b/sm/call-agent.c
index 0d15a5595..0647acbb8 100644
--- a/sm/call-agent.c
+++ b/sm/call-agent.c
@@ -81,41 +81,53 @@ start_agent (ctrl_t ctrl)
{
const char *pgmname;
const char *argv[3];
+ char *sockname;
int no_close_list[3];
int i;
- if (opt.verbose)
- log_info (_("no running gpg-agent - starting one\n"));
-
- gpgsm_status (ctrl, STATUS_PROGRESS, "starting_agent ? 0 0");
+ /* First check whether we can connect at the standard
+ socket. */
+ sockname = make_filename (opt.homedir, "S.gpg-agent", NULL);
+ rc = assuan_socket_connect (&ctx, sockname, 0);
+ xfree (sockname);
- if (fflush (NULL))
+ if (rc)
{
- gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno));
- log_error ("error flushing pending output: %s\n", strerror (errno));
- return tmperr;
+ /* With no success start a new server. */
+ if (opt.verbose)
+ log_info (_("no running gpg-agent - starting one\n"));
+
+ gpgsm_status (ctrl, STATUS_PROGRESS, "starting_agent ? 0 0");
+
+ if (fflush (NULL))
+ {
+ gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno));
+ log_error ("error flushing pending output: %s\n",
+ strerror (errno));
+ return tmperr;
+ }
+
+ if (!opt.agent_program || !*opt.agent_program)
+ opt.agent_program = GNUPG_DEFAULT_AGENT;
+ if ( !(pgmname = strrchr (opt.agent_program, '/')))
+ pgmname = opt.agent_program;
+ else
+ pgmname++;
+
+ argv[0] = pgmname;
+ argv[1] = "--server";
+ argv[2] = NULL;
+
+ i=0;
+ if (log_get_fd () != -1)
+ no_close_list[i++] = log_get_fd ();
+ no_close_list[i++] = fileno (stderr);
+ no_close_list[i] = -1;
+
+ /* Connect to the agent and perform initial handshaking. */
+ rc = assuan_pipe_connect (&ctx, opt.agent_program, (char**)argv,
+ no_close_list);
}
-
- if (!opt.agent_program || !*opt.agent_program)
- opt.agent_program = GNUPG_DEFAULT_AGENT;
- if ( !(pgmname = strrchr (opt.agent_program, '/')))
- pgmname = opt.agent_program;
- else
- pgmname++;
-
- argv[0] = pgmname;
- argv[1] = "--server";
- argv[2] = NULL;
-
- i=0;
- if (log_get_fd () != -1)
- no_close_list[i++] = log_get_fd ();
- no_close_list[i++] = fileno (stderr);
- no_close_list[i] = -1;
-
- /* Connect to the agent and perform initial handshaking. */
- rc = assuan_pipe_connect (&ctx, opt.agent_program, (char**)argv,
- no_close_list);
}
else
{
@@ -123,7 +135,7 @@ start_agent (ctrl_t ctrl)
int pid;
infostr = xstrdup (infostr);
- if ( !(p = strchr (infostr, ':')) || p == infostr)
+ if ( !(p = strchr (infostr, PATHSEP_C)) || p == infostr)
{
log_error (_("malformed GPG_AGENT_INFO environment variable\n"));
xfree (infostr);
diff --git a/sm/call-dirmngr.c b/sm/call-dirmngr.c
index d00a53db5..9c4a5f22f 100644
--- a/sm/call-dirmngr.c
+++ b/sm/call-dirmngr.c
@@ -209,7 +209,7 @@ start_dirmngr (void)
infostr = xstrdup (infostr);
if (!try_default && *infostr)
{
- if ( !(p = strchr (infostr, ':')) || p == infostr)
+ if ( !(p = strchr (infostr, PATHSEP_C)) || p == infostr)
{
log_error (_("malformed DIRMNGR_INFO environment variable\n"));
xfree (infostr);
diff --git a/sm/import.c b/sm/import.c
index 457ef6423..6d00e91ea 100644
--- a/sm/import.c
+++ b/sm/import.c
@@ -25,6 +25,7 @@
#include <errno.h>
#include <time.h>
#include <assert.h>
+#include <unistd.h>
#include "gpgsm.h"
#include <gcrypt.h>