mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-21 10:09:57 +01:00
common,gpg,sm,tools: Don't remove translate_sys2libc_fd_int.
* common/sysutils.c (translate_sys2libc_fd_int): Recover. (translate_sys2libc_fdstr): Remove. (check_special_filename): Follow the change. * common/sysutils.h (translate_sys2libc_fd_int): Recover. (translate_sys2libc_fdstr): Remove. * g10/gpg.c, g10/gpgv.c, sm/gpgsm.c: Revert the changes. * tools/gpg-auth.c, tools/gpg-card.c, tools/gpg-pair-tool.c: Likewise. * tools/gpg-wks-client.c, tools/gpgconf.c: Likewise. -- GnuPG-bug-id: 6551 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
72ac77c4fa
commit
b9b0c18320
@ -556,6 +556,24 @@ 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. On WindowsCE the
|
||||
passed FD is a rendezvous ID and the function finishes the pipe
|
||||
creation. */
|
||||
int
|
||||
translate_sys2libc_fd_int (int fd, int for_write)
|
||||
{
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
if (fd <= 2)
|
||||
return fd; /* Do not do this for error, stdin, stdout, stderr. */
|
||||
|
||||
return translate_sys2libc_fd ((void*)fd, for_write);
|
||||
#else
|
||||
(void)for_write;
|
||||
return fd;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Parse the string representation of a file reference (file handle on
|
||||
@ -636,30 +654,6 @@ gnupg_sys2libc_fdstr (const char *fdstr, int for_write,
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This is the same as translate_sys2libc_fd but takes a string
|
||||
which represents a system handle on Windows a file descriptor
|
||||
on POSIX.
|
||||
|
||||
(1) 0, 1, or 2 which means stdin, stdout, and stderr, respectively.
|
||||
(2) Integer representation (by %d of printf).
|
||||
(3) Hex representation which starts as "0x".
|
||||
*/
|
||||
int
|
||||
translate_sys2libc_fdstr (const char *fdstr, int for_write)
|
||||
{
|
||||
gpg_error_t err;
|
||||
int fd;
|
||||
|
||||
err = gnupg_sys2libc_fdstr (fdstr, for_write, NULL, &fd);
|
||||
if (err)
|
||||
{
|
||||
log_error ("FDSTR error: %s\n", fdstr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
/* Check whether FNAME has the form "-&nnnn", where N is a non-zero
|
||||
* number. Returns this number or -1 if it is not the case. If the
|
||||
@ -679,7 +673,7 @@ check_special_filename (const char *fname, int for_write, int notranslate)
|
||||
;
|
||||
if (!fname[i])
|
||||
return notranslate? atoi (fname)
|
||||
/**/ : translate_sys2libc_fdstr (fname, for_write);
|
||||
/**/ : translate_sys2libc_fd_int (atoi (fname), for_write);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -73,9 +73,9 @@ unsigned int get_uint_nonce (void);
|
||||
void gnupg_sleep (unsigned int seconds);
|
||||
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);
|
||||
gpg_error_t gnupg_sys2libc_fdstr (const char *fdstr, int for_write,
|
||||
gnupg_fd_t *r_hd, int *r_fd);
|
||||
int translate_sys2libc_fdstr (const char *fdstr, int for_write);
|
||||
int check_special_filename (const char *fname, int for_write, int notranslate);
|
||||
FILE *gnupg_tmpfile (void);
|
||||
void gnupg_reopen_std (const char *pgmname);
|
||||
|
24
g10/gpg.c
24
g10/gpg.c
@ -603,7 +603,7 @@ static gpgrt_opt_t opts[] = {
|
||||
ARGPARSE_s_s (oDisplayCharset, "charset", "@"),
|
||||
ARGPARSE_conffile (oOptions, "options", N_("|FILE|read options from FILE")),
|
||||
ARGPARSE_noconffile (oNoOptions, "no-options", "@"),
|
||||
ARGPARSE_s_s (oLoggerFD, "logger-fd", "@"),
|
||||
ARGPARSE_s_i (oLoggerFD, "logger-fd", "@"),
|
||||
ARGPARSE_s_s (oLoggerFile, "log-file",
|
||||
N_("|FILE|write server mode logs to FILE")),
|
||||
ARGPARSE_s_s (oLoggerFile, "logger-file", "@"), /* 1.4 compatibility. */
|
||||
@ -854,7 +854,7 @@ static gpgrt_opt_t opts[] = {
|
||||
ARGPARSE_s_n (oSkipHiddenRecipients, "skip-hidden-recipients", "@"),
|
||||
ARGPARSE_s_n (oNoSkipHiddenRecipients, "no-skip-hidden-recipients", "@"),
|
||||
ARGPARSE_s_s (oOverrideSessionKey, "override-session-key", "@"),
|
||||
ARGPARSE_s_s (oOverrideSessionKeyFD, "override-session-key-fd", "@"),
|
||||
ARGPARSE_s_i (oOverrideSessionKeyFD, "override-session-key-fd", "@"),
|
||||
|
||||
ARGPARSE_header ("Security", N_("Options controlling the security")),
|
||||
|
||||
@ -894,14 +894,14 @@ static gpgrt_opt_t opts[] = {
|
||||
ARGPARSE_s_n (oNoBatch, "no-batch", "@"),
|
||||
ARGPARSE_s_n (oAnswerYes, "yes", "@"),
|
||||
ARGPARSE_s_n (oAnswerNo, "no", "@"),
|
||||
ARGPARSE_s_s (oStatusFD, "status-fd", "@"),
|
||||
ARGPARSE_s_i (oStatusFD, "status-fd", "@"),
|
||||
ARGPARSE_s_s (oStatusFile, "status-file", "@"),
|
||||
ARGPARSE_s_s (oAttributeFD, "attribute-fd", "@"),
|
||||
ARGPARSE_s_i (oAttributeFD, "attribute-fd", "@"),
|
||||
ARGPARSE_s_s (oAttributeFile, "attribute-file", "@"),
|
||||
ARGPARSE_s_s (oCommandFD, "command-fd", "@"),
|
||||
ARGPARSE_s_i (oCommandFD, "command-fd", "@"),
|
||||
ARGPARSE_s_s (oCommandFile, "command-file", "@"),
|
||||
ARGPARSE_o_s (oPassphrase, "passphrase", "@"),
|
||||
ARGPARSE_s_s (oPassphraseFD, "passphrase-fd", "@"),
|
||||
ARGPARSE_s_i (oPassphraseFD, "passphrase-fd", "@"),
|
||||
ARGPARSE_s_s (oPassphraseFile, "passphrase-file", "@"),
|
||||
ARGPARSE_s_i (oPassphraseRepeat,"passphrase-repeat", "@"),
|
||||
ARGPARSE_s_s (oPinentryMode, "pinentry-mode", "@"),
|
||||
@ -2867,19 +2867,19 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case oStatusFD:
|
||||
set_status_fd ( translate_sys2libc_fdstr (pargs.r.ret_str, 1) );
|
||||
set_status_fd ( translate_sys2libc_fd_int (pargs.r.ret_int, 1) );
|
||||
break;
|
||||
case oStatusFile:
|
||||
set_status_fd ( open_info_file (pargs.r.ret_str, 1, 0) );
|
||||
break;
|
||||
case oAttributeFD:
|
||||
set_attrib_fd ( translate_sys2libc_fdstr (pargs.r.ret_str, 1) );
|
||||
set_attrib_fd ( translate_sys2libc_fd_int (pargs.r.ret_int, 1) );
|
||||
break;
|
||||
case oAttributeFile:
|
||||
set_attrib_fd ( open_info_file (pargs.r.ret_str, 1, 1) );
|
||||
break;
|
||||
case oLoggerFD:
|
||||
log_set_fd (translate_sys2libc_fdstr (pargs.r.ret_str, 1));
|
||||
log_set_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1));
|
||||
break;
|
||||
case oLoggerFile:
|
||||
logfile = pargs.r.ret_str;
|
||||
@ -3245,7 +3245,7 @@ main (int argc, char **argv)
|
||||
set_passphrase_from_string (pargs.r_type ? pargs.r.ret_str : "");
|
||||
break;
|
||||
case oPassphraseFD:
|
||||
pwfd = translate_sys2libc_fdstr (pargs.r.ret_str, 0);
|
||||
pwfd = translate_sys2libc_fd_int (pargs.r.ret_int, 0);
|
||||
break;
|
||||
case oPassphraseFile:
|
||||
pwfd = open_info_file (pargs.r.ret_str, 0, 1);
|
||||
@ -3267,7 +3267,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case oCommandFD:
|
||||
opt.command_fd = translate_sys2libc_fdstr (pargs.r.ret_str, 0);
|
||||
opt.command_fd = translate_sys2libc_fd_int (pargs.r.ret_int, 0);
|
||||
if (! gnupg_fd_valid (opt.command_fd))
|
||||
log_error ("command-fd is invalid: %s\n", strerror (errno));
|
||||
break;
|
||||
@ -3526,7 +3526,7 @@ main (int argc, char **argv)
|
||||
opt.override_session_key = pargs.r.ret_str;
|
||||
break;
|
||||
case oOverrideSessionKeyFD:
|
||||
ovrseskeyfd = translate_sys2libc_fdstr (pargs.r.ret_str, 0);
|
||||
ovrseskeyfd = translate_sys2libc_fd_int (pargs.r.ret_int, 0);
|
||||
break;
|
||||
case oMergeOnly:
|
||||
deprecated_warning(configname,pargs.lineno,"--merge-only",
|
||||
|
@ -82,9 +82,9 @@ static gpgrt_opt_t opts[] = {
|
||||
ARGPARSE_s_s (oOutput, "output", N_("|FILE|write output to FILE")),
|
||||
ARGPARSE_s_n (oIgnoreTimeConflict, "ignore-time-conflict",
|
||||
N_("make timestamp conflicts only a warning")),
|
||||
ARGPARSE_s_s (oStatusFD, "status-fd",
|
||||
ARGPARSE_s_i (oStatusFD, "status-fd",
|
||||
N_("|FD|write status info to this FD")),
|
||||
ARGPARSE_s_s (oLoggerFD, "logger-fd", "@"),
|
||||
ARGPARSE_s_i (oLoggerFD, "logger-fd", "@"),
|
||||
ARGPARSE_s_s (oLoggerFile, "log-file", "@"),
|
||||
ARGPARSE_s_s (oHomedir, "homedir", "@"),
|
||||
ARGPARSE_s_s (oWeakDigest, "weak-digest",
|
||||
@ -232,10 +232,10 @@ main( int argc, char **argv )
|
||||
case oKeyring: append_to_strlist( &nrings, pargs.r.ret_str); break;
|
||||
case oOutput: opt.outfile = pargs.r.ret_str; break;
|
||||
case oStatusFD:
|
||||
set_status_fd (translate_sys2libc_fdstr (pargs.r.ret_str, 1));
|
||||
set_status_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1));
|
||||
break;
|
||||
case oLoggerFD:
|
||||
log_set_fd (translate_sys2libc_fdstr (pargs.r.ret_str, 1));
|
||||
log_set_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1));
|
||||
break;
|
||||
case oLoggerFile:
|
||||
log_set_file (pargs.r.ret_str);
|
||||
|
12
sm/gpgsm.c
12
sm/gpgsm.c
@ -290,7 +290,7 @@ static gpgrt_opt_t opts[] = {
|
||||
ARGPARSE_s_s (oLogFile, "log-file",
|
||||
N_("|FILE|write server mode logs to FILE")),
|
||||
ARGPARSE_s_n (oNoLogFile, "no-log-file", "@"),
|
||||
ARGPARSE_s_s (oLoggerFD, "logger-fd", "@"),
|
||||
ARGPARSE_s_i (oLoggerFD, "logger-fd", "@"),
|
||||
ARGPARSE_s_n (oLogTime, "log-time", "@"),
|
||||
ARGPARSE_s_n (oNoSecmemWarn, "no-secmem-warning", "@"),
|
||||
|
||||
@ -422,9 +422,9 @@ static gpgrt_opt_t opts[] = {
|
||||
ARGPARSE_s_n (oNoBatch, "no-batch", "@"),
|
||||
ARGPARSE_s_n (oAnswerYes, "yes", N_("assume yes on most questions")),
|
||||
ARGPARSE_s_n (oAnswerNo, "no", N_("assume no on most questions")),
|
||||
ARGPARSE_s_s (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_s (oPassphraseFD, "passphrase-fd", "@"),
|
||||
ARGPARSE_s_i (oPassphraseFD, "passphrase-fd", "@"),
|
||||
ARGPARSE_s_s (oPinentryMode, "pinentry-mode", "@"),
|
||||
|
||||
|
||||
@ -1156,7 +1156,7 @@ main ( int argc, char **argv)
|
||||
break;
|
||||
|
||||
case oPassphraseFD:
|
||||
pwfd = translate_sys2libc_fdstr (pargs.r.ret_str, 0);
|
||||
pwfd = translate_sys2libc_fd_int (pargs.r.ret_int, 0);
|
||||
break;
|
||||
|
||||
case oPinentryMode:
|
||||
@ -1300,10 +1300,10 @@ main ( int argc, char **argv)
|
||||
break;
|
||||
|
||||
case oStatusFD:
|
||||
ctrl.status_fd = translate_sys2libc_fdstr (pargs.r.ret_str, 1);
|
||||
ctrl.status_fd = translate_sys2libc_fd_int (pargs.r.ret_int, 1);
|
||||
break;
|
||||
case oLoggerFD:
|
||||
log_set_fd (translate_sys2libc_fdstr (pargs.r.ret_str, 1));
|
||||
log_set_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1));
|
||||
break;
|
||||
case oWithMD5Fingerprint:
|
||||
opt.with_md5_fingerprint=1; /*fall through*/
|
||||
|
@ -94,7 +94,7 @@ static gpgrt_opt_t opts[] = {
|
||||
ARGPARSE_s_n (oVerbose, "verbose", ("verbose")),
|
||||
ARGPARSE_s_n (oQuiet, "quiet", ("be somewhat more quiet")),
|
||||
ARGPARSE_s_s (oDebug, "debug", "@"),
|
||||
ARGPARSE_s_s (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 (oWithColons, "with-colons", "@"),
|
||||
ARGPARSE_s_n (oNoAutostart, "no-autostart", "@"),
|
||||
ARGPARSE_s_s (oAgentProgram, "agent-program", "@"),
|
||||
@ -168,7 +168,7 @@ parse_arguments (gpgrt_argparse_t *pargs, gpgrt_opt_t *popts)
|
||||
case oAgentProgram: opt.agent_program = pargs->r.ret_str; break;
|
||||
|
||||
case oStatusFD:
|
||||
gnupg_set_status_fd (translate_sys2libc_fdstr (pargs->r.ret_str, 1));
|
||||
gnupg_set_status_fd (translate_sys2libc_fd_int (pargs->r.ret_int, 1));
|
||||
break;
|
||||
|
||||
case oWithColons: opt.with_colons = 1; break;
|
||||
|
@ -94,7 +94,7 @@ static gpgrt_opt_t opts[] = {
|
||||
ARGPARSE_s_s (oDebug, "debug", "@"),
|
||||
ARGPARSE_s_s (oGpgProgram, "gpg", "@"),
|
||||
ARGPARSE_s_s (oGpgsmProgram, "gpgsm", "@"),
|
||||
ARGPARSE_s_s (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 (oWithColons, "with-colons", "@"),
|
||||
ARGPARSE_s_n (oNoAutostart, "no-autostart", "@"),
|
||||
ARGPARSE_s_s (oAgentProgram, "agent-program", "@"),
|
||||
@ -225,7 +225,7 @@ parse_arguments (gpgrt_argparse_t *pargs, gpgrt_opt_t *popts)
|
||||
case oAgentProgram: opt.agent_program = pargs->r.ret_str; break;
|
||||
|
||||
case oStatusFD:
|
||||
gnupg_set_status_fd (translate_sys2libc_fdstr (pargs->r.ret_str, 1));
|
||||
gnupg_set_status_fd (translate_sys2libc_fd_int (pargs->r.ret_int, 1));
|
||||
break;
|
||||
|
||||
case oWithColons: opt.with_colons = 1; break;
|
||||
|
@ -179,7 +179,7 @@ static gpgrt_opt_t opts[] = {
|
||||
ARGPARSE_s_s (oSAS, "sas", N_("|SAS|the SAS as shown by the peer")),
|
||||
ARGPARSE_s_s (oDebug, "debug", "@"),
|
||||
ARGPARSE_s_s (oOutput, "output", N_("|FILE|write the request to FILE")),
|
||||
ARGPARSE_s_s (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_s (oHomedir, "homedir", "@"),
|
||||
|
||||
@ -390,7 +390,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case oStatusFD:
|
||||
set_status_fd (translate_sys2libc_fdstr (pargs.r.ret_str, 1));
|
||||
set_status_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1));
|
||||
break;
|
||||
|
||||
case oHomedir:
|
||||
|
@ -115,7 +115,7 @@ static gpgrt_opt_t opts[] = {
|
||||
ARGPARSE_s_s (oGpgProgram, "gpg", "@"),
|
||||
ARGPARSE_s_n (oSend, "send", "send the mail using sendmail"),
|
||||
ARGPARSE_s_s (oOutput, "output", "|FILE|write the mail to FILE"),
|
||||
ARGPARSE_s_s (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 (oNoAutostart, "no-autostart", "@"),
|
||||
ARGPARSE_s_n (oWithColons, "with-colons", "@"),
|
||||
ARGPARSE_s_s (oBlacklist, "blacklist", "@"),
|
||||
@ -248,7 +248,7 @@ parse_arguments (gpgrt_argparse_t *pargs, gpgrt_opt_t *popts)
|
||||
fake_submission_addr = pargs->r.ret_str;
|
||||
break;
|
||||
case oStatusFD:
|
||||
wks_set_status_fd (translate_sys2libc_fdstr (pargs->r.ret_str, 1));
|
||||
wks_set_status_fd (translate_sys2libc_fd_int (pargs->r.ret_int, 1));
|
||||
break;
|
||||
case oWithColons:
|
||||
opt.with_colons = 1;
|
||||
|
@ -118,7 +118,7 @@ static gpgrt_opt_t opts[] =
|
||||
{ oQuiet, "quiet", 0, N_("quiet") },
|
||||
{ oDryRun, "dry-run", 0, N_("do not make any changes") },
|
||||
{ oRuntime, "runtime", 0, N_("activate changes at runtime, if possible") },
|
||||
ARGPARSE_s_s (oStatusFD, "status-fd",
|
||||
ARGPARSE_s_i (oStatusFD, "status-fd",
|
||||
N_("|FD|write status info to this FD")),
|
||||
/* hidden options */
|
||||
{ oHomedir, "homedir", 2, "@" },
|
||||
@ -645,7 +645,7 @@ main (int argc, char **argv)
|
||||
case oBuilddir: gnupg_set_builddir (pargs.r.ret_str); break;
|
||||
case oNull: opt.null = 1; break;
|
||||
case oStatusFD:
|
||||
set_status_fd (translate_sys2libc_fdstr (pargs.r.ret_str, 1));
|
||||
set_status_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1));
|
||||
break;
|
||||
case oShowSocket: show_socket = 1; break;
|
||||
case oChUid: changeuser = pargs.r.ret_str; break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user