mirror of
https://github.com/telemt/telemt.git
synced 2026-10-29 03:57:15 +03:00
Trusted Helper Argv0 for Multi-call Firewall Binaries
Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
This commit is contained in:
+5
-9
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user