package users
import "github.com/hashicorp/nomad/helper/users"
Index ¶
- func Current() (*user.User, error)
- func Lookup(username string) (*user.User, error)
- func LookupUnix(username string) (int, int, string, error)
- func SocketFileFor(logger hclog.Logger, path, username string) (net.Listener, error)
- func WriteFileFor(path string, contents []byte, username string) error
Functions ¶
func Current ¶
Current returns the current user, acquired while holding a global process lock.
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 LookupUnix ¶
LookupUnix returns the UID, GID, and home directory for username or returns an error. ID values are int to work well with Go library functions.
Will always fail on Windows and Plan 9.
func SocketFileFor ¶
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 WriteFileFor ¶
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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
helper/users/dynamic | Package dynamic provides a way of allocating UID/GID to be used by Nomad tasks with no associated service users managed by the operating system. |
- Version
- v1.10.0 (latest)
- Published
- Apr 9, 2025
- Platform
- linux/amd64
- Imports
- 11 packages
- Last checked
- 2 days ago –
Tools for package owners.