Macro sudo_plugin::sudo_io_plugin
[−]
[src]
macro_rules! sudo_io_plugin { ( $name:ident : $ty:ty { $($cb:ident : $fn:ident),* $(,)* } ) => { ... }; }
Emits the boilerplate stanza for creating and initializing a custom sudo I/O plugin.
Example
extern crate libc; use sudo_plugin::errors::*; use std::io::Write; sudo_io_plugin! { example : Example { close: close, log_stdout: log_stdout, } } struct Example { } impl Example { fn open(plugin: &'static sudo_plugin::Plugin) -> Result<Self> { plugin.stdout().write(b"example sudo plugin initialized"); Ok(Example {}) } fn close(&mut self, _: i32, _: i32) { println!("example sudo plugin exited"); } fn log_stdout(&mut self, _: &[u8]) -> Result<()> { println!("example sudo plugin received output on stdout"); Ok(()) } }
The generated plugin will have the entry point example, so to
enable it, you'd copy the library to example.so in sudo's plugin
directory (on macOS, /usr/local/libexec/sudo) and add the following
to /etc/sudo.conf:
ⓘThis example is not tested
Plugin example example.so