diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 5f4739bd22276..3e26ed2b97c23 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -165,7 +165,7 @@ pub fn opts() -> Vec { 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]") @@ -178,7 +178,7 @@ pub fn opts() -> Vec { "PASSES") }), stable("plugins", |o| { - o.optmulti("", "plugins", "space separated list of plugins to also load", + o.optmulti("", "plugins", "removed", "PLUGINS") }), stable("no-default", |o| { @@ -741,9 +741,16 @@ where R: 'static + Send, } } + 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, ..)| { @@ -757,10 +764,6 @@ where R: 'static + Send, }; pm.add_plugin(plugin); } - info!("loading plugins..."); - for pname in plugins { - pm.load_plugin(pname); - } // Run everything! info!("Executing passes/plugins"); @@ -776,8 +779,6 @@ fn check_deprecated_options(matches: &getopts::Matches, diag: &errors::Handler) let deprecated_flags = [ "input-format", "output-format", - "plugin-path", - "plugins", "no-defaults", "passes", ]; diff --git a/src/librustdoc/plugins.rs b/src/librustdoc/plugins.rs index 1a1e60a6945ed..261ff728aef60 100644 --- a/src/librustdoc/plugins.rs +++ b/src/librustdoc/plugins.rs @@ -12,47 +12,20 @@ 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 , callbacks: Vec , - /// 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. @@ -70,23 +43,3 @@ impl PluginManager { 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 -}