gpg,sm,tools: Use string for option --*-fd.

* g10/gpg.c (opts): Use string for oLoggerFD, oOverrideSessionKeyFD,
oStatusFD, oAttributeFD, oCommandFD, and oPassphraseFD.
(main): Use translate_sys2libc_fdstr.
* g10/gpgv.c (opts): Use string for oLoggerFD, and oStatusFD.
(main): Use translate_sys2libc_fdstr.
* sm/gpgsm.c (opts): Use string for oLoggerFD, oStatusFD, and
oPassphraseFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpg-auth.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
tools/gpg-card.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpg-pair-tool.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpg-wks-client.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpgconf.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpgtar-create.c (gpgtar_create): Fix for opt.status_fd.
* tools/gpgtar-extract.c (gpgtar_extract): Fix for opt.status_fd.
* tools/gpgtar-list.c (gpgtar_list): Fix for opt.status_fd.
* tools/gpgtar.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpgtar.h (opts): Use string for oStatusFD.

--

GnuPG-bug-id: 6551
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2023-06-23 13:10:19 +09:00
parent 04d0851cca
commit 2756147e39
No known key found for this signature in database
GPG Key ID: 640114AF89DE6054
13 changed files with 88 additions and 50 deletions

View File

@ -603,7 +603,7 @@ static gpgrt_opt_t opts[] = {
ARGPARSE_s_s (oDisplayCharset, "charset", "@"), ARGPARSE_s_s (oDisplayCharset, "charset", "@"),
ARGPARSE_conffile (oOptions, "options", N_("|FILE|read options from FILE")), ARGPARSE_conffile (oOptions, "options", N_("|FILE|read options from FILE")),
ARGPARSE_noconffile (oNoOptions, "no-options", "@"), ARGPARSE_noconffile (oNoOptions, "no-options", "@"),
ARGPARSE_s_i (oLoggerFD, "logger-fd", "@"), ARGPARSE_s_s (oLoggerFD, "logger-fd", "@"),
ARGPARSE_s_s (oLoggerFile, "log-file", ARGPARSE_s_s (oLoggerFile, "log-file",
N_("|FILE|write server mode logs to FILE")), N_("|FILE|write server mode logs to FILE")),
ARGPARSE_s_s (oLoggerFile, "logger-file", "@"), /* 1.4 compatibility. */ 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 (oSkipHiddenRecipients, "skip-hidden-recipients", "@"),
ARGPARSE_s_n (oNoSkipHiddenRecipients, "no-skip-hidden-recipients", "@"), ARGPARSE_s_n (oNoSkipHiddenRecipients, "no-skip-hidden-recipients", "@"),
ARGPARSE_s_s (oOverrideSessionKey, "override-session-key", "@"), ARGPARSE_s_s (oOverrideSessionKey, "override-session-key", "@"),
ARGPARSE_s_i (oOverrideSessionKeyFD, "override-session-key-fd", "@"), ARGPARSE_s_s (oOverrideSessionKeyFD, "override-session-key-fd", "@"),
ARGPARSE_header ("Security", N_("Options controlling the security")), 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 (oNoBatch, "no-batch", "@"),
ARGPARSE_s_n (oAnswerYes, "yes", "@"), ARGPARSE_s_n (oAnswerYes, "yes", "@"),
ARGPARSE_s_n (oAnswerNo, "no", "@"), ARGPARSE_s_n (oAnswerNo, "no", "@"),
ARGPARSE_s_i (oStatusFD, "status-fd", "@"), ARGPARSE_s_s (oStatusFD, "status-fd", "@"),
ARGPARSE_s_s (oStatusFile, "status-file", "@"), ARGPARSE_s_s (oStatusFile, "status-file", "@"),
ARGPARSE_s_i (oAttributeFD, "attribute-fd", "@"), ARGPARSE_s_s (oAttributeFD, "attribute-fd", "@"),
ARGPARSE_s_s (oAttributeFile, "attribute-file", "@"), ARGPARSE_s_s (oAttributeFile, "attribute-file", "@"),
ARGPARSE_s_i (oCommandFD, "command-fd", "@"), ARGPARSE_s_s (oCommandFD, "command-fd", "@"),
ARGPARSE_s_s (oCommandFile, "command-file", "@"), ARGPARSE_s_s (oCommandFile, "command-file", "@"),
ARGPARSE_o_s (oPassphrase, "passphrase", "@"), ARGPARSE_o_s (oPassphrase, "passphrase", "@"),
ARGPARSE_s_i (oPassphraseFD, "passphrase-fd", "@"), ARGPARSE_s_s (oPassphraseFD, "passphrase-fd", "@"),
ARGPARSE_s_s (oPassphraseFile, "passphrase-file", "@"), ARGPARSE_s_s (oPassphraseFile, "passphrase-file", "@"),
ARGPARSE_s_i (oPassphraseRepeat,"passphrase-repeat", "@"), ARGPARSE_s_i (oPassphraseRepeat,"passphrase-repeat", "@"),
ARGPARSE_s_s (oPinentryMode, "pinentry-mode", "@"), ARGPARSE_s_s (oPinentryMode, "pinentry-mode", "@"),
@ -2867,19 +2867,19 @@ main (int argc, char **argv)
break; break;
case oStatusFD: case oStatusFD:
set_status_fd ( translate_sys2libc_fd_int (pargs.r.ret_int, 1) ); set_status_fd ( translate_sys2libc_fdstr (pargs.r.ret_str, 1) );
break; break;
case oStatusFile: case oStatusFile:
set_status_fd ( open_info_file (pargs.r.ret_str, 1, 0) ); set_status_fd ( open_info_file (pargs.r.ret_str, 1, 0) );
break; break;
case oAttributeFD: case oAttributeFD:
set_attrib_fd ( translate_sys2libc_fd_int (pargs.r.ret_int, 1) ); set_attrib_fd ( translate_sys2libc_fdstr (pargs.r.ret_str, 1) );
break; break;
case oAttributeFile: case oAttributeFile:
set_attrib_fd ( open_info_file (pargs.r.ret_str, 1, 1) ); set_attrib_fd ( open_info_file (pargs.r.ret_str, 1, 1) );
break; break;
case oLoggerFD: case oLoggerFD:
log_set_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1)); log_set_fd (translate_sys2libc_fdstr (pargs.r.ret_str, 1));
break; break;
case oLoggerFile: case oLoggerFile:
logfile = pargs.r.ret_str; 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 : ""); set_passphrase_from_string (pargs.r_type ? pargs.r.ret_str : "");
break; break;
case oPassphraseFD: case oPassphraseFD:
pwfd = translate_sys2libc_fd_int (pargs.r.ret_int, 0); pwfd = translate_sys2libc_fdstr (pargs.r.ret_str, 0);
break; break;
case oPassphraseFile: case oPassphraseFile:
pwfd = open_info_file (pargs.r.ret_str, 0, 1); pwfd = open_info_file (pargs.r.ret_str, 0, 1);
@ -3267,7 +3267,7 @@ main (int argc, char **argv)
break; break;
case oCommandFD: case oCommandFD:
opt.command_fd = translate_sys2libc_fd_int (pargs.r.ret_int, 0); opt.command_fd = translate_sys2libc_fdstr (pargs.r.ret_str, 0);
if (! gnupg_fd_valid (opt.command_fd)) if (! gnupg_fd_valid (opt.command_fd))
log_error ("command-fd is invalid: %s\n", strerror (errno)); log_error ("command-fd is invalid: %s\n", strerror (errno));
break; break;
@ -3526,7 +3526,7 @@ main (int argc, char **argv)
opt.override_session_key = pargs.r.ret_str; opt.override_session_key = pargs.r.ret_str;
break; break;
case oOverrideSessionKeyFD: case oOverrideSessionKeyFD:
ovrseskeyfd = translate_sys2libc_fd_int (pargs.r.ret_int, 0); ovrseskeyfd = translate_sys2libc_fdstr (pargs.r.ret_str, 0);
break; break;
case oMergeOnly: case oMergeOnly:
deprecated_warning(configname,pargs.lineno,"--merge-only", deprecated_warning(configname,pargs.lineno,"--merge-only",

View File

@ -82,9 +82,9 @@ static gpgrt_opt_t opts[] = {
ARGPARSE_s_s (oOutput, "output", N_("|FILE|write output to FILE")), ARGPARSE_s_s (oOutput, "output", N_("|FILE|write output to FILE")),
ARGPARSE_s_n (oIgnoreTimeConflict, "ignore-time-conflict", ARGPARSE_s_n (oIgnoreTimeConflict, "ignore-time-conflict",
N_("make timestamp conflicts only a warning")), N_("make timestamp conflicts only a warning")),
ARGPARSE_s_i (oStatusFD, "status-fd", ARGPARSE_s_s (oStatusFD, "status-fd",
N_("|FD|write status info to this FD")), N_("|FD|write status info to this FD")),
ARGPARSE_s_i (oLoggerFD, "logger-fd", "@"), ARGPARSE_s_s (oLoggerFD, "logger-fd", "@"),
ARGPARSE_s_s (oLoggerFile, "log-file", "@"), ARGPARSE_s_s (oLoggerFile, "log-file", "@"),
ARGPARSE_s_s (oHomedir, "homedir", "@"), ARGPARSE_s_s (oHomedir, "homedir", "@"),
ARGPARSE_s_s (oWeakDigest, "weak-digest", 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 oKeyring: append_to_strlist( &nrings, pargs.r.ret_str); break;
case oOutput: opt.outfile = pargs.r.ret_str; break; case oOutput: opt.outfile = pargs.r.ret_str; break;
case oStatusFD: case oStatusFD:
set_status_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1)); set_status_fd (translate_sys2libc_fdstr (pargs.r.ret_str, 1));
break; break;
case oLoggerFD: case oLoggerFD:
log_set_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1)); log_set_fd (translate_sys2libc_fdstr (pargs.r.ret_str, 1));
break; break;
case oLoggerFile: case oLoggerFile:
log_set_file (pargs.r.ret_str); log_set_file (pargs.r.ret_str);

