summaryrefslogtreecommitdiff
path: root/pkg/specgen/generate
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2022-02-23 14:18:12 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2022-03-28 16:30:47 -0400
commitcdf74f20820a578ea515e67b00a13714ff8bd6f2 (patch)
treeda66e7cd3cb0910cdbef663b9e9533e40fc861a1 /pkg/specgen/generate
parentc75030590cc992d87dbd8dc02501d3bad257fd84 (diff)
downloadpodman-cdf74f20820a578ea515e67b00a13714ff8bd6f2.tar.gz
podman-cdf74f20820a578ea515e67b00a13714ff8bd6f2.tar.bz2
podman-cdf74f20820a578ea515e67b00a13714ff8bd6f2.zip
Set systemd mode if entrypoint begins with /bin/sh -c
Fixes: https://github.com/containers/podman/issues/13324 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/specgen/generate')
-rw-r--r--pkg/specgen/generate/container_create.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go
index 8ab0eae5a..a014f5047 100644
--- a/pkg/specgen/generate/container_create.go
+++ b/pkg/specgen/generate/container_create.go
@@ -304,7 +304,16 @@ func createContainerOptions(ctx context.Context, rt *libpod.Runtime, s *specgen.
"/usr/sbin/init": true,
"/usr/local/sbin/init": true,
}
- if useSystemdCommands[command[0]] || (filepath.Base(command[0]) == "systemd") {
+ // Grab last command incase this is launched from a shell
+ cmd := command
+ if len(command) > 2 {
+ // Podman build will add "/bin/sh" "-c" to
+ // Entrypoint. Remove and search for systemd
+ if command[0] == "/bin/sh" && command[1] == "-c" {
+ cmd = command[2:]
+ }
+ }
+ if useSystemdCommands[cmd[0]] || (filepath.Base(cmd[0]) == "systemd") {
useSystemd = true
}
}