feat: v1.0.2, add feature harden_process
This commit is contained in:
@@ -36,6 +36,7 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "harden_process")]
|
||||
fn harden_process() {
|
||||
let ignore_harden_process_error = std::env::var("IGNORE_HARDEN_PROCESS_ERROR")
|
||||
.map(|v| &v == "true").unwrap_or_else(|_| false);
|
||||
@@ -75,6 +76,7 @@ fn inner_main() -> CommandError {
|
||||
let matches = app.get_matches();
|
||||
for command in &commands {
|
||||
if let Some(sub_cmd_matches) = matches.subcommand_matches(command.name()) {
|
||||
#[cfg(feature = "harden_process")]
|
||||
if command.name() == "serve" { harden_process(); }
|
||||
return command.run(&matches, sub_cmd_matches);
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@ pub struct Process {
|
||||
pub exec: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
#[cfg(not(all(target_os = "linux", feature = "harden_process")))]
|
||||
pub fn get_process(_port: u16) -> Option<Process> {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(all(target_os = "linux", feature = "harden_process"))]
|
||||
pub fn get_process(port: u16) -> Option<Process> {
|
||||
let all_procs = match procfs::process::all_processes() {
|
||||
Err(e) => {
|
||||
|
||||
Reference in New Issue
Block a user