From b008df209bbb227d231e7c0ffc0e2562b89c48d3 Mon Sep 17 00:00:00 2001 From: Alan Shreve Date: Mon, 10 Aug 2015 17:23:52 -0700 Subject: [PATCH] Change escaping rules of executable paths to cope with older versions of systemd --- service_linux.go | 3 +++ service_systemd_linux.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/service_linux.go b/service_linux.go index 9341c06..550decd 100644 --- a/service_linux.go +++ b/service_linux.go @@ -69,4 +69,7 @@ var tf = map[string]interface{}{ "cmd": func(s string) string { return `"` + strings.Replace(s, `"`, `\"`, -1) + `"` }, + "cmdEscape": func(s string) string { + return strings.Replace(s, " ", `\x20`, -1) + }, } diff --git a/service_systemd_linux.go b/service_systemd_linux.go index 571683f..5bb1cfc 100644 --- a/service_systemd_linux.go +++ b/service_systemd_linux.go @@ -157,12 +157,12 @@ func (s *systemd) Restart() error { const systemdScript = `[Unit] Description={{.Description}} -ConditionFileIsExecutable={{.Path|cmd}} +ConditionFileIsExecutable={{.Path|cmdEscape}} [Service] StartLimitInterval=5 StartLimitBurst=10 -ExecStart={{.Path|cmd}}{{range .Arguments}} {{.|cmd}}{{end}} +ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}} {{if .ChRoot}}RootDirectory={{.ChRoot|cmd}}{{end}} {{if .WorkingDirectory}}WorkingDirectory={{.WorkingDirectory|cmd}}{{end}} {{if .UserName}}User={{.UserName}}{{end}}