GNUPG-1-9-BRANCH gnupg (12 files)
cvs user wk
cvs at cvs.gnupg.org
Mon Dec 13 16:45:46 CET 2004
Date: Monday, December 13, 2004 @ 16:49:56
Author: wk
Path: /cvs/gnupg/gnupg
Tag: GNUPG-1-9-BRANCH
Modified: agent/call-scd.c agent/findkey.c agent/gpg-agent.c
common/simple-pwquery.c jnlib/ChangeLog jnlib/stringhelp.c
jnlib/stringhelp.h jnlib/w32-afunix.h jnlib/w32-pth.h
sm/call-agent.c tools/ChangeLog tools/gpgconf-comp.c
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.
-------------------------+
agent/call-scd.c | 6 +++++
agent/findkey.c | 6 ++++-
agent/gpg-agent.c | 48 +++++++++++++++++++++++++++++++++++++---------
common/simple-pwquery.c | 2 +
jnlib/ChangeLog | 2 +
jnlib/stringhelp.c | 46 +++++++++++++++++++++++++++++++++++---------
jnlib/stringhelp.h | 5 ++++
jnlib/w32-afunix.h | 1
jnlib/w32-pth.h | 8 ++++++-
sm/call-agent.c | 2 -
tools/ChangeLog | 4 +++
tools/gpgconf-comp.c | 2 -
12 files changed, 110 insertions(+), 22 deletions(-)
Index: gnupg/agent/call-scd.c
diff -u gnupg/agent/call-scd.c:1.13.2.4 gnupg/agent/call-scd.c:1.13.2.5
--- gnupg/agent/call-scd.c:1.13.2.4 Mon Apr 26 20:26:41 2004
+++ gnupg/agent/call-scd.c Mon Dec 13 16:49:56 2004
@@ -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 @@
/* 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 @@
scd_ctx = NULL;
}
else
+#endif
return 0;
}
@@ -275,10 +279,12 @@
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;
Index: gnupg/agent/findkey.c
diff -u gnupg/agent/findkey.c:1.17.2.4 gnupg/agent/findkey.c:1.17.2.5
--- gnupg/agent/findkey.c:1.17.2.4 Sat Feb 21 14:05:22 2004
+++ gnupg/agent/findkey.c Mon Dec 13 16:49:56 2004
@@ -76,7 +76,11 @@
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
Index: gnupg/agent/gpg-agent.c
diff -u gnupg/agent/gpg-agent.c:1.31.2.20 gnupg/agent/gpg-agent.c:1.31.2.21
--- gnupg/agent/gpg-agent.c:1.31.2.20 Thu Dec 2 08:48:09 2004
+++ gnupg/agent/gpg-agent.c Mon Dec 13 16:49:56 2004
@@ -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 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 @@
/* 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 @@
}
/* 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 @@
; /* NOTREACHED */
else
{ /* Regular server mode */
+#ifndef HAVE_W32_SYSTEM
int fd;
pid_t pid;
int len;
@@ -888,18 +897,21 @@
#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 @@
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 @@
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 @@
|| (*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 @@
{
switch (signo)
{
+#ifndef HAVE_W32_SYSTEM
case SIGHUP:
log_info ("SIGHUP received - "
"re-reading configuration and flushing cache\n");
@@ -1134,7 +1160,7 @@
cleanup ();
agent_exit (0);
break;
-
+#endif
default:
log_info ("signal %d received - no action defined\n", signo);
}
@@ -1178,6 +1204,7 @@
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 @@
sigaddset (&sigs, SIGINT);
sigaddset (&sigs, SIGTERM);
ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
+#else
+ ev = NULL;
+#endif
for (;;)
{
Index: gnupg/common/simple-pwquery.c
diff -u gnupg/common/simple-pwquery.c:1.1.2.5 gnupg/common/simple-pwquery.c:1.1.2.6
--- gnupg/common/simple-pwquery.c:1.1.2.5 Thu Dec 2 08:48:09 2004
+++ gnupg/common/simple-pwquery.c Mon Dec 13 16:49:56 2004
@@ -182,8 +182,10 @@
}
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)))
Index: gnupg/jnlib/ChangeLog
diff -u gnupg/jnlib/ChangeLog:1.3.2.21 gnupg/jnlib/ChangeLog:1.3.2.22
--- gnupg/jnlib/ChangeLog:1.3.2.21 Mon Dec 13 10:05:31 2004
+++ gnupg/jnlib/ChangeLog Mon Dec 13 16:49:56 2004
@@ -1,5 +1,7 @@
2004-12-13 Werner Koch <wk at g10code.com>
+ * stringhelp.c (w32_strerror) [W32]: New.
+
* w32-pth.c, w32-pth.h: Added real code written by Timo Schulz.
Not finished, though.
Index: gnupg/jnlib/stringhelp.c
diff -u gnupg/jnlib/stringhelp.c:1.2.2.4 gnupg/jnlib/stringhelp.c:1.2.2.5
--- gnupg/jnlib/stringhelp.c:1.2.2.4 Wed Aug 18 15:21:56 2004
+++ gnupg/jnlib/stringhelp.c Mon Dec 13 16:49:56 2004
@@ -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 @@
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 @@
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 @@
return 0;
}
#endif
+
+
Index: gnupg/jnlib/stringhelp.h
diff -u gnupg/jnlib/stringhelp.h:1.2.2.2 gnupg/jnlib/stringhelp.h:1.2.2.3
--- gnupg/jnlib/stringhelp.h:1.2.2.2 Wed Jun 18 21:56:10 2003
+++ gnupg/jnlib/stringhelp.h Mon Dec 13 16:49:56 2004
@@ -49,6 +49,11 @@
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);
Index: gnupg/jnlib/w32-afunix.h
diff -u gnupg/jnlib/w32-afunix.h:1.1.2.1 gnupg/jnlib/w32-afunix.h:1.1.2.2
--- gnupg/jnlib/w32-afunix.h:1.1.2.1 Tue Nov 30 10:48:37 2004
+++ gnupg/jnlib/w32-afunix.h Mon Dec 13 16:49:56 2004
@@ -23,6 +23,7 @@
#include <sys/types.h>
#include <windows.h>
+#include <ws2tcpip.h>
#include <unistd.h>
#define DIRSEP_C '\\'
Index: gnupg/jnlib/w32-pth.h
diff -u gnupg/jnlib/w32-pth.h:1.1.2.3 gnupg/jnlib/w32-pth.h:1.1.2.4
--- gnupg/jnlib/w32-pth.h:1.1.2.3 Mon Dec 13 10:05:31 2004
+++ gnupg/jnlib/w32-pth.h Mon Dec 13 16:49:56 2004
@@ -53,7 +53,7 @@
/* 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 @@
+/* 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); */
Index: gnupg/sm/call-agent.c
diff -u gnupg/sm/call-agent.c:1.35.2.7 gnupg/sm/call-agent.c:1.35.2.8
--- gnupg/sm/call-agent.c:1.35.2.7 Mon Apr 26 15:28:08 2004
+++ gnupg/sm/call-agent.c Mon Dec 13 16:49:56 2004
@@ -113,7 +113,7 @@
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);
}
Index: gnupg/tools/ChangeLog
diff -u gnupg/tools/ChangeLog:1.25.2.58 gnupg/tools/ChangeLog:1.25.2.59
--- gnupg/tools/ChangeLog:1.25.2.58 Wed Nov 24 15:50:20 2004
+++ gnupg/tools/ChangeLog Mon Dec 13 16:49:56 2004
@@ -1,3 +1,7 @@
+2004-12-13 Werner Koch <wk at g10code.com>
+
+ * gpgconf-comp.c <ignore-ocsp-service-url>: Fixed typo.
+
2004-11-24 Werner Koch <wk at g10code.com>
* gpgconf-comp.c <dirmngr>: Add --ignore-http-dp, --ignore-ldap-dp
Index: gnupg/tools/gpgconf-comp.c
diff -u gnupg/tools/gpgconf-comp.c:1.1.2.46 gnupg/tools/gpgconf-comp.c:1.1.2.47
--- gnupg/tools/gpgconf-comp.c:1.1.2.46 Wed Nov 24 15:50:20 2004
+++ gnupg/tools/gpgconf-comp.c Mon Dec 13 16:49:56 2004
@@ -790,7 +790,7 @@
{ "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,
More information about the Gnupg-commits
mailing list