Trusted Helper Argv0 for Multi-call Firewall Binaries

Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
This commit is contained in:
Alexey
2026-09-28 05:48:43 +03:00
parent 6f2245952d
commit 555d0be6d9
4 changed files with 46 additions and 17 deletions
+5 -9
View File
@@ -1,9 +1,8 @@
use std::path::{Path, PathBuf};
use std::process::Command;
use rand::RngExt;
use crate::util::trusted_command::resolve_trusted_helper;
use crate::util::trusted_command::trusted_helper_command;
/// Options for the fire-and-forget init command.
#[derive(Debug, Clone)]
@@ -167,11 +166,8 @@ pub fn run_init(opts: InitOptions) -> Result<(), Box<dyn std::error::Error>> {
eprintln!("[+] Service started");
std::thread::sleep(std::time::Duration::from_secs(1));
let status = resolve_trusted_helper("systemctl").and_then(|command_path| {
Command::new(command_path)
.args(["is-active", "telemt.service"])
.output()
.ok()
let status = trusted_helper_command("systemctl").and_then(|mut command| {
command.args(["is-active", "telemt.service"]).output().ok()
});
match status {
Some(out) if out.status.success() => {
@@ -334,11 +330,11 @@ weight = 10
}
fn run_cmd(cmd: &str, args: &[&str]) {
let Some(command_path) = resolve_trusted_helper(cmd) else {
let Some(mut command) = trusted_helper_command(cmd) else {
eprintln!("[!] Refusing unavailable or untrusted command: {}", cmd);
return;
};
match Command::new(command_path).args(args).output() {
match command.args(args).output() {
Ok(output) => {
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);