View File

@ -290,7 +290,7 @@ static gpgrt_opt_t opts[] = {
ARGPARSE_s_s (oLogFile, "log-file", ARGPARSE_s_s (oLogFile, "log-file",
N_("|FILE|write server mode logs to FILE")), N_("|FILE|write server mode logs to FILE")),
ARGPARSE_s_n (oNoLogFile, "no-log-file", "@"), ARGPARSE_s_n (oNoLogFile, "no-log-file", "@"),
ARGPARSE_s_i (oLoggerFD, "logger-fd", "@"), ARGPARSE_s_s (oLoggerFD, "logger-fd", "@"),
ARGPARSE_s_n (oLogTime, "log-time", "@"), ARGPARSE_s_n (oLogTime, "log-time", "@"),
ARGPARSE_s_n (oNoSecmemWarn, "no-secmem-warning", "@"), 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 (oNoBatch, "no-batch", "@"),
ARGPARSE_s_n (oAnswerYes, "yes", N_("assume yes on most questions")), ARGPARSE_s_n (oAnswerYes, "yes", N_("assume yes on most questions")),
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_s (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_i (oPassphraseFD, "passphrase-fd", "@"), ARGPARSE_s_s (oPassphraseFD, "passphrase-fd", "@"),
ARGPARSE_s_s (oPinentryMode, "pinentry-mode", "@"), ARGPARSE_s_s (oPinentryMode, "pinentry-mode", "@"),
@ -1156,7 +1156,7 @@ main ( int argc, char **argv)
break; break;
case oPassphraseFD: case oPassphraseFD:
pwfd = translate_sys2libc_fd_int (pargs.r.ret_int, 0); pwfd = translate_sys2libc_fdstr (pargs.r.ret_str, 0);
break; break;
case oPinentryMode: case oPinentryMode:
@ -1300,10 +1300,10 @@ main ( int argc, char **argv)
break; break;
case oStatusFD: case oStatusFD:
ctrl.status_fd = translate_sys2libc_fd_int (pargs.r.ret_int, 1); ctrl.status_fd = translate_sys2libc_fdstr (pargs.r.ret_str, 1);
break; break;
case oLoggerFD: case oLoggerFD:
log_set_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1)); log_set_fd (translate_sys2libc_fdstr (pargs.r.ret_str, 1));
break; break;
case oWithMD5Fingerprint: case oWithMD5Fingerprint:
opt.with_md5_fingerprint=1; /*fall through*/ opt.with_md5_fingerprint=1; /*fall through*/

