[W32] Changed default socket for dirmngr.

[W32] Add some code for event notifications 
      between scdaemon and gpg-agent.
This commit is contained in:
Werner Koch 2007-11-27 08:01:19 +00:00
parent 3d4ef0c814
commit 598a3d0ab4
12 changed files with 107 additions and 22 deletions

View File

@ -1,3 +1,15 @@
2007-11-20 Werner Koch <wk@g10code.com>
* gpg-agent.c (get_agent_scd_notify_event): New.
(handle_signal): Factor SIGUSR2 code out to:
(agent_sigusr2_action): .. New.
(agent_sighup_action): Print info message here and not in
handle_signal.
(handle_connections) [PTH_EVENT_HANDLE]: Call agent_sigusr2_action.
* call-scd.c (agent_scd_check_aliveness) [W32]: Implemented.
(start_scd) [W32]: Send event-signal option.
2007-11-19 Werner Koch <wk@g10code.com>
* call-pinentry.c (agent_askpin): Set the tooltip for the quality

View File

@ -205,6 +205,9 @@ cache_mode_t;
void agent_exit (int rc) JNLIB_GCC_A_NR; /* Also implemented in other tools */
const char *get_agent_socket_name (void);
const char *get_agent_ssh_socket_name (void);
#ifdef HAVE_W32_SYSTEM
void *get_agent_scd_notify_event (void);
#endif
void agent_sighup_action (void);
/*-- command.c --*/

View File

