aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/ChangeLog11
-rw-r--r--common/iobuf.c2
-rw-r--r--common/sysutils.c128
-rw-r--r--common/sysutils.h10
-rw-r--r--g10/ChangeLog7
-rw-r--r--g10/gpg.c14
6 files changed, 19 insertions, 153 deletions
diff --git a/common/ChangeLog b/common/ChangeLog
index 3d545866c..3840eaacd 100644
--- a/common/ChangeLog
+++ b/common/ChangeLog
@@ -1,3 +1,14 @@
+2008-06-25 Marcus Brinkmann <[email protected]>
+
+ Revert last three changes related to handle translation.
+ * sysutils.c:
+ (FD_TRANSLATE_MAX, fd_translate, fd_translate_len)
+ (translate_table_init, translate_table_lookup): Removed.
+ * iobuf.c (check_special_filename): Do not use
+ translate_table_lookup.
+ * sysutils.h (translate_table_init, translate_table_lookup):
+ Remove prototypes.
+
2008-06-19 Werner Koch <[email protected]>
* sysutils.c: Remove <ctype.h>.
diff --git a/common/iobuf.c b/common/iobuf.c
index 3cac9e072..ae35d301e 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -1177,7 +1177,7 @@ check_special_filename (const char *fname)
for (i = 0; digitp (fname+i); i++)
;
if (!fname[i])
- return translate_table_lookup (atoi (fname));
+ return atoi (fname);
}
return -1;
}
diff --git a/common/sysutils.c b/common/sysutils.c
index 564b075e1..5e550b43a 100644
--- a/common/sysutils.c
+++ b/common/sysutils.c
@@ -278,127 +278,6 @@ gnupg_sleep (unsigned int seconds)
}
-
-/* Handle translation. On W32, we provide handle values on the
- command line directly and using special file names such as
- "-&HANDLE". However, in GPGME we can not directly inherit the
- handles as this may interfere with other components in a
- multithreaded application. Thus, we inject the handles after
- creating the GPG process. The problem is that the handle numbers
- change at injection, but it is too late to change the command line.
- Hence this hack, which allows us to translate the handle values
- in the command line to their new values after injection.
-
- Handles that must be translated are those occuring in special file
- names (see iobuf.c::check_special_filename) as well as those given
- directly to options (see translate_sys2libc_fd_int). */
-
-/* For W32, we may have to translate handle values given on the
- command line. */
-#define FD_TRANSLATE_MAX 8
-static struct
-{
- int from;
- int to;
-} fd_translate[FD_TRANSLATE_MAX];
-
-/* Number of entries used in fd_translate. */
-static int fd_translate_len;
-
-
-/* Initialize the fd translation table. This reads one line from
- stdin which is expected to be in the format "FROM TO [...]" where
- each "FROM TO" pair are two handle numbers. Handle number FROM on
- the command line is translated to handle number TO.
-
- Note that this function may be called while still being setuid. */
-void
-translate_table_init (void)
-{
- /* Hold roughly 8 pairs of 64 bit numbers in hex notation:
- "0xFEDCBA9876543210 0xFEDCBA9876543210". 8*19*2 - 1 = 303. This
- plans ahead for a time where a HANDLE is 64 bit. */
-#define TRANS_MAX 350
- char line[TRANS_MAX + 1];
- char *linep;
- int idx;
- int res;
- int newl = 0;
-
- /* We always read one line from stdin. */
- for (idx = 0; idx < TRANS_MAX; idx++)
- {
- do
- res = read (0, &line[idx], 1);
- while (res == -1 && errno == EINTR);
- if (res != 1)
- break;
- if (line[idx] == '\n')
- {
- newl = 1;
- break;
- }
- }
- if (!newl)
- {
- char buf[1];
- do
- {
- do
- res = read (0, buf, 1);
- while (res == -1 && errno == EINTR);
- }
- while (res == 1 && *buf != '\n');
- }
-
- line[idx] = '\0';
- linep = line;
-
- /* Now start to read mapping pairs. */
- for (idx = 0; idx < FD_TRANSLATE_MAX; idx++)
- {
- unsigned long from;
- unsigned long to;
- char *tail;
-
- while (spacep (linep))
- linep++;
- if (*linep == '\0')
- break;
- from = strtoul (linep, &tail, 0);
- if (tail == NULL || ! (*tail == '\0' || spacep (tail)))
- break;
- linep = tail;
-
- while (spacep (linep))
- linep++;
- if (*linep == '\0')
- break;
- to = strtoul (linep, &tail, 0);
- if (tail == NULL || ! (*tail == '\0' || spacep (tail)))
- break;
- linep = tail;
-
- fd_translate[idx].from = from;
- fd_translate[idx].to = to;
- fd_translate_len++;
- }
-}
-
-
-/* Translate a handle number. */
-int
-translate_table_lookup (int fd)
-{
- int idx;
-
- for (idx = 0; idx < fd_translate_len; idx++)
- if (fd_translate[idx].from == fd)
- return fd_translate[idx].to;
- return fd;
-}
-
-
/* This function is a NOP for POSIX systems but required under Windows
as the file handles as returned by OS calls (like CreateFile) are
different from the libc file descriptors (like open). This function
@@ -424,7 +303,6 @@ translate_sys2libc_fd (gnupg_fd_t fd, int for_write)
#endif
}
-
/* This is the same as translate_sys2libc_fd but takes an integer
which is assumed to be such an system handle. */
int
@@ -434,14 +312,8 @@ translate_sys2libc_fd_int (int fd, int for_write)
if (fd <= 2)
return fd; /* Do not do this for error, stdin, stdout, stderr. */
- /* Note: If this function is ever used in a different context than
- option parsing in the main function, a variant that does not do
- translation probable needs to be used. */
- fd = translate_table_lookup (fd);
-
return translate_sys2libc_fd ((void*)fd, for_write);
#else
- fd = translate_table_lookup (fd);
return fd;
#endif
}
diff --git a/common/sysutils.h b/common/sysutils.h
index 9e0a323dd..de1e3bb1e 100644
--- a/common/sysutils.h
+++ b/common/sysutils.h
@@ -43,16 +43,6 @@ int enable_core_dumps (void);
const unsigned char *get_session_marker (size_t *rlen);
/*int check_permissions (const char *path,int extension,int checkonly);*/
void gnupg_sleep (unsigned int seconds);
-
-/* Initialize the fd translation table. This reads one line from
- stdin which is expected to be in the format "FROM TO [...]" where
- each "FROM TO" pair are two handle numbers. Handle number FROM on
- the command line is translated to handle number TO. */
-void translate_table_init (void);
-
-/* Translate a handle number. */
-int translate_table_lookup (int fd);
-
int translate_sys2libc_fd (gnupg_fd_t fd, int for_write);
int translate_sys2libc_fd_int (int fd, int for_write);
FILE *gnupg_tmpfile (void);
diff --git a/g10/ChangeLog b/g10/ChangeLog
index c4e6b38d9..4aa1ed114 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,10 @@
+2008-06-25 Marcus Brinkmann <[email protected]>
+
+ * gpg.c (enum cmd_and_opt_values): Remove option
+ oEnableW32HandleTranslation.
+ (opts): Remove option --enable-w32-handle-translation.
+ (main): Remove variable w32_handle_translation.
+
2008-06-19 Werner Koch <[email protected]>
* gpg.c (gpgconf_list): Add "group".
diff --git a/g10/gpg.c b/g10/gpg.c
index 9019cf22d..a88e6d702 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -300,7 +300,6 @@ enum cmd_and_opt_values
oNoAllowFreeformUID,
oAllowSecretKeyImport,
oEnableSpecialFilenames,
- oEnableW32HandleTranslation,
oNoLiteral,
oSetFilesize,
oHonorHttpProxy,
@@ -665,7 +664,6 @@ static ARGPARSE_OPTS opts[] = {
{ oAllowSecretKeyImport, "allow-secret-key-import", 0, "@" },
{ oTryAllSecrets, "try-all-secrets", 0, "@" },
{ oEnableSpecialFilenames, "enable-special-filenames", 0, "@" },
- { oEnableW32HandleTranslation, "enable-w32-handle-translation", 0, "@" },
{ oNoExpensiveTrustChecks, "no-expensive-trust-checks", 0, "@" },
{ aDeleteSecretAndPublicKeys, "delete-secret-and-public-keys",256, "@" },
{ aRebuildKeydbCaches, "rebuild-keydb-caches", 256, "@"},
@@ -1878,7 +1876,6 @@ main (int argc, char **argv)
int eyes_only=0;
int multifile=0;
int pwfd = -1;
- int w32_handle_translation = 0;
int with_fpr = 0; /* make an option out of --fingerprint */
int any_explicit_recipient = 0;
int require_secmem=0,got_secmem=0;
@@ -1994,15 +1991,6 @@ main (int argc, char **argv)
{
/* Not used */
}
- else if (pargs.r_opt == oEnableW32HandleTranslation )
- {
- /* We must initialize handle translation before parsing
- the options. */
- if (! w32_handle_translation)
- translate_table_init ();
- w32_handle_translation = 1;
- break;
- }
}
#ifdef HAVE_DOSISH_SYSTEM
@@ -2781,7 +2769,6 @@ main (int argc, char **argv)
case oEnableSpecialFilenames:
iobuf_enable_special_filenames (1);
break;
- case oEnableW32HandleTranslation: break;
case oNoExpensiveTrustChecks: opt.no_expensive_trust_checks=1; break;
case oAutoCheckTrustDB: opt.no_auto_check_trustdb=0; break;
case oNoAutoCheckTrustDB: opt.no_auto_check_trustdb=1; break;
@@ -3346,7 +3333,6 @@ main (int argc, char **argv)
if( pwfd != -1 ) /* Read the passphrase now. */
read_passphrase_from_fd( pwfd );
-
fname = argc? *argv : NULL;
if(fname && utf8_strings)