Change escaping rules of executable paths to cope with older versions of systemd
This commit is contained in:
@@ -69,4 +69,7 @@ var tf = map[string]interface{}{
|
|||||||
"cmd": func(s string) string {
|
"cmd": func(s string) string {
|
||||||
return `"` + strings.Replace(s, `"`, `\"`, -1) + `"`
|
return `"` + strings.Replace(s, `"`, `\"`, -1) + `"`
|
||||||
},
|
},
|
||||||
|
"cmdEscape": func(s string) string {
|
||||||
|
return strings.Replace(s, " ", `\x20`, -1)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,12 +157,12 @@ func (s *systemd) Restart() error {
|
|||||||
|
|
||||||
const systemdScript = `[Unit]
|
const systemdScript = `[Unit]
|
||||||
Description={{.Description}}
|
Description={{.Description}}
|
||||||
ConditionFileIsExecutable={{.Path|cmd}}
|
ConditionFileIsExecutable={{.Path|cmdEscape}}
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
StartLimitInterval=5
|
StartLimitInterval=5
|
||||||
StartLimitBurst=10
|
StartLimitBurst=10
|
||||||
ExecStart={{.Path|cmd}}{{range .Arguments}} {{.|cmd}}{{end}}
|
ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}}
|
||||||
{{if .ChRoot}}RootDirectory={{.ChRoot|cmd}}{{end}}
|
{{if .ChRoot}}RootDirectory={{.ChRoot|cmd}}{{end}}
|
||||||
{{if .WorkingDirectory}}WorkingDirectory={{.WorkingDirectory|cmd}}{{end}}
|
{{if .WorkingDirectory}}WorkingDirectory={{.WorkingDirectory|cmd}}{{end}}
|
||||||
{{if .UserName}}User={{.UserName}}{{end}}
|
{{if .UserName}}User={{.UserName}}{{end}}
|
||||||
|
|||||||
Reference in New Issue
Block a user