diff options
author | Werner Koch <[email protected]> | 2021-06-25 07:55:27 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2021-06-25 07:55:52 +0000 |
commit | 9579c7786278b75d9c58b7c21b2f3c8bc7849810 (patch) | |
tree | 0307a60a0530fec50f538b8848f9bd0fc5fb21aa /g10/keyserver.c | |
parent | tools: Tweak ccidmon output. (diff) | |
download | gnupg-9579c7786278b75d9c58b7c21b2f3c8bc7849810.tar.gz gnupg-9579c7786278b75d9c58b7c21b2f3c8bc7849810.zip |
gpg: Let --fetch-key return an exit code on failure.
* g10/keyserver.c (keyserver_fetch): Return an error code.
* g10/gpg.c (main) <aFetchKeys>: Return 1 in case of no data.
--
GnuPG-bug-id: 5376
Diffstat (limited to 'g10/keyserver.c')
-rw-r--r-- | g10/keyserver.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/g10/keyserver.c b/g10/keyserver.c index f3f7c09f6..f6d12e25e 100644 --- a/g10/keyserver.c +++ b/g10/keyserver.c @@ -1648,6 +1648,8 @@ keyserver_fetch (ctrl_t ctrl, strlist_t urilist, int origin) strlist_t sl; estream_t datastream; unsigned int save_options = opt.keyserver_options.import_options; + int any_success = 0; + gpg_error_t firsterr = 0; /* Switch on fast-import, since fetch can handle more than one import and we don't want each set to rebuild the trustdb. @@ -1671,13 +1673,25 @@ keyserver_fetch (ctrl_t ctrl, strlist_t urilist, int origin) import_print_stats (stats_handle); import_release_stats_handle (stats_handle); + any_success = 1; } else - log_info (_("WARNING: unable to fetch URI %s: %s\n"), - sl->d, gpg_strerror (err)); + { + log_info (_("WARNING: unable to fetch URI %s: %s\n"), + sl->d, gpg_strerror (err)); + if (!firsterr) + firsterr = err; + } es_fclose (datastream); } + if (!urilist) + err = gpg_error (GPG_ERR_NO_NAME); + else if (any_success) + err = 0; + else + err = firsterr; + opt.keyserver_options.import_options = save_options; /* If the original options didn't have fast import, and the trustdb @@ -1685,7 +1699,7 @@ keyserver_fetch (ctrl_t ctrl, strlist_t urilist, int origin) if (!(opt.keyserver_options.import_options&IMPORT_FAST)) check_or_update_trustdb (ctrl); - return 0; + return err; } |