Load AccountsDB plugins relative to plugin config (#23000)

This commit is contained in:
Richard Patel
2022-02-12 00:20:54 +01:00
committed by GitHub
parent f7753ce85f
commit 12dffc105a

View File

@@ -170,13 +170,24 @@ impl AccountsDbPluginService {
let libpath = result["libpath"] let libpath = result["libpath"]
.as_str() .as_str()
.ok_or(AccountsdbPluginServiceError::LibPathNotSet)?; .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 let config_file = accountsdb_plugin_config_file
.as_os_str() .as_os_str()
.to_str() .to_str()
.ok_or(AccountsdbPluginServiceError::InvalidPluginPath)?; .ok_or(AccountsdbPluginServiceError::InvalidPluginPath)?;
unsafe { 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 { if let Err(err) = result {
let msg = format!( let msg = format!(
"Failed to load the plugin library: {:?}, error: {:?}", "Failed to load the plugin library: {:?}, error: {:?}",