mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
gpg,gpgsm: New option --disable-fd-translation.
* common/sysutils.c (no_translate_sys2libc_fd) [W32]: New global. (disable_translate_sys2libc_fd): New. (translate_sys2libc_fd): Make static and cobuild only for Windows. (translate_sys2libc_fd_int): Use no_translate_sys2libc_fd flag. * g10/gpg.c, sm/gpgsm.c (oDisableFdTranslation): New const. (opts): Add option "disable-fd-translation". (main): Set option. -- GnuPG-bug-id: 7060
This commit is contained in:
parent
cec1fde1bc
commit
f9919bcc48
@ -113,6 +113,8 @@ static int allow_special_filenames;
|
|||||||
#ifdef HAVE_W32_SYSTEM
|
#ifdef HAVE_W32_SYSTEM
|
||||||
/* State of gnupg_inhibit_set_foregound_window. */
|
/* State of gnupg_inhibit_set_foregound_window. */
|
||||||
static int inhibit_set_foregound_window;
|
static int inhibit_set_foregound_window;
|
||||||
|
/* Disable the use of _open_osfhandle. */
|
||||||
|
static int no_translate_sys2libc_fd;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -351,6 +353,16 @@ enable_special_filenames (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Disable the use use of _open_osfhandle on Windows. */
|
||||||
|
void
|
||||||
|
disable_translate_sys2libc_fd (void)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_W32_SYSTEM
|
||||||
|
no_translate_sys2libc_fd = 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Return a string which is used as a kind of process ID. */
|
/* Return a string which is used as a kind of process ID. */
|
||||||
const byte *
|
const byte *
|
||||||
get_session_marker (size_t *rlen)
|
get_session_marker (size_t *rlen)
|
||||||
@ -537,10 +549,10 @@ gnupg_usleep (unsigned int usecs)
|
|||||||
different from the libc file descriptors (like open). This function
|
different from the libc file descriptors (like open). This function
|
||||||
translates system file handles to libc file handles. FOR_WRITE
|
translates system file handles to libc file handles. FOR_WRITE
|
||||||
gives the direction of the handle. */
|
gives the direction of the handle. */
|
||||||
int
|
#if defined(HAVE_W32_SYSTEM)
|
||||||
|
static int
|
||||||
translate_sys2libc_fd (gnupg_fd_t fd, int for_write)
|
translate_sys2libc_fd (gnupg_fd_t fd, int for_write)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_W32_SYSTEM)
|
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
if (fd == GNUPG_INVALID_FD)
|
if (fd == GNUPG_INVALID_FD)
|
||||||
@ -552,11 +564,9 @@ translate_sys2libc_fd (gnupg_fd_t fd, int for_write)
|
|||||||
if (x == -1)
|
if (x == -1)
|
||||||
log_error ("failed to translate osfhandle %p\n", (void *) fd);
|
log_error ("failed to translate osfhandle %p\n", (void *) fd);
|
||||||
return x;
|
return x;
|
||||||
#else /*!HAVE_W32_SYSTEM */
|
|
||||||
(void)for_write;
|
|
||||||
return fd;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif /*!HAVE_W32_SYSTEM */
|
||||||
|
|
||||||
|
|
||||||
/* This is the same as translate_sys2libc_fd but takes an integer
|
/* This is the same as translate_sys2libc_fd but takes an integer
|
||||||
which is assumed to be such an system handle. */
|
which is assumed to be such an system handle. */
|
||||||
@ -564,7 +574,7 @@ int
|
|||||||
translate_sys2libc_fd_int (int fd, int for_write)
|
translate_sys2libc_fd_int (int fd, int for_write)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_W32_SYSTEM
|
#ifdef HAVE_W32_SYSTEM
|
||||||
if (fd <= 2)
|
if (fd <= 2 || no_translate_sys2libc_fd)
|
||||||
return fd; /* Do not do this for stdin, stdout, and stderr. */
|
return fd; /* Do not do this for stdin, stdout, and stderr. */
|
||||||
|
|
||||||
return translate_sys2libc_fd ((void*)(intptr_t)fd, for_write);
|
return translate_sys2libc_fd ((void*)(intptr_t)fd, for_write);
|
||||||
|
@ -75,12 +75,13 @@ void trap_unaligned (void);
|
|||||||
int disable_core_dumps (void);
|
int disable_core_dumps (void);
|
||||||
int enable_core_dumps (void);
|
int enable_core_dumps (void);
|
||||||
void enable_special_filenames (void);
|
void enable_special_filenames (void);
|
||||||
|
void disable_translate_sys2libc_fd (void);
|
||||||
|
|
||||||
const unsigned char *get_session_marker (size_t *rlen);
|
const unsigned char *get_session_marker (size_t *rlen);
|
||||||
unsigned int get_uint_nonce (void);
|
unsigned int get_uint_nonce (void);
|
||||||
/*int check_permissions (const char *path,int extension,int checkonly);*/
|
/*int check_permissions (const char *path,int extension,int checkonly);*/
|
||||||
void gnupg_sleep (unsigned int seconds);
|
void gnupg_sleep (unsigned int seconds);
|
||||||
void gnupg_usleep (unsigned int usecs);
|
void gnupg_usleep (unsigned int usecs);
|
||||||
int translate_sys2libc_fd (gnupg_fd_t fd, int for_write);
|
|
||||||
int translate_sys2libc_fd_int (int fd, int for_write);
|
int translate_sys2libc_fd_int (int fd, int for_write);
|
||||||
gpg_error_t gnupg_parse_fdstr (const char *fdstr, es_syshd_t *r_syshd);
|
gpg_error_t gnupg_parse_fdstr (const char *fdstr, es_syshd_t *r_syshd);
|
||||||
int check_special_filename (const char *fname, int for_write, int notranslate);
|
int check_special_filename (const char *fname, int for_write, int notranslate);
|
||||||
|
@ -3856,6 +3856,12 @@ This option enables a mode in which filenames of the form
|
|||||||
@file{-&n}, where n is a non-negative decimal number,
|
@file{-&n}, where n is a non-negative decimal number,
|
||||||
refer to the file descriptor n and not to a file with that name.
|
refer to the file descriptor n and not to a file with that name.
|
||||||
|
|
||||||
|
@item --disable-fd-translation
|
||||||
|
@opindex disable-fd-translation
|
||||||
|
This option changes the behaviour for all following options to expect
|
||||||
|
libc file descriptors instead of HANDLE values on the command line.
|
||||||
|
The option has an effect only on Windows.
|
||||||
|
|
||||||
@item --no-expensive-trust-checks
|
@item --no-expensive-trust-checks
|
||||||
@opindex no-expensive-trust-checks
|
@opindex no-expensive-trust-checks
|
||||||
Experimental use only.
|
Experimental use only.
|
||||||
|
@ -770,6 +770,18 @@ list of flag names and are OR-ed together. The special flag "none"
|
|||||||
clears the list and allows one to start over with an empty list. To get a
|
clears the list and allows one to start over with an empty list. To get a
|
||||||
list of available flags the sole word "help" can be used.
|
list of available flags the sole word "help" can be used.
|
||||||
|
|
||||||
|
@item --enable-special-filenames
|
||||||
|
@opindex enable-special-filenames
|
||||||
|
This option enables a mode in which filenames of the form
|
||||||
|
@file{-&n}, where n is a non-negative decimal number,
|
||||||
|
refer to the file descriptor n and not to a file with that name.
|
||||||
|
|
||||||
|
@item --disable-fd-translation
|
||||||
|
@opindex disable-fd-translation
|
||||||
|
This option changes the behaviour for all following options to expect
|
||||||
|
libc file descriptors instead of HANDLE values on the command line.
|
||||||
|
The option has an effect only on Windows.
|
||||||
|
|
||||||
@item --debug-level @var{level}
|
@item --debug-level @var{level}
|
||||||
@opindex debug-level
|
@opindex debug-level
|
||||||
Select the debug level for investigating problems. @var{level} may be
|
Select the debug level for investigating problems. @var{level} may be
|
||||||
|
@ -354,6 +354,7 @@ enum cmd_and_opt_values
|
|||||||
oAllowSecretKeyImport,
|
oAllowSecretKeyImport,
|
||||||
oAllowOldCipherAlgos,
|
oAllowOldCipherAlgos,
|
||||||
oEnableSpecialFilenames,
|
oEnableSpecialFilenames,
|
||||||
|
oDisableFdTranslation,
|
||||||
oNoLiteral,
|
oNoLiteral,
|
||||||
oSetFilesize,
|
oSetFilesize,
|
||||||
oHonorHttpProxy,
|
oHonorHttpProxy,
|
||||||
@ -880,7 +881,6 @@ static gpgrt_opt_t opts[] = {
|
|||||||
ARGPARSE_s_n (oAllowOldCipherAlgos, "allow-old-cipher-algos", "@"),
|
ARGPARSE_s_n (oAllowOldCipherAlgos, "allow-old-cipher-algos", "@"),
|
||||||
ARGPARSE_s_s (oWeakDigest, "weak-digest","@"),
|
ARGPARSE_s_s (oWeakDigest, "weak-digest","@"),
|
||||||
ARGPARSE_s_s (oVerifyOptions, "verify-options", "@"),
|
ARGPARSE_s_s (oVerifyOptions, "verify-options", "@"),
|
||||||
ARGPARSE_s_n (oEnableSpecialFilenames, "enable-special-filenames", "@"),
|
|
||||||
ARGPARSE_s_n (oNoRandomSeedFile, "no-random-seed-file", "@"),
|
ARGPARSE_s_n (oNoRandomSeedFile, "no-random-seed-file", "@"),
|
||||||
ARGPARSE_s_n (oNoSigCache, "no-sig-cache", "@"),
|
ARGPARSE_s_n (oNoSigCache, "no-sig-cache", "@"),
|
||||||
ARGPARSE_s_n (oIgnoreTimeConflict, "ignore-time-conflict", "@"),
|
ARGPARSE_s_n (oIgnoreTimeConflict, "ignore-time-conflict", "@"),
|
||||||
@ -912,6 +912,8 @@ static gpgrt_opt_t opts[] = {
|
|||||||
ARGPARSE_s_i (oPassphraseRepeat,"passphrase-repeat", "@"),
|
ARGPARSE_s_i (oPassphraseRepeat,"passphrase-repeat", "@"),
|
||||||
ARGPARSE_s_s (oPinentryMode, "pinentry-mode", "@"),
|
ARGPARSE_s_s (oPinentryMode, "pinentry-mode", "@"),
|
||||||
ARGPARSE_s_n (oForceSignKey, "force-sign-key", "@"),
|
ARGPARSE_s_n (oForceSignKey, "force-sign-key", "@"),
|
||||||
|
ARGPARSE_s_n (oEnableSpecialFilenames, "enable-special-filenames", "@"),
|
||||||
|
ARGPARSE_s_n (oDisableFdTranslation, "disable-fd-translation", "@"),
|
||||||
|
|
||||||
ARGPARSE_header (NULL, N_("Other options")),
|
ARGPARSE_header (NULL, N_("Other options")),
|
||||||
|
|
||||||
@ -3563,6 +3565,10 @@ main (int argc, char **argv)
|
|||||||
enable_special_filenames ();
|
enable_special_filenames ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case oDisableFdTranslation:
|
||||||
|
disable_translate_sys2libc_fd ();
|
||||||
|
break;
|
||||||
|
|
||||||
case oNoExpensiveTrustChecks: opt.no_expensive_trust_checks=1; break;
|
case oNoExpensiveTrustChecks: opt.no_expensive_trust_checks=1; break;
|
||||||
case oAutoCheckTrustDB: opt.no_auto_check_trustdb=0; break;
|
case oAutoCheckTrustDB: opt.no_auto_check_trustdb=0; break;
|
||||||
case oNoAutoCheckTrustDB: opt.no_auto_check_trustdb=1; break;
|
case oNoAutoCheckTrustDB: opt.no_auto_check_trustdb=1; break;
|
||||||
|
@ -117,6 +117,7 @@ enum cmd_and_opt_values {
|
|||||||
oLogTime,
|
oLogTime,
|
||||||
|
|
||||||
oEnableSpecialFilenames,
|
oEnableSpecialFilenames,
|
||||||
|
oDisableFdTranslation,
|
||||||
|
|
||||||
oAgentProgram,
|
oAgentProgram,
|
||||||
oDisplay,
|
oDisplay,
|
||||||
@ -428,6 +429,7 @@ static gpgrt_opt_t opts[] = {
|
|||||||
ARGPARSE_s_n (oAnswerNo, "no", N_("assume no on most questions")),
|
ARGPARSE_s_n (oAnswerNo, "no", N_("assume no on most questions")),
|
||||||
ARGPARSE_s_i (oStatusFD, "status-fd", N_("|FD|write status info to this FD")),
|
ARGPARSE_s_i (oStatusFD, "status-fd", N_("|FD|write status info to this FD")),
|
||||||
ARGPARSE_s_n (oEnableSpecialFilenames, "enable-special-filenames", "@"),
|
ARGPARSE_s_n (oEnableSpecialFilenames, "enable-special-filenames", "@"),
|
||||||
|
ARGPARSE_s_n (oDisableFdTranslation, "disable-fd-translation", "@"),
|
||||||
ARGPARSE_s_i (oPassphraseFD, "passphrase-fd", "@"),
|
ARGPARSE_s_i (oPassphraseFD, "passphrase-fd", "@"),
|
||||||
ARGPARSE_s_s (oPinentryMode, "pinentry-mode", "@"),
|
ARGPARSE_s_s (oPinentryMode, "pinentry-mode", "@"),
|
||||||
|
|
||||||
@ -1461,6 +1463,10 @@ main ( int argc, char **argv)
|
|||||||
enable_special_filenames ();
|
enable_special_filenames ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case oDisableFdTranslation:
|
||||||
|
disable_translate_sys2libc_fd ();
|
||||||
|
break;
|
||||||
|
|
||||||
case oValidationModel: parse_validation_model (pargs.r.ret_str); break;
|
case oValidationModel: parse_validation_model (pargs.r.ret_str); break;
|
||||||
|
|
||||||
case oKeyServer:
|
case oKeyServer:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user