|
|
@@ -947,6 +947,23 @@ def systemd_quote(value):
|
|
|
return f'"{value}"'
|
|
|
|
|
|
|
|
|
+def systemd_path_value(value):
|
|
|
+ """Escape a filesystem path for an unquoted systemd path directive."""
|
|
|
+ escaped = []
|
|
|
+ for character in str(value):
|
|
|
+ if character == "%":
|
|
|
+ escaped.append("%%")
|
|
|
+ elif (
|
|
|
+ character.isspace()
|
|
|
+ or not character.isprintable()
|
|
|
+ or character in {"\\", '"', "'", "#"}
|
|
|
+ ):
|
|
|
+ escaped.extend(f"\\x{byte:02x}" for byte in character.encode("utf-8"))
|
|
|
+ else:
|
|
|
+ escaped.append(character)
|
|
|
+ return "".join(escaped)
|
|
|
+
|
|
|
+
|
|
|
def render_mod_host_service(config):
|
|
|
binary = ROOT / config["binary_source"]
|
|
|
service_template = ROOT / config["service_source"]
|
|
|
@@ -1451,7 +1468,7 @@ def render_slweb_service(config, source_config, tools_digest):
|
|
|
if not service_template.is_file():
|
|
|
raise RuntimeError(f"SLWeb service template is missing: {service_template}")
|
|
|
replacements = {
|
|
|
- "@SLWEB_DIRECTORY@": systemd_quote(destination),
|
|
|
+ "@SLWEB_DIRECTORY@": systemd_path_value(destination),
|
|
|
"@PYTHON@": systemd_quote(config["python_path"]),
|
|
|
"@OSC_HOST@": source_config["osc"]["host"],
|
|
|
"@OSC_PORT@": str(source_config["osc"]["port"]),
|