Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load plugins from multiple paths #21300

Closed
milahu opened this issue Jan 29, 2023 · 4 comments
Closed

load plugins from multiple paths #21300

milahu opened this issue Jan 29, 2023 · 4 comments
Assignees

Comments

@milahu
Copy link

milahu commented Jan 29, 2023

what

radare2 should load plugins from multiple paths

R2_LIBR_PLUGIN_PATH=/path/a:/path/b:/path/c r2

similar to MOZ_PLUGIN_PATH, QT_PLUGIN_PATH, QTWEBKIT_PLUGIN_PATH, ...

why

make radare plugins play nice with package managers like nix

downstream issues:

current situation

(i hope that im wrong but ...)

currently, plugins are loaded from *one* path

either from R2_LIBR_PLUGINS (defined on compiletime)
or from getenv("R2_LIBR_PLUGINS") (defined on runtime)

radare2/doc/plugins.md

Lines 1 to 13 in 510ddab

LIBR PLUGINS
============
Plugins must be configured using the root ./configure-plugins script.
Libraries can be compiled:
- as shared libraries (so, dylib, dll) (DEFAULT)
- as static libraries (a, lib, ..)
./configure-plugins --enable-shared --enable-dynamic
R2_LIBR_PLUGINS environment variable is honored as another search path for plugins

#define R_LIB_ENV "R2_LIBR_PLUGINS"

radare2/libr/core/libs.c

Lines 76 to 78 in 1100e12

char *p = r_sys_getenv (R_LIB_ENV);
if (p && *p) {
r_lib_opendir (core->lib, p);

R_API bool r_lib_opendir(RLib *lib, const char *path) {

R_API bool r_lib_opendir(RLib *lib, const char *path) {
// ...
#ifdef R2_LIBR_PLUGINS
	if (!path) {
		path = R2_LIBR_PLUGINS;
	}
#endif

challenges

workaround

use the R2_LIBR_PLUGINS env variable and symlink multiple plugins into one folder

related

#define R2_PLUGINS "lib/radare2/" R2_VERSION

will be replaced by #20545

#define R2_VERSION_ABI "@R2_VERSION_MAJOR@.@[email protected]"

#define R2_PLUGINS "lib/radare2/" R2_VERSION_ABI
#define R2_EXTRAS "lib/radare2-extras/" R2_VERSION_ABI
#define R2_BINDINGS "lib/radare2-bindings/" R2_VERSION_ABI

... ideally also support multiple paths for extras and bindings

@trufae
Copy link
Collaborator

trufae commented Jan 29, 2023

Please submit the patch as a pullrequest its better place to discuss code changes than issues

@milahu
Copy link
Author

milahu commented Jan 29, 2023

sorry, this is low priority because has workaround

@trufae
Copy link
Collaborator

trufae commented Jan 29, 2023

ill take a look when i have some spare time this or next week, thanks for reporting!

@trufae trufae self-assigned this Feb 21, 2023
@trufae trufae added this to the 5.8.4 - codename "smouldering" milestone Feb 21, 2023
@trufae
Copy link
Collaborator

trufae commented Feb 22, 2023

you can use the R2_LIBR_PLUGINS env var already but its just one string with the absolute path, i can split that with colons to support multoiple paths. but libr/core/libs.c already handles this env var

@radare radare closed this as completed Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants