mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-09 18:59:50 +08:00
fix(tunnel): stop quoting WorkingDirectory in generated systemd unit
systemd (verified on Ubuntu 20.04 / systemd 245 with systemd-analyze verify) treats the quoted value as part of the path and rejects the unit with: WorkingDirectory= path is not absolute: "/etc/aether-tunnel". This made aether-tunnel setup fail after a seemingly successful one-line install, so remote proxy nodes never came online. WorkingDirectory= takes the rest of the line as the path, so spaces in the working directory stay intact unquoted; newline/specifier injection is already rejected by validate_service_unit_path. ExecStart= and Environment= keep their existing quoting. Updates #817 (proxy node section; reproduced there with the full systemd-analyze verify output).
This commit is contained in:
@@ -340,7 +340,12 @@ fn render_systemd_unit(
|
|||||||
validate_service_unit_path(working_dir, "working directory")?;
|
validate_service_unit_path(working_dir, "working directory")?;
|
||||||
|
|
||||||
let exe_path = systemd_quote(exe_path);
|
let exe_path = systemd_quote(exe_path);
|
||||||
let working_dir = systemd_quote(working_dir);
|
// systemd treats a quoted WorkingDirectory value as part of the path
|
||||||
|
// (systemd-analyze reports `path is not absolute: "/etc/aether-tunnel"`),
|
||||||
|
// so this directive must stay unquoted. The directive takes the rest of
|
||||||
|
// the line as the path, so values with spaces stay intact, and
|
||||||
|
// validate_service_unit_path rejects newline/specifier injection.
|
||||||
|
let working_dir = working_dir.to_string();
|
||||||
let config_env = systemd_quote(&format!("AETHER_TUNNEL_CONFIG={config_path}"));
|
let config_env = systemd_quote(&format!("AETHER_TUNNEL_CONFIG={config_path}"));
|
||||||
Ok(format!(
|
Ok(format!(
|
||||||
"[Unit]\n\
|
"[Unit]\n\
|
||||||
@@ -980,7 +985,8 @@ mod tests {
|
|||||||
assert!(unit.contains(
|
assert!(unit.contains(
|
||||||
r#"Environment="AETHER_TUNNEL_CONFIG=/var/lib/aether tunnel/config\\\\node.toml""#
|
r#"Environment="AETHER_TUNNEL_CONFIG=/var/lib/aether tunnel/config\\\\node.toml""#
|
||||||
));
|
));
|
||||||
assert!(unit.contains(r#"WorkingDirectory="/var/lib/aether tunnel""#));
|
assert!(unit.contains("WorkingDirectory=/var/lib/aether tunnel\n"));
|
||||||
|
assert!(!unit.contains("WorkingDirectory=\""));
|
||||||
assert_eq!(systemd_quote("a\\b\"c"), r#""a\\b\"c""#);
|
assert_eq!(systemd_quote("a\\b\"c"), r#""a\\b\"c""#);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user