aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Brinkmann <[email protected]>2007-07-10 16:06:44 +0000
committerMarcus Brinkmann <[email protected]>2007-07-10 16:06:44 +0000
commit2d9c4431b883224891d24611536964b4abb492a7 (patch)
treebd69ef1d8374b48c7c487c2440dcef3aaa134630
parentPost-release fixup. (diff)
downloadgpgme-2d9c4431b883224891d24611536964b4abb492a7.tar.gz
gpgme-2d9c4431b883224891d24611536964b4abb492a7.zip
2007-07-10 Marcus Brinkmann <[email protected]>
* priv-io.h (_gpgme_io_dup): New prototype. * posix-io.c (_gpgme_io_dup): New function. * w32-io.c (_gpgme_io_dup): Likewise. * w32-glib-io.c (_gpgme_io_dup): Likewise. * engine-gpgsm.c (start): Use _gpgme_dup() instead of dup().
Diffstat (limited to '')
-rw-r--r--gpgme/ChangeLog8
-rw-r--r--gpgme/engine-gpgsm.c3
-rw-r--r--gpgme/posix-io.c5
-rw-r--r--gpgme/priv-io.h3
-rw-r--r--gpgme/w32-glib-io.c8
-rw-r--r--gpgme/w32-io.c19
6 files changed, 45 insertions, 1 deletions
diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog
index 3b538efc..d2b021d6 100644
--- a/gpgme/ChangeLog
+++ b/gpgme/ChangeLog
@@ -1,3 +1,11 @@
+2007-07-10 Marcus Brinkmann <[email protected]>
+
+ * priv-io.h (_gpgme_io_dup): New prototype.
+ * posix-io.c (_gpgme_io_dup): New function.
+ * w32-io.c (_gpgme_io_dup): Likewise.
+ * w32-glib-io.c (_gpgme_io_dup): Likewise.
+ * engine-gpgsm.c (start): Use _gpgme_dup() instead of dup().
+
2007-07-08 Marcus Brinkmann <[email protected]>
* engine-gpgsm.c [HAVE_W32_SYSTEM]: Enable the bunch of the file.
diff --git a/gpgme/engine-gpgsm.c b/gpgme/engine-gpgsm.c
index d43a480d..0b78c29c 100644
--- a/gpgme/engine-gpgsm.c
+++ b/gpgme/engine-gpgsm.c
@@ -988,7 +988,8 @@ start (engine_gpgsm_t gpgsm, const char *command)
status_fd and register/unregister it manually as needed, but this
increases code duplication and is more complicated as we can not
use the close notifications etc. */
- gpgsm->status_cb.fd = dup (fdlist[0]);
+
+ gpgsm->status_cb.fd = _gpgme_io_dup (fdlist[0]);
if (gpgsm->status_cb.fd < 0)
return gpg_error_from_syserror ();
diff --git a/gpgme/posix-io.c b/gpgme/posix-io.c
index 5cb71f9b..82142f84 100644
--- a/gpgme/posix-io.c
+++ b/gpgme/posix-io.c
@@ -495,3 +495,8 @@ _gpgme_io_sendmsg (int fd, const struct msghdr *msg, int flags)
}
+int
+_gpgme_io_dup (int fd)
+{
+ return dup (fd);
+}
diff --git a/gpgme/priv-io.h b/gpgme/priv-io.h
index 4c2a604a..6b422840 100644
--- a/gpgme/priv-io.h
+++ b/gpgme/priv-io.h
@@ -64,4 +64,7 @@ int _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock);
line that the child process expects. */
int _gpgme_io_fd2str (char *buf, int buflen, int fd);
+/* Like dup(). */
+int _gpgme_io_dup (int fd);
+
#endif /* IO_H */
diff --git a/gpgme/w32-glib-io.c b/gpgme/w32-glib-io.c
index 20099ef6..183a560c 100644
--- a/gpgme/w32-glib-io.c
+++ b/gpgme/w32-glib-io.c
@@ -660,3 +660,11 @@ leave:
free (pollfds_map);
return count;
}
+
+
+int
+_gpgme_io_dup (int fd)
+{
+ return _dup (fd);
+}
+
diff --git a/gpgme/w32-io.c b/gpgme/w32-io.c
index fd53a6fb..947bb62e 100644
--- a/gpgme/w32-io.c
+++ b/gpgme/w32-io.c
@@ -1140,6 +1140,25 @@ _gpgme_io_fd2str (char *buf, int buflen, int fd)
return snprintf (buf, buflen, "%d", fd);
}
+
+int
+_gpgme_io_dup (int fd)
+{
+ HANDLE handle = fd_to_handle (fd);
+ HANDLE new_handle = fd_to_handle (fd);
+
+ /* For NT we have to set the sync flag. It seems that the only
+ * way to do it is by duplicating the handle. Tsss.. */
+ if (!DuplicateHandle( GetCurrentProcess(), handle,
+ GetCurrentProcess(), &new_handle,
+ 0, FALSE, DUPLICATE_SAME_ACCESS))
+ {
+ DEBUG1 ("** DuplicateHandle failed: ec=%d\n", (int) GetLastError());
+ }
+
+ return handle_to_fd (new_handle);
+}
+
/* The following interface is only useful for GPGME Glib. */