From a65884e6b6894c56492771b0a1bbb8458941a991 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Thu, 16 Jun 2011 13:10:55 +0200 Subject: vdagents: add VDAGENTD_VERSION message Disconnects vdagent if version mismatch. --- src/vdagent.c | 12 ++++++++++++ src/vdagentd-proto-strings.h | 1 + src/vdagentd-proto.h | 1 + src/vdagentd.c | 3 +++ 4 files changed, 17 insertions(+) diff --git a/src/vdagent.c b/src/vdagent.c index 2b69865..db18617 100644 --- a/src/vdagent.c +++ b/src/vdagent.c @@ -19,6 +19,10 @@ along with this program. If not, see . */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include #include @@ -68,6 +72,14 @@ void daemon_read_complete(struct udscs_connection **connp, vdagent_x11_clipboard_release(x11, header->arg1); free(data); break; + case VDAGENTD_VERSION: + if (strcmp(data, VERSION) != 0) { + fprintf(logfile, + "Fatal vdagentd version mismatch: got %s expected %s\n", + data, VERSION); + udscs_destroy_connection(connp); + } + break; default: if (verbose) fprintf(logfile, "Unknown message from vdagentd type: %d\n", diff --git a/src/vdagentd-proto-strings.h b/src/vdagentd-proto-strings.h index 02adf01..f39e25b 100644 --- a/src/vdagentd-proto-strings.h +++ b/src/vdagentd-proto-strings.h @@ -29,6 +29,7 @@ static const char * const vdagentd_messages[] = { "clipboard request", "clipboard data", "clipboard release", + "version", }; #endif diff --git a/src/vdagentd-proto.h b/src/vdagentd-proto.h index e570d2b..9d96540 100644 --- a/src/vdagentd-proto.h +++ b/src/vdagentd-proto.h @@ -33,6 +33,7 @@ enum { VDAGENTD_CLIPBOARD_REQUEST, /* arg1: selection, arg 2 = type */ VDAGENTD_CLIPBOARD_DATA, /* arg1: sel, arg 2: type, data: data */ VDAGENTD_CLIPBOARD_RELEASE, /* arg1: selection */ + VDAGENTD_VERSION, /* daemon -> client, data: version string */ VDAGENTD_NO_MESSAGES /* Must always be last */ }; diff --git a/src/vdagentd.c b/src/vdagentd.c index be6ef1f..3c05ef0 100644 --- a/src/vdagentd.c +++ b/src/vdagentd.c @@ -522,6 +522,9 @@ void agent_connect(struct udscs_connection *conn) udscs_set_user_data(conn, (void *)agent_data); update_active_session_connection(); + udscs_write(conn, VDAGENTD_VERSION, 0, 0, + (uint8_t *)VERSION, strlen(VERSION) + 1); + if (mon_config) udscs_write(conn, VDAGENTD_MONITORS_CONFIG, 0, 0, (uint8_t *)mon_config, sizeof(VDAgentMonitorsConfig) + -- cgit v1.2.3