mirror of
https://github.com/irssi/irssi.git
synced 2026-08-23 10:32:31 +02:00
module check irssi version
Add explicit checks into every module to match the Irssi version date.
This commit is contained in:
parent
0ca0c882a5
commit
0f01ed0de3
8 changed files with 56 additions and 1 deletions
|
|
@ -27,6 +27,8 @@
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
|
#include "irssi-version.h"
|
||||||
|
|
||||||
#ifdef HAVE_GMODULE
|
#ifdef HAVE_GMODULE
|
||||||
|
|
||||||
/* Returns the module name without path, "lib" prefix or ".so" suffix */
|
/* Returns the module name without path, "lib" prefix or ".so" suffix */
|
||||||
|
|
@ -160,11 +162,14 @@ static int module_load_name(const char *path, const char *rootmodule,
|
||||||
{
|
{
|
||||||
void (*module_init) (void);
|
void (*module_init) (void);
|
||||||
void (*module_deinit) (void);
|
void (*module_deinit) (void);
|
||||||
|
char *(*module_version) (void);
|
||||||
GModule *gmodule;
|
GModule *gmodule;
|
||||||
MODULE_REC *module;
|
MODULE_REC *module;
|
||||||
MODULE_FILE_REC *rec;
|
MODULE_FILE_REC *rec;
|
||||||
|
gpointer value_version = NULL;
|
||||||
gpointer value1, value2 = NULL;
|
gpointer value1, value2 = NULL;
|
||||||
char *initfunc, *deinitfunc;
|
char *versionfunc, *initfunc, *deinitfunc;
|
||||||
|
char *module_versionstr, *irssi_versionstr;
|
||||||
int found;
|
int found;
|
||||||
|
|
||||||
gmodule = module_open(path, &found);
|
gmodule = module_open(path, &found);
|
||||||
|
|
@ -176,6 +181,30 @@ static int module_load_name(const char *path, const char *rootmodule,
|
||||||
return found ? 0 : -1;
|
return found ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get the module's irssi abi version string and bail out on mismatch */
|
||||||
|
versionfunc = module_get_func(rootmodule, submodule, "abicheck");
|
||||||
|
if (!g_module_symbol(gmodule, versionfunc, &value_version)) {
|
||||||
|
g_free(versionfunc);
|
||||||
|
module_error(MODULE_ERROR_VERSION_MISMATCH, "0",
|
||||||
|
rootmodule, submodule);
|
||||||
|
g_module_close(gmodule);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
g_free(versionfunc);
|
||||||
|
module_version = value_version;
|
||||||
|
module_versionstr = module_version();
|
||||||
|
irssi_versionstr = g_strdup_printf("%d.%d", IRSSI_VERSION_DATE, IRSSI_VERSION_TIME);
|
||||||
|
if (g_strcmp0(module_versionstr, irssi_versionstr) != 0) {
|
||||||
|
module_error(MODULE_ERROR_VERSION_MISMATCH, module_versionstr,
|
||||||
|
rootmodule, submodule);
|
||||||
|
g_free(irssi_versionstr);
|
||||||
|
g_free(module_versionstr);
|
||||||
|
g_module_close(gmodule);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
g_free(irssi_versionstr);
|
||||||
|
g_free(module_versionstr);
|
||||||
|
|
||||||
/* get the module's init() and deinit() functions */
|
/* get the module's init() and deinit() functions */
|
||||||
initfunc = module_get_func(rootmodule, submodule, "init");
|
initfunc = module_get_func(rootmodule, submodule, "init");
|
||||||
deinitfunc = module_get_func(rootmodule, submodule, "deinit");
|
deinitfunc = module_get_func(rootmodule, submodule, "deinit");
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
enum {
|
enum {
|
||||||
MODULE_ERROR_ALREADY_LOADED,
|
MODULE_ERROR_ALREADY_LOADED,
|
||||||
MODULE_ERROR_LOAD,
|
MODULE_ERROR_LOAD,
|
||||||
|
MODULE_ERROR_VERSION_MISMATCH,
|
||||||
MODULE_ERROR_INVALID
|
MODULE_ERROR_INVALID
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,10 @@ static void sig_module_error(void *number, const char *data,
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
|
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
|
||||||
TXT_MODULE_LOAD_ERROR, rootmodule, submodule, data);
|
TXT_MODULE_LOAD_ERROR, rootmodule, submodule, data);
|
||||||
break;
|
break;
|
||||||
|
case MODULE_ERROR_VERSION_MISMATCH:
|
||||||
|
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
|
||||||
|
TXT_MODULE_VERSION_MISMATCH, rootmodule, submodule, data);
|
||||||
|
break;
|
||||||
case MODULE_ERROR_INVALID:
|
case MODULE_ERROR_INVALID:
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
|
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
|
||||||
TXT_MODULE_INVALID, rootmodule, submodule);
|
TXT_MODULE_INVALID, rootmodule, submodule);
|
||||||
|
|
@ -99,6 +103,7 @@ static int module_list_sub(MODULE_REC *module, int mark_type,
|
||||||
return all_dynamic;
|
return all_dynamic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void cmd_load_list(void)
|
static void cmd_load_list(void)
|
||||||
{
|
{
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,7 @@ FORMAT_REC fecommon_core_formats[] = {
|
||||||
{ "module_already_loaded", "Module {hilight $0/$1} already loaded", 2, { 0, 0 } },
|
{ "module_already_loaded", "Module {hilight $0/$1} already loaded", 2, { 0, 0 } },
|
||||||
{ "module_not_loaded", "Module {hilight $0/$1} is not loaded", 2, { 0, 0 } },
|
{ "module_not_loaded", "Module {hilight $0/$1} is not loaded", 2, { 0, 0 } },
|
||||||
{ "module_load_error", "Error loading module {hilight $0/$1}: $2", 3, { 0, 0, 0 } },
|
{ "module_load_error", "Error loading module {hilight $0/$1}: $2", 3, { 0, 0, 0 } },
|
||||||
|
{ "module_version_mismatch", "{hilight $0/$1} is version $2 but Irssi is version $V.$versiontime, cannot load", 3, { 0, 0, 0 } },
|
||||||
{ "module_invalid", "{hilight $0/$1} isn't Irssi module", 2, { 0, 0 } },
|
{ "module_invalid", "{hilight $0/$1} isn't Irssi module", 2, { 0, 0 } },
|
||||||
{ "module_loaded", "Loaded module {hilight $0/$1}", 2, { 0, 0 } },
|
{ "module_loaded", "Loaded module {hilight $0/$1}", 2, { 0, 0 } },
|
||||||
{ "module_unloaded", "Unloaded module {hilight $0/$1}", 2, { 0, 0 } },
|
{ "module_unloaded", "Unloaded module {hilight $0/$1}", 2, { 0, 0 } },
|
||||||
|
|
|
||||||
|
|
@ -166,6 +166,7 @@ enum {
|
||||||
TXT_MODULE_ALREADY_LOADED,
|
TXT_MODULE_ALREADY_LOADED,
|
||||||
TXT_MODULE_NOT_LOADED,
|
TXT_MODULE_NOT_LOADED,
|
||||||
TXT_MODULE_LOAD_ERROR,
|
TXT_MODULE_LOAD_ERROR,
|
||||||
|
TXT_MODULE_VERSION_MISMATCH,
|
||||||
TXT_MODULE_INVALID,
|
TXT_MODULE_INVALID,
|
||||||
TXT_MODULE_LOADED,
|
TXT_MODULE_LOADED,
|
||||||
TXT_MODULE_UNLOADED,
|
TXT_MODULE_UNLOADED,
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
|
#include "irssi-version.h"
|
||||||
|
|
||||||
#include "fe-common/core/printtext.h"
|
#include "fe-common/core/printtext.h"
|
||||||
|
|
||||||
|
|
@ -108,3 +109,8 @@ void irc_proxy_deinit(void)
|
||||||
{
|
{
|
||||||
proxy_listen_deinit();
|
proxy_listen_deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *irc_proxy_abicheck(void)
|
||||||
|
{
|
||||||
|
return g_strdup_printf("%d.%d", IRSSI_VERSION_DATE, IRSSI_VERSION_TIME);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "irssi-version.h"
|
||||||
|
|
||||||
#include "perl-core.h"
|
#include "perl-core.h"
|
||||||
#include "perl-common.h"
|
#include "perl-common.h"
|
||||||
|
|
@ -466,3 +467,8 @@ void perl_core_deinit(void)
|
||||||
signal_remove("script error", (SIGNAL_FUNC) sig_script_error);
|
signal_remove("script error", (SIGNAL_FUNC) sig_script_error);
|
||||||
PERL_SYS_TERM();
|
PERL_SYS_TERM();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *perl_core_abicheck(void)
|
||||||
|
{
|
||||||
|
return g_strdup_printf("%d.%d", IRSSI_VERSION_DATE, IRSSI_VERSION_TIME);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include "printtext.h"
|
#include "printtext.h"
|
||||||
#include "completion.h"
|
#include "completion.h"
|
||||||
|
#include "irssi-version.h"
|
||||||
|
|
||||||
#include "perl-core.h"
|
#include "perl-core.h"
|
||||||
|
|
||||||
|
|
@ -278,3 +279,8 @@ void fe_perl_deinit(void)
|
||||||
|
|
||||||
perl_core_print_script_error(TRUE);
|
perl_core_print_script_error(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *fe_perl_abicheck(void)
|
||||||
|
{
|
||||||
|
return g_strdup_printf("%d.%d", IRSSI_VERSION_DATE, IRSSI_VERSION_TIME);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue