mirror of
https://git.proxmox.com/git/proxmox-firewall
synced 2025-10-04 12:55:09 +00:00
firewall: wait for nft process
NftClient never waits for the child process to terminate leading to defunct leftover processes. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
This commit is contained in:
parent
11954b1a08
commit
7438bb262a
@ -36,35 +36,15 @@ impl NftClient {
|
|||||||
return Err(NftError::from(error));
|
return Err(NftError::from(error));
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut error_output = String::new();
|
let output = child.wait_with_output().map_err(NftError::from)?;
|
||||||
|
|
||||||
match child
|
if output.status.success() {
|
||||||
.stderr
|
Ok(String::from_utf8(output.stdout).expect("output is valid utf-8"))
|
||||||
.take()
|
} else {
|
||||||
.expect("can get stderr")
|
Err(NftError::Command(
|
||||||
.read_to_string(&mut error_output)
|
String::from_utf8(output.stderr).expect("output is valid utf-8"),
|
||||||
{
|
))
|
||||||
Ok(_) if !error_output.is_empty() => {
|
|
||||||
return Err(NftError::Command(error_output));
|
|
||||||
}
|
}
|
||||||
Err(error) => {
|
|
||||||
return Err(NftError::from(error));
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut output = String::new();
|
|
||||||
|
|
||||||
if let Err(error) = child
|
|
||||||
.stdout
|
|
||||||
.take()
|
|
||||||
.expect("can get stdout")
|
|
||||||
.read_to_string(&mut output)
|
|
||||||
{
|
|
||||||
return Err(NftError::from(error));
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(output)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_json_commands(commands: &Commands) -> Result<Option<CommandOutput>, NftError> {
|
pub fn run_json_commands(commands: &Commands) -> Result<Option<CommandOutput>, NftError> {
|
||||||
|
Loading…
Reference in New Issue
Block a user