diff options
-rw-r--r-- | libpod/util.go | 1 | ||||
-rw-r--r-- | pkg/specgenutil/specgen.go | 8 | ||||
-rw-r--r-- | pkg/systemd/generate/common.go | 2 | ||||
-rw-r--r-- | pkg/systemd/generate/common_test.go | 18 | ||||
-rw-r--r-- | test/e2e/run_entrypoint_test.go | 1 | ||||
-rw-r--r-- | test/system/200-pod.bats | 11 | ||||
-rw-r--r-- | test/system/250-systemd.bats | 3 |
7 files changed, 25 insertions, 19 deletions
diff --git a/libpod/util.go b/libpod/util.go index 5154a261e..e89c6faaa 100644 --- a/libpod/util.go +++ b/libpod/util.go @@ -56,6 +56,7 @@ func WaitForFile(path string, chWait chan error, timeout time.Duration) (bool, e inotifyEvents = watcher.Events } defer watcher.Close() + defer watcher.Remove(filepath.Dir(path)) } var timeoutChan <-chan time.Time diff --git a/pkg/specgenutil/specgen.go b/pkg/specgenutil/specgen.go index 637a6a8dd..5e4bd2f65 100644 --- a/pkg/specgenutil/specgen.go +++ b/pkg/specgenutil/specgen.go @@ -409,11 +409,9 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions s.WorkDir = c.Workdir if c.Entrypoint != nil { entrypoint := []string{} - if ep := *c.Entrypoint; len(ep) > 0 { - // Check if entrypoint specified is json - if err := json.Unmarshal([]byte(*c.Entrypoint), &entrypoint); err != nil { - entrypoint = append(entrypoint, ep) - } + // Check if entrypoint specified is json + if err := json.Unmarshal([]byte(*c.Entrypoint), &entrypoint); err != nil { + entrypoint = append(entrypoint, *c.Entrypoint) } s.Entrypoint = entrypoint } diff --git a/pkg/systemd/generate/common.go b/pkg/systemd/generate/common.go index 24c85a27e..8689e084c 100644 --- a/pkg/systemd/generate/common.go +++ b/pkg/systemd/generate/common.go @@ -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 diff --git a/pkg/systemd/generate/common_test.go b/pkg/systemd/generate/common_test.go index 45004ecb0..b9a43df8c 100644 --- a/pkg/systemd/generate/common_test.go +++ b/pkg/systemd/generate/common_test.go @@ -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 { diff --git a/test/e2e/run_entrypoint_test.go b/test/e2e/run_entrypoint_test.go index e91e75adf..4fb6054e2 100644 --- a/test/e2e/run_entrypoint_test.go +++ b/test/e2e/run_entrypoint_test.go @@ -103,7 +103,6 @@ ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] }) It("podman run user entrypoint overrides image entrypoint and image cmd", func() { - SkipIfRemote("#12521: podman-remote not handling passing empty --entrypoint") dockerfile := `FROM quay.io/libpod/alpine:latest CMD ["-i"] ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] diff --git a/test/system/200-pod.bats b/test/system/200-pod.bats index 60cfbc9dd..b166914db 100644 --- a/test/system/200-pod.bats +++ b/test/system/200-pod.bats @@ -8,7 +8,7 @@ function teardown() { run_podman rm -f -t 0 -a run_podman image list --format '{{.ID}} {{.Repository}}' while read id name; do - if [[ "$name" =~ /pause ]]; then + if [[ "$name" =~ /podman-pause ]]; then run_podman rmi $id fi done <<<"$output" @@ -79,11 +79,6 @@ EOF is "$output" ".*initializing source docker://$image:.*" } -function rm_podman_pause_image() { - run_podman version --format "{{.Server.Version}}-{{.Server.Built}}" - run_podman rmi -f "localhost/podman-pause:$output" -} - @test "podman pod - communicating between pods" { podname=pod$(random_string) run_podman 1 pod exists $podname @@ -129,8 +124,6 @@ function rm_podman_pause_image() { # Pod no longer exists run_podman 1 pod exists $podid run_podman 1 pod exists $podname - - rm_podman_pause_image } @test "podman pod - communicating via /dev/shm " { @@ -154,7 +147,6 @@ function rm_podman_pause_image() { # Pause image hasn't been pulled run_podman 1 image exists k8s.gcr.io/pause:3.5 - rm_podman_pause_image } # Random byte @@ -343,7 +335,6 @@ EOF # Pause image hasn't been pulled run_podman 1 image exists k8s.gcr.io/pause:3.5 - rm_podman_pause_image } # vim: filetype=sh diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats index 56d36934d..c49727cc9 100644 --- a/test/system/250-systemd.bats +++ b/test/system/250-systemd.bats @@ -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 |