From eb8bfdad3e6e4f3bbb308c2ae8c8b6dbba7d4f1c Mon Sep 17 00:00:00 2001
From: Joseph Gooch <mrwizard@dok.org>
Date: Tue, 16 Jun 2020 14:57:43 +0000
Subject: Fix --init and --init-path

Init properly passed into specgen
Allow --init with --systemd=true but not --systemd=always.

Signed-off-by: Joseph Gooch <mrwizard@dok.org>
---
 pkg/specgen/generate/oci.go     | 2 +-
 pkg/specgen/generate/storage.go | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

(limited to 'pkg')

diff --git a/pkg/specgen/generate/oci.go b/pkg/specgen/generate/oci.go
index 266abd28d..1c34f622b 100644
--- a/pkg/specgen/generate/oci.go
+++ b/pkg/specgen/generate/oci.go
@@ -112,7 +112,7 @@ func makeCommand(ctx context.Context, s *specgen.SpecGenerator, img *image.Image
 		if initPath == "" {
 			return nil, errors.Errorf("no path to init binary found but container requested an init")
 		}
-		finalCommand = append([]string{initPath, "--"}, finalCommand...)
+		finalCommand = append([]string{"/dev/init", "--"}, finalCommand...)
 	}
 
 	return finalCommand, nil
diff --git a/pkg/specgen/generate/storage.go b/pkg/specgen/generate/storage.go
index 241c9adeb..0d78421a6 100644
--- a/pkg/specgen/generate/storage.go
+++ b/pkg/specgen/generate/storage.go
@@ -314,8 +314,8 @@ func addContainerInitBinary(s *specgen.SpecGenerator, path string) (spec.Mount,
 	if !s.PidNS.IsPrivate() {
 		return mount, fmt.Errorf("cannot add init binary as PID 1 (PID namespace isn't private)")
 	}
-	if s.Systemd == "true" || s.Systemd == "always" {
-		return mount, fmt.Errorf("cannot use container-init binary with systemd")
+	if s.Systemd == "always" {
+		return mount, fmt.Errorf("cannot use container-init binary with systemd=always")
 	}
 	if _, err := os.Stat(path); os.IsNotExist(err) {
 		return mount, errors.Wrap(err, "container-init binary not found on the host")
-- 
cgit v1.2.3-54-g00ecf