Change escaping rules of executable paths to cope with older versions of systemd

This commit is contained in:
Alan Shreve
2015-08-10 17:23:52 -07:00
parent 1ab12303aa
commit b008df209b
2 changed files with 5 additions and 2 deletions
+3
View File
@@ -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)
},
}
+2 -2
View File
@@ -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}}