1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

gpg: Emit FAILURE stati now in almost all cases.

* g10/cpr.c (write_status_failure): Make it print only once.
* g10/gpg.c (wrong_args): Bump error counter.
(g10_exit): Print a FAILURE status if we ever did a log_error etc.
(main): Use log_error instead of log_fatal at one place.  Print a
FAILURE status for a bad option.  Ditto for certain exit points so
that we can see different error locations.
--

This makes it easier to detect errors by tools which have no way to
get the exit code (e.g. due to double forking).

GnuPG-bug-id: 3872
Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2018-04-06 17:32:08 +02:00
parent cfd0779808
commit 0336e5d1a7
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
3 changed files with 65 additions and 11 deletions

View file

@ -1464,7 +1464,7 @@ main ( int argc, char **argv)
DIM (compliance_options),
opt.quiet);
if (compliance < 0)
gpgsm_exit (1);
log_inc_errorcount (); /* Force later termination. */
opt.compliance = compliance;
}
break;
@ -1493,7 +1493,11 @@ main ( int argc, char **argv)
NULL);
if (log_get_errorcount(0))
gpgsm_exit(2);
{
gpgsm_status_with_error (&ctrl, STATUS_FAILURE,
"option-parser", gpg_error (GPG_ERR_GENERAL));
gpgsm_exit(2);
}
if (pwfd != -1) /* Read the passphrase now. */
read_passphrase_from_fd (pwfd);
@ -1660,7 +1664,11 @@ main ( int argc, char **argv)
gnupg_compliance_option_string (opt.compliance));
if (log_get_errorcount(0))
gpgsm_exit(2);
{
gpgsm_status_with_error (&ctrl, STATUS_FAILURE, "option-postprocessing",
gpg_error (GPG_ERR_GENERAL));
gpgsm_exit (2);
}
/* Set the random seed file. */
if (use_random_seed)