summaryrefslogtreecommitdiffstats
path: root/sm/gpgsm.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2018-04-06 17:32:08 +0200
committerWerner Koch <wk@gnupg.org>2018-04-06 17:32:25 +0200
commit0336e5d1a7b9d46e06c838e6a98aecfcc9542882 (patch)
treefa8cb0d1ab91dbd0b1ee6d280e3f98c2fc3b44ef /sm/gpgsm.c
parentdoc: Add a code comment about back signatures. (diff)
downloadgnupg2-0336e5d1a7b9d46e06c838e6a98aecfcc9542882.tar.xz
gnupg2-0336e5d1a7b9d46e06c838e6a98aecfcc9542882.zip
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>
Diffstat (limited to '')
-rw-r--r--sm/gpgsm.c14
1 files changed, 11 insertions, 3 deletions
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)