diff options
author | Kevin Krakauer <krakauer@google.com> | 2018-09-17 11:30:16 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-09-17 11:31:28 -0700 |
commit | 25add7b22b1b0b6a4bac1e72536d3f3a0c70f048 (patch) | |
tree | 87b4ecb9dcf96d2de23cb54328d04650e60b502e /runsc/boot/fds.go | |
parent | de5a590ee203b4ee217da68dbec8e58a7753e520 (diff) |
runsc: Fix stdin/out/err in multi-container mode.
Stdin/out/err weren't being sent to the sentry.
PiperOrigin-RevId: 213307171
Change-Id: Ie4b634a58b1b69aa934ce8597e5cc7a47a2bcda2
Diffstat (limited to 'runsc/boot/fds.go')
-rw-r--r-- | runsc/boot/fds.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/runsc/boot/fds.go b/runsc/boot/fds.go index 9de5a78b1..91c698fea 100644 --- a/runsc/boot/fds.go +++ b/runsc/boot/fds.go @@ -16,7 +16,6 @@ package boot import ( "fmt" - "syscall" "gvisor.googlesource.com/gvisor/pkg/sentry/context" "gvisor.googlesource.com/gvisor/pkg/sentry/fs" @@ -28,15 +27,19 @@ import ( // createFDMap creates an fd map that contains stdin, stdout, and stderr. If // console is true, then ioctl calls will be passed through to the host fd. -func createFDMap(ctx context.Context, k *kernel.Kernel, l *limits.LimitSet, console bool) (*kernel.FDMap, error) { +func createFDMap(ctx context.Context, k *kernel.Kernel, l *limits.LimitSet, console bool, stdioFDs []int) (*kernel.FDMap, error) { + if len(stdioFDs) != 3 { + return nil, fmt.Errorf("stdioFDs should contain exactly 3 FDs (stdin, stdout, and stderr), but %d FDs received", len(stdioFDs)) + } + fdm := k.NewFDMap() defer fdm.DecRef() // Maps sandbox fd to host fd. fdMap := map[int]int{ - 0: syscall.Stdin, - 1: syscall.Stdout, - 2: syscall.Stderr, + 0: stdioFDs[0], + 1: stdioFDs[1], + 2: stdioFDs[2], } mounter := fs.FileOwnerFromContext(ctx) |