mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
A whole bunch of changes to allow building for W32.
This commit is contained in:
parent
53ae21e745
commit
69967b0412
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2004-12-15 Werner Koch <wk@g10code.com>
|
||||
|
||||
* Makefile.am (SUBDIRS) [W32]: Do not build in tests/.
|
||||
|
||||
* acinclude.m4: Add proper macro name quoting for use with
|
||||
automake 1.9.
|
||||
|
||||
* configure.ac: Add replacement check for ttyname.
|
||||
Removed support for a included zlib.
|
||||
|
||||
2004-12-06 Werner Koch <wk@g10code.com>
|
||||
|
||||
* configure.ac (have_w32_system): New. Disable Pth checks for W32.
|
||||
|
@ -53,8 +53,14 @@ else
|
||||
scd =
|
||||
endif
|
||||
|
||||
if HAVE_W32_SYSTEM
|
||||
tests =
|
||||
else
|
||||
tests = tests
|
||||
endif
|
||||
|
||||
SUBDIRS = m4 intl jnlib common ${kbx} \
|
||||
${gpg} ${sm} ${agent} ${scd} tools po doc tests
|
||||
${gpg} ${sm} ${agent} ${scd} tools po doc ${tests}
|
||||
|
||||
dist-hook:
|
||||
@set -e; \
|
||||
|
22
acinclude.m4
22
acinclude.m4
@ -20,7 +20,7 @@ dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
|
||||
dnl Check whether a typedef exists and create a #define $2 if it exists
|
||||
dnl
|
||||
AC_DEFUN(GNUPG_CHECK_TYPEDEF,
|
||||
AC_DEFUN([GNUPG_CHECK_TYPEDEF],
|
||||
[ AC_MSG_CHECKING(for $1 typedef)
|
||||
AC_CACHE_VAL(gnupg_cv_typedef_$1,
|
||||
[AC_TRY_COMPILE([#define _GNU_SOURCE 1
|
||||
@ -38,7 +38,7 @@ AC_DEFUN(GNUPG_CHECK_TYPEDEF,
|
||||
|
||||
dnl GNUPG_CHECK_GNUMAKE
|
||||
dnl
|
||||
AC_DEFUN(GNUPG_CHECK_GNUMAKE,
|
||||
AC_DEFUN([GNUPG_CHECK_GNUMAKE],
|
||||
[
|
||||
if ${MAKE-make} --version 2>/dev/null | grep '^GNU ' >/dev/null 2>&1; then
|
||||
:
|
||||
@ -55,7 +55,7 @@ AC_DEFUN(GNUPG_CHECK_GNUMAKE,
|
||||
|
||||
dnl GNUPG_CHECK_FAQPROG
|
||||
dnl
|
||||
AC_DEFUN(GNUPG_CHECK_FAQPROG,
|
||||
AC_DEFUN([GNUPG_CHECK_FAQPROG],
|
||||
[ AC_MSG_CHECKING(for faqprog.pl)
|
||||
if faqprog.pl -V 2>/dev/null | grep '^faqprog.pl ' >/dev/null 2>&1; then
|
||||
working_faqprog=yes
|
||||
@ -82,7 +82,7 @@ dnl fi
|
||||
|
||||
dnl GNUPG_CHECK_DOCBOOK_TO_TEXI
|
||||
dnl
|
||||
AC_DEFUN(GNUPG_CHECK_DOCBOOK_TO_TEXI,
|
||||
AC_DEFUN([GNUPG_CHECK_DOCBOOK_TO_TEXI],
|
||||
[
|
||||
AC_CHECK_PROG(DOCBOOK_TO_TEXI, docbook2texi, yes, no)
|
||||
AC_MSG_CHECKING(for sgml to texi tools)
|
||||
@ -101,7 +101,7 @@ AC_DEFUN(GNUPG_CHECK_DOCBOOK_TO_TEXI,
|
||||
dnl GNUPG_CHECK_ENDIAN
|
||||
dnl define either LITTLE_ENDIAN_HOST or BIG_ENDIAN_HOST
|
||||
dnl
|
||||
define(GNUPG_CHECK_ENDIAN,
|
||||
AC_DEFUN([GNUPG_CHECK_ENDIAN],
|
||||
[
|
||||
tmp_assumed_endian=big
|
||||
if test "$cross_compiling" = yes; then
|
||||
@ -158,7 +158,7 @@ define(GNUPG_CHECK_ENDIAN,
|
||||
|
||||
|
||||
# Check for the getsockopt SO_PEERCRED
|
||||
AC_DEFUN(GNUPG_SYS_SO_PEERCRED,
|
||||
AC_DEFUN([GNUPG_SYS_SO_PEERCRED],
|
||||
[ AC_MSG_CHECKING(for SO_PEERCRED)
|
||||
AC_CACHE_VAL(gnupg_cv_sys_so_peercred,
|
||||
[AC_TRY_COMPILE([#include <sys/socket.h>],
|
||||
@ -183,7 +183,7 @@ AC_DEFUN(GNUPG_SYS_SO_PEERCRED,
|
||||
# either be "yes" or "no" and decided on the default value for
|
||||
# build_NAME and whether --enable-NAME or --disable-NAME is shown with
|
||||
# ./configure --help
|
||||
AC_DEFUN(GNUPG_BUILD_PROGRAM,
|
||||
AC_DEFUN([GNUPG_BUILD_PROGRAM],
|
||||
[build_$1=$2
|
||||
m4_if([$2],[yes],[
|
||||
AC_ARG_ENABLE([$1], AC_HELP_STRING([--disable-$1],
|
||||
@ -210,7 +210,7 @@ AC_DEFUN(GNUPG_BUILD_PROGRAM,
|
||||
# If the version is sufficient, HAVE_PTH will be set to yes.
|
||||
#
|
||||
# Taken form the m4 macros which come with Pth
|
||||
AC_DEFUN(GNUPG_PTH_VERSION_CHECK,
|
||||
AC_DEFUN([GNUPG_PTH_VERSION_CHECK],
|
||||
[
|
||||
_pth_version=`$PTH_CONFIG --version | awk 'NR==1 {print [$]3}'`
|
||||
_req_version="ifelse([$1],,1.2.0,$1)"
|
||||
@ -253,7 +253,7 @@ AC_DEFUN(GNUPG_PTH_VERSION_CHECK,
|
||||
# mlock is there a macro using memlk()
|
||||
dnl GNUPG_CHECK_MLOCK
|
||||
dnl
|
||||
define(GNUPG_CHECK_MLOCK,
|
||||
AC_DEFUN([GNUPG_CHECK_MLOCK],
|
||||
[ AC_CHECK_FUNCS(mlock)
|
||||
if test "$ac_cv_func_mlock" = "no"; then
|
||||
AC_CHECK_HEADERS(sys/mman.h)
|
||||
@ -343,7 +343,7 @@ define(GNUPG_CHECK_MLOCK,
|
||||
dnl Stolen from gcc
|
||||
dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
|
||||
dnl of the usual 2.
|
||||
AC_DEFUN(GNUPG_FUNC_MKDIR_TAKES_ONE_ARG,
|
||||
AC_DEFUN([GNUPG_FUNC_MKDIR_TAKES_ONE_ARG],
|
||||
[AC_CHECK_HEADERS(sys/stat.h unistd.h direct.h)
|
||||
AC_CACHE_CHECK([if mkdir takes one argument], gnupg_cv_mkdir_takes_one_arg,
|
||||
[AC_TRY_COMPILE([
|
||||
@ -371,7 +371,7 @@ dnl AM_PATH_OPENSC([MINIMUM-VERSION,
|
||||
dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
|
||||
dnl Test for OpenSC and define OPENSC_CFLAGS and OPENSC_LIBS
|
||||
dnl
|
||||
AC_DEFUN(AM_PATH_OPENSC,
|
||||
AC_DEFUN([AM_PATH_OPENSC],
|
||||
[ AC_ARG_WITH(opensc-prefix,
|
||||
AC_HELP_STRING([--with-opensc-prefix=PFX],
|
||||
[prefix where OpenSC is installed (optional)]),
|
||||
|
@ -1,3 +1,16 @@
|
||||
2004-12-15 Werner Koch <wk@g10code.com>
|
||||
|
||||
* gpg-agent.c [W32]: Various hacks to make it work.
|
||||
|
||||
* findkey.c (agent_write_private_key) [W32]: Adjust open call.
|
||||
|
||||
* call-scd.c (start_scd) [W32]: Don't check whether the daemon
|
||||
didn't died. To hard to do under Windows.
|
||||
(start_scd) [W32]: Disable sending of the event signal option.
|
||||
|
||||
* protect-tool.c (read_file, export_p12_file) [W32]: Use setmode
|
||||
to get stdout and stin into binary mode.
|
||||
|
||||
2004-12-05 Moritz Schulte <moritz@g10code.com>
|
||||
|
||||
* query.c (start_pinentry): Allow CTRL be NULL.
|
||||
|
@ -215,7 +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 */
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
pid = assuan_get_pid (scd_ctx);
|
||||
if (pid != (pid_t)(-1) && pid
|
||||
&& ((rc=waitpid (pid, NULL, WNOHANG))==-1 || (rc == pid)) )
|
||||
|
@ -33,7 +33,7 @@
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#endif
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#ifdef USE_GNU_PTH
|
||||
@ -438,17 +438,18 @@ main (int argc, char **argv )
|
||||
|
||||
/* Libgcrypt requires us to register the threading model first.
|
||||
Note that this will also do the pth_init. */
|
||||
#if defined(USE_GNU_PTH) && !defined(HAVE_W32_SYSTEM)
|
||||
#ifdef USE_GNU_PTH
|
||||
# ifdef HAVE_W32_SYSTEM
|
||||
pth_init ();
|
||||
# else /*!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 && !HAVE_W32_SYSTEM*/
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
pth_init ();
|
||||
#endif
|
||||
# endif/*!HAVE_W32_SYSTEM*/
|
||||
#endif /*USE_GNU_PTH*/
|
||||
|
||||
/* Check that the libraries are suitable. Do it here because
|
||||
the option parsing may need services of the library. */
|
||||
@ -716,12 +717,11 @@ 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 */
|
||||
|
@ -35,6 +35,9 @@
|
||||
#ifdef HAVE_LANGINFO_CODESET
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
#ifdef HAVE_DOSISH_SYSTEM
|
||||
#include <fcntl.h> /* for setmode() */
|
||||
#endif
|
||||
|
||||
#define JNLIB_NEED_LOG_LOGV
|
||||
#include "agent.h"
|
||||
@ -262,6 +265,9 @@ read_file (const char *fname, size_t *r_length)
|
||||
size_t nread, bufsize = 0;
|
||||
|
||||
fp = stdin;
|
||||
#ifdef HAVE_DOSISH_SYSTEM
|
||||
setmode ( fileno(fp) , O_BINARY );
|
||||
#endif
|
||||
buf = NULL;
|
||||
buflen = 0;
|
||||
#define NCHUNK 8192
|
||||
@ -975,6 +981,9 @@ export_p12_file (const char *fname)
|
||||
if (!key)
|
||||
return;
|
||||
|
||||
#ifdef HAVE_DOSISH_SYSTEM
|
||||
setmode ( fileno (stdout) , O_BINARY );
|
||||
#endif
|
||||
fwrite (key, keylen, 1, stdout);
|
||||
xfree (key);
|
||||
}
|
||||
@ -1056,12 +1065,12 @@ main (int argc, char **argv )
|
||||
gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
|
||||
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
opt_homedir = read_w32_registry_string ( NULL,
|
||||
"Software\\GNU\\GnuPG", "HomeDir" );
|
||||
#else
|
||||
#else /*!HAVE_W32_SYSTEM*/
|
||||
opt_homedir = getenv ("GNUPGHOME");
|
||||
#endif
|
||||
#endif /*!HAVE_W32_SYSTEM*/
|
||||
if (!opt_homedir || !*opt_homedir)
|
||||
opt_homedir = GNUPG_DEFAULT_HOMEDIR;
|
||||
|
||||
@ -1213,9 +1222,10 @@ get_passphrase (int promptno)
|
||||
if (!pw)
|
||||
{
|
||||
if (err)
|
||||
log_error ("error while asking for the passphrase\n");
|
||||
log_error (_("error while asking for the passphrase: %s\n"),
|
||||
gpg_strerror (err));
|
||||
else
|
||||
log_info ("cancelled\n");
|
||||
log_info (_("cancelled\n"));
|
||||
agent_exit (0);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,18 @@
|
||||
2004-12-15 Werner Koch <wk@g10code.com>
|
||||
|
||||
* sysutils.h [W32]: Prototypes for registry functions.
|
||||
* w32reg.c: Include sysutils.h
|
||||
|
||||
* simple-pwquery.c [W32]: Dummy code to allow a build.
|
||||
|
||||
* exechelp.c [W32]: Implemented for W32 .
|
||||
|
||||
* ttyname.c: New.
|
||||
|
||||
* asshelp.c (send_one_option): New.
|
||||
(send_pinentry_environment): Cleaned up and made sure that empty
|
||||
values are not send.
|
||||
|
||||
2004-12-07 Werner Koch <wk@g10code.com>
|
||||
|
||||
* asshelp.c (send_pinentry_environment) [W32]: Do not use ttyname.
|
||||
|
119
common/asshelp.c
119
common/asshelp.c
@ -32,8 +32,32 @@
|
||||
|
||||
#include "asshelp.h"
|
||||
|
||||
/* Send the assuan command pertaining to the pinenry environment. The
|
||||
OPT_* arguments are optional and may be used to overide the
|
||||
|
||||
static gpg_error_t
|
||||
send_one_option (assuan_context_t ctx, const char *name, const char *value)
|
||||
{
|
||||
gpg_error_t err;
|
||||
char *optstr;
|
||||
|
||||
if (!value || !*value)
|
||||
err = 0; /* Avoid sending empty strings. */
|
||||
else if (asprintf (&optstr, "OPTION %s=%s", name, value ) < 0)
|
||||
err = gpg_error_from_errno (errno);
|
||||
else
|
||||
{
|
||||
assuan_error_t ae;
|
||||
|
||||
ae = assuan_transact (ctx, optstr, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
err = ae? map_assuan_err (ae) : 0;
|
||||
free (optstr);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/* Send the assuan commands pertaining to the pinenry environment. The
|
||||
OPT_* arguments are optional and may be used to override the
|
||||
defaults taken from the current locale. */
|
||||
gpg_error_t
|
||||
send_pinentry_environment (assuan_context_t ctx,
|
||||
@ -43,62 +67,49 @@ send_pinentry_environment (assuan_context_t ctx,
|
||||
const char *opt_lc_ctype,
|
||||
const char *opt_lc_messages)
|
||||
{
|
||||
int rc = 0;
|
||||
gpg_error_t err = 0;
|
||||
char *dft_display = NULL;
|
||||
char *dft_ttyname = NULL;
|
||||
char *dft_ttytype = NULL;
|
||||
char *old_lc = NULL;
|
||||
char *dft_lc = NULL;
|
||||
|
||||
/* Send the DISPLAY variable. */
|
||||
dft_display = getenv ("DISPLAY");
|
||||
if (opt_display || dft_display)
|
||||
{
|
||||
char *optstr;
|
||||
if (asprintf (&optstr, "OPTION display=%s",
|
||||
opt_display ? opt_display : dft_display) < 0)
|
||||
return gpg_error_from_errno (errno);
|
||||
rc = assuan_transact (ctx, optstr, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL);
|
||||
free (optstr);
|
||||
if (rc)
|
||||
return map_assuan_err (rc);
|
||||
err = send_one_option (ctx, "display",
|
||||
opt_display ? opt_display : dft_display);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Send the name of the TTY. */
|
||||
if (!opt_ttyname)
|
||||
{
|
||||
dft_ttyname = getenv ("GPG_TTY");
|
||||
#ifdef HAVE_DOSISH_SYSTEM
|
||||
if (!dft_ttyname || !*dft_ttyname )
|
||||
dft_ttyname = "/dev/tty"; /* Use a fake. */
|
||||
#else
|
||||
if ((!dft_ttyname || !*dft_ttyname) && ttyname (0))
|
||||
dft_ttyname = ttyname (0);
|
||||
#endif
|
||||
}
|
||||
if (opt_ttyname || dft_ttyname)
|
||||
{
|
||||
char *optstr;
|
||||
if (asprintf (&optstr, "OPTION ttyname=%s",
|
||||
opt_ttyname ? opt_ttyname : dft_ttyname) < 0)
|
||||
return gpg_error_from_errno (errno);
|
||||
rc = assuan_transact (ctx, optstr, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL);
|
||||
free (optstr);
|
||||
if (rc)
|
||||
return map_assuan_err (rc);
|
||||
err = send_one_option (ctx, "ttyname",
|
||||
opt_ttyname ? opt_ttyname : dft_ttyname);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Send the type of the TTY. */
|
||||
dft_ttytype = getenv ("TERM");
|
||||
if (opt_ttytype || (dft_ttyname && dft_ttytype))
|
||||
{
|
||||
char *optstr;
|
||||
if (asprintf (&optstr, "OPTION ttytype=%s",
|
||||
opt_ttyname ? opt_ttytype : dft_ttytype) < 0)
|
||||
return gpg_error_from_errno (errno);
|
||||
rc = assuan_transact (ctx, optstr, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL);
|
||||
free (optstr);
|
||||
if (rc)
|
||||
return map_assuan_err (rc);
|
||||
err = send_one_option (ctx, "ttytype",
|
||||
opt_ttyname ? opt_ttytype : dft_ttytype);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Send the value for LC_CTYPE. */
|
||||
#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE)
|
||||
old_lc = setlocale (LC_CTYPE, NULL);
|
||||
if (old_lc)
|
||||
@ -111,18 +122,8 @@ send_pinentry_environment (assuan_context_t ctx,
|
||||
#endif
|
||||
if (opt_lc_ctype || (dft_ttyname && dft_lc))
|
||||
{
|
||||
char *optstr;
|
||||
if (asprintf (&optstr, "OPTION lc-ctype=%s",
|
||||
opt_lc_ctype ? opt_lc_ctype : dft_lc) < 0)
|
||||
rc = gpg_error_from_errno (errno);
|
||||
else
|
||||
{
|
||||
rc = assuan_transact (ctx, optstr, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL);
|
||||
free (optstr);
|
||||
if (rc)
|
||||
rc = map_assuan_err (rc);
|
||||
}
|
||||
err = send_one_option (ctx, "lc-ctype",
|
||||
opt_lc_ctype ? opt_lc_ctype : dft_lc);
|
||||
}
|
||||
#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE)
|
||||
if (old_lc)
|
||||
@ -131,8 +132,10 @@ send_pinentry_environment (assuan_context_t ctx,
|
||||
free (old_lc);
|
||||
}
|
||||
#endif
|
||||
if (rc)
|
||||
return rc;
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* Send the value for LC_MESSAGES. */
|
||||
#if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES)
|
||||
old_lc = setlocale (LC_MESSAGES, NULL);
|
||||
if (old_lc)
|
||||
@ -145,18 +148,8 @@ send_pinentry_environment (assuan_context_t ctx,
|
||||
#endif
|
||||
if (opt_lc_messages || (dft_ttyname && dft_lc))
|
||||
{
|
||||
char *optstr;
|
||||
if (asprintf (&optstr, "OPTION lc-messages=%s",
|
||||
opt_lc_messages ? opt_lc_messages : dft_lc) < 0)
|
||||
rc = gpg_error_from_errno (errno);
|
||||
else
|
||||
{
|
||||
rc = assuan_transact (ctx, optstr, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL);
|
||||
free (optstr);
|
||||
if (rc)
|
||||
rc = map_assuan_err (rc);
|
||||
}
|
||||
err = send_one_option (ctx, "display",
|
||||
opt_lc_messages ? opt_lc_messages : dft_lc);
|
||||
}
|
||||
#if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES)
|
||||
if (old_lc)
|
||||
@ -165,7 +158,9 @@ send_pinentry_environment (assuan_context_t ctx,
|
||||
free (old_lc);
|
||||
}
|
||||
#endif
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,7 @@
|
||||
#ifdef USE_GNU_PTH
|
||||
#include <pth.h>
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#else
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
@ -39,6 +38,9 @@
|
||||
#include "i18n.h"
|
||||
#include "exechelp.h"
|
||||
|
||||
/* Define to 1 do enable debugging. */
|
||||
#define DEBUG_W32_SPAWN 1
|
||||
|
||||
|
||||
#ifdef _POSIX_OPEN_MAX
|
||||
#define MAX_OPEN_FDS _POSIX_OPEN_MAX
|
||||
@ -57,6 +59,105 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
/* We assume that a HANDLE can be represented by an int which should
|
||||
be true for all i386 systems (HANDLE is defined as void *) and
|
||||
these are the only systems for which Windows is available. Further
|
||||
we assume that -1 denotes an invalid handle. */
|
||||
# define fd_to_handle(a) ((HANDLE)(a))
|
||||
# define handle_to_fd(a) ((int)(a))
|
||||
# define pid_to_handle(a) ((HANDLE)(a))
|
||||
# define handle_to_pid(a) ((int)(a))
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
/* Build a command line for use with W32's CreateProcess. On success
|
||||
CMDLINE gets the address of a newly allocated string. */
|
||||
static gpg_error_t
|
||||
build_w32_commandline (const char *pgmname, const char **argv, char **cmdline)
|
||||
{
|
||||
int i, n;
|
||||
const char *s;
|
||||
char *buf, *p;
|
||||
|
||||
*cmdline = NULL;
|
||||
n = strlen (pgmname);
|
||||
for (i=0; (s=argv[i]); i++)
|
||||
{
|
||||
n += strlen (s) + 1 + 2; /* (1 space, 2 quoting */
|
||||
for (; *s; s++)
|
||||
if (*s == '\"')
|
||||
n++; /* Need to double inner quotes. */
|
||||
}
|
||||
n++;
|
||||
|
||||
buf = p = xtrymalloc (n);
|
||||
if (!buf)
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
/* fixme: PGMNAME may not contain spaces etc. */
|
||||
p = stpcpy (p, pgmname);
|
||||
for (i=0; argv[i]; i++)
|
||||
{
|
||||
if (!*argv[i]) /* Empty string. */
|
||||
p = stpcpy (p, " \"\"");
|
||||
else if (strpbrk (argv[i], " \t\n\v\f\""))
|
||||
{
|
||||
p = stpcpy (p, " \"");
|
||||
for (s=argv[i]; *s; s++)
|
||||
{
|
||||
*p++ = *s;
|
||||
if (*s == '\"')
|
||||
*p++ = *s;
|
||||
}
|
||||
*p++ = '\"';
|
||||
*p = 0;
|
||||
}
|
||||
else
|
||||
p = stpcpy (stpcpy (p, " "), argv[i]);
|
||||
}
|
||||
|
||||
*cmdline= buf;
|
||||
return 0;
|
||||
}
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
/* Create pipe where the write end is inheritable. */
|
||||
static int
|
||||
create_inheritable_pipe (int filedes[2])
|
||||
{
|
||||
HANDLE r, w, h;
|
||||
SECURITY_ATTRIBUTES sec_attr;
|
||||
|
||||
memset (&sec_attr, 0, sizeof sec_attr );
|
||||
sec_attr.nLength = sizeof sec_attr;
|
||||
sec_attr.bInheritHandle = FALSE;
|
||||
|
||||
if (!CreatePipe (&r, &w, &sec_attr, 0))
|
||||
return -1;
|
||||
|
||||
if (!DuplicateHandle (GetCurrentProcess(), w,
|
||||
GetCurrentProcess(), &h, 0,
|
||||
TRUE, DUPLICATE_SAME_ACCESS ))
|
||||
{
|
||||
log_error ("DuplicateHandle failed: %s\n", w32_strerror (-1));
|
||||
CloseHandle (r);
|
||||
CloseHandle (w);
|
||||
return -1;
|
||||
}
|
||||
CloseHandle (w);
|
||||
w = h;
|
||||
|
||||
filedes[0] = handle_to_fd (r);
|
||||
filedes[1] = handle_to_fd (w);
|
||||
return 0;
|
||||
}
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
|
||||
|
||||
|
||||
/* Fork and exec the PGMNAME, connect the file descriptor of INFILE to
|
||||
stdin, write the output to OUTFILE, return a new stream in
|
||||
@ -73,10 +174,121 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
|
||||
void (*preexec)(void),
|
||||
FILE **statusfile, pid_t *pid)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
gpg_error_t err;
|
||||
SECURITY_ATTRIBUTES sec_attr;
|
||||
PROCESS_INFORMATION pi =
|
||||
{
|
||||
NULL, /* Returns process handle. */
|
||||
0, /* Returns primary thread handle. */
|
||||
0, /* Returns pid. */
|
||||
0 /* Returns tid. */
|
||||
};
|
||||
STARTUPINFO si;
|
||||
int cr_flags;
|
||||
char *cmdline;
|
||||
int fd, fdout, rp[2];
|
||||
|
||||
#else /* !_WIN32 */
|
||||
/* Setup return values. */
|
||||
*statusfile = NULL;
|
||||
*pid = (pid_t)(-1);
|
||||
fflush (infile);
|
||||
rewind (infile);
|
||||
fd = _get_osfhandle (fileno (infile));
|
||||
fdout = _get_osfhandle (fileno (outfile));
|
||||
if (fd == -1 || fdout == -1)
|
||||
log_fatal ("no file descriptor for file passed to gnupg_spawn_process\n");
|
||||
|
||||
/* Prepare security attributes. */
|
||||
memset (&sec_attr, 0, sizeof sec_attr );
|
||||
sec_attr.nLength = sizeof sec_attr;
|
||||
sec_attr.bInheritHandle = FALSE;
|
||||
|
||||
/* Build the command line. */
|
||||
err = build_w32_commandline (pgmname, argv, &cmdline);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* Create a pipe. */
|
||||
if (create_inheritable_pipe (rp))
|
||||
{
|
||||
err = gpg_error (GPG_ERR_GENERAL);
|
||||
log_error (_("error creating a pipe: %s\n"), gpg_strerror (err));
|
||||
xfree (cmdline);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Start the process. Note that we can't run the PREEXEC function
|
||||
because this would change our own environment. */
|
||||
memset (&si, 0, sizeof si);
|
||||
si.cb = sizeof (si);
|
||||
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
|
||||
si.wShowWindow = DEBUG_W32_SPAWN? SW_SHOW : SW_MINIMIZE;
|
||||
si.hStdInput = fd_to_handle (fd);
|
||||
si.hStdOutput = fd_to_handle (fdout);
|
||||
si.hStdError = fd_to_handle (rp[1]);
|
||||
|
||||
cr_flags = (CREATE_DEFAULT_ERROR_MODE
|
||||
| GetPriorityClass (GetCurrentProcess ())
|
||||
| CREATE_SUSPENDED);
|
||||
log_debug ("CreateProcess, path=`%s' cmdline=`%s'", pgmname, cmdline);
|
||||
if (!CreateProcess (pgmname, /* Program to start. */
|
||||
cmdline, /* Command line arguments. */
|
||||
&sec_attr, /* Process security attributes. */
|
||||
&sec_attr, /* Thread security attributes. */
|
||||
TRUE, /* Inherit handles. */
|
||||
cr_flags, /* Creation flags. */
|
||||
NULL, /* Environment. */
|
||||
NULL, /* Use current drive/directory. */
|
||||
&si, /* Startup information. */
|
||||
&pi /* Returns process information. */
|
||||
))
|
||||
{
|
||||
log_error ("CreateProcess failed: %s\n", w32_strerror (-1));
|
||||
xfree (cmdline);
|
||||
CloseHandle (fd_to_handle (rp[0]));
|
||||
CloseHandle (fd_to_handle (rp[1]));
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
xfree (cmdline);
|
||||
cmdline = NULL;
|
||||
|
||||
/* Close the other end of the pipe. */
|
||||
CloseHandle (fd_to_handle (rp[1]));
|
||||
|
||||
log_debug ("CreateProcess ready: hProcess=%p hThread=%p"
|
||||
" dwProcessID=%d dwThreadId=%d\n",
|
||||
pi.hProcess, pi.hThread,
|
||||
(int) pi.dwProcessId, (int) pi.dwThreadId);
|
||||
|
||||
/* Process ha been created suspended; resume it now. */
|
||||
ResumeThread (pi.hThread);
|
||||
CloseHandle (pi.hThread);
|
||||
|
||||
{
|
||||
int x;
|
||||
|
||||
x = _open_osfhandle (rp[0], 0);
|
||||
if (x == -1)
|
||||
log_error ("failed to translate osfhandle %p\n", (void*)rp[0] );
|
||||
else
|
||||
{
|
||||
log_debug ("_open_osfhandle %p yields %d\n", (void*)fd, x );
|
||||
*statusfile = fdopen (x, "r");
|
||||
}
|
||||
}
|
||||
if (!*statusfile)
|
||||
{
|
||||
err = gpg_error_from_errno (errno);
|
||||
log_error (_("can't fdopen pipe for reading: %s\n"), gpg_strerror (err));
|
||||
CloseHandle (pi.hProcess);
|
||||
return err;
|
||||
}
|
||||
|
||||
*pid = handle_to_pid (pi.hProcess);
|
||||
return 0;
|
||||
|
||||
#else /* !HAVE_W32_SYSTEM */
|
||||
gpg_error_t err;
|
||||
int fd, fdout, rp[2];
|
||||
|
||||
@ -87,8 +299,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
|
||||
fd = fileno (infile);
|
||||
fdout = fileno (outfile);
|
||||
if (fd == -1 || fdout == -1)
|
||||
log_fatal ("no file descriptor for file passed"
|
||||
" to gnupg_spawn_process: %s\n", strerror (errno) );
|
||||
log_fatal ("no file descriptor for file passed to gnupg_spawn_process\n");
|
||||
|
||||
if (pipe (rp) == -1)
|
||||
{
|
||||
@ -170,7 +381,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif /* !_WIN32 */
|
||||
#endif /* !HAVE_W32_SYSTEM */
|
||||
}
|
||||
|
||||
|
||||
@ -183,10 +394,51 @@ gnupg_wait_process (const char *pgmname, pid_t pid)
|
||||
{
|
||||
gpg_err_code_t ec;
|
||||
|
||||
#ifdef _WIN32
|
||||
ec = GPG_ERR_NOT_IMPLEMENTED;
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
HANDLE proc = fd_to_handle (pid);
|
||||
int code;
|
||||
DWORD exc;
|
||||
|
||||
#else /* !_WIN32 */
|
||||
if (pid == (pid_t)(-1))
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
/* FIXME: We should do a pth_waitpid here. However this has not yet
|
||||
been implemented. A special W32 pth system call would even be
|
||||
better. */
|
||||
code = WaitForSingleObject (proc, INFINITE);
|
||||
switch (code)
|
||||
{
|
||||
case WAIT_FAILED:
|
||||
log_error (_("waiting for process %d to terminate failed: %s\n"),
|
||||
(int)pid, w32_strerror (-1));
|
||||
ec = GPG_ERR_GENERAL;
|
||||
break;
|
||||
|
||||
case WAIT_OBJECT_0:
|
||||
if (!GetExitCodeProcess (proc, &exc))
|
||||
{
|
||||
log_error (_("error getting exit code of process %d: %s\n"),
|
||||
(int)pid, w32_strerror (-1) );
|
||||
ec = GPG_ERR_GENERAL;
|
||||
}
|
||||
else if (exc)
|
||||
{
|
||||
log_error (_("error running `%s': exit status %d\n"),
|
||||
pgmname, (int)exc );
|
||||
ec = GPG_ERR_GENERAL;
|
||||
}
|
||||
else
|
||||
ec = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
log_error ("WaitForSingleObject returned unexpected "
|
||||
"code %d for pid %d\n", code, (int)pid );
|
||||
ec = GPG_ERR_GENERAL;
|
||||
break;
|
||||
}
|
||||
|
||||
#else /* !HAVE_W32_SYSTEM */
|
||||
int i, status;
|
||||
|
||||
if (pid == (pid_t)(-1))
|
||||
@ -222,7 +474,7 @@ gnupg_wait_process (const char *pgmname, pid_t pid)
|
||||
}
|
||||
else
|
||||
ec = 0;
|
||||
#endif /* !_WIN32 */
|
||||
#endif /* !HAVE_W32_SYSTEM */
|
||||
|
||||
return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, ec);
|
||||
|
||||
|
@ -1096,7 +1096,7 @@ iobuf_cancel (iobuf_t a)
|
||||
if (s && *s)
|
||||
{
|
||||
#if defined(HAVE_DOSISH_SYSTEM) || defined(__riscos__)
|
||||
remove_name = m_strdup (s);
|
||||
remove_name = xstrdup (s);
|
||||
#else
|
||||
remove (s);
|
||||
#endif
|
||||
@ -1267,7 +1267,7 @@ iobuf_sockopen (int fd, const char *mode)
|
||||
size_t len;
|
||||
|
||||
a = iobuf_alloc (strchr (mode, 'w') ? 2 : 1, 8192);
|
||||
scx = m_alloc (sizeof *scx + 25);
|
||||
scx = xmalloc (sizeof *scx + 25);
|
||||
scx->sock = fd;
|
||||
scx->print_only_name = 1;
|
||||
sprintf (scx->fname, "[sock %d]", fd);
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#ifdef _WIN32
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
@ -182,10 +182,8 @@ 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)))
|
||||
@ -261,7 +259,7 @@ agent_send_all_options (int fd)
|
||||
static int
|
||||
agent_open (int *rfd)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
return SPWQ_NO_AGENT; /* FIXME */
|
||||
#else
|
||||
int rc;
|
||||
|
@ -27,5 +27,12 @@ int enable_core_dumps (void);
|
||||
const unsigned char *get_session_marker (size_t *rlen);
|
||||
int check_permissions (const char *path,int extension,int checkonly);
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
/*-- w32reg.c --*/
|
||||
char *read_w32_registry_string( const char *root,
|
||||
const char *dir, const char *name );
|
||||
int write_w32_registry_string(const char *root, const char *dir,
|
||||
const char *name, const char *value);
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
|
||||
#endif /*GNUPG_COMMON_SYSUTILS_H*/
|
||||
|
32
common/ttyname.c
Normal file
32
common/ttyname.c
Normal file
@ -0,0 +1,32 @@
|
||||
/* ttyname.c - Replacement for ttyname.
|
||||
* Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
* GnuPG is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GnuPG is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
/* This one is a simple dummy and suitable for Dosish systems. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
char *
|
||||
ttyname (int fd)
|
||||
{
|
||||
return NULL;
|
||||
}
|
@ -147,7 +147,9 @@ int asprintf (char **result, const char *format, ...) JNLIB_GCC_A_PRINTF(2,3);
|
||||
#ifndef HAVE_STRSEP
|
||||
char *strsep (char **stringp, const char *delim);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_TTYNAME
|
||||
char *ttyname (int fd);
|
||||
#endif
|
||||
|
||||
/*-- some macros to replace ctype ones and avoid locale problems --*/
|
||||
#define spacep(p) (*(p) == ' ' || *(p) == '\t')
|
||||
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#if defined (_WIN32) || defined (__CYGWIN32__)
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
/* This module is only used in this environment */
|
||||
|
||||
#include <stdio.h>
|
||||
@ -29,6 +29,7 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "sysutils.h"
|
||||
|
||||
static HKEY
|
||||
get_root_key(const char *root)
|
||||
@ -169,4 +170,4 @@ write_w32_registry_string(const char *root, const char *dir,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* __MINGW32__ || __CYGWIN32__ */
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
|
30
configure.ac
30
configure.ac
@ -218,12 +218,6 @@ if test "$use_exec" = yes ; then
|
||||
AC_MSG_RESULT($enableval)
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([whether the included zlib is requested])
|
||||
AC_ARG_WITH(included-zlib,
|
||||
[ --with-included-zlib use the zlib code included here],
|
||||
[g10_force_zlib=yes], [g10_force_zlib=no] )
|
||||
AC_MSG_RESULT($g10_force_zlib)
|
||||
|
||||
dnl
|
||||
dnl Check whether we want to use Linux capabilities
|
||||
dnl
|
||||
@ -799,6 +793,7 @@ AC_REPLACE_FUNCS(fseeko ftello)
|
||||
AC_REPLACE_FUNCS(isascii)
|
||||
AC_REPLACE_FUNCS(putc_unlocked)
|
||||
AC_REPLACE_FUNCS(strsep)
|
||||
AC_REPLACE_FUNCS(ttyname)
|
||||
|
||||
|
||||
|
||||
@ -923,14 +918,10 @@ fi
|
||||
|
||||
dnl Do we have zlib? Must do it here because Solaris failed
|
||||
dnl when compiling a conftest (due to the "-lz" from LIBS).
|
||||
use_local_zlib=yes
|
||||
if test "$g10_force_zlib" = "yes"; then
|
||||
:
|
||||
else
|
||||
_cppflags="${CPPFLAGS}"
|
||||
_ldflags="${LDFLAGS}"
|
||||
_cppflags="${CPPFLAGS}"
|
||||
_ldflags="${LDFLAGS}"
|
||||
|
||||
AC_ARG_WITH(zlib,
|
||||
AC_ARG_WITH(zlib,
|
||||
[ --with-zlib=DIR use libz in DIR],[
|
||||
if test -d "$withval"; then
|
||||
CPPFLAGS="${CPPFLAGS} -I$withval/include"
|
||||
@ -938,23 +929,12 @@ else
|
||||
fi
|
||||
])
|
||||
|
||||
AC_CHECK_HEADER(zlib.h,
|
||||
AC_CHECK_HEADER(zlib.h,
|
||||
AC_CHECK_LIB(z, deflateInit2_,
|
||||
use_local_zlib=no
|
||||
LIBS="$LIBS -lz",
|
||||
CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}),
|
||||
CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags})
|
||||
fi
|
||||
|
||||
if test "$use_local_zlib" = yes ; then
|
||||
AM_CONDITIONAL(ENABLE_LOCAL_ZLIB, true)
|
||||
AC_CONFIG_LINKS(zlib.h:zlib/zlib.h zconf.h:zlib/zconf.h )
|
||||
ZLIBS="../zlib/libzlib.a"
|
||||
else
|
||||
AM_CONDITIONAL(ENABLE_LOCAL_ZLIB, false)
|
||||
ZLIBS=
|
||||
fi
|
||||
AC_SUBST(ZLIBS)
|
||||
|
||||
|
||||
# See wether we want to run the long test suite.
|
||||
|
@ -171,6 +171,8 @@ start_agent (void)
|
||||
if (rc)
|
||||
return map_assuan_err (rc);
|
||||
|
||||
#warning put this code into common/asshelp.c
|
||||
|
||||
dft_display = getenv ("DISPLAY");
|
||||
if (opt.display || dft_display)
|
||||
{
|
||||
|
@ -1,3 +1,7 @@
|
||||
2004-12-15 Werner Koch <wk@g10code.com>
|
||||
|
||||
* logging.c [W32]: Don't include unavailable headers.
|
||||
|
||||
2004-12-14 Werner Koch <wk@g10code.com>
|
||||
|
||||
* w32-pth.c (_pth_strerror): Renamed to ...
|
||||
|
@ -35,16 +35,13 @@
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef _WIN32
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#endif
|
||||
#endif /*!HAVE_W32_SYSTEM*/
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#ifdef __MINGW32__
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define JNLIB_NEED_LOG_LOGV 1
|
||||
|
@ -14,7 +14,7 @@ dnl AM_PATH_KSBA([MINIMUM-VERSION,
|
||||
dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
|
||||
dnl Test for libksba and define KSBA_CFLAGS and KSBA_LIBS
|
||||
dnl
|
||||
AC_DEFUN(AM_PATH_KSBA,
|
||||
AC_DEFUN([AM_PATH_KSBA],
|
||||
[ AC_ARG_WITH(ksba-prefix,
|
||||
AC_HELP_STRING([--with-ksba-prefix=PFX],
|
||||
[prefix where KSBA is installed (optional)]),
|
||||
|
@ -1,3 +1,14 @@
|
||||
2004-12-15 Werner Koch <wk@g10code.com>
|
||||
|
||||
* scdaemon.c [W32]: Various hacks to make it run under W32.
|
||||
|
||||
* command.c (scd_update_reader_status_file) [W32]: Don't use kill.
|
||||
|
||||
* apdu.c [W32]: Disable use of pcsc_wrapper.
|
||||
|
||||
* Makefile.am (scdaemon_LDADD): Reorder libs.
|
||||
(sc_copykeys_LDADD): Add libassuan because it is needed for W32.
|
||||
|
||||
2004-12-06 Werner Koch <wk@g10code.com>
|
||||
|
||||
* Makefile.am (pkglib_PROGRAMS): Build only for W32.
|
||||
|
@ -19,7 +19,7 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
bin_PROGRAMS = scdaemon sc-copykeys
|
||||
if HAVE_W32_SYSTEM
|
||||
if ! HAVE_W32_SYSTEM
|
||||
pkglib_PROGRAMS = pcsc-wrapper
|
||||
endif
|
||||
|
||||
@ -53,10 +53,8 @@ scdaemon_SOURCES = \
|
||||
|
||||
|
||||
scdaemon_LDADD = ../jnlib/libjnlib.a ../common/libcommon.a \
|
||||
$(LIBGCRYPT_LIBS) $(pth_libs) \
|
||||
$(KSBA_LIBS) $(LIBASSUAN_LIBS) \
|
||||
$(LIBUSB_LIBS) $(OPENSC_LIBS) -lgpg-error @LIBINTL@ \
|
||||
@DL_LIBS@
|
||||
$(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(pth_libs) $(LIBASSUAN_LIBS) \
|
||||
$(LIBUSB_LIBS) $(OPENSC_LIBS) -lgpg-error $(LIBINTL) $(DL_LIBS)
|
||||
|
||||
sc_copykeys_SOURCES = \
|
||||
sc-copykeys.c scdaemon.h \
|
||||
@ -70,10 +68,10 @@ sc_copykeys_SOURCES = \
|
||||
sc_copykeys_LDADD = \
|
||||
../jnlib/libjnlib.a ../common/libcommon.a \
|
||||
../common/libsimple-pwquery.a \
|
||||
$(LIBGCRYPT_LIBS) $(pth_libs) \
|
||||
$(KSBA_LIBS) $(LIBUSB_LIBS) $(OPENSC_LIBS) \
|
||||
$(LIBGCRYPT_LIBS) $(pth_libs) $(KSBA_LIBS) $(LIBASSUAN_LIBS) \
|
||||
$(LIBUSB_LIBS) $(OPENSC_LIBS) \
|
||||
-lgpg-error @LIBINTL@ @DL_LIBS@
|
||||
|
||||
pcsc_wrapper_SOURCES = pcsc-wrapper.c
|
||||
pcsc_wrapper_LDADD = @DL_LIBS@
|
||||
pcsc_wrapper_LDADD = $(DL_LIBS)
|
||||
pcsc_wrapper_CFLAGS =
|
||||
|
@ -65,9 +65,14 @@
|
||||
#include "dynload.h"
|
||||
#include "ccid-driver.h"
|
||||
|
||||
|
||||
/* To to conflicting use of threading libraries we usually can't link
|
||||
against libpcsclite. Instead we use a wrapper program. */
|
||||
#ifdef USE_GNU_PTH
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
#define NEED_PCSC_WRAPPER 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_READER 4 /* Number of readers we support concurrently. */
|
||||
|
@ -1260,8 +1260,13 @@ scd_update_reader_status_file (void)
|
||||
int signo = primary_connection->server_local->event_signal;
|
||||
|
||||
log_info ("client pid is %d, sending signal %d\n", pid, signo);
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
#warning Need to implement a notification service
|
||||
#else
|
||||
if (pid != (pid_t)(-1) && pid && signo > 0)
|
||||
kill (pid, signo);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,8 +29,10 @@
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#ifdef USE_GNU_PTH
|
||||
@ -47,6 +49,9 @@
|
||||
#include "i18n.h"
|
||||
#include "sysutils.h"
|
||||
#include "app-common.h"
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
#include "../jnlib/w32-afunix.h"
|
||||
#endif
|
||||
|
||||
|
||||
enum cmd_and_opt_values
|
||||
@ -131,7 +136,12 @@ static ARGPARSE_OPTS opts[] = {
|
||||
};
|
||||
|
||||
|
||||
/* The card dirver we use by default for PC/SC. */
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
#define DEFAULT_PCSC_DRIVER "winscard.dll"
|
||||
#else
|
||||
#define DEFAULT_PCSC_DRIVER "libpcsclite.so"
|
||||
#endif
|
||||
|
||||
|
||||
static volatile int caught_fatal_sig = 0;
|
||||
@ -148,8 +158,10 @@ static char socket_name[128];
|
||||
|
||||
#ifndef HAVE_OPENSC
|
||||
#ifdef USE_GNU_PTH
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
/* Pth wrapper function definitions. */
|
||||
GCRY_THREAD_OPTION_PTH_IMPL;
|
||||
#endif
|
||||
|
||||
static void *ticker_thread (void *arg);
|
||||
#endif /*USE_GNU_PTH*/
|
||||
@ -341,12 +353,16 @@ main (int argc, char **argv )
|
||||
Note that this will also do the pth_init. */
|
||||
#ifndef HAVE_OPENSC
|
||||
#ifdef USE_GNU_PTH
|
||||
# ifdef HAVE_W32_SYSTEM
|
||||
pth_init ();
|
||||
# else /*!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 /*!HAVE_W32_SYSTEM*/
|
||||
#endif /*USE_GNU_PTH*/
|
||||
#endif /*!HAVE_OPENSC*/
|
||||
|
||||
@ -649,12 +665,15 @@ main (int argc, char **argv )
|
||||
if (!p)
|
||||
BUG ();
|
||||
*p = 0;;
|
||||
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
if (!mkdtemp(socket_name))
|
||||
{
|
||||
log_error ("can't create directory `%s': %s\n",
|
||||
socket_name, strerror(errno) );
|
||||
exit (1);
|
||||
}
|
||||
#endif
|
||||
*p = '/';
|
||||
|
||||
if (strchr (socket_name, ':') )
|
||||
@ -669,7 +688,11 @@ main (int argc, char **argv )
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
fd = _w32_sock_new (AF_UNIX, SOCK_STREAM, 0);
|
||||
#else
|
||||
fd = socket (AF_UNIX, SOCK_STREAM, 0);
|
||||
#endif
|
||||
if (fd == -1)
|
||||
{
|
||||
log_error ("can't create socket: %s\n", strerror(errno) );
|
||||
@ -682,7 +705,13 @@ main (int argc, char **argv )
|
||||
len = (offsetof (struct sockaddr_un, sun_path)
|
||||
+ strlen(serv_addr.sun_path) + 1);
|
||||
|
||||
if (bind (fd, (struct sockaddr*)&serv_addr, len) == -1)
|
||||
if (
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
_w32_sock_bind
|
||||
#else
|
||||
bind
|
||||
#endif
|
||||
(fd, (struct sockaddr*)&serv_addr, len) == -1)
|
||||
{
|
||||
log_error ("error binding socket to `%s': %s\n",
|
||||
serv_addr.sun_path, strerror (errno) );
|
||||
@ -702,6 +731,7 @@ main (int argc, char **argv )
|
||||
|
||||
|
||||
fflush (NULL);
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
pid = fork ();
|
||||
if (pid == (pid_t)-1)
|
||||
{
|
||||
@ -800,6 +830,8 @@ main (int argc, char **argv )
|
||||
exit (1);
|
||||
}
|
||||
|
||||
#endif /*!HAVE_W32_SYSTEM*/
|
||||
|
||||
scd_command_handler (fd);
|
||||
|
||||
close (fd);
|
||||
@ -846,6 +878,7 @@ handle_signal (int signo)
|
||||
{
|
||||
switch (signo)
|
||||
{
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
case SIGHUP:
|
||||
log_info ("SIGHUP received - "
|
||||
"re-reading configuration and resetting cards\n");
|
||||
@ -882,6 +915,7 @@ handle_signal (int signo)
|
||||
cleanup ();
|
||||
scd_exit (0);
|
||||
break;
|
||||
#endif /*!HAVE_W32_SYSTEM*/
|
||||
|
||||
default:
|
||||
log_info ("signal %d received - no action defined\n", signo);
|
||||
@ -901,6 +935,7 @@ ticker_thread (void *dummy_arg)
|
||||
sigset_t sigs;
|
||||
int signo;
|
||||
|
||||
#ifndef HAVE_W32_SYSTEM /* fixme */
|
||||
sigemptyset (&sigs );
|
||||
sigaddset (&sigs, SIGHUP);
|
||||
sigaddset (&sigs, SIGUSR1);
|
||||
@ -908,6 +943,9 @@ ticker_thread (void *dummy_arg)
|
||||
sigaddset (&sigs, SIGINT);
|
||||
sigaddset (&sigs, SIGTERM);
|
||||
sigs_ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
|
||||
#else
|
||||
sigs_ev = NULL;
|
||||
#endif
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
10
sm/ChangeLog
10
sm/ChangeLog
@ -1,3 +1,13 @@
|
||||
2004-12-15 Werner Koch <wk@g10code.com>
|
||||
|
||||
* misc.c (setup_pinentry_env) [W32]: Don't use it.
|
||||
|
||||
* gpgsm.c (main) [W32]: Init Pth because we need it for the socket
|
||||
operations and to resolve libassuan symbols.
|
||||
(run_protect_tool) [W32]: Disable it.
|
||||
|
||||
* Makefile.am (gpgsm_LDADD): Move LIBASSUAN_LIBS more to the end.
|
||||
|
||||
2004-12-07 Werner Koch <wk@g10code.com>
|
||||
|
||||
* Makefile.am (gpgsm_LDADD): Put libassuan before jnlib because
|
||||
|
@ -51,9 +51,9 @@ gpgsm_SOURCES = \
|
||||
certreqgen.c
|
||||
|
||||
|
||||
gpgsm_LDADD = $(LIBASSUAN_LIBS) ../jnlib/libjnlib.a ../kbx/libkeybox.a \
|
||||
../common/libcommon.a \
|
||||
$(LIBGCRYPT_LIBS) $(KSBA_LIBS) -lgpg-error \
|
||||
$(LIBINTL)
|
||||
gpgsm_LDADD = ../jnlib/libjnlib.a ../kbx/libkeybox.a \
|
||||
../common/libcommon.a \
|
||||
$(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(LIBASSUAN_LIBS) -lgpg-error \
|
||||
$(LIBINTL)
|
||||
|
||||
|
||||
|
15
sm/gpgsm.c
15
sm/gpgsm.c
@ -26,6 +26,9 @@
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef USE_GNU_PTH
|
||||
# include <pth.h>
|
||||
#endif
|
||||
|
||||
#include "gpgsm.h"
|
||||
#include <gcrypt.h>
|
||||
@ -736,6 +739,11 @@ main ( int argc, char **argv)
|
||||
NEED_KSBA_VERSION, ksba_check_version (NULL) );
|
||||
}
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
pth_init ();
|
||||
#endif
|
||||
|
||||
|
||||
gcry_control (GCRYCTL_USE_SECURE_RNDPOOL);
|
||||
|
||||
may_coredump = disable_core_dumps ();
|
||||
@ -746,7 +754,8 @@ main ( int argc, char **argv)
|
||||
i18n_init();
|
||||
|
||||
opt.def_cipher_algoid = "1.2.840.113549.3.7"; /*des-EDE3-CBC*/
|
||||
#ifdef __MINGW32__
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
opt.homedir = read_w32_registry_string ( NULL,
|
||||
"Software\\GNU\\GnuPG", "HomeDir" );
|
||||
#else
|
||||
@ -1688,7 +1697,7 @@ open_fwrite (const char *filename)
|
||||
static void
|
||||
run_protect_tool (int argc, char **argv)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
const char *pgm;
|
||||
char **av;
|
||||
int i;
|
||||
@ -1707,6 +1716,6 @@ run_protect_tool (int argc, char **argv)
|
||||
av[i] = NULL;
|
||||
execv (pgm, av);
|
||||
log_error ("error executing `%s': %s\n", pgm, strerror (errno));
|
||||
#endif
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
gpgsm_exit (2);
|
||||
}
|
||||
|
@ -1,3 +1,13 @@
|
||||
2004-12-15 Werner Koch <wk@g10code.com>
|
||||
|
||||
* Makefile.am (bin_PROGRAMS) [W32]: Do not build watchgnupg.
|
||||
|
||||
* gpgconf-comp.c (gpg_agent_runtime_change) [W32]: No way yet to
|
||||
send a signal. Disable.
|
||||
(change_options_file, change_options_program) [W32]: No link(2),
|
||||
so we disable it.
|
||||
(gc_component_change_options): Use rename instead of link.
|
||||
|
||||
2004-12-13 Werner Koch <wk@g10code.com>
|
||||
|
||||
* gpgconf-comp.c <ignore-ocsp-service-url>: Fixed typo.
|
||||
|
@ -32,7 +32,10 @@ sbin_SCRIPTS = addgnupghome
|
||||
|
||||
bin_SCRIPTS = gpgsm-gencert.sh
|
||||
|
||||
bin_PROGRAMS = gpgconf watchgnupg
|
||||
bin_PROGRAMS = gpgconf
|
||||
if !HAVE_W32_SYSTEM
|
||||
bin_PROGRAMS += watchgnupg
|
||||
endif
|
||||
|
||||
gpgconf_SOURCES = gpgconf.c gpgconf.h gpgconf-comp.c no-libgcrypt.c
|
||||
|
||||
|
@ -861,6 +861,7 @@ static struct
|
||||
void
|
||||
gpg_agent_runtime_change (void)
|
||||
{
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
char *agent = getenv ("GPG_AGENT_INFO");
|
||||
char *pid_str;
|
||||
unsigned long pid_long;
|
||||
@ -888,6 +889,7 @@ gpg_agent_runtime_change (void)
|
||||
|
||||
/* Ignore any errors here. */
|
||||
kill (pid, SIGHUP);
|
||||
#endif /*!HAVE_W32_SYSTEM*/
|
||||
}
|
||||
|
||||
|
||||
@ -1741,7 +1743,12 @@ change_options_file (gc_component_t component, gc_backend_t backend,
|
||||
arg = NULL;
|
||||
}
|
||||
|
||||
#if HAVE_W32_SYSTEM
|
||||
res = 0;
|
||||
#warning no backups for W32 yet - need to write a copy function
|
||||
#else
|
||||
res = link (dest_filename, orig_filename);
|
||||
#endif
|
||||
if (res < 0 && errno != ENOENT)
|
||||
return -1;
|
||||
if (res < 0)
|
||||
@ -2005,7 +2012,12 @@ change_options_program (gc_component_t component, gc_backend_t backend,
|
||||
src_filename = xasprintf ("%s.gpgconf.%i.new", dest_filename, getpid ());
|
||||
orig_filename = xasprintf ("%s.gpgconf.%i.bak", dest_filename, getpid ());
|
||||
|
||||
#if HAVE_W32_SYSTEM
|
||||
res = 0;
|
||||
#warning no backups for W32 yet - need to write a copy function
|
||||
#else
|
||||
res = link (dest_filename, orig_filename);
|
||||
#endif
|
||||
if (res < 0 && errno != ENOENT)
|
||||
return -1;
|
||||
if (res < 0)
|
||||
@ -2418,12 +2430,18 @@ gc_component_change_options (int component, FILE *in)
|
||||
err = rename (src_pathname[i], dest_pathname[i]);
|
||||
else
|
||||
{
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
/* FIXME: Won't work becuase W32 doesn't silently
|
||||
overwrite. */
|
||||
err = rename (src_pathname[i], dest_pathname[i]);
|
||||
#else /*!HAVE_W32_SYSTEM*/
|
||||
/* This is a bit safer than rename() because we
|
||||
expect DEST_PATHNAME not to be there. If it
|
||||
happens to be there, this will fail. */
|
||||
err = link (src_pathname[i], dest_pathname[i]);
|
||||
if (!err)
|
||||
unlink (src_pathname[i]);
|
||||
#endif /*!HAVE_W32_SYSTEM*/
|
||||
}
|
||||
if (err)
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user