o.optmulti("", "extern", "pass an --extern to rustc", "NAME=PATH")
}),
stable("plugin-path", |o| {
- o.optmulti("", "plugin-path", "directory to load plugins from", "DIR")
+ o.optmulti("", "plugin-path", "removed", "DIR")
}),
stable("C", |o| {
o.optmulti("C", "codegen", "pass a codegen option to rustc", "OPT[=VALUE]")
"PASSES")
}),
stable("plugins", |o| {
- o.optmulti("", "plugins", "space separated list of plugins to also load",
+ o.optmulti("", "plugins", "removed",
"PLUGINS")
}),
stable("no-default", |o| {
}
}
+ if !plugins.is_empty() {
+ eprintln!("WARNING: --plugins no longer functions; see CVE-2018-1000622");
+ }
+
+ if !plugin_path.is_none() {
+ eprintln!("WARNING: --plugin-path no longer functions; see CVE-2018-1000622");
+ }
+
// Load all plugins/passes into a PluginManager
- let path = plugin_path.unwrap_or("/tmp/rustdoc/plugins".to_string());
- let mut pm = plugins::PluginManager::new(PathBuf::from(path));
+ let mut pm = plugins::PluginManager::new();
for pass in &passes {
let plugin = match passes::PASSES.iter()
.position(|&(p, ..)| {
};
pm.add_plugin(plugin);
}
- info!("loading plugins...");
- for pname in plugins {
- pm.load_plugin(pname);
- }
// Run everything!
info!("Executing passes/plugins");
let deprecated_flags = [
"input-format",
"output-format",
- "plugin-path",
- "plugins",
"no-defaults",
"passes",
];
use clean;
-use std::mem;
-use std::string::String;
-use std::path::PathBuf;
-
-use rustc_metadata::dynamic_lib as dl;
-
pub type PluginResult = clean::Crate;
pub type PluginCallback = fn (clean::Crate) -> PluginResult;
/// Manages loading and running of plugins
pub struct PluginManager {
- dylibs: Vec<dl::DynamicLibrary> ,
callbacks: Vec<PluginCallback> ,
- /// The directory plugins will be loaded from
- pub prefix: PathBuf,
}
impl PluginManager {
/// Create a new plugin manager
- pub fn new(prefix: PathBuf) -> PluginManager {
+ pub fn new() -> PluginManager {
PluginManager {
- dylibs: Vec::new(),
callbacks: Vec::new(),
- prefix,
- }
- }
-
- /// Load a plugin with the given name.
- ///
- /// Turns `name` into the proper dynamic library filename for the given
- /// platform. On windows, it turns into name.dll, on macOS, name.dylib, and
- /// elsewhere, libname.so.
- pub fn load_plugin(&mut self, name: String) {
- let x = self.prefix.join(libname(name));
- let lib_result = dl::DynamicLibrary::open(Some(&x));
- let lib = lib_result.unwrap();
- unsafe {
- let plugin = lib.symbol("rustdoc_plugin_entrypoint").unwrap();
- self.callbacks.push(mem::transmute::<*mut u8,PluginCallback>(plugin));
}
- self.dylibs.push(lib);
}
/// Load a normal Rust function as a plugin.
krate
}
}
-
-#[cfg(target_os = "windows")]
-fn libname(mut n: String) -> String {
- n.push_str(".dll");
- n
-}
-
-#[cfg(target_os="macos")]
-fn libname(mut n: String) -> String {
- n.push_str(".dylib");
- n
-}
-
-#[cfg(all(not(target_os="windows"), not(target_os="macos")))]
-fn libname(n: String) -> String {
- let mut i = String::from("lib");
- i.push_str(&n);
- i.push_str(".so");
- i
-}