summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/contexttest/contexttest.go
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2020-08-21 15:04:24 -0700
committergVisor bot <gvisor-bot@google.com>2020-08-21 15:06:09 -0700
commit5f33fdf37e6386975323ca2bab0dccd51d82df65 (patch)
tree46a6de1218e453dd4902e143b6cbea4fee5fb937 /pkg/sentry/contexttest/contexttest.go
parent5ec3d4ed3e3cda8944e851ef845f6d275999858a (diff)
Pass overlay credentials via context in copy up.
Some VFS operations (those which operate on FDs) get their credentials via the context instead of via an explicit creds param. For these cases, we must pass the overlay credentials on the context. PiperOrigin-RevId: 327881259
Diffstat (limited to 'pkg/sentry/contexttest/contexttest.go')
-rw-r--r--pkg/sentry/contexttest/contexttest.go22
1 files changed, 1 insertions, 21 deletions
diff --git a/pkg/sentry/contexttest/contexttest.go b/pkg/sentry/contexttest/contexttest.go
index 8e5658c7a..dfd195a23 100644
--- a/pkg/sentry/contexttest/contexttest.go
+++ b/pkg/sentry/contexttest/contexttest.go
@@ -144,27 +144,7 @@ func (t *TestContext) MemoryFile() *pgalloc.MemoryFile {
// RootContext returns a Context that may be used in tests that need root
// credentials. Uses ptrace as the platform.Platform.
func RootContext(tb testing.TB) context.Context {
- return WithCreds(Context(tb), auth.NewRootCredentials(auth.NewRootUserNamespace()))
-}
-
-// WithCreds returns a copy of ctx carrying creds.
-func WithCreds(ctx context.Context, creds *auth.Credentials) context.Context {
- return &authContext{ctx, creds}
-}
-
-type authContext struct {
- context.Context
- creds *auth.Credentials
-}
-
-// Value implements context.Context.
-func (ac *authContext) Value(key interface{}) interface{} {
- switch key {
- case auth.CtxCredentials:
- return ac.creds
- default:
- return ac.Context.Value(key)
- }
+ return auth.ContextWithCredentials(Context(tb), auth.NewRootCredentials(auth.NewRootUserNamespace()))
}
// WithLimitSet returns a copy of ctx carrying l.