From 0336e5d1a7b9d46e06c838e6a98aecfcc9542882 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 6 Apr 2018 17:32:08 +0200 Subject: 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 --- sm/gpgsm.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'sm/gpgsm.c') diff --git a/sm/gpgsm.c b/sm/gpgsm.c index b81e3b6e8..da1783df2 100644 --- a/sm/gpgsm.c +++ b/sm/gpgsm.c @@ -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) -- cgit v1.2.3