[Dovecot] [PATCH] dovadm plugins underlinking
Hi, Running doveadm on Alpine Linux will show various underlinking errors: /usr/bin/doveadm: symbol 'acl_user_module': can't resolve symbol in lib '/usr/lib/dovecot/doveadm/lib10_doveadm_acl_plugin.so'. /usr/bin/doveadm: symbol 'acl_identifier_parse': can't resolve symbol in lib '/usr/lib/dovecot/doveadm/lib10_doveadm_acl_plugin.so'. ... (complete list is found here: http://bugs.alpinelinux.org/issues/1274) I understand that those are "harmless" (at least as long as you dont use those plugins), and even if some dynamic linkers are forgiving, the doveadm plugin modules are technically underlinked. The lib10_doveadm_acl_plugin.so uses symbol acl_user_module: $ nm -D /usr/lib/dovecot/doveadm/lib10_doveadm_acl_plugin.so | grep acl_user_module U acl_user_module That symbol is defined in lib01_acl_plugin.so: $ nm -D /usr/lib/dovecot/lib01_acl_plugin.so | grep acl_user_module 000000000020fb80 D acl_user_module Which means that lib10_doveadm_acl_plugin.so should be directly linked to lib01_acl_plugin.so. But it is not: $ readelf -d /usr/lib/dovecot/doveadm/lib10_doveadm_acl_plugin.so | grep NEEDED 0x0000000000000001 (NEEDED) Shared library: [librt.so.0.9.32] 0x0000000000000001 (NEEDED) Shared library: [libc.so.0.9.32] Below is a patch that should solve it. --- diff -r 4d268e810c15 src/plugins/acl/Makefile.am --- a/src/plugins/acl/Makefile.am Mon Oct 08 08:53:54 2012 +0300 +++ b/src/plugins/acl/Makefile.am Wed Oct 10 11:03:49 2012 +0200 @@ -10,7 +10,8 @@ -I$(top_srcdir)/src/doveadm NOPLUGIN_LDFLAGS = -lib10_doveadm_acl_plugin_la_LDFLAGS = -module -avoid-version +lib10_doveadm_acl_plugin_la_LDFLAGS = -module -avoid-version -Wl,-rpath,$(moduledir) +lib10_doveadm_acl_plugin_la_LIBADD = $(module_LTLIBRARIES) lib01_acl_plugin_la_LDFLAGS = -module -avoid-version module_LTLIBRARIES = \ diff -r 4d268e810c15 src/plugins/expire/Makefile.am --- a/src/plugins/expire/Makefile.am Mon Oct 08 08:53:54 2012 +0300 +++ b/src/plugins/expire/Makefile.am Wed Oct 10 11:03:49 2012 +0200 @@ -14,7 +14,8 @@ -I$(top_srcdir)/src/doveadm NOPLUGIN_LDFLAGS = -lib10_doveadm_expire_plugin_la_LDFLAGS = -module -avoid-version +lib10_doveadm_expire_plugin_la_LDFLAGS = -module -avoid-version -Wl,-rpath,$(moduledir) +lib10_doveadm_expire_plugin_la_LIBADD = $(module_LTLIBRARIES) lib20_expire_plugin_la_LDFLAGS = -module -avoid-version module_LTLIBRARIES = \ diff -r 4d268e810c15 src/plugins/fts/Makefile.am --- a/src/plugins/fts/Makefile.am Mon Oct 08 08:53:54 2012 +0300 +++ b/src/plugins/fts/Makefile.am Wed Oct 10 11:03:49 2012 +0200 @@ -11,7 +11,8 @@ -I$(top_srcdir)/src/doveadm NOPLUGIN_LDFLAGS = -lib20_doveadm_fts_plugin_la_LDFLAGS = -module -avoid-version +lib20_doveadm_fts_plugin_la_LDFLAGS = -module -avoid-version -Wl,-rpath,$(moduledir) +lib20_doveadm_fts_plugin_la_LIBADD = $(module_LTLIBRARIES) lib20_fts_plugin_la_LDFLAGS = -module -avoid-version module_LTLIBRARIES = \ diff -r 4d268e810c15 src/plugins/quota/Makefile.am --- a/src/plugins/quota/Makefile.am Mon Oct 08 08:53:54 2012 +0300 +++ b/src/plugins/quota/Makefile.am Wed Oct 10 11:03:49 2012 +0200 @@ -11,7 +11,8 @@ -I$(top_srcdir)/src/doveadm NOPLUGIN_LDFLAGS = -lib10_doveadm_quota_plugin_la_LDFLAGS = -module -avoid-version +lib10_doveadm_quota_plugin_la_LDFLAGS = -module -avoid-version -Wl,-rpath,$(moduledir) +lib10_doveadm_quota_plugin_la_LIBADD = $(module_LTLIBRARIES) lib10_quota_plugin_la_LDFLAGS = -module -avoid-version module_LTLIBRARIES = \ diff -r 4d268e810c15 src/plugins/zlib/Makefile.am --- a/src/plugins/zlib/Makefile.am Mon Oct 08 08:53:54 2012 +0300 +++ b/src/plugins/zlib/Makefile.am Wed Oct 10 11:03:49 2012 +0200 @@ -11,7 +11,8 @@ -I$(top_srcdir)/src/doveadm NOPLUGIN_LDFLAGS = -lib10_doveadm_zlib_plugin_la_LDFLAGS = -module -avoid-version +lib10_doveadm_zlib_plugin_la_LDFLAGS = -module -avoid-version -Wl,-rpath,$(moduledir) +lib10_doveadm_zlib_plugin_la_LIBADD = $(module_LTLIBRARIES) lib20_zlib_plugin_la_LDFLAGS = -module -avoid-version module_LTLIBRARIES = \
On 10.10.2012, at 13.00, Natanael Copa wrote:
Running doveadm on Alpine Linux will show various underlinking errors: /usr/bin/doveadm: symbol 'acl_user_module': can't resolve symbol in lib '/usr/lib/dovecot/doveadm/lib10_doveadm_acl_plugin.so'. /usr/bin/doveadm: symbol 'acl_identifier_parse': can't resolve symbol in lib '/usr/lib/dovecot/doveadm/lib10_doveadm_acl_plugin.so'. .. Which means that lib10_doveadm_acl_plugin.so should be directly linked to lib01_acl_plugin.so. But it is not: .. Below is a patch that should solve it.
I think I once did that with imap_quota plugin for quota plugin. The problem was that then it was possible to set "mail_plugins=imap_quota", which automatically loaded the quota plugin, but didn't call its quota_plugin_init() function, which caused some strange behavior (crashed probably).
With doveadm the similar behavior is done for pretty much the same reason. doveadm tries to load all of the plugins, and it intentionally fails for those that fail to load due to not being enabled in mail_plugins setting. doveadm acl command shouldn't work if acl plugin isn't enabled.
Maybe there are some other ways to make this work more nicely. There would still be time to change it for v2.2 if you have good ideas. :)
On Wed, Oct 10, 2012 at 12:22 PM, Timo Sirainen tss@iki.fi wrote:
On 10.10.2012, at 13.00, Natanael Copa wrote:
Running doveadm on Alpine Linux will show various underlinking errors:
With doveadm the similar behavior is done for pretty much the same reason. doveadm tries to load all of the plugins, and it intentionally fails for those that fail to load due to not being enabled in mail_plugins setting. doveadm acl command shouldn't work if acl plugin isn't enabled.
Why does it need to load all the plugins? Why not only try to load those who are enabled?
Maybe there are some other ways to make this work more nicely. There would still be time to change it for v2.2 if you have good ideas. :)
Link statically? Or only link in the .o files that has the needed symbols?
I'm not familiar with the code, but how about adding an char* adm_module to the module struct, and then instead of trying to dlopen all in doveadm dir, loop through all the already loaded modules and dlopen(loaded_module->adm_module)?
-- Natanael Copa
On 10.10.2012, at 15.17, Natanael Copa wrote:
On Wed, Oct 10, 2012 at 12:22 PM, Timo Sirainen tss@iki.fi wrote:
On 10.10.2012, at 13.00, Natanael Copa wrote:
Running doveadm on Alpine Linux will show various underlinking errors:
With doveadm the similar behavior is done for pretty much the same reason. doveadm tries to load all of the plugins, and it intentionally fails for those that fail to load due to not being enabled in mail_plugins setting. doveadm acl command shouldn't work if acl plugin isn't enabled.
Why does it need to load all the plugins? Why not only try to load those who are enabled?
doveadm has two types of commands: mail commands and non-mail commands. The mail_plugins can add new mail features, and doveadm plugins can add more doveadm commands, which use the new mail features. But doveadm can also have plugins that add non-mail commands, which don't need anything in mail_plugins. So both cases would need to work..
participants (2)
-
Natanael Copa
-
Timo Sirainen