View File

@ -94,7 +94,7 @@ static gpgrt_opt_t opts[] = {
ARGPARSE_s_n (oVerbose, "verbose", ("verbose")), ARGPARSE_s_n (oVerbose, "verbose", ("verbose")),
ARGPARSE_s_n (oQuiet, "quiet", ("be somewhat more quiet")), ARGPARSE_s_n (oQuiet, "quiet", ("be somewhat more quiet")),
ARGPARSE_s_s (oDebug, "debug", "@"), ARGPARSE_s_s (oDebug, "debug", "@"),
ARGPARSE_s_i (oStatusFD, "status-fd", N_("|FD|write status info to this FD")), ARGPARSE_s_s (oStatusFD, "status-fd", N_("|FD|write status info to this FD")),
ARGPARSE_s_n (oWithColons, "with-colons", "@"), ARGPARSE_s_n (oWithColons, "with-colons", "@"),
ARGPARSE_s_n (oNoAutostart, "no-autostart", "@"), ARGPARSE_s_n (oNoAutostart, "no-autostart", "@"),
ARGPARSE_s_s (oAgentProgram, "agent-program", "@"), 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 oAgentProgram: opt.agent_program = pargs->r.ret_str; break;
case oStatusFD: case oStatusFD:
gnupg_set_status_fd (translate_sys2libc_fd_int (pargs->r.ret_int, 1)); gnupg_set_status_fd (translate_sys2libc_fdstr (pargs->r.ret_str, 1));
break; break;
case oWithColons: opt.with_colons = 1; break; case oWithColons: opt.with_colons = 1; break;

View File

@ -94,7 +94,7 @@ static gpgrt_opt_t opts[] = {
ARGPARSE_s_s (oDebug, "debug", "@"), ARGPARSE_s_s (oDebug, "debug", "@"),
ARGPARSE_s_s (oGpgProgram, "gpg", "@"), ARGPARSE_s_s (oGpgProgram, "gpg", "@"),
ARGPARSE_s_s (oGpgsmProgram, "gpgsm", "@"), ARGPARSE_s_s (oGpgsmProgram, "gpgsm", "@"),
ARGPARSE_s_i (oStatusFD, "status-fd", N_("|FD|write status info to this FD")), ARGPARSE_s_s (oStatusFD, "status-fd", N_("|FD|write status info to this FD")),
ARGPARSE_s_n (oWithColons, "with-colons", "@"), ARGPARSE_s_n (oWithColons, "with-colons", "@"),
ARGPARSE_s_n (oNoAutostart, "no-autostart", "@"), ARGPARSE_s_n (oNoAutostart, "no-autostart", "@"),
ARGPARSE_s_s (oAgentProgram, "agent-program", "@"), 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 oAgentProgram: opt.agent_program = pargs->r.ret_str; break;
case oStatusFD: case oStatusFD:
gnupg_set_status_fd (translate_sys2libc_fd_int (pargs->r.ret_int, 1)); gnupg_set_status_fd (translate_sys2libc_fdstr (pargs->r.ret_str, 1));
break; break;
case oWithColons: opt.with_colons = 1; break; case oWithColons: opt.with_colons = 1; break;

View File

@ -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 (oSAS, "sas", N_("|SAS|the SAS as shown by the peer")),
ARGPARSE_s_s (oDebug, "debug", "@"), ARGPARSE_s_s (oDebug, "debug", "@"),
ARGPARSE_s_s (oOutput, "output", N_("|FILE|write the request to FILE")), ARGPARSE_s_s (oOutput, "output", N_("|FILE|write the request to FILE")),
ARGPARSE_s_i (oStatusFD, "status-fd", N_("|FD|write status info to this FD")), ARGPARSE_s_s (oStatusFD, "status-fd", N_("|FD|write status info to this FD")),
ARGPARSE_s_s (oHomedir, "homedir", "@"), ARGPARSE_s_s (oHomedir, "homedir", "@"),
@ -390,7 +390,7 @@ main (int argc, char **argv)
break; break;
case oStatusFD: case oStatusFD:
set_status_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1)); set_status_fd (translate_sys2libc_fdstr (pargs.r.ret_str, 1));
break; break;
case oHomedir: case oHomedir:

