Permalink
Browse files

stage1: escape '%' in command lines as well as '$'

systemd substitutes both %-specifiers and $-variables starting from the
second command-line argument, and rkt should escape both of them.

Fixes #3925
  • Loading branch information...
clchiou committed May 5, 2018
1 parent 601d988 commit 6c293b65535ff73bcc0885dbd1010a9fc268456b
Showing with 4 additions and 0 deletions.
  1. +1 −0 stage1/init/common/pod.go
  2. +3 −0 stage1/init/common/pod_test.go
@@ -55,6 +55,7 @@ func execEscape(i int, str string) string {
if i > 0 { // These are escaped only after the first argument
escapeMap[`$`] = `$`
escapeMap[`%`] = `%`
}
escArg := fmt.Sprintf("%q", str)
@@ -55,6 +55,9 @@ func TestQuoteExec(t *testing.T) {
}, {
input: []string{`$path$`, `$argument`},
output: `"$path$" "$$argument"`,
}, {
input: []string{`%path%`, `%argument`},
output: `"%path%" "%%argument"`,
}, {
input: []string{`path`, `Args\nwith\nnewlines`},
output: `"path" "Args\\nwith\\nnewlines"`,

0 comments on commit 6c293b6

Please sign in to comment.