mirror of https://github.com/containers/podman.git
Merge pull request #12545 from vrothberg/fix-12477
generate systemd: support entrypoint JSON strings
This commit is contained in:
commit
4a52a457d1
|
|
@ -101,7 +101,7 @@ func escapeSystemdArguments(command []string) []string {
|
|||
func escapeSystemdArg(arg string) string {
|
||||
arg = strings.ReplaceAll(arg, "$", "$$")
|
||||
arg = strings.ReplaceAll(arg, "%", "%%")
|
||||
if strings.ContainsAny(arg, " \t") {
|
||||
if strings.ContainsAny(arg, " \t\"") {
|
||||
arg = strconv.Quote(arg)
|
||||
} else if strings.Contains(arg, `\`) {
|
||||
// strconv.Quote also escapes backslashes so
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ func TestEscapeSystemdArguments(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
[]string{"foo", "bar=\"arg\""},
|
||||
[]string{"foo", "bar=\"arg\""},
|
||||
[]string{"foo", "\"bar=\\\"arg\\\"\""},
|
||||
},
|
||||
{
|
||||
[]string{"foo", "bar=\"arg with space\""},
|
||||
|
|
@ -192,6 +192,22 @@ func TestEscapeSystemdArguments(t *testing.T) {
|
|||
[]string{"foo", `command with two backslashes \\`},
|
||||
[]string{"foo", `"command with two backslashes \\\\"`},
|
||||
},
|
||||
{
|
||||
[]string{"podman", "create", "--entrypoint", "foo"},
|
||||
[]string{"podman", "create", "--entrypoint", "foo"},
|
||||
},
|
||||
{
|
||||
[]string{"podman", "create", "--entrypoint=foo"},
|
||||
[]string{"podman", "create", "--entrypoint=foo"},
|
||||
},
|
||||
{
|
||||
[]string{"podman", "create", "--entrypoint", "[\"foo\"]"},
|
||||
[]string{"podman", "create", "--entrypoint", "\"[\\\"foo\\\"]\""},
|
||||
},
|
||||
{
|
||||
[]string{"podman", "create", "--entrypoint", "[\"sh\", \"-c\", \"date '+%s'\"]"},
|
||||
[]string{"podman", "create", "--entrypoint", "\"[\\\"sh\\\", \\\"-c\\\", \\\"date '+%%s'\\\"]\""},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
|
|
|||
|
|
@ -104,8 +104,9 @@ function service_cleanup() {
|
|||
}
|
||||
|
||||
@test "podman autoupdate local" {
|
||||
# Note that the entrypoint may be a JSON string which requires preserving the quotes (see #12477)
|
||||
cname=$(random_string)
|
||||
run_podman create --name $cname --label "io.containers.autoupdate=local" $IMAGE top
|
||||
run_podman create --name $cname --label "io.containers.autoupdate=local" --entrypoint '["top"]' $IMAGE
|
||||
|
||||
# Start systemd service to run this container
|
||||
service_setup
|
||||
|
|
|
|||
Loading…
Reference in New Issue