View File

@ -115,7 +115,7 @@ static gpgrt_opt_t opts[] = {
ARGPARSE_s_s (oGpgProgram, "gpg", "@"), ARGPARSE_s_s (oGpgProgram, "gpg", "@"),
ARGPARSE_s_n (oSend, "send", "send the mail using sendmail"), ARGPARSE_s_n (oSend, "send", "send the mail using sendmail"),
ARGPARSE_s_s (oOutput, "output", "|FILE|write the mail to FILE"), ARGPARSE_s_s (oOutput, "output", "|FILE|write the mail to FILE"),
ARGPARSE_s_i (oStatusFD, "status-fd", N_("|FD|write status info to this FD")), ARGPARSE_s_s (oStatusFD, "status-fd", N_("|FD|write status info to this FD")),
ARGPARSE_s_n (oNoAutostart, "no-autostart", "@"), ARGPARSE_s_n (oNoAutostart, "no-autostart", "@"),
ARGPARSE_s_n (oWithColons, "with-colons", "@"), ARGPARSE_s_n (oWithColons, "with-colons", "@"),
ARGPARSE_s_s (oBlacklist, "blacklist", "@"), 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; fake_submission_addr = pargs->r.ret_str;
break; break;
case oStatusFD: case oStatusFD:
wks_set_status_fd (translate_sys2libc_fd_int (pargs->r.ret_int, 1)); wks_set_status_fd (translate_sys2libc_fdstr (pargs->r.ret_str, 1));
break; break;
case oWithColons: case oWithColons:
opt.with_colons = 1; opt.with_colons = 1;

View File

@ -118,7 +118,7 @@ static gpgrt_opt_t opts[] =
{ oQuiet, "quiet", 0, N_("quiet") }, { oQuiet, "quiet", 0, N_("quiet") },
{ oDryRun, "dry-run", 0, N_("do not make any changes") }, { oDryRun, "dry-run", 0, N_("do not make any changes") },
{ oRuntime, "runtime", 0, N_("activate changes at runtime, if possible") }, { oRuntime, "runtime", 0, N_("activate changes at runtime, if possible") },
ARGPARSE_s_i (oStatusFD, "status-fd", ARGPARSE_s_s (oStatusFD, "status-fd",
N_("|FD|write status info to this FD")), N_("|FD|write status info to this FD")),
/* hidden options */ /* hidden options */
{ oHomedir, "homedir", 2, "@" }, { oHomedir, "homedir", 2, "@" },
@ -645,7 +645,7 @@ main (int argc, char **argv)
case oBuilddir: gnupg_set_builddir (pargs.r.ret_str); break; case oBuilddir: gnupg_set_builddir (pargs.r.ret_str); break;
case oNull: opt.null = 1; break; case oNull: opt.null = 1; break;
case oStatusFD: case oStatusFD:
set_status_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1)); set_status_fd (translate_sys2libc_fdstr (pargs.r.ret_str, 1));
break; break;
case oShowSocket: show_socket = 1; break; case oShowSocket: show_socket = 1; break;
case oChUid: changeuser = pargs.r.ret_str; break; case oChUid: changeuser = pargs.r.ret_str; break;

