aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2004-12-13 15:49:56 +0000
committerWerner Koch <[email protected]>2004-12-13 15:49:56 +0000
commit801ab885224b7d85aa11cb9f239f33cb420d3159 (patch)
tree692dfc401226c89d17e8dd3a84fb778fedb97207
parentAdded real code written by Timo Schulz. (diff)
downloadgnupg-801ab885224b7d85aa11cb9f239f33cb420d3159.tar.gz
gnupg-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 '')
-rw-r--r--agent/call-scd.c6
-rw-r--r--agent/findkey.c6
-rw-r--r--agent/gpg-agent.c48
-rw-r--r--common/simple-pwquery.c2
-rw-r--r--jnlib/ChangeLog2
-rw-r--r--jnlib/stringhelp.c46
-rw-r--r--jnlib/stringhelp.h5
-rw-r--r--jnlib/w32-afunix.h1
-rw-r--r--jnlib/w32-pth.h8
-rw-r--r--sm/call-agent.c2
-rw-r--r--tools/ChangeLog4
-rw-r--r--tools/gpgconf-comp.c2
12 files changed, 110 insertions, 22 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 (;;)
{
diff --git a/common/simple-pwquery.c b/common/simple-pwquery.c
index fab6306fa..1e8eae63b 100644
--- a/common/simple-pwquery.c
+++ b/common/simple-pwquery.c
@@ -182,8 +182,10 @@ agent_send_all_options (int fd)
}
dft_ttyname = getenv ("GPG_TTY");
+#ifndef HAVE_W32_SYSTEM
if ((!dft_ttyname || !*dft_ttyname) && ttyname (0))
dft_ttyname = ttyname (0);
+#endif
if (dft_ttyname && *dft_ttyname)
{
if ((rc=agent_send_option (fd, "ttyname", dft_ttyname)))
diff --git a/jnlib/ChangeLog b/jnlib/ChangeLog
index b33b7842f..f27ef87b6 100644
--- a/jnlib/ChangeLog
+++ b/jnlib/ChangeLog
@@ -1,5 +1,7 @@
2004-12-13 Werner Koch <[email protected]>
+ * stringhelp.c (w32_strerror) [W32]: New.
+
* w32-pth.c, w32-pth.h: Added real code written by Timo Schulz.
Not finished, though.
diff --git a/jnlib/stringhelp.c b/jnlib/stringhelp.c
index 568152fdd..5a3b41528 100644
--- a/jnlib/stringhelp.c
+++ b/jnlib/stringhelp.c
@@ -1,5 +1,6 @@
/* stringhelp.c - standard string helper functions
- * Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2003,
+ * 2004 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -23,14 +24,17 @@
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
+#ifdef HAVE_W32_SYSTEM
+#include <windows.h>
+#endif
#include "libjnlib-config.h"
#include "utf8conv.h"
#include "stringhelp.h"
-/****************
- * look for the substring SUB in buffer and return a pointer to that
+/*
+ * Look for the substring SUB in buffer and return a pointer to that
* substring in BUF or NULL if not found.
* Comparison is case-insensitive.
*/
@@ -72,11 +76,12 @@ ascii_memistr( const char *buf, size_t buflen, const char *sub )
return NULL ;
}
-/****************
- * Wie strncpy(), aber es werden maximal n-1 zeichen kopiert und ein
- * '\0' angeh�ngt. Ist n = 0, so geschieht nichts, ist Destination
- * gleich NULL, so wird via jnlib_xmalloc Speicher besorgt, ist dann nicht
- * gen�gend Speicher vorhanden, so bricht die funktion ab.
+/* This function is similar to strncpy(). However it won't copy more
+ than N - 1 characters and makes sure that a '\0' is appended. With
+ N given as 0, nothing will happen. With DEST given as NULL, memory
+ will be allocated using jnlib_xmalloc (i.e. if it runs out of core
+ the function terminates). Returns DES or a pointer to the
+ allocated memory.
*/
char *
mem2str( char *dest , const void *src , size_t n )
@@ -452,8 +457,29 @@ sanitize_buffer (const unsigned char *p, size_t n, int delim)
return buffer;
}
+
/****************************************************
- ******** locale insensitive ctype functions ********
+ ********** W32 specific functions ****************
+ ****************************************************/
+
+#ifdef HAVE_W32_SYSTEM
+const char *
+w32_strerror (int ec)
+{
+ static char strerr[256];
+
+ if (ec == -1)
+ ec = (int)GetLastError ();
+ FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, ec,
+ MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
+ strerr, DIM (strerr)-1, NULL);
+ return strerr;
+}
+#endif /*HAVE_W32_SYSTEM*/
+
+
+/****************************************************
+ ******** Locale insensitive ctype functions ********
****************************************************/
/* FIXME: replace them by a table lookup and macros */
int
@@ -626,3 +652,5 @@ memicmp( const char *a, const char *b, size_t n )
return 0;
}
#endif
+
+
diff --git a/jnlib/stringhelp.h b/jnlib/stringhelp.h
index fe5786e59..412da3a0e 100644
--- a/jnlib/stringhelp.h
+++ b/jnlib/stringhelp.h
@@ -49,6 +49,11 @@ size_t print_sanitized_utf8_string (FILE *fp, const char *string, int delim);
char *sanitize_buffer (const unsigned char *p, size_t n, int delim);
+#ifdef HAVE_W32_SYSTEM
+const char *w32_strerror (int ec);
+#endif
+
+
const char *ascii_memistr( const char *buf, size_t buflen, const char *sub );
int ascii_isupper (int c);
int ascii_islower (int c);
diff --git a/jnlib/w32-afunix.h b/jnlib/w32-afunix.h
index 1319de5e6..367832299 100644
--- a/jnlib/w32-afunix.h
+++ b/jnlib/w32-afunix.h
@@ -23,6 +23,7 @@
#include <sys/types.h>
#include <windows.h>
+#include <ws2tcpip.h>
#include <unistd.h>
#define DIRSEP_C '\\'
diff --git a/jnlib/w32-pth.h b/jnlib/w32-pth.h
index efb17d255..bb010ae99 100644
--- a/jnlib/w32-pth.h
+++ b/jnlib/w32-pth.h
@@ -53,7 +53,7 @@ enum
/* Mutex values. */
#define PTH_MUTEX_INITIALIZED (1<<0)
#define PTH_MUTEX_LOCKED (1<<1)
-#define PTH_MUTEX_INIT {{NULL, NULL}, PTH_MUTEX_INITIALIZED, NULL, 0}
+#define PTH_MUTEX_INIT {PTH_MUTEX_INITIALIZED}
#define PTH_KEY_INIT (1<<0)
@@ -235,6 +235,12 @@ pth_event_t pth_event (unsigned long spec, ...);
+/* Backward compatibility (Pth < 1.5.0). */
+#define pth_event_occurred(ev) \
+ ( pth_event_status(ev) == PTH_STATUS_OCCURRED \
+ || pth_event_status(ev) == PTH_STATUS_FAILED )
+
+
/*-- pth_util.c --*/
/* void sigemptyset (struct sigset_s * ss); */
diff --git a/sm/call-agent.c b/sm/call-agent.c
index 2e8c75496..3ea1c4565 100644
--- a/sm/call-agent.c
+++ b/sm/call-agent.c
@@ -113,7 +113,7 @@ start_agent (ctrl_t ctrl)
no_close_list[i++] = fileno (stderr);
no_close_list[i] = -1;
- /* connect to the agent and perform initial handshaking */
+ /* Connect to the agent and perform initial handshaking. */
rc = assuan_pipe_connect (&ctx, opt.agent_program, (char**)argv,
no_close_list);
}
diff --git a/tools/ChangeLog b/tools/ChangeLog
index ac8d54a47..cb341ad4f 100644
--- a/tools/ChangeLog
+++ b/tools/ChangeLog
@@ -1,3 +1,7 @@
+2004-12-13 Werner Koch <[email protected]>
+
+ * gpgconf-comp.c <ignore-ocsp-service-url>: Fixed typo.
+
2004-11-24 Werner Koch <[email protected]>
* gpgconf-comp.c <dirmngr>: Add --ignore-http-dp, --ignore-ldap-dp
diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c
index 8873cdf13..5d78df86d 100644
--- a/tools/gpgconf-comp.c
+++ b/tools/gpgconf-comp.c
@@ -790,7 +790,7 @@ static gc_option_t gc_options_dirmngr[] =
{ "allow-ocsp", GC_OPT_FLAG_NONE, GC_LEVEL_BASIC,
"dirmngr", "allow sending OCSP requests",
GC_ARG_TYPE_NONE, GC_BACKEND_DIRMNGR },
- { "ignore-ocsp-servic-url", GC_OPT_FLAG_NONE, GC_LEVEL_ADVANCED,
+ { "ignore-ocsp-service-url", GC_OPT_FLAG_NONE, GC_LEVEL_ADVANCED,
"dirmngr", "ignore certificate contained OCSP service URLs",
GC_ARG_TYPE_NONE, GC_BACKEND_DIRMNGR },
{ "ocsp-responder", GC_OPT_FLAG_NONE, GC_LEVEL_ADVANCED,