Ensure that plugin is always built from the same version as the main
rrdd executable. If the version numbers don't match, don't load the
plugin.
This will ensure there are no strange bugs that appear when plugin
code is not built against the same source as the main executable.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
*.conf
*.rrd
*.so
+
+version.h
+.*
#include "string.h"
#include "utils.h"
#include "plugin.h"
+#include "version.h"
static int parse_opts(const char *str, char *ow_path, size_t pathlen, double *offset)
{
struct plugin_info plugin_info = {
.name = "onewire_parser",
.init = init_onewire_parser,
+ .version = RRDD_VERSION,
};
typedef int (plugin_init_fn_t)(void);
struct plugin_info {
+ /* Plugin version, must match with main executable version */
+ const char *version;
+
/* Name of the plugin, used in debug prints */
const char *name;
#include "plugin_manager.h"
#include "plugin.h"
#include "debug.h"
+#include "version.h"
static char *exec_path;
goto out;
}
+ if (!info->version) {
+ pr_err("Plugin %s version info missing\n", path);
+ ret = -1;
+ goto out;
+ }
+
+ if (strcmp(RRDD_VERSION, info->version)) {
+ pr_err("Plugin %s version mismatch, expected %s, got %s\n",
+ path, RRDD_VERSION, info->version);
+ ret = -1;
+ goto out;
+ }
+
if (!info->init) {
pr_err("Plugin info structure has NULL .init callback\n");
goto out;