Skip to content

Commit ad1414d

Browse files
authored
Merge pull request containerd#64 from thehajime/fix-darwin-fchown
darwin: ignore fchown failure on darwin
2 parents 23d84c5 + 52ac244 commit ad1414d

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ require (
66
github.com/containerd/console v0.0.0-20191206165004-02ecf6a7291e
77
github.com/opencontainers/runtime-spec v1.0.1
88
github.com/pkg/errors v0.8.1
9+
github.com/sirupsen/logrus v1.6.0
910
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449
1011
)

go.sum

+7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
github.com/containerd/console v0.0.0-20191206165004-02ecf6a7291e h1:GdiIYd8ZDOrT++e1NjhSD4rGt9zaJukHm4rt5F4mRQc=
22
github.com/containerd/console v0.0.0-20191206165004-02ecf6a7291e/go.mod h1:8Pf4gM6VEbTNRIT26AyyU7hxdQU3MvAvxVI0sc00XBE=
3+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4+
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
35
github.com/opencontainers/runtime-spec v1.0.1 h1:wY4pOY8fBdSIvs9+IDHC55thBuEulhzfSgKeC1yFvzQ=
46
github.com/opencontainers/runtime-spec v1.0.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
57
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
68
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
9+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
10+
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
11+
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
12+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
13+
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
714
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
815
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 h1:gSbV7h1NRL2G1xTg/owz62CST1oJBmxy4QpMMregXVQ=
916
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

io_unix.go

+23-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ package runc
2020

2121
import (
2222
"github.com/pkg/errors"
23+
"github.com/sirupsen/logrus"
2324
"golang.org/x/sys/unix"
25+
"runtime"
2426
)
2527

2628
// NewPipeIO creates pipe pairs to be used with runc
@@ -47,7 +49,13 @@ func NewPipeIO(uid, gid int, opts ...IOOpt) (i IO, err error) {
4749
}
4850
pipes = append(pipes, stdin)
4951
if err = unix.Fchown(int(stdin.r.Fd()), uid, gid); err != nil {
50-
return nil, errors.Wrap(err, "failed to chown stdin")
52+
// TODO: revert with proper darwin solution, skipping for now
53+
// as darwin chown is returning EINVAL on anonymous pipe
54+
if runtime.GOOS == "darwin" {
55+
logrus.WithError(err).Debug("failed to chown stdin, ignored")
56+
} else {
57+
return nil, errors.Wrap(err, "failed to chown stdin")
58+
}
5159
}
5260
}
5361
if option.OpenStdout {
@@ -56,7 +64,13 @@ func NewPipeIO(uid, gid int, opts ...IOOpt) (i IO, err error) {
5664
}
5765
pipes = append(pipes, stdout)
5866
if err = unix.Fchown(int(stdout.w.Fd()), uid, gid); err != nil {
59-
return nil, errors.Wrap(err, "failed to chown stdout")
67+
// TODO: revert with proper darwin solution, skipping for now
68+
// as darwin chown is returning EINVAL on anonymous pipe
69+
if runtime.GOOS == "darwin" {
70+
logrus.WithError(err).Debug("failed to chown stdout, ignored")
71+
} else {
72+
return nil, errors.Wrap(err, "failed to chown stdout")
73+
}
6074
}
6175
}
6276
if option.OpenStderr {
@@ -65,7 +79,13 @@ func NewPipeIO(uid, gid int, opts ...IOOpt) (i IO, err error) {
6579
}
6680
pipes = append(pipes, stderr)
6781
if err = unix.Fchown(int(stderr.w.Fd()), uid, gid); err != nil {
68-
return nil, errors.Wrap(err, "failed to chown stderr")
82+
// TODO: revert with proper darwin solution, skipping for now
83+
// as darwin chown is returning EINVAL on anonymous pipe
84+
if runtime.GOOS == "darwin" {
85+
logrus.WithError(err).Debug("failed to chown stderr, ignored")
86+
} else {
87+
return nil, errors.Wrap(err, "failed to chown stderr")
88+
}
6989
}
7090
}
7191
return &pipeIO{

0 commit comments

Comments
 (0)