diff options
author | Ian Gudger <igudger@google.com> | 2019-04-29 21:20:05 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-04-29 21:21:08 -0700 |
commit | 81ecd8b6eab7457b331762626f8c210fec3504e6 (patch) | |
tree | 4c5e5aaf3ac8ff475657c66671dd6828938ae45e /pkg/sentry/fs/host/control.go | |
parent | 2843f2a956f5ef23e621f571f5c3e6a1e4a8223a (diff) |
Implement the MSG_CTRUNC msghdr flag for Unix sockets.
Updates google/gvisor#206
PiperOrigin-RevId: 245880573
Change-Id: Ifa715e98d47f64b8a32b04ae9378d6cd6bd4025e
Diffstat (limited to 'pkg/sentry/fs/host/control.go')
-rw-r--r-- | pkg/sentry/fs/host/control.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pkg/sentry/fs/host/control.go b/pkg/sentry/fs/host/control.go index 480f0c8f4..9ebb9bbb3 100644 --- a/pkg/sentry/fs/host/control.go +++ b/pkg/sentry/fs/host/control.go @@ -32,17 +32,20 @@ func newSCMRights(fds []int) control.SCMRights { } // Files implements control.SCMRights.Files. -func (c *scmRights) Files(ctx context.Context, max int) control.RightsFiles { +func (c *scmRights) Files(ctx context.Context, max int) (control.RightsFiles, bool) { n := max + var trunc bool if l := len(c.fds); n > l { n = l + } else if n < l { + trunc = true } rf := control.RightsFiles(fdsToFiles(ctx, c.fds[:n])) // Only consume converted FDs (fdsToFiles may convert fewer than n FDs). c.fds = c.fds[len(rf):] - return rf + return rf, trunc } // Clone implements transport.RightsControlMessage.Clone. |