[svn] dirmngr - r261 - in trunk: . doc src
svn author wk
cvs at cvs.gnupg.org
Mon Aug 13 15:33:20 CEST 2007
Author: wk
Date: 2007-08-13 15:32:46 +0200 (Mon, 13 Aug 2007)
New Revision: 261
Modified:
trunk/ChangeLog
trunk/autogen.sh
trunk/configure.ac
trunk/doc/Makefile.am
trunk/src/ChangeLog
trunk/src/Makefile.am
trunk/src/dirmngr-client.c
trunk/src/dirmngr.c
trunk/src/get-path.c
Log:
Fixed a few W32 issues.
starting and stopping a services does now work.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-08-09 15:51:16 UTC (rev 260)
+++ trunk/ChangeLog 2007-08-13 13:32:46 UTC (rev 261)
@@ -1,3 +1,11 @@
+2007-08-12 Werner Koch <wk at g10code.com>
+
+ * doc/Makefile.am (yat2m): Change the way this helper is build.
+ * configure.ac (CC_FOR_BUILD): New.
+
+ * autogen.sh: Update script to modern version and add --build-w32
+ option.
+
2007-08-09 Werner Koch <wk at g10code.com>
* doc/dirmngr.texi (Dirmngr Options): Describe the new format of
Modified: trunk/autogen.sh
===================================================================
--- trunk/autogen.sh 2007-08-09 15:51:16 UTC (rev 260)
+++ trunk/autogen.sh 2007-08-13 13:32:46 UTC (rev 261)
@@ -28,9 +28,77 @@
return 1
}
+# Allow to override the default tool names
+AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX}
+AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX}
+
+AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX}
+ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX}
+
+GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX}
+MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX}
+
DIE=no
+FORCE=
+if test x"$1" = x"--force"; then
+ FORCE=" --force"
+ shift
+fi
+# ***** W32 build script *******
+# Used to cross-compile for Windows.
+if test "$1" = "--build-w32"; then
+ tmp=`dirname $0`
+ tsdir=`cd "$tmp"; pwd`
+ shift
+ if [ ! -f $tsdir/config.guess ]; then
+ echo "$tsdir/config.guess not found" >&2
+ exit 1
+ fi
+ build=`$tsdir/config.guess`
+
+ [ -z "$w32root" ] && w32root="$HOME/w32root"
+ echo "Using $w32root as standard install directory" >&2
+
+ # Locate the cross compiler
+ crossbindir=
+ for host in i586-mingw32msvc i386-mingw32msvc mingw32; do
+ if ${host}-gcc --version >/dev/null 2>&1 ; then
+ crossbindir=/usr/${host}/bin
+ conf_CC="CC=${host}-gcc"
+ break;
+ fi
+ done
+ if [ -z "$crossbindir" ]; then
+ echo "Cross compiler kit not installed" >&2
+ echo "Under Debian GNU/Linux, you may install it using" >&2
+ echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2
+ echo "Stop." >&2
+ exit 1
+ fi
+
+ if [ -f "$tsdir/config.log" ]; then
+ if ! head $tsdir/config.log | grep "$host" >/dev/null; then
+ echo "Please run a 'make distclean' first" >&2
+ exit 1
+ fi
+ fi
+
+
+ ./configure --enable-maintainer-mode --prefix=${w32root} \
+ --host=${host} --build=${build} \
+ --with-gpg-error-prefix=${w32root} \
+ --with-ksba-prefix=${w32root} \
+ --with-libgcrypt-prefix=${w32root} \
+ --with-libassuan-prefix=${w32root} \
+ --with-pth-prefix=${w32root}
+ rc=$?
+ exit $rc
+fi
+# ***** end W32 build script *******
+
+
# ***** AMD64 cross build script *******
# Used to cross-compile for AMD64 (for testing)
if test "$1" = "--build-amd64"; then
@@ -108,17 +176,7 @@
exit 1
fi
-# Allow to override the default tool names
-AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX}
-AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX}
-AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX}
-ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX}
-
-GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX}
-MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX}
-
-
if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then
check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf
fi
@@ -145,7 +203,7 @@
$AUTOHEADER
echo "Running automake --gnu ..."
$AUTOMAKE --gnu;
-echo "Running autoconf..."
-$AUTOCONF
+echo "Running autoconf${FORCE} ..."
+$AUTOCONF${FORCE}
echo "You may now run \"./configure --enable-maintainer-mode --sysconfdir=/etc && make\"."
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2007-08-09 15:51:16 UTC (rev 260)
+++ trunk/configure.ac 2007-08-13 13:32:46 UTC (rev 261)
@@ -130,7 +130,22 @@
fi
fi
+# We need to compile and run a program on the build machine. A
+# comment in libgpg-error says that the AC_PROG_CC_FOR_BUILD macro in
+# the AC archive is broken for autoconf 2.57. Given that tehre is no
+# newer version of that macro, we assume that it is also broken for
+# autoconf 2.61 and thus we use a simple but usually sufficient
+# approach.
+AC_MSG_CHECKING(for cc for build)
+if test "$cross_compiling" = "yes"; then
+ CC_FOR_BUILD="${CC_FOR_BUILD-cc}"
+else
+ CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
+fi
+AC_MSG_RESULT($CC_FOR_BUILD)
+AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
+
# Tweaks for certain OSes.
mmap_needed=yes
have_w32_system=no
Modified: trunk/doc/Makefile.am
===================================================================
--- trunk/doc/Makefile.am 2007-08-09 15:51:16 UTC (rev 260)
+++ trunk/doc/Makefile.am 2007-08-13 13:32:46 UTC (rev 261)
@@ -19,10 +19,8 @@
## Process this file with automake to produce Makefile.in
-EXTRA_DIST = internals.texi see-also-note.texi
+EXTRA_DIST = internals.texi see-also-note.texi yat2m.c
-noinst_PROGRAMS = yat2m
-
AM_MAKEFINFOFLAGS = -I $(srcdir) --css-include=/dev/null
YAT2M_OPTIONS = -I $(srcdir) \
@@ -37,10 +35,14 @@
dirmngr_TEXINFOS = gpl.texi
+CLEANFILES = yat2m
+
DISTCLEANFILES = dirmngr.ops yat2m-stamp.tmp yat2m-stamp $(myman_pages)
-yat2m_SOURCES = yat2m.c
+yat2m: yat2m.c
+ $(CC_FOR_BUILD) -o $@ $(srcdir)/yat2m.c
+
yat2m-stamp: $(myman_sources)
@rm -f yat2m-stamp.tmp
@touch yat2m-stamp.tmp
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2007-08-09 15:51:16 UTC (rev 260)
+++ trunk/src/ChangeLog 2007-08-13 13:32:46 UTC (rev 261)
@@ -1,3 +1,20 @@
+2007-08-13 Werner Koch <wk at g10code.com>
+
+ * dirmngr.c (handle_connections): Use a timeout in the accept
+ fucntion. Block signals while creating a new thread. */
+ (shutdown_pending): Needs to be volatile as also accessed bt the
+ service function.
+ (w32_service_control): Do not use the regular log fucntions here.
+ (handle_tick): New.
+ (main): With system_service in effect use aDaemon as default
+ command.
+ (main) [W32]: Only temporary redefine main for the sake of Emacs's
+ "C-x 4 a".
+
+ * dirmngr-client.c (main) [W32]: Initialize sockets.
+ (start_dirmngr): Use default_socket_name instead of a constant.
+ * Makefile.am (dirmngr_client_SOURCES): Add get-path.c
+
2007-08-09 Werner Koch <wk at g10code.com>
* dirmngr.c (parse_ocsp_signer): New.
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2007-08-09 15:51:16 UTC (rev 260)
+++ trunk/src/Makefile.am 2007-08-13 13:32:46 UTC (rev 261)
@@ -63,7 +63,7 @@
$(GPG_ERROR_LIBS) $(LDAPLIBS) $(LIBINTL)
dirmngr_client_SOURCES = dirmngr-client.c i18n.h util.h b64enc.c \
- no-libgcrypt.c no-libgcrypt.h
+ get-path.c no-libgcrypt.c no-libgcrypt.h
dirmngr_client_LDADD = ../jnlib/libjnlib.a $(LIBOBJS) $(LIBASSUAN_LIBS) \
$(GPG_ERROR_LIBS) $(LIBINTL)
Modified: trunk/src/dirmngr-client.c
===================================================================
--- trunk/src/dirmngr-client.c 2007-08-09 15:51:16 UTC (rev 260)
+++ trunk/src/dirmngr-client.c 2007-08-13 13:32:46 UTC (rev 261)
@@ -81,7 +81,6 @@
{ 0 }
};
-#define DEFAULT_SOCKET_NAME "/var/run/dirmngr/socket"
/* The usual structure for the program flags. */
static struct
@@ -197,6 +196,16 @@
set_strusage (my_strusage);
log_set_prefix ("dirmngr-client",
JNLIB_LOG_WITH_PREFIX);
+
+ /* For W32 we need to initialize the socket subsystem. Becuase we
+ don't use Pth we need to do this explicit. */
+#ifdef HAVE_W32_SYSTEM
+ {
+ WSADATA wsadat;
+
+ WSAStartup (0x202, &wsadat);
+ }
+#endif /*HAVE_W32_SYSTEM*/
/* Init Assuan. */
assuan_set_assuan_log_stream (log_get_stream ());
@@ -444,7 +453,7 @@
infostr = opt.force_pipe_server? NULL : getenv ("DIRMNGR_INFO");
if (only_daemon && (!infostr || !*infostr))
{
- infostr = DEFAULT_SOCKET_NAME;
+ infostr = xstrdup (default_socket_name ());
try_default = 1;
}
if (!infostr || !*infostr)
Modified: trunk/src/dirmngr.c
===================================================================
--- trunk/src/dirmngr.c 2007-08-09 15:51:16 UTC (rev 260)
+++ trunk/src/dirmngr.c 2007-08-13 13:32:46 UTC (rev 261)
@@ -213,10 +213,20 @@
/* Helper to implement --debug-level. */
static const char *debug_level;
/* Flag indicating that a shutdown has been requested. */
-static int shutdown_pending;
+static volatile int shutdown_pending;
/* Counter for the active connections. */
static int active_connections;
+/* The timer tick used for housekeeping stuff. For Windows we use a
+ longer period as the SetWaitableTimer seems to signal earlier than
+ the 2 seconds. */
+#ifdef HAVE_W32_SYSTEM
+#define TIMERTICK_INTERVAL (4)
+#else
+#define TIMERTICK_INTERVAL (2) /* Seconds. */
+#endif
+
+
/* Prototypes. */
static void cleanup (void);
static ldap_server_t parse_ldapserver_file (const char* filename);
@@ -501,31 +511,36 @@
/* event_type and event_data are not used here. */
switch (control)
{
- case SERVICE_CONTROL_STOP:
case SERVICE_CONTROL_SHUTDOWN:
+ /* For shutdown we will try to force termination. */
service_status.dwCurrentState = SERVICE_STOP_PENDING;
SetServiceStatus (service_handle, &service_status);
+ shutdown_pending = 3;
+ break;
- if (!shutdown_pending)
- log_info (_("SIGTERM received - shutting down ...\n"));
- shutdown_pending++;
+ case SERVICE_CONTROL_STOP:
+ service_status.dwCurrentState = SERVICE_STOP_PENDING;
+ SetServiceStatus (service_handle, &service_status);
+ shutdown_pending = 1;
break;
default:
- log_info (_("unhandled control request %lu\n"), control);
break;
}
return 0;
}
+#endif /*HAVE_W32_SYSTEM*/
+
+
+#ifdef HAVE_W32_SYSTEM
+#define main real_main
#endif
-
int
+main (int argc, char **argv)
+{
#ifdef HAVE_W32_SYSTEM
-real_main (int argc, char **argv)
-#else
-main (int argc, char **argv)
+#undef main
#endif
-{
enum cmd_and_opt_values cmd = 0;
ARGPARSE_ARGS pargs;
int orig_argc;
@@ -567,7 +582,7 @@
service_status.dwWaitHint = 10000; /* 10 seconds timeout. */
SetServiceStatus (service_handle, &service_status);
}
-#endif
+#endif /*HAVE_W32_SYSTEM*/
set_strusage (my_strusage);
log_set_prefix ("dirmngr", 1|4);
@@ -836,7 +851,9 @@
#endif
/* Ready. Now to our duties. */
- if (!cmd)
+ if (!cmd && opt.system_service)
+ cmd = aDaemon;
+ else if (!cmd)
cmd = aServer;
rc = 0;
@@ -1219,9 +1236,7 @@
};
if (!StartServiceCtrlDispatcher (DispatchTable))
- log_error (_("failed to start service ctrl dispatcher: ec=%d\n"),
- (int) GetLastError ());
-
+ return 1;
return 0;
}
}
@@ -1644,7 +1659,28 @@
}
+/* This is the worker for the ticker. It is called every few seconds
+ and may only do fast operations. */
+static void
+handle_tick (void)
+{
+ /* Nothing real to do right now. Actually we need the timeout only
+ for W32 where we don't use signals and need a way for the loop to
+ check for the shutdown flag. */
+#ifdef HAVE_W32_SYSTEM
+ if (shutdown_pending)
+ log_info (_("SIGTERM received - shutting down ...\n"));
+ if (shutdown_pending > 2)
+ {
+ log_info (_("shutdown forced\n"));
+ log_info ("%s %s stopped\n", strusage(11), strusage(13) );
+ cleanup ();
+ dirmngr_exit (0);
+ }
+#endif /*HAVE_W32_SYSTEM*/
+}
+
/* Helper to call a connection's main fucntion. */
static void *
start_connection_thread (void *arg)
@@ -1670,8 +1706,8 @@
handle_connections (int listen_fd)
{
pth_attr_t tattr;
- pth_event_t ev;
- sigset_t sigs;
+ pth_event_t ev, time_ev;
+ sigset_t sigs, oldsigs;
int signo;
struct sockaddr_un paddr;
socklen_t plen = sizeof( paddr );
@@ -1694,6 +1730,7 @@
sigs = 0;
ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
#endif
+ time_ev = NULL;
for (;;)
{
@@ -1711,12 +1748,29 @@
continue;
}
+ if (!time_ev)
+ time_ev = pth_event (PTH_EVENT_TIME,
+ pth_timeout (TIMERTICK_INTERVAL, 0));
+
+ if (time_ev)
+ pth_event_concat (ev, time_ev, NULL);
fd = pth_accept_ev (listen_fd, (struct sockaddr *)&paddr, &plen, ev);
+ if (time_ev)
+ pth_event_isolate (time_ev);
+
if (fd == -1)
{
- if (pth_event_occurred (ev))
+ if (pth_event_occurred (ev)
+ || (time_ev && pth_event_occurred (time_ev)) )
{
- handle_signal (signo);
+ if (pth_event_occurred (ev))
+ handle_signal (signo);
+ if (time_ev && pth_event_occurred (time_ev))
+ {
+ pth_event_free (time_ev, PTH_FREE_ALL);
+ time_ev = NULL;
+ handle_tick ();
+ }
continue;
}
log_error (_("accept failed: %s - waiting 1s\n"), strerror (errno));
@@ -1724,15 +1778,39 @@
continue;
}
+ if (pth_event_occurred (ev))
+ {
+ handle_signal (signo);
+ }
+
+ if (time_ev && pth_event_occurred (time_ev))
+ {
+ pth_event_free (time_ev, PTH_FREE_ALL);
+ time_ev = NULL;
+ handle_tick ();
+ }
+
+
+ /* We now might create a new thread and because we don't want
+ any signals (as we are handling them here) to be delivered to
+ a new thread we need to block those signals. */
+ pth_sigmask (SIG_BLOCK, &sigs, &oldsigs);
+
+ /* Create thread to handle this connection. */
if (!pth_spawn (tattr, start_connection_thread, (void*)fd))
{
log_error (_("error spawning connection handler: %s\n"),
strerror (errno) );
close (fd);
}
+
+ /* Restore the signal mask. */
+ pth_sigmask (SIG_SETMASK, &oldsigs, NULL);
}
pth_event_free (ev, PTH_FREE_ALL);
+ if (time_ev)
+ pth_event_free (time_ev, PTH_FREE_ALL);
cleanup ();
log_info ("%s %s stopped\n", strusage(11), strusage(13));
}
Modified: trunk/src/get-path.c
===================================================================
--- trunk/src/get-path.c 2007-08-09 15:51:16 UTC (rev 260)
+++ trunk/src/get-path.c 2007-08-13 13:32:46 UTC (rev 261)
@@ -292,7 +292,7 @@
/* Get the standard home directory. In general this function should
not be used as it does not consider a registry value (under W32) or
- the GNUPGHOME encironment variable. It is better to use
+ the GNUPGHOME environment variable. It is better to use
default_homedir(). */
const char *
standard_homedir (void)
More information about the Gnupg-commits
mailing list