diff options
Diffstat (limited to 'tools/gpgtar.c')
-rw-r--r-- | tools/gpgtar.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/tools/gpgtar.c b/tools/gpgtar.c index ea1e1e751..f93ba2e65 100644 --- a/tools/gpgtar.c +++ b/tools/gpgtar.c @@ -127,7 +127,7 @@ static gpgrt_opt_t opts[] = { ARGPARSE_s_n (oBatch, "batch", "@"), ARGPARSE_s_n (oAnswerYes, "yes", "@"), 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 (oWithLog, "with-log", "@"), @@ -398,7 +398,7 @@ parse_arguments (gpgrt_argparse_t *pargs, gpgrt_opt_t *popts) case oBatch: opt.batch = 1; break; case oAnswerYes: opt.answer_yes = 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 oWithLog: opt.with_log = 1; break; @@ -480,7 +480,7 @@ main (int argc, char **argv) log_assert (sizeof (struct ustar_raw_header) == 512); /* Set default options */ - opt.status_fd = -1; + opt.status_fd = NULL; /* The configuraton directories for use by gpgrt_argparser. */ gpgrt_set_confdir (GPGRT_CONFDIR_SYS, gnupg_sysconfdir ()); @@ -512,31 +512,32 @@ main (int argc, char **argv) /* Set status stream for our own use of --status-fd. The original * 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); + es_syshd_t syshd; - if (!gnupg_fd_valid (fd)) - log_fatal ("status-fd is invalid: %s\n", strerror (errno)); + err = gnupg_parse_fdstr (opt.status_fd, &syshd); + if (err) + log_fatal ("status-fd is invalid: %s\n", gpg_strerror (err)); - if (fd == 1) + if (syshd.type == ES_SYSHD_FD && syshd.u.fd == 1) { opt.status_stream = es_stdout; if (!skip_crypto) log_fatal ("using stdout for the status-fd is not possible\n"); } - else if (fd == 2) + else if (syshd.type == ES_SYSHD_FD && syshd.u.fd == 2) opt.status_stream = es_stderr; else { - opt.status_stream = es_fdopen (fd, "w"); + opt.status_stream = es_sysopen (&syshd, "w"); if (opt.status_stream) es_setvbuf (opt.status_stream, NULL, _IOLBF, 0); } if (!opt.status_stream) { - log_fatal ("can't open fd %d for status output: %s\n", - fd, strerror (errno)); + log_fatal ("can't open fd %s for status output: %s\n", + opt.status_fd, strerror (errno)); } } |