summaryrefslogtreecommitdiffstats
path: root/g10/call-dirmngr.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2016-01-08 10:33:19 +0100
committerWerner Koch <wk@gnupg.org>2016-01-08 10:33:19 +0100
commit2aa42baaf3dd7c3ae613ae0c61760a17c8adfcd0 (patch)
tree999020286b5be3264f6803aabb486e081482a69e /g10/call-dirmngr.c
parentcommon: New function compare_version_strings. (diff)
downloadgnupg2-2aa42baaf3dd7c3ae613ae0c61760a17c8adfcd0.tar.xz
gnupg2-2aa42baaf3dd7c3ae613ae0c61760a17c8adfcd0.zip
Print warnings if old daemon versions are used.
* common/status.h (STATUS_WARNING): New. * g10/call-agent.c (warn_version_mismatch): New. (start_agent): Call warn function. * g10/call-dirmngr.c: Include status.h. (warn_version_mismatch): New. (create_context): Call warn function. * sm/call-agent.c (warn_version_mismatch): New. (start_agent): Call warn function. (gpgsm_agent_learn): Call warn function. * sm/call-dirmngr.c (warn_version_mismatch): New. (prepare_dirmngr): Call warn function. -- We have seen too often bug reports which are due to still running old versions of the daemons. To catch this problematic use we now print warning messages and also provide the warning via the status interface. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'g10/call-dirmngr.c')
-rw-r--r--g10/call-dirmngr.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/g10/call-dirmngr.c b/g10/call-dirmngr.c
index b1c856d77..360e12743 100644
--- a/g10/call-dirmngr.c
+++ b/g10/call-dirmngr.c
@@ -38,6 +38,7 @@
#include "i18n.h"
#include "asshelp.h"
#include "keyserver.h"
+#include "status.h"
#include "call-dirmngr.h"
@@ -132,6 +133,40 @@ gpg_dirmngr_deinit_session_data (ctrl_t ctrl)
}
+/* Print a warning if the server's version number is less than our
+ version number. Returns an error code on a connection problem. */
+static gpg_error_t
+warn_version_mismatch (assuan_context_t ctx, const char *servername)
+{
+ gpg_error_t err;
+ char *serverversion;
+ const char *myversion = strusage (13);
+
+ err = get_assuan_server_version (ctx, 0, &serverversion);
+ if (err)
+ log_error (_("error getting version from '%s': %s\n"),
+ servername, gpg_strerror (err));
+ else if (!compare_version_strings (serverversion, myversion))
+ {
+ char *warn;
+
+ warn = xtryasprintf (_("server '%s' is older than us (%s < %s)"),
+ servername, serverversion, myversion);
+ if (!warn)
+ err = gpg_error_from_syserror ();
+ else
+ {
+ log_info (_("WARNING: %s\n"), warn);
+ write_status_strings (STATUS_WARNING, "server_version_mismatch 0",
+ " ", warn, NULL);
+ xfree (warn);
+ }
+ }
+ xfree (serverversion);
+ return err;
+}
+
+
/* Try to connect to the Dirmngr via a socket or spawn it if possible.
Handle the server's initial greeting and set global options. */
static gpg_error_t
@@ -157,7 +192,7 @@ create_context (ctrl_t ctrl, assuan_context_t *r_ctx)
log_info (_("no dirmngr running in this session\n"));
}
}
- else if (!err)
+ else if (!err && !(err = warn_version_mismatch (ctx, DIRMNGR_NAME)))
{
char *line;