View File

@ -1246,13 +1246,19 @@ gpgtar_create (char **inpattern, const char *files_from, int null_names,
ccparray_put (&ccp, "--no"); ccparray_put (&ccp, "--no");
if (opt.require_compliance) if (opt.require_compliance)
ccparray_put (&ccp, "--require-compliance"); ccparray_put (&ccp, "--require-compliance");
if (opt.status_fd != -1) if (opt.status_fd)
{ {
static char tmpbuf[40]; static char tmpbuf[40];
es_syshd_t hd;
snprintf (tmpbuf, sizeof tmpbuf, "--status-fd=%d", opt.status_fd); snprintf (tmpbuf, sizeof tmpbuf, "--status-fd=%s", opt.status_fd);
ccparray_put (&ccp, tmpbuf); ccparray_put (&ccp, tmpbuf);
except[0] = opt.status_fd; es_syshd (opt.status_stream, &hd);
#ifdef HAVE_W32_SYSTEM
except[0] = hd.u.handle;
#else
except[0] = hd.u.fd;
#endif
} }
ccparray_put (&ccp, "--output"); ccparray_put (&ccp, "--output");

View File

@ -392,13 +392,19 @@ gpgtar_extract (const char *filename, int decrypt)
ccparray_put (&ccp, "--batch"); ccparray_put (&ccp, "--batch");
if (opt.require_compliance) if (opt.require_compliance)
ccparray_put (&ccp, "--require-compliance"); ccparray_put (&ccp, "--require-compliance");
if (opt.status_fd != -1) if (opt.status_fd)
{ {
static char tmpbuf[40]; static char tmpbuf[40];
es_syshd_t hd;
snprintf (tmpbuf, sizeof tmpbuf, "--status-fd=%d", opt.status_fd); snprintf (tmpbuf, sizeof tmpbuf, "--status-fd=%s", opt.status_fd);
ccparray_put (&ccp, tmpbuf); ccparray_put (&ccp, tmpbuf);
except[0] = opt.status_fd; es_syshd (opt.status_stream, &hd);
#ifdef HAVE_W32_SYSTEM
except[0] = hd.u.handle;
#else
except[0] = hd.u.fd;
#endif
} }
if (opt.with_log) if (opt.with_log)
{ {

View File

@ -476,13 +476,19 @@ gpgtar_list (const char *filename, int decrypt)
ccparray_put (&ccp, "--batch"); ccparray_put (&ccp, "--batch");
if (opt.require_compliance) if (opt.require_compliance)
ccparray_put (&ccp, "--require-compliance"); ccparray_put (&ccp, "--require-compliance");
if (opt.status_fd != -1) if (opt.status_fd)
{ {
static char tmpbuf[40]; static char tmpbuf[40];
es_syshd_t hd;
snprintf (tmpbuf, sizeof tmpbuf, "--status-fd=%d", opt.status_fd); snprintf (tmpbuf, sizeof tmpbuf, "--status-fd=%s", opt.status_fd);
ccparray_put (&ccp, tmpbuf); ccparray_put (&ccp, tmpbuf);
except[0] = opt.status_fd; es_syshd (opt.status_stream, &hd);
#ifdef HAVE_W32_SYSTEM
except[0] = hd.u.handle;
#else
except[0] = hd.u.fd;
#endif
} }
ccparray_put (&ccp, "--output"); ccparray_put (&ccp, "--output");
ccparray_put (&ccp, "-"); ccparray_put (&ccp, "-");

View File

@ -125,7 +125,7 @@ static gpgrt_opt_t opts[] = {
ARGPARSE_s_n (oBatch, "batch", "@"), ARGPARSE_s_n (oBatch, "batch", "@"),
ARGPARSE_s_n (oAnswerYes, "yes", "@"), ARGPARSE_s_n (oAnswerYes, "yes", "@"),
ARGPARSE_s_n (oAnswerNo, "no", "@"), ARGPARSE_s_n (oAnswerNo, "no", "@"),
ARGPARSE_s_i (oStatusFD, "status-fd", "@"), ARGPARSE_s_s (oStatusFD, "status-fd", "@"),
ARGPARSE_s_n (oRequireCompliance, "require-compliance", "@"), ARGPARSE_s_n (oRequireCompliance, "require-compliance", "@"),
ARGPARSE_s_n (oWithLog, "with-log", "@"), ARGPARSE_s_n (oWithLog, "with-log", "@"),
@ -395,7 +395,7 @@ parse_arguments (gpgrt_argparse_t *pargs, gpgrt_opt_t *popts)
case oBatch: opt.batch = 1; break; case oBatch: opt.batch = 1; break;
case oAnswerYes: opt.answer_yes = 1; break; case oAnswerYes: opt.answer_yes = 1; break;
case oAnswerNo: opt.answer_no = 1; break; case oAnswerNo: opt.answer_no = 1; break;
case oStatusFD: opt.status_fd = pargs->r.ret_int; break; case oStatusFD: opt.status_fd = pargs->r.ret_str; break;
case oRequireCompliance: opt.require_compliance = 1; break; case oRequireCompliance: opt.require_compliance = 1; break;
case oWithLog: opt.with_log = 1; break; case oWithLog: opt.with_log = 1; break;
@ -477,7 +477,7 @@ main (int argc, char **argv)
log_assert (sizeof (struct ustar_raw_header) == 512); log_assert (sizeof (struct ustar_raw_header) == 512);
/* Set default options */ /* Set default options */
opt.status_fd = -1; opt.status_fd = NULL;
/* The configuraton directories for use by gpgrt_argparser. */ /* The configuraton directories for use by gpgrt_argparser. */
gpgrt_set_confdir (GPGRT_CONFDIR_SYS, gnupg_sysconfdir ()); gpgrt_set_confdir (GPGRT_CONFDIR_SYS, gnupg_sysconfdir ());
@ -509,12 +509,23 @@ main (int argc, char **argv)
/* Set status stream for our own use of --status-fd. The original /* Set status stream for our own use of --status-fd. The original
* status fd is passed verbatim to gpg. */ * status fd is passed verbatim to gpg. */
if (opt.status_fd != -1) if (opt.status_fd)
{ {
int fd = translate_sys2libc_fd_int (opt.status_fd, 1); int fd = -1;
if (!gnupg_fd_valid (fd)) #ifdef HAVE_W32_SYSTEM
log_fatal ("status-fd is invalid: %s\n", strerror (errno)); gnupg_fd_t hd;
err = gnupg_sys2libc_fdstr (opt.status_fd, 1, &hd, NULL);
if ((uintptr_t)hd == 1)
fd = 1;
else if ((uintptr_t)hd == 2)
fd = 2;
#else
err = gnupg_sys2libc_fdstr (opt.status_fd, 1, NULL, &fd);
#endif
if (err)
log_fatal ("status-fd is invalid: %s\n", gpg_strerror (err));
if (fd == 1) if (fd == 1)
{ {
@ -526,7 +537,16 @@ main (int argc, char **argv)
opt.status_stream = es_stderr; opt.status_stream = es_stderr;
else else
{ {
opt.status_stream = es_fdopen (fd, "w"); es_syshd_t syshd;
#ifdef HAVE_W32_SYSTEM
syshd.type = ES_SYSHD_HANDLE;
syshd.u.handle = hd;
#else
syshd.type = ES_SYSHD_FD;
syshd.u.handle = fd;
#endif
opt.status_stream = es_sysopen (&syshd, "w");
if (opt.status_stream) if (opt.status_stream)
es_setvbuf (opt.status_stream, NULL, _IOLBF, 0); es_setvbuf (opt.status_stream, NULL, _IOLBF, 0);
} }

View File

@ -44,7 +44,7 @@ struct
int batch; int batch;
int answer_yes; int answer_yes;
int answer_no; int answer_no;
int status_fd; const char *status_fd;
estream_t status_stream; estream_t status_stream;
int require_compliance; int require_compliance;
int with_log; int with_log;