diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-08-21 22:09:18 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-08-21 22:09:18 +0000 |
commit | 2584fdbb39bad0fb018fc3687338dbbce173d6a9 (patch) | |
tree | 435549a701a5c7128a5f0d2a2caa4c6855b635a1 /pkg/sentry/kernel/auth | |
parent | 1b1de470fa39ce55df3559c2e4901a74d3084f13 (diff) | |
parent | 5f33fdf37e6386975323ca2bab0dccd51d82df65 (diff) |
Merge release-20200810.0-84-g5f33fdf37 (automated)
Diffstat (limited to 'pkg/sentry/kernel/auth')
-rw-r--r-- | pkg/sentry/kernel/auth/context.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pkg/sentry/kernel/auth/context.go b/pkg/sentry/kernel/auth/context.go index ef5723127..c08d47787 100644 --- a/pkg/sentry/kernel/auth/context.go +++ b/pkg/sentry/kernel/auth/context.go @@ -34,3 +34,23 @@ func CredentialsFromContext(ctx context.Context) *Credentials { } return NewAnonymousCredentials() } + +// ContextWithCredentials returns a copy of ctx carrying creds. +func ContextWithCredentials(ctx context.Context, creds *Credentials) context.Context { + return &authContext{ctx, creds} +} + +type authContext struct { + context.Context + creds *Credentials +} + +// Value implements context.Context. +func (ac *authContext) Value(key interface{}) interface{} { + switch key { + case CtxCredentials: + return ac.creds + default: + return ac.Context.Value(key) + } +} |