summaryrefslogtreecommitdiffstats
path: root/agent
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2004-12-13 16:49:56 +0100
committerWerner Koch <wk@gnupg.org>2004-12-13 16:49:56 +0100
commit801ab885224b7d85aa11cb9f239f33cb420d3159 (patch)
tree692dfc401226c89d17e8dd3a84fb778fedb97207 /agent
parentAdded real code written by Timo Schulz. (diff)
downloadgnupg2-801ab885224b7d85aa11cb9f239f33cb420d3159.tar.xz
gnupg2-801ab885224b7d85aa11cb9f239f33cb420d3159.zip
VArious hacks to make it at least build under W32.
* stringhelp.c (w32_strerror) [W32]: New. * w32-pth.c, w32-pth.h: Added real code written by Timo Schulz. Not finished, though. * gpgconf-comp.c <ignore-ocsp-service-url>: Fixed typo.
Diffstat (limited to 'agent')
-rw-r--r--agent/call-scd.c6
-rw-r--r--agent/findkey.c6
-rw-r--r--agent/gpg-agent.c48
3 files changed, 50 insertions, 10 deletions
diff --git a/agent/call-scd.c b/agent/call-scd.c
index 2427d8ca3..575986dc9 100644
--- a/agent/call-scd.c
+++ b/agent/call-scd.c
@@ -34,7 +34,9 @@
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
+#ifndef HAVE_W32_SYSTEM
#include <sys/wait.h>
+#endif
#ifdef USE_GNU_PTH
# include <pth.h>
#endif
@@ -213,6 +215,7 @@ start_scd (ctrl_t ctrl)
/* We better do a sanity check now to see whether it has
accidently died. */
+#ifndef HAVE_W32_SYSTEM /* fixme */
pid = assuan_get_pid (scd_ctx);
if (pid != (pid_t)(-1) && pid
&& ((rc=waitpid (pid, NULL, WNOHANG))==-1 || (rc == pid)) )
@@ -221,6 +224,7 @@ start_scd (ctrl_t ctrl)
scd_ctx = NULL;
}
else
+#endif
return 0;
}
@@ -275,10 +279,12 @@ start_scd (ctrl_t ctrl)
simply as a pipe server. */
if (ctrl->connection_fd != -1)
{
+#ifndef HAVE_W32_SYSTEM
char buf[100];
sprintf (buf, "OPTION event-signal=%d", SIGUSR2);
assuan_transact (scd_ctx, buf, NULL, NULL, NULL, NULL, NULL, NULL);
+#endif
}
return 0;
diff --git a/agent/findkey.c b/agent/findkey.c
index 9866b54b9..b54528295 100644
--- a/agent/findkey.c
+++ b/agent/findkey.c
@@ -76,7 +76,11 @@ agent_write_private_key (const unsigned char *grip,
The mode parameter to open is what fopen uses. It will be
combined with the process' umask automatically. */
fd = open (fname, O_CREAT | O_EXCL | O_RDWR,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
+ S_IRUSR | S_IWUSR
+#ifndef HAVE_W32_SYSTEM
+ | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
+#endif
+ );
if (fd < 0)
fp = 0;
else
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 92af49b7a..6801839aa 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -29,9 +29,11 @@
#include <assert.h>
#include <time.h>
#include <fcntl.h>
-#include <sys/socket.h>
#include <sys/stat.h>
+#ifndef HAVE_W32_SYSTEM
+#include <sys/socket.h>
#include <sys/un.h>
+#endif
#include <unistd.h>
#include <signal.h>
#ifdef USE_GNU_PTH
@@ -40,11 +42,13 @@
#define JNLIB_NEED_LOG_LOGV
#include "agent.h"
-#include <assuan.h> /* malloc hooks */
+#include <assuan.h> /* Malloc hooks */
#include "i18n.h"
#include "sysutils.h"
-
+#ifdef HAVE_W32_SYSTEM
+#include "../jnlib/w32-afunix.h"
+#endif
enum cmd_and_opt_values
{ aNull = 0,
@@ -175,7 +179,9 @@ static void create_directories (void);
static void handle_connections (int listen_fd);
/* Pth wrapper function definitions. */
+#ifndef HAVE_W32_SYSTEM
GCRY_THREAD_OPTION_PTH_IMPL;
+#endif
#endif /*USE_GNU_PTH*/
static void check_for_running_agent (void);
@@ -432,14 +438,14 @@ main (int argc, char **argv )
/* Libgcrypt requires us to register the threading model first.
Note that this will also do the pth_init. */
-#ifdef USE_GNU_PTH
+#if defined(USE_GNU_PTH) && !defined(HAVE_W32_SYSTEM)
err = gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pth);
if (err)
{
log_fatal ("can't register GNU Pth with Libgcrypt: %s\n",
gpg_strerror (err));
}
-#endif /*USE_GNU_PTH*/
+#endif /*USE_GNU_PTH && !HAVE_W32_SYSTEM*/
/* Check that the libraries are suitable. Do it here because
the option parsing may need services of the library. */
@@ -707,10 +713,12 @@ main (int argc, char **argv )
}
/* Make sure that we have a default ttyname. */
+#ifndef HAVE_W32_SYSTEM
if (!default_ttyname && ttyname (1))
default_ttyname = xstrdup (ttyname (1));
if (!default_ttytype && getenv ("TERM"))
default_ttytype = xstrdup (getenv ("TERM"));
+#endif
if (pipe_server)
{ /* this is the simple pipe based server */
@@ -720,6 +728,7 @@ main (int argc, char **argv )
; /* NOTREACHED */
else
{ /* Regular server mode */
+#ifndef HAVE_W32_SYSTEM
int fd;
pid_t pid;
int len;
@@ -888,18 +897,21 @@ main (int argc, char **argv )
#ifdef USE_GNU_PTH
if (!disable_pth)
{
+#ifndef HAVE_W32_SYSTEM /* FIXME */
struct sigaction sa;
sa.sa_handler = SIG_IGN;
sigemptyset (&sa.sa_mask);
sa.sa_flags = 0;
sigaction (SIGPIPE, &sa, NULL);
+#endif
handle_connections (fd);
}
else
#endif /*!USE_GNU_PTH*/
/* setup signals */
{
+#ifndef HAVE_W32_SYSTEM /* FIXME */
struct sigaction oact, nact;
nact.sa_handler = cleanup_sh;
@@ -915,10 +927,11 @@ main (int argc, char **argv )
nact.sa_handler = SIG_IGN;
sigaction (SIGPIPE, &nact, NULL);
sigaction (SIGINT, &nact, NULL);
-
+#endif
start_command_handler (fd, -1);
}
close (fd);
+#endif
}
return 0;
@@ -1029,9 +1042,15 @@ create_private_keys_directory (const char *home)
fname = make_filename (home, GNUPG_PRIVATE_KEYS_DIR, NULL);
if (stat (fname, &statbuf) && errno == ENOENT)
{
+#ifdef HAVE_W32_SYSTEM /*FIXME: Setup proper permissions. */
+ if (!CreateDirectory (fname, NULL))
+ log_error (_("can't create directory `%s': %s\n"),
+ fname, w32_strerror (-1) );
+#else
if (mkdir (fname, S_IRUSR|S_IWUSR|S_IXUSR ))
log_error (_("can't create directory `%s': %s\n"),
- fname, strerror(errno) );
+ fname, strerror (errno) );
+#endif
else if (!opt.quiet)
log_info (_("directory `%s' created\n"), fname);
}
@@ -1063,9 +1082,15 @@ create_directories (void)
|| (*defhome != '~' && !strcmp (home, defhome) )
)
{
+#ifdef HAVE_W32_SYSTEM
+ if (!CreateDirectory (home, NULL))
+ log_error (_("can't create directory `%s': %s\n"),
+ home, w32_strerror (-1) );
+#else
if (mkdir (home, S_IRUSR|S_IWUSR|S_IXUSR ))
log_error (_("can't create directory `%s': %s\n"),
- home, strerror(errno) );
+ home, strerror (errno) );
+#endif
else
{
if (!opt.quiet)
@@ -1096,6 +1121,7 @@ handle_signal (int signo)
{
switch (signo)
{
+#ifndef HAVE_W32_SYSTEM
case SIGHUP:
log_info ("SIGHUP received - "
"re-reading configuration and flushing cache\n");
@@ -1134,7 +1160,7 @@ handle_signal (int signo)
cleanup ();
agent_exit (0);
break;
-
+#endif
default:
log_info ("signal %d received - no action defined\n", signo);
}
@@ -1178,6 +1204,7 @@ handle_connections (int listen_fd)
pth_attr_set (tattr, PTH_ATTR_STACK_SIZE, 256*1024);
pth_attr_set (tattr, PTH_ATTR_NAME, "gpg-agent");
+#ifndef HAVE_W32_SYSTEM /* fixme */
sigemptyset (&sigs );
sigaddset (&sigs, SIGHUP);
sigaddset (&sigs, SIGUSR1);
@@ -1185,6 +1212,9 @@ handle_connections (int listen_fd)
sigaddset (&sigs, SIGINT);
sigaddset (&sigs, SIGTERM);
ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
+#else
+ ev = NULL;
+#endif
for (;;)
{