Changeset 9d6c0f2 for protocols


Ignore:
Timestamp:
2016-05-15T16:16:37Z (8 years ago)
Author:
jgeboski <jgeboski@…>
Parents:
4fe91a1
Message:

Implemented ABI checking for external plugins

As of now, bitlbee will load any plugin regardless of the ABI it was
built against. This is really problematic when structures or symbols
are changed within bitlbee. This often leads to the plugin not loading
or the plugin acting in an undefined way. Typically a simple rebuild of
the plugin will resolve such issues, but many users have no idea that
this is required after they have updated bitlbee.

Each plugin must now have an init_plugin_abi() function along with its
init_plugin() function. This new function is called very early in the
plugin loading process to ensure the plugin actually matches the ABI of
bitlbee. The constant value of BITLBEE_ABI_VERSION_CODE is returned by
the function, which embeds the constant value into the plugin. This
value is then read by bitlbee upon every plugin load to ensure that the
proper ABI is use. If not, bitlbee will refuse to load the plugin.

The boiler-plate implementation of init_plugin_abi():

guint init_plugin_abi(void)
{

return BITLBEE_ABI_VERSION_CODE;

}

Third party plugins may also want to provide backwards compatibility
with older bitlbee versions by defining the missing version macro:

#ifndef BITLBEE_ABI_VERSION_CODE
#define BITLBEE_ABI_VERSION_CODE 0
#endif

Location:
protocols
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    r4fe91a1 r9d6c0f2  
    4242gboolean load_plugin(char *path)
    4343{
     44        guint abi;
     45        guint (*abi_function) (void);
    4446        void (*init_function) (void);
    4547
     
    5153        }
    5254
     55        if (!g_module_symbol(mod, "init_plugin_abi", (gpointer *) &abi_function)) {
     56                log_message(LOGLVL_WARNING, "Can't find function `init_plugin_abi' in `%s'\n", path);
     57                g_module_close(mod);
     58                return FALSE;
     59        }
     60
     61        abi = abi_function();
     62
     63        if (abi != BITLBEE_ABI_VERSION_CODE) {
     64                log_message(LOGLVL_WARNING,
     65                            "`%s' uses ABI %u but %u is required\n",
     66                            path, abi, BITLBEE_ABI_VERSION_CODE);
     67                g_module_close(mod);
     68                return FALSE;
     69        }
     70
    5371        if (!g_module_symbol(mod, "init_plugin", (gpointer *) &init_function)) {
    5472                log_message(LOGLVL_WARNING, "Can't find function `init_plugin' in `%s'\n", path);
     73                g_module_close(mod);
    5574                return FALSE;
    5675        }
  • protocols/skype/skype.c

    r4fe91a1 r9d6c0f2  
    17631763        register_protocol(ret);
    17641764}
     1765
     1766guint init_plugin_abi(void)
     1767{
     1768        return BITLBEE_ABI_VERSION_CODE;
     1769}
Note: See TracChangeset for help on using the changeset viewer.