users

package
v1.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2023 License: MPL-2.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Current

func Current() (*user.User, error)

Current returns the current user, acquired while holding a global process lock.

func Lookup

func Lookup(username string) (*user.User, error)

Lookup returns the user.User entry associated with the given username.

Values are cached up to 1 hour, or 1 minute for failure cases.

func SocketFileFor added in v1.5.0

func SocketFileFor(logger hclog.Logger, path, username string) (net.Listener, error)

SocketFileFor creates a unix domain socket file on the specified path and, if possible, makes it usable by only the specified user. Failing that it will leave the socket open to all users. Non-fatal errors are logged.

See WriteFileFor if writing a regular file.

func UIDforUser added in v1.5.0

func UIDforUser(username string) (int, error)

UIDforUser returns the UID for the specified username or returns an error.

Will always fail on Windows and Plan 9.

func WriteFileFor added in v1.5.0

func WriteFileFor(path string, contents []byte, username string) error

WriteFileFor is like os.WriteFile except if possible it chowns the file to the specified user (possibly from Task.User) and sets the permissions to 0o600.

If chowning fails (either due to OS or Nomad being unprivileged), the file will be left world readable (0o666).

On failure a multierror with both the original and fallback errors will be returned.

See SocketFileFor if writing a unix socket file.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL