From 12dffc105ac6e992120932157fb413d1b759300a Mon Sep 17 00:00:00 2001 From: Richard Patel Date: Sat, 12 Feb 2022 00:20:54 +0100 Subject: [PATCH] Load AccountsDB plugins relative to plugin config (#23000) --- .../src/accountsdb_plugin_service.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/accountsdb-plugin-manager/src/accountsdb_plugin_service.rs b/accountsdb-plugin-manager/src/accountsdb_plugin_service.rs index 9e274c04d0..fee6e639c1 100644 --- a/accountsdb-plugin-manager/src/accountsdb_plugin_service.rs +++ b/accountsdb-plugin-manager/src/accountsdb_plugin_service.rs @@ -170,13 +170,24 @@ impl AccountsDbPluginService { let libpath = result["libpath"] .as_str() .ok_or(AccountsdbPluginServiceError::LibPathNotSet)?; + let mut libpath = PathBuf::from(libpath); + if libpath.is_relative() { + let config_dir = accountsdb_plugin_config_file.parent().ok_or_else(|| { + AccountsdbPluginServiceError::CannotOpenConfigFile(format!( + "Failed to resolve parent of {:?}", + accountsdb_plugin_config_file, + )) + })?; + libpath = config_dir.join(libpath); + } + let config_file = accountsdb_plugin_config_file .as_os_str() .to_str() .ok_or(AccountsdbPluginServiceError::InvalidPluginPath)?; unsafe { - let result = plugin_manager.load_plugin(libpath, config_file); + let result = plugin_manager.load_plugin(libpath.to_str().unwrap(), config_file); if let Err(err) = result { let msg = format!( "Failed to load the plugin library: {:?}, error: {:?}",