[svn] gpgme - r1302 - in trunk: assuan gpgme
svn author wk
cvs at cvs.gnupg.org
Thu Feb 14 20:51:24 CET 2008
Author: wk
Date: 2008-02-14 20:51:21 +0100 (Thu, 14 Feb 2008)
New Revision: 1302
Modified:
trunk/assuan/ChangeLog
trunk/assuan/assuan-pipe-connect.c
trunk/gpgme/ChangeLog
trunk/gpgme/engine-gpgconf.c
trunk/gpgme/engine-gpgsm.c
trunk/gpgme/gpgme.h
trunk/gpgme/posix-io.c
trunk/gpgme/posix-util.c
trunk/gpgme/priv-io.h
trunk/gpgme/rungpg.c
trunk/gpgme/util.h
trunk/gpgme/version.c
trunk/gpgme/w32-glib-io.c
trunk/gpgme/w32-io.c
trunk/gpgme/w32-qt-io.cpp
trunk/gpgme/w32-util.c
Log:
Chnages to supporta pinnetry notification
Modified: trunk/assuan/ChangeLog
===================================================================
--- trunk/assuan/ChangeLog 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/assuan/ChangeLog 2008-02-14 19:51:21 UTC (rev 1302)
@@ -1,3 +1,8 @@
+2008-02-14 Werner Koch <wk at g10code.com>
+
+ * assuan-pipe-connect.c (_gpgme_io_spawn): Adjust prototype.
+ (pipe_connect_gpgme, pipe_connect_gpgme): Adjust call.
+
2008-01-04 Marcus Brinkmann <marcus at g10code.de>
* assuan-pipe-connect.c (_gpgme_io_pipe)
Modified: trunk/gpgme/ChangeLog
===================================================================
--- trunk/gpgme/ChangeLog 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/gpgme/ChangeLog 2008-02-14 19:51:21 UTC (rev 1302)
@@ -1,3 +1,18 @@
+2008-02-14 Werner Koch <wk at g10code.com>
+
+ * w32-io.c (_gpgme_io_spawn): Add arg R_PID to return the pid.
+ * posix-io.c (_gpgme_io_spawn): Ditto.
+ * w32-glib-io.c (_gpgme_io_spawn): Ditto.
+ * w32-qt-io.cpp (_gpgme_io_spawn): Ditto.
+ * priv-io.h (_gpgme_io_spawn): Adjust prototyp and change all callers.
+ * rungpg.c (start): Call _gpgme_allow_set_foregound_window.
+
+ * w32-util.c (_gpgme_allow_set_foregound_window): New.
+ * posix-util.c (_gpgme_allow_set_foregound_window): New.
+ * engine-gpgsm.c (default_inq_cb): New.
+ (gpgsm_new) [W32]: Enable pinentry notifications.
+ (status_handler): Handle inquiries.
+
2008-01-30 Marcus Brinkmann <marcus at g10code.de>
* kdpipeiodevice.cpp: New version by Frank Osterfeld, fixes race
Modified: trunk/assuan/assuan-pipe-connect.c
===================================================================
--- trunk/assuan/assuan-pipe-connect.c 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/assuan/assuan-pipe-connect.c 2008-02-14 19:51:21 UTC (rev 1302)
@@ -44,7 +44,7 @@
int _gpgme_io_pipe (int filedes[2], int inherit_idx);
int _gpgme_io_spawn (const char *path, char **argv,
struct spawn_fd_item_s *fd_child_list,
- struct spawn_fd_item_s *fd_parent_list);
+ struct spawn_fd_item_s *fd_parent_list, pid_t *r_pid);
#endif
/* Hacks for Slowaris. */
@@ -643,7 +643,7 @@
child_fds[2].fd = -1;
/* Start the process. */
- res = _gpgme_io_spawn (name, argv, child_fds, child_fds);
+ res = _gpgme_io_spawn (name, argv, child_fds, child_fds, NULL);
if (res == -1)
{
_assuan_log_printf ("CreateProcess failed: %s\n", strerror (errno));
Modified: trunk/gpgme/engine-gpgconf.c
===================================================================
--- trunk/gpgme/engine-gpgconf.c 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/gpgme/engine-gpgconf.c 2008-02-14 19:51:21 UTC (rev 1302)
@@ -219,7 +219,7 @@
pfd[0].fd = rp[1];
cfd[0].fd = rp[1];
- status = _gpgme_io_spawn (gpgconf->file_name, argv, cfd, pfd);
+ status = _gpgme_io_spawn (gpgconf->file_name, argv, cfd, pfd, NULL);
if (status < 0)
{
_gpgme_io_close (rp[0]);
@@ -630,7 +630,7 @@
pfd[0].fd = rp[0];
cfd[0].fd = rp[0];
- status = _gpgme_io_spawn (gpgconf->file_name, argv, cfd, pfd);
+ status = _gpgme_io_spawn (gpgconf->file_name, argv, cfd, pfd, NULL);
if (status < 0)
{
_gpgme_io_close (rp[0]);
Modified: trunk/gpgme/engine-gpgsm.c
===================================================================
--- trunk/gpgme/engine-gpgsm.c 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/gpgme/engine-gpgsm.c 2008-02-14 19:51:21 UTC (rev 1302)
@@ -285,7 +285,21 @@
}
+/* This is the default inquiry callback. We use it to handle the
+ Pinentry notifications. */
static gpgme_error_t
+default_inq_cb (engine_gpgsm_t gpgsm, const char *line)
+{
+ if (!strncmp (line, "PINENTRY_LAUNCHED", 17) && (line[17]==' '||!line[17]))
+ {
+ _gpgme_allow_set_foregound_window ((pid_t)strtoul (line+17, NULL, 10));
+ }
+
+ return 0;
+}
+
+
+static gpgme_error_t
gpgsm_cancel (void *engine)
{
engine_gpgsm_t gpgsm = engine;
@@ -528,6 +542,19 @@
err = 0; /* This is an optional feature of gpgsm. */
}
+
+#ifdef HAVE_W32_SYSTEM
+ /* Under Windows we need to use AllowSetForegroundWindow. Tell
+ gpgsm to tell us when it needs it. */
+ if (!err)
+ {
+ err = assuan_transact (gpgsm->assuan_ctx, "OPTION allow-pinentry-notify",
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ if (gpg_err_code (err) == GPG_ERR_UNKNOWN_OPTION)
+ err = 0; /* This is a new feature of gpgsm. */
+ }
+#endif /*HAVE_W32_SYSTEM*/
+
#if !USE_DESCRIPTOR_PASSING
if (!err
&& (_gpgme_io_set_close_notify (gpgsm->input_cb.fd,
@@ -861,7 +888,7 @@
"fd 0x%x: ERR line - mapped to: %s",
fd, err ? gpg_strerror (err) : "ok");
/* Try our best to terminate the connection friendly. */
- // assuan_write_line (gpgsm->assuan_ctx, "BYE");
+ /* assuan_write_line (gpgsm->assuan_ctx, "BYE"); */
}
else if (linelen >= 2
&& line[0] == 'O' && line[1] == 'K'
@@ -1028,6 +1055,20 @@
"fd 0x%x: S line (%s) - final status: %s",
fd, line+2, err? gpg_strerror (err):"ok");
}
+ else if (linelen >= 7
+ && line[0] == 'I' && line[1] == 'N' && line[2] == 'Q'
+ && line[3] == 'U' && line[4] == 'I' && line[5] == 'R'
+ && line[6] == 'E'
+ && (line[7] == '\0' || line[7] == ' '))
+ {
+ char *keyword = line+7;
+
+ while (*keyword == ' ')
+ keyword++;;
+ default_inq_cb (gpgsm, keyword);
+ assuan_write_line (gpgsm->assuan_ctx, "END");
+ }
+
}
while (!err && assuan_pending_line (gpgsm->assuan_ctx));
Modified: trunk/gpgme/gpgme.h
===================================================================
--- trunk/gpgme/gpgme.h 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/gpgme/gpgme.h 2008-02-14 19:51:21 UTC (rev 1302)
@@ -72,7 +72,7 @@
AM_PATH_GPGME macro) check that this header matches the installed
library. Warning: Do not edit the next line. configure will do
that for you! */
-#define GPGME_VERSION "1.1.7-svn1300"
+#define GPGME_VERSION "1.1.7-svn1301"
Modified: trunk/gpgme/posix-io.c
===================================================================
--- trunk/gpgme/posix-io.c 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/gpgme/posix-io.c 2008-02-14 19:51:21 UTC (rev 1302)
@@ -235,7 +235,7 @@
int
_gpgme_io_spawn (const char *path, char **argv,
struct spawn_fd_item_s *fd_child_list,
- struct spawn_fd_item_s *fd_parent_list)
+ struct spawn_fd_item_s *fd_parent_list, pid_t *r_pid)
{
pid_t pid;
int i;
@@ -358,6 +358,9 @@
for (i = 0; fd_parent_list[i].fd != -1; i++)
_gpgme_io_close (fd_parent_list[i].fd);
+ if (r_pid)
+ *r_pid = pid;
+
return TRACE_SYSRES (0);
}
Modified: trunk/gpgme/posix-util.c
===================================================================
--- trunk/gpgme/posix-util.c 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/gpgme/posix-util.c 2008-02-14 19:51:21 UTC (rev 1302)
@@ -65,3 +65,10 @@
{
return 0;
}
+
+void
+_gpgme_allow_set_foregound_window (pid_t pid)
+{
+ (void)pid;
+ /* Not needed. */
+}
Modified: trunk/gpgme/priv-io.h
===================================================================
--- trunk/gpgme/priv-io.h 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/gpgme/priv-io.h 2008-02-14 19:51:21 UTC (rev 1302)
@@ -56,7 +56,7 @@
fds in FD_CHILD_LIST in the child. */
int _gpgme_io_spawn (const char *path, char **argv,
struct spawn_fd_item_s *fd_child_list,
- struct spawn_fd_item_s *fd_parent_list);
+ struct spawn_fd_item_s *fd_parent_list, pid_t *r_pid);
int _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock);
/* Write the printable version of FD to the buffer BUF of length
Modified: trunk/gpgme/rungpg.c
===================================================================
--- trunk/gpgme/rungpg.c 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/gpgme/rungpg.c 2008-02-14 19:51:21 UTC (rev 1302)
@@ -1226,6 +1226,7 @@
int i, n;
int status;
struct spawn_fd_item_s *fd_child_list, *fd_parent_list;
+ pid_t pid;
if (!gpg)
return gpg_error (GPG_ERR_INV_VALUE);
@@ -1309,7 +1310,7 @@
status = _gpgme_io_spawn (gpg->file_name ? gpg->file_name :
_gpgme_get_gpg_path (),
- gpg->argv, fd_child_list, fd_parent_list);
+ gpg->argv, fd_child_list, fd_parent_list, &pid);
saved_errno = errno;
free (fd_child_list);
if (status == -1)
@@ -1356,6 +1357,8 @@
}
}
+ _gpgme_allow_set_foregound_window (pid);
+
gpg_io_event (gpg, GPGME_EVENT_START, NULL);
/* fixme: check what data we can release here */
Modified: trunk/gpgme/util.h
===================================================================
--- trunk/gpgme/util.h 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/gpgme/util.h 2008-02-14 19:51:21 UTC (rev 1302)
@@ -33,6 +33,7 @@
const char *_gpgme_get_gpgsm_path (void);
const char *_gpgme_get_gpgconf_path (void);
int _gpgme_get_conf_int (const char *key, int *value);
+void _gpgme_allow_set_foregound_window (pid_t pid);
/*-- replacement functions in <funcname>.c --*/
Modified: trunk/gpgme/version.c
===================================================================
--- trunk/gpgme/version.c 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/gpgme/version.c 2008-02-14 19:51:21 UTC (rev 1302)
@@ -212,7 +212,7 @@
pfd[0].fd = rp[1];
cfd[0].fd = rp[1];
- status = _gpgme_io_spawn (file_name, argv, cfd, pfd);
+ status = _gpgme_io_spawn (file_name, argv, cfd, pfd, NULL);
if (status < 0)
{
_gpgme_io_close (rp[0]);
Modified: trunk/gpgme/w32-glib-io.c
===================================================================
--- trunk/gpgme/w32-glib-io.c 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/gpgme/w32-glib-io.c 2008-02-14 19:51:21 UTC (rev 1302)
@@ -450,7 +450,7 @@
int
_gpgme_io_spawn (const char *path, char **argv,
struct spawn_fd_item_s *fd_child_list,
- struct spawn_fd_item_s *fd_parent_list)
+ struct spawn_fd_item_s *fd_parent_list, pid_t *r_pid)
{
SECURITY_ATTRIBUTES sec_attr;
PROCESS_INFORMATION pi =
@@ -458,7 +458,7 @@
NULL, /* returns process handle */
0, /* returns primary thread handle */
0, /* returns pid */
- 0 /* returns tid */
+ 0 /* returns tid */
};
STARTUPINFO si;
char *envblock = NULL;
@@ -593,7 +593,9 @@
"dwProcessID=%d, dwThreadId=%d",
pi.hProcess, pi.hThread,
(int) pi.dwProcessId, (int) pi.dwThreadId);
-
+ if (r_pid)
+ *r_pid = (pid_t)pi.dwProcessId;
+
if (ResumeThread (pi.hThread) < 0)
TRACE_LOG1 ("ResumeThread failed: ec=%d", (int) GetLastError ());
Modified: trunk/gpgme/w32-io.c
===================================================================
--- trunk/gpgme/w32-io.c 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/gpgme/w32-io.c 2008-02-14 19:51:21 UTC (rev 1302)
@@ -1007,7 +1007,7 @@
int
_gpgme_io_spawn (const char *path, char **argv,
struct spawn_fd_item_s *fd_child_list,
- struct spawn_fd_item_s *fd_parent_list)
+ struct spawn_fd_item_s *fd_parent_list, pid_t *r_pid)
{
SECURITY_ATTRIBUTES sec_attr;
PROCESS_INFORMATION pi =
@@ -1015,7 +1015,7 @@
NULL, /* returns process handle */
0, /* returns primary thread handle */
0, /* returns pid */
- 0 /* returns tid */
+ 0 /* returns tid */
};
STARTUPINFO si;
char *envblock = NULL;
@@ -1147,6 +1147,8 @@
"dwProcessID=%d, dwThreadId=%d",
pi.hProcess, pi.hThread,
(int) pi.dwProcessId, (int) pi.dwThreadId);
+ if (r_pid)
+ *r_pid = (pid_t)pi.dwProcessId;
if (ResumeThread (pi.hThread) < 0)
TRACE_LOG1 ("ResumeThread failed: ec=%d", (int) GetLastError ());
Modified: trunk/gpgme/w32-qt-io.cpp
===================================================================
--- trunk/gpgme/w32-qt-io.cpp 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/gpgme/w32-qt-io.cpp 2008-02-14 19:51:21 UTC (rev 1302)
@@ -399,7 +399,7 @@
int
_gpgme_io_spawn (const char *path, char **argv,
struct spawn_fd_item_s *fd_child_list,
- struct spawn_fd_item_s *fd_parent_list)
+ struct spawn_fd_item_s *fd_parent_list, pid_t *r_pid)
{
SECURITY_ATTRIBUTES sec_attr;
PROCESS_INFORMATION pi =
@@ -543,6 +543,8 @@
"dwProcessID=%d, dwThreadId=%d",
pi.hProcess, pi.hThread,
(int) pi.dwProcessId, (int) pi.dwThreadId);
+ if (r_pid)
+ *r_pid = (pid_t)pi.dwProcessId;
if (ResumeThread (pi.hThread) < 0)
TRACE_LOG1 ("ResumeThread failed: ec=%d", (int) GetLastError ());
Modified: trunk/gpgme/w32-util.c
===================================================================
--- trunk/gpgme/w32-util.c 2008-01-30 14:17:26 UTC (rev 1301)
+++ trunk/gpgme/w32-util.c 2008-02-14 19:51:21 UTC (rev 1302)
@@ -363,3 +363,35 @@
free (tmp);
return 1;
}
+
+
+void
+_gpgme_allow_set_foregound_window (pid_t pid)
+{
+ static int initialized;
+ static BOOL (WINAPI * func)(DWORD);
+ void *handle;
+
+ if (!initialized)
+ {
+ /* Available since W2000; thus we dynload it. */
+ initialized = 1;
+ handle = dlopen ("user32.dll", RTLD_LAZY);
+ if (handle)
+ {
+ func = dlsym (handle, "AllowSetForegroundWindow");
+ if (!func)
+ {
+ dlclose (handle);
+ handle = NULL;
+ }
+ }
+ }
+
+ if (!pid || pid == (pid_t)(-1))
+ ;
+ else if (func)
+ func (pid);
+
+}
+
More information about the Gnupg-commits
mailing list