summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--recipes-containers/runc/runc-docker/0001-runc-Add-console-socket-dev-null.patch32
-rw-r--r--recipes-containers/runc/runc-docker/0001-runc-docker-SIGUSR1-daemonize.patch133
-rw-r--r--recipes-containers/runc/runc-docker_git.bb14
-rw-r--r--recipes-containers/runc/runc-opencontainers_git.bb4
4 files changed, 4 insertions, 179 deletions
diff --git a/recipes-containers/runc/runc-docker/0001-runc-Add-console-socket-dev-null.patch b/recipes-containers/runc/runc-docker/0001-runc-Add-console-socket-dev-null.patch
deleted file mode 100644
index cb0ddc37..00000000
--- a/recipes-containers/runc/runc-docker/0001-runc-Add-console-socket-dev-null.patch
+++ /dev/null
@@ -1,32 +0,0 @@
1From 3fff2a3505fba1d1ff0074edff15708a77f6cfa9 Mon Sep 17 00:00:00 2001
2From: Jason Wessel <jason.wessel@windriver.com>
3Date: Wed, 12 Jul 2017 13:35:03 -0700
4Subject: [PATCH] runc: Add --console-socket=/dev/null
5
6This allows for setting up a detached session where you do not want to
7set the terminal to false in the config.json. More or less this is a
8runtime override.
9
10Upstream-Status: Inappropriate [embedded specific]
11
12Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
13---
14 utils_linux.go | 5 +++++
15 1 file changed, 5 insertions(+)
16
17Index: git/src/import/utils_linux.go
18===================================================================
19--- git.orig/src/import/utils_linux.go
20+++ git/src/import/utils_linux.go
21@@ -267,6 +267,11 @@
22 }
23
24 func (r *runner) run(config *specs.Process) (int, error) {
25+ if (r.consoleSocket == "/dev/null") {
26+ r.detach = false
27+ r.consoleSocket = ""
28+ config.Terminal = false
29+ }
30 var err error
31 defer func() {
32 if err != nil {
diff --git a/recipes-containers/runc/runc-docker/0001-runc-docker-SIGUSR1-daemonize.patch b/recipes-containers/runc/runc-docker/0001-runc-docker-SIGUSR1-daemonize.patch
deleted file mode 100644
index d3d1134b..00000000
--- a/recipes-containers/runc/runc-docker/0001-runc-docker-SIGUSR1-daemonize.patch
+++ /dev/null
@@ -1,133 +0,0 @@
1From cd7d76a6d1ecb1856f6ed666fb5c30dc105aa94e Mon Sep 17 00:00:00 2001
2From: Jason Wessel <jason.wessel@windriver.com>
3Date: Tue, 5 Dec 2017 18:28:28 -0800
4Subject: [PATCH] runc-docker: Allow "run start ..." to daemonize with $SIGUSR1_PARENT_PID
5
6The runc-docker has all the code in it to properly run a stop hook if
7you use it in the foreground. It doesn't work in the back ground
8because there is no way for a golang application to fork a child exit
9out of the parent process because all the golang threads stay with the
10parent.
11
12This patch has three parts that happen ONLY when $SIGUSR1_PARENT_PID
13is set.
14
151) The code was copied which performs the normal the signal handling
16 block which is used for the foreground operation of runc.
17
182) At the point where runc start would normally exit, it closes
19 stdin/stdout/stderr so it would be possible to daemonize "runc start ...".
20
213) The code to send a SIGUSR1 to the parent process was added. The
22 idea being that a parent process would simply exit at that point
23 because it was blocking until runc performed everything it was
24 required to perform.
25
26Upstream-Status: Inappropriate [embedded specific]
27
28Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
29---
30 signals.go | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++----
31 utils_linux.go | 2 +-
32 2 files changed, 51 insertions(+), 5 deletions(-)
33
34Index: git/src/import/signals.go
35===================================================================
36--- git.orig/src/import/signals.go
37+++ git/src/import/signals.go
38@@ -5,7 +5,9 @@
39 import (
40 "os"
41 "os/signal"
42+ "syscall" // only for Signal
43
44+ "strconv"
45 "github.com/opencontainers/runc/libcontainer"
46 "github.com/opencontainers/runc/libcontainer/system"
47 "github.com/opencontainers/runc/libcontainer/utils"
48@@ -55,9 +57,6 @@
49 func (h *signalHandler) forward(process *libcontainer.Process, tty *tty, detach bool) (int, error) {
50 // make sure we know the pid of our main process so that we can return
51 // after it dies.
52- if detach && h.notifySocket == nil {
53- return 0, nil
54- }
55
56 pid1, err := process.Pid()
57 if err != nil {
58@@ -67,12 +66,61 @@
59 if h.notifySocket != nil {
60 if detach {
61 _ = h.notifySocket.run(pid1)
62- return 0, nil
63 }
64 _ = h.notifySocket.run(os.Getpid())
65 go func() { _ = h.notifySocket.run(0) }()
66 }
67
68+ if (detach) {
69+ // This allows the parent process to daemonize this process
70+ // so long as stdin/stderr/stdout are closed
71+ if envVal := os.Getenv("SIGUSR1_PARENT_PID"); envVal != "" {
72+ // Close stdin/stdout/stderr
73+ os.Stdin.Close()
74+ os.Stdout.Close()
75+ os.Stderr.Close()
76+ // Notify parent to detach
77+ i, err := strconv.Atoi(envVal)
78+ if (err != nil) {
79+ return 0, nil
80+ }
81+ unix.Kill(i, unix.SIGUSR1)
82+ // Loop waiting on the child to signal or exit,
83+ // after which all stop hooks will be run
84+ for s := range h.signals {
85+ switch s {
86+ case unix.SIGCHLD:
87+ exits, err := h.reap()
88+ if err != nil {
89+ logrus.Error(err)
90+ }
91+ for _, e := range exits {
92+ logrus.WithFields(logrus.Fields{
93+ "pid": e.pid,
94+ "status": e.status,
95+ }).Debug("process exited")
96+ if e.pid == pid1 {
97+ // call Wait() on the process even though we already have the exit
98+ // status because we must ensure that any of the go specific process
99+ // fun such as flushing pipes are complete before we return.
100+ process.Wait()
101+ if h.notifySocket != nil {
102+ h.notifySocket.Close()
103+ }
104+ return e.status, nil
105+ }
106+ }
107+ default:
108+ logrus.Debugf("sending signal to process %s", s)
109+ if err := unix.Kill(pid1, s.(syscall.Signal)); err != nil {
110+ logrus.Error(err)
111+ }
112+ }
113+ }
114+ }
115+ return 0, nil
116+ }
117+
118 // Perform the initial tty resize. Always ignore errors resizing because
119 // stdout might have disappeared (due to races with when SIGHUP is sent).
120 _ = tty.resize()
121Index: git/src/import/utils_linux.go
122===================================================================
123--- git.orig/src/import/utils_linux.go
124+++ git/src/import/utils_linux.go
125@@ -345,7 +345,7 @@
126 if err != nil {
127 r.terminate(process)
128 }
129- if detach {
130+ if (detach && os.Getenv("SIGUSR1_PARENT_PID") == "") {
131 return 0, nil
132 }
133 if err == nil {
diff --git a/recipes-containers/runc/runc-docker_git.bb b/recipes-containers/runc/runc-docker_git.bb
deleted file mode 100644
index 24c7cb3b..00000000
--- a/recipes-containers/runc/runc-docker_git.bb
+++ /dev/null
@@ -1,14 +0,0 @@
1include runc.inc
2
3# Note: this rev is before the required protocol field, update when all components
4# have been updated to match.
5SRCREV_runc-docker = "b7da16731c8b55e0e38070ac1d84a56b15f6db37"
6SRC_URI = "git://github.com/opencontainers/runc;branch=main;name=runc-docker;protocol=https;destsuffix=${GO_SRCURI_DESTSUFFIX} \
7 file://0001-runc-Add-console-socket-dev-null.patch \
8 file://0001-Makefile-respect-GOBUILDFLAGS-for-runc-and-remove-re.patch \
9 file://0001-runc-docker-SIGUSR1-daemonize.patch \
10 "
11
12RUNC_VERSION = "1.2.0-rc.3"
13
14CVE_PRODUCT = "runc"
diff --git a/recipes-containers/runc/runc-opencontainers_git.bb b/recipes-containers/runc/runc-opencontainers_git.bb
index c3ebbd8b..86da5fb4 100644
--- a/recipes-containers/runc/runc-opencontainers_git.bb
+++ b/recipes-containers/runc/runc-opencontainers_git.bb
@@ -7,6 +7,10 @@ SRC_URI = " \
7 " 7 "
8RUNC_VERSION = "1.2.0" 8RUNC_VERSION = "1.2.0"
9 9
10# for compatibility with existing RDEPENDS that have existed since
11# runc-docker and runc-opencontainers were separate
12RPROVIDES:${PN} += "runc-docker"
13
10CVE_PRODUCT = "runc" 14CVE_PRODUCT = "runc"
11 15
12LDFLAGS += "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd', '', d)}" 16LDFLAGS += "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd', '', d)}"