package user

import "gvisor.dev/gvisor/pkg/sentry/fsimpl/user"

Package user contains methods for resolving filesystem paths based on the user and their environment.

Index

Functions

func FindGroupInGroupFile

func FindGroupInGroupFile(group io.Reader, gidString string) auth.KGID

FindGroupInGroupFile parses a group file and returns the given group's gid. If the gid is a number, we don't need to read the file.

If we don't find the group, we return 0.

func FindUIDGIDInPasswd

func FindUIDGIDInPasswd(passwd io.Reader, user string) (auth.KUID, auth.KGID)

FindUIDGIDInPasswd parses a passwd file and returns the given user's uid and gid.

func GetExecUIDGIDFromUser

func GetExecUIDGIDFromUser(ctx context.Context, vmns *vfs.MountNamespace, user string) (auth.KUID, auth.KGID)

GetExecUIDGIDFromUser retrieves the UID and GID from /etc/passwd file for the given user.

func MaybeAddExecUserHome

func MaybeAddExecUserHome(ctx context.Context, vmns *vfs.MountNamespace, uid auth.KUID, envv []string) ([]string, error)

MaybeAddExecUserHome returns a new slice with the HOME environment variable set if the slice does not already contain it, otherwise it returns the original slice unmodified.

func ResolveExecutablePath

func ResolveExecutablePath(ctx context.Context, args *kernel.CreateProcessArgs) (string, error)

ResolveExecutablePath resolves the given executable name given the working dir and environment. Returns *ExecutableResolveError when the executable cannot be resolved.

Types

type ExecutableResolveError

type ExecutableResolveError struct {
	// contains filtered or unexported fields
}

ExecutableResolveError represents a failure to resolve the executable in ResolveExecutablePath.

Source Files

path.go user.go

Version
v0.0.0-20250605235530-a6711d1e1dc6 (latest)
Published
Jun 5, 2025
Platform
linux/amd64
Imports
15 packages
Last checked
4 hours ago

Tools for package owners.