From 25d72ac039192adba2295ff6195dc5adb93ecb3c Mon Sep 17 00:00:00 2001 From: sabraman Date: Sun, 22 Mar 2026 23:52:01 +0300 Subject: [PATCH] quote init systemd execstart paths --- src/cli.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 6dc0e2a..948e46d 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -7,11 +7,17 @@ use std::process::Command; /// Options for the init command pub struct InitOptions { + /// Listen port for the generated proxy configuration. pub port: u16, + /// TLS masking domain written into the generated configuration. pub domain: String, + /// Optional user-provided MTProxy secret in hex form. pub secret: Option, + /// Username inserted into the generated access configuration. pub username: String, + /// Destination directory for the generated config file. pub config_dir: PathBuf, + /// Skips starting the service after installation. pub no_start: bool, } @@ -265,6 +271,16 @@ weight = 10 } fn generate_systemd_unit(exe_path: &Path, config_path: &Path) -> String { + let exe = exe_path + .display() + .to_string() + .replace('\\', "\\\\") + .replace('"', "\\\""); + let config = config_path + .display() + .to_string() + .replace('\\', "\\\\") + .replace('"', "\\\""); format!( r#"[Unit] Description=Telemt MTProxy @@ -274,7 +290,7 @@ Wants=network-online.target [Service] Type=simple -ExecStart={exe} {config} +ExecStart="{exe}" "{config}" Restart=always RestartSec=5 LimitNOFILE=65535 @@ -287,9 +303,7 @@ PrivateTmp=true [Install] WantedBy=multi-user.target -"#, - exe = exe_path.display(), - config = config_path.display(), +"# ) }