@ -374,14 +374,17 @@ start_scd (ctrl_t ctrl)
}
/* Tell the scdaemon we want him to send us an event signal. */
#ifndef HAVE_W32_SYSTEM
{
char buf[100];
sprintf (buf, "OPTION event-signal=%d", SIGUSR2);
#ifdef HAVE_W32_SYSTEM
snprintf (buf, sizeof buf, "OPTION event-signal=%lx",
(unsigned long)get_agent_scd_notify_event ());
#else
snprintf (buf, sizeof buf, "OPTION event-signal=%d", SIGUSR2);
#endif
assuan_transact (ctx, buf, NULL, NULL, NULL, NULL, NULL, NULL);
}
#endif
primary_scd_ctx = ctx;
primary_scd_ctx_reusable = 0;
@ -408,6 +411,9 @@ agent_scd_check_aliveness (void)
pth_event_t evt;
pid_t pid;
int rc;
#ifdef HAVE_W32_SYSTEM
DWORD dummyec;
#endif
if (!primary_scd_ctx)
return; /* No scdaemon running. */
@ -435,10 +441,12 @@ agent_scd_check_aliveness (void)
{
pid = assuan_get_pid (primary_scd_ctx);
#ifdef HAVE_W32_SYSTEM
#warning Need to implement an alive test for scdaemon
if (pid != (pid_t)(void*)(-1) && pid
&& !GetExitCodeProcess ((HANDLE)pid, &dummyec))
#else
if (pid != (pid_t)(-1) && pid
&& ((rc=waitpid (pid, NULL, WNOHANG))==-1 || (rc == pid)) )
#endif
{
/* Okay, scdaemon died. Disconnect the primary connection
now but take care that it won't do another wait. Also
@ -467,7 +475,6 @@ agent_scd_check_aliveness (void)
xfree (socket_name);
socket_name = NULL;
}
#endif
}
if (!pth_mutex_release (&start_scd_lock))

View File

@ -353,7 +353,7 @@ cmd_geteventcounter (assuan_context_t ctx, char *line)
/* This function should be called once for all key removals or
additions. Thus function is assured not to do any context
additions. This function is assured not to do any context
switches. */
void
bump_key_eventcounter (void)
@ -363,7 +363,7 @@ bump_key_eventcounter (void)
}
/* This function should be called for all card reader status
changes. Thus function is assured not to do any context
changes. This function is assured not to do any context
switches. */
void
bump_card_eventcounter (void)

View File

@ -1246,6 +1246,28 @@ get_agent_ssh_socket_name (void)
}
/* Under W32, this function returns the handle of the scdaemon
notification event. Calling it the first time creates that
event. */
#ifdef HAVE_W32_SYSTEM
void *
get_agent_scd_notify_event (void)
{
static HANDLE the_event;
if (!the_event)
{
SECURITY_ATTRIBUTES sa = { sizeof (SECURITY_ATTRIBUTES), NULL, TRUE};
the_event = CreateEvent ( &sa, FALSE, FALSE, NULL);
if (!the_event)
log_error ("can't create scd notify event: %s\n", w32_strerror (-1) );
}
return the_event;
}
#endif /*HAVE_W32_SYSTEM*/
/* Create a name for the socket. With USE_STANDARD_SOCKET given as
true using STANDARD_NAME in the home directory or if given as
@ -1486,17 +1508,29 @@ handle_tick (void)
}
/* A global fucntion which allows us to call the reload stuff from
other palces too. This is only used when build for W32. */
/* A global function which allows us to call the reload stuff from
other places too. This is only used when build for W32. */
void
agent_sighup_action (void)
{
log_info ("SIGHUP received - "
"re-reading configuration and flushing cache\n");
agent_flush_cache ();
reread_configuration ();
agent_reload_trustlist ();
}
static void
agent_sigusr2_action (void)
{
if (opt.verbose)
log_info ("SIGUSR2 received - checking smartcard status\n");
/* Nothing to check right now. We only increment a counter. */
bump_card_eventcounter ();
}
static void
handle_signal (int signo)
{
@ -1504,8 +1538,6 @@ handle_signal (int signo)
{
#ifndef HAVE_W32_SYSTEM
case SIGHUP:
log_info ("SIGHUP received - "
"re-reading configuration and flushing cache\n");
agent_sighup_action ();
break;
@ -1517,10 +1549,7 @@ handle_signal (int signo)
break;
case SIGUSR2:
if (opt.verbose)
log_info ("SIGUSR2 received - checking smartcard status\n");
/* Nothing to check right now. We only increment a counter. */
bump_card_eventcounter ();
agent_sigusr2_action ();
break;
case SIGTERM:
@ -1652,8 +1681,15 @@ handle_connections (gnupg_fd_t listen_fd, gnupg_fd_t listen_fd_ssh)
pth_sigmask (SIG_UNBLOCK, &sigs, NULL);
ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
#else
# ifdef PTH_EVENT_HANDLE
sigs = 0;
ev = pth_event (PTH_EVENT_HANDLE, get_agent_scd_notify_event ());
signo = 0;
# else
/* Use a dummy event. */
sigs = 0;
ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
# endif
#endif
time_ev = NULL;
@ -1706,7 +1742,13 @@ handle_connections (gnupg_fd_t listen_fd, gnupg_fd_t listen_fd_ssh)
|| (time_ev && pth_event_occurred (time_ev)))
{
if (pth_event_occurred (ev))
handle_signal (signo);
{
#if defined(HAVE_W32_SYSTEM) && defined(PTH_EVENT_HANDLE)
agent_sigusr2_action ();
#else
handle_signal (signo);
#endif
}
if (time_ev && pth_event_occurred (time_ev))
{
pth_event_free (time_ev, PTH_FREE_ALL);
@ -1723,7 +1765,11 @@ handle_connections (gnupg_fd_t listen_fd, gnupg_fd_t listen_fd_ssh)
if (pth_event_occurred (ev))
{
#if defined(HAVE_W32_SYSTEM) && defined(PTH_EVENT_HANDLE)
agent_sigusr2_action ();
#else
handle_signal (signo);
#endif
}
if (time_ev && pth_event_occurred (time_ev))

View File

@ -1,3 +1,7 @@
2007-11-27 Werner Koch <wk@g10code.com>
* homedir.c (dirmngr_socket_name): Use CSIDL_WINDOWS.
2007-11-15 Werner Koch <wk@g10code.com>
* asshelp.c (send_pinentry_environment): Add args XAUTHORITY and

View File

@ -299,8 +299,13 @@ dirmngr_socket_name (void)
if (!name)
{
const char *s1, *s2;
s1 = w32_rootdir ();
char s1[MAX_PATH];
const char *s2;
/* We need something akin CSIDL_COMMON_PROGRAMS, but local
(non-roaming). */
if (w32_shgetfolderpath (NULL, CSIDL_WINDOWS, NULL, 0, s1) < 0)
strcpy (s1, "C:\\WINDOWS");
s2 = DIRSEP_S "S.dirmngr";
name = xmalloc (strlen (s1) + strlen (s2) + 1);
strcpy (stpcpy (name, s1), s2);

View File

@ -1,5 +1,8 @@
2007-11-19 Werner Koch <wk@g10code.com>
* gpg.texi (GPG Configuration Options): English Grammar fix.
Thanks to Gerg Troxel.
* gpgsm.texi (Certificate Options): Document
--auto-issuer-key-retrieve.

View File

@ -1141,7 +1141,7 @@ found.
Set the name of the native character set. This is used to convert
some informational strings like user IDs to the proper UTF-8 encoding.
Note that this has nothing to do with the character set of data to be
encrypted or signed; GnuPG does not recode user supplied data. If
encrypted or signed; GnuPG does not recode user-supplied data. If
this option is not used, the default character set is determined from
the current locale. A verbosity level of 3 shows the chosen set.
Valid values for @code{name} are:

View File

@ -10,7 +10,7 @@ msgstr ""
"Project-Id-Version: gnupg-2.0.6\n"
"Report-Msgid-Bugs-To: translations@gnupg.org\n"
"POT-Creation-Date: 2007-11-19 16:02+0100\n"
"PO-Revision-Date: 2007-11-19 16:41+0100\n"
"PO-Revision-Date: 2007-11-20 14:43+0100\n"
"Last-Translator: Walter Koch <koch@u32.de>\n"
"Language-Team: German <de@li.org>\n"
"MIME-Version: 1.0\n"
@ -7009,7 +7009,7 @@ msgstr "Der Herausgeber wird von einer externen Stelle gesucht\n"
#: sm/certchain.c:498
#, c-format
msgid "number of issuers matching: %d\n"
msgstr "Anzahl der übereinstimmenden Heruasgeber: %d\n"
msgstr "Anzahl der übereinstimmenden Herausgeber: %d\n"
#: sm/certchain.c:651 sm/certchain.c:1069 sm/certchain.c:1674 sm/decrypt.c:259
#: sm/encrypt.c:341 sm/sign.c:327 sm/verify.c:113

View File

@ -1,3 +1,8 @@
2007-11-22 Werner Koch <wk@g10code.com>
* Makefile.am (./gpg_dearmor): Add --homedir so that we don't
auto create a ~/.gnupg/. From Gentoo.
2007-10-25 Werner Koch <wk@g10code.com>
Add missing copyright notices to *.test.

View File

@ -61,7 +61,7 @@ prepared.stamp: ./pubring.gpg ./secring.gpg ./plain-1 ./plain-2 ./plain-3 \
./gpg_dearmor:
echo '#!/bin/sh' >./gpg_dearmor
echo "../../g10/gpg2 --no-options --no-greeting \
echo "../../g10/gpg2 --no-options --no-greeting --homedir . \
--no-secmem-warning --batch --dearmor" >>./gpg_dearmor
chmod 755 ./gpg_dearmor