diff options
Diffstat (limited to 'agent')
-rw-r--r-- | agent/ChangeLog | 22 | ||||
-rw-r--r-- | agent/Makefile.am | 24 | ||||
-rw-r--r-- | agent/agent.h | 1 | ||||
-rw-r--r-- | agent/call-pinentry.c | 2 | ||||
-rw-r--r-- | agent/command.c | 12 | ||||
-rw-r--r-- | agent/gpg-agent.c | 59 |
6 files changed, 81 insertions, 39 deletions
diff --git a/agent/ChangeLog b/agent/ChangeLog index 607a02282..73bcfe10a 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,25 @@ +2007-07-04 Werner Koch <wk@g10code.com> + + * gpg-agent.c (TIMERTICK_INTERVAL): New. + +2007-07-03 Werner Koch <wk@g10code.com> + + * gpg-agent.c (handle_connections): Do not use FD_SETSIZE for + select but compute the correct number. + +2007-07-02 Werner Koch <wk@g10code.com> + + * command.c (cmd_reloadagent) [W32]: New. + (register_commands) [W32]: New command RELOADAGENT. + + * Makefile.am (gpg_agent_SOURCES): Remove w32main.c and w32main.h. + (gpg_agent_res_ldflags): Remove icon file as we don't have a + proper icon yet. + * gpg-agent.c (main): do not include w32main.h. Remove all calls + to w32main.c. + (agent_sighup_action): New. + (handle_signal): Use it. + 2007-06-26 Werner Koch <wk@g10code.com> * gpg-agent.c (create_directories) [W32]: Made it work. diff --git a/agent/Makefile.am b/agent/Makefile.am index 1a8047856..74c1cf810 100644 --- a/agent/Makefile.am +++ b/agent/Makefile.am @@ -23,7 +23,7 @@ bin_PROGRAMS = gpg-agent libexec_PROGRAMS = gpg-protect-tool gpg-preset-passphrase noinst_PROGRAMS = $(TESTS) -EXTRA_DIST = gpg-agent.ico gpg-agent-resource.rc +# EXTRA_DIST = gpg-agent.ico gpg-agent-resource.rc AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common -I$(top_srcdir)/intl @@ -47,25 +47,21 @@ gpg_agent_SOURCES = \ call-scd.c \ learncard.c -if HAVE_W32_SYSTEM -gpg_agent_SOURCES += w32main.c w32main.h -endif - common_libs = ../jnlib/libjnlib.a $(libcommon) ../gl/libgnu.a commonpth_libs = ../jnlib/libjnlib.a $(libcommonpth) ../gl/libgnu.a pwquery_libs = ../common/libsimple-pwquery.a -if HAVE_W32_SYSTEM -.rc.o: - $(WINDRES) `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \ - sed -e 's/-I/--include-dir /g;s/-D/--define /g'` -i $< -o $@ - -gpg_agent_res_ldflags = -Wl,gpg-agent-resource.o -Wl,--subsystem,windows -gpg_agent_res_deps = gpg-agent-resource.o -else +#if HAVE_W32_SYSTEM +#.rc.o: +# $(WINDRES) `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \ +# sed -e 's/-I/--include-dir /g;s/-D/--define /g'` -i $< -o $@ +# +#gpg_agent_res_ldflags = -Wl,gpg-agent-resource.o -Wl,--subsystem,windows +#gpg_agent_res_deps = gpg-agent-resource.o +#else gpg_agent_res_ldflags = gpg_agent_res_deps = -endif +#endif gpg_agent_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_PTH_CFLAGS) $(PTH_CFLAGS) diff --git a/agent/agent.h b/agent/agent.h index 690a86df5..17c7eed56 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -190,6 +190,7 @@ 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); +void agent_sighup_action (void); /*-- command.c --*/ gpg_error_t agent_write_status (ctrl_t ctrl, const char *keyword, ...); diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c index 8882e8d55..e995c4f1c 100644 --- a/agent/call-pinentry.c +++ b/agent/call-pinentry.c @@ -225,7 +225,7 @@ start_pinentry (ctrl_t ctrl) pgmname++; /* OS X needs the entire file name in argv[0], so that it can locate - the resource bundle. For other systems we stick to the the usual + the resource bundle. For other systems we stick to the usual convention of supplying only the name of the program. */ #ifdef __APPLE__ argv[0] = opt.pinentry_program; diff --git a/agent/command.c b/agent/command.c index 011ed580d..0c0cb54ed 100644 --- a/agent/command.c +++ b/agent/command.c @@ -1323,6 +1323,17 @@ cmd_killagent (assuan_context_t ctx, char *line) ctrl->server_local->stopme = 1; return 0; } + +/* RELOADAGENT + + As signals are inconvenient under Windows, we provide this command + to allow reloading of the configuration. */ +static int +cmd_reloadagent (assuan_context_t ctx, char *line) +{ + agent_sighup_action (); + return 0; +} #endif /*HAVE_W32_SYSTEM*/ @@ -1506,6 +1517,7 @@ register_commands (assuan_context_t ctx) { "UPDATESTARTUPTTY", cmd_updatestartuptty }, #ifdef HAVE_W32_SYSTEM { "KILLAGENT", cmd_killagent }, + { "RELOADAGENT", cmd_reloadagent }, #endif { "GETINFO", cmd_getinfo }, { NULL } diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index b69142825..a75acec94 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -48,7 +48,6 @@ #include "sysutils.h" #ifdef HAVE_W32_SYSTEM # include "../jnlib/w32-afunix.h" -# include "w32main.h" #endif #include "setenv.h" @@ -171,6 +170,14 @@ static ARGPARSE_OPTS opts[] = { #define MAX_CACHE_TTL_SSH (120*60) /* 2 hours */ #define MIN_PASSPHRASE_LEN (8) +/* 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 /* flag to indicate that a shutdown was requested */ static int shutdown_pending; @@ -408,16 +415,9 @@ parse_rereadable_options (ARGPARSE_ARGS *pargs, int reread) } -/* The main entry point. For W32 another name is used as the real - entry points needs to be named WinMain and is defined in - w32main.c. */ -#ifdef HAVE_W32_SYSTEM -int -w32_main (int argc, char **argv ) -#else +/* The main entry point. */ int main (int argc, char **argv ) -#endif { ARGPARSE_ARGS pargs; int orig_argc; @@ -851,7 +851,6 @@ main (int argc, char **argv ) #ifdef HAVE_W32_SYSTEM pid = getpid (); printf ("set GPG_AGENT_INFO=%s;%lu;1\n", socket_name, (ulong)pid); - w32_setup_taskbar (); #else /*!HAVE_W32_SYSTEM*/ pid = fork (); if (pid == (pid_t)-1) @@ -1430,6 +1429,17 @@ 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. */ +void +agent_sighup_action (void) +{ + agent_flush_cache (); + reread_configuration (); + agent_reload_trustlist (); +} + + static void handle_signal (int signo) { @@ -1439,9 +1449,7 @@ handle_signal (int signo) case SIGHUP: log_info ("SIGHUP received - " "re-reading configuration and flushing cache\n"); - agent_flush_cache (); - reread_configuration (); - agent_reload_trustlist (); + agent_sighup_action (); break; case SIGUSR1: @@ -1545,6 +1553,7 @@ handle_connections (int listen_fd, int listen_fd_ssh) fd_set fdset, read_fdset; int ret; int fd; + int nfd; tattr = pth_attr_new(); pth_attr_set (tattr, PTH_ATTR_JOINABLE, 0); @@ -1562,24 +1571,25 @@ handle_connections (int listen_fd, int listen_fd_ssh) pth_sigmask (SIG_UNBLOCK, &sigs, NULL); ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo); #else - ev = NULL; - signo = 0; + sigs = 0; + ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo); #endif time_ev = NULL; FD_ZERO (&fdset); FD_SET (listen_fd, &fdset); + nfd = listen_fd; if (listen_fd_ssh != -1) - FD_SET (listen_fd_ssh, &fdset); + { + FD_SET (listen_fd_ssh, &fdset); + if (listen_fd_ssh > nfd) + nfd = listen_fd_ssh; + } for (;;) { sigset_t oldsigs; -#ifdef HAVE_W32_SYSTEM - w32_poll_events (); -#endif - if (shutdown_pending) { if (pth_ctrl (PTH_CTRL_GETTHREADS) == 1) @@ -1596,7 +1606,8 @@ handle_connections (int listen_fd, int listen_fd_ssh) /* Create a timeout event if needed. */ if (!time_ev) - time_ev = pth_event (PTH_EVENT_TIME, pth_timeout (2, 0)); + time_ev = pth_event (PTH_EVENT_TIME, + pth_timeout (TIMERTICK_INTERVAL, 0)); /* POSIX says that fd_set should be implemented as a structure, thus a simple assignment is fine to copy the entire set. */ @@ -1604,7 +1615,7 @@ handle_connections (int listen_fd, int listen_fd_ssh) if (time_ev) pth_event_concat (ev, time_ev, NULL); - ret = pth_select_ev (FD_SETSIZE, &read_fdset, NULL, NULL, NULL, ev); + ret = pth_select_ev (nfd+1, &read_fdset, NULL, NULL, NULL, ev); if (time_ev) pth_event_isolate (time_ev); @@ -1643,8 +1654,8 @@ handle_connections (int listen_fd, int listen_fd_ssh) /* We now might create new threads and because we don't want any - signals - we are handling here - to be delivered to a new - thread. Thus we need to block those signals. */ + signals (as we are handling them here) to be delivered to a + new thread. Thus we need to block those signals. */ pth_sigmask (SIG_BLOCK, &sigs, &oldsigs); if (FD_ISSET (listen_fd, &read_fdset)) |