Documentation ¶
Index ¶
- func Current() (*user.User, error)
- func Lookup(username string) (*user.User, error)
- func Nobody() user.User
- func NobodyIDs() (uint32, uint32)
- func SocketFileFor(logger hclog.Logger, path, username string) (net.Listener, error)
- func UIDforUser(username string) (int, error)
- func WriteFileFor(path string, contents []byte, username string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Lookup ¶
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 Nobody ¶
Nobody returns User data for the "nobody" user on the system, bypassing the locking / file read / NSS lookup.
func SocketFileFor ¶ added in v1.5.0
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
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
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.