unix::passwd+x86_64 +linux

Index

Types

type grent = struct {
	// Name of the group
	name: str,
	// Optional encrypted password
	password: str,
	// Numerical group ID
	gid: unix::gid,
	// List of usernames that are members of this group
	userlist: []str,
};
type pwent = struct {
	// Login name
	username: str,
	// Optional encrypted password
	password: str,
	// Numerical user ID
	uid: unix::uid,
	// Numerical group ID
	gid: unix::gid,
	// User name or comment field
	comment: str,
	// User home directory
	homedir: str,
	// Optional user command interpreter
	shell: str,
};

Errors

type invalid = !void;

Functions

fn getgid(gid: unix::gid) (grent | void);
fn getgroup(name: str) (grent | void);
fn getuid(uid: unix::uid) (pwent | void);
fn getuser(username: str) (pwent | void);
fn grent_finish(ent: *grent) void;
fn nextgr(in: io::handle) (grent | io::EOF | io::error | invalid);
fn nextpw(in: io::handle) (pwent | io::EOF | io::error | invalid);
fn pwent_finish(ent: *pwent) void;

Types

type grent[link]

type grent = struct {
	// Name of the group
	name: str,
	// Optional encrypted password
	password: str,
	// Numerical group ID
	gid: unix::gid,
	// List of usernames that are members of this group
	userlist: []str,
};

A Unix-like group file entry.

type pwent[link]

type pwent = struct {
	// Login name
	username: str,
	// Optional encrypted password
	password: str,
	// Numerical user ID
	uid: unix::uid,
	// Numerical group ID
	gid: unix::gid,
	// User name or comment field
	comment: str,
	// User home directory
	homedir: str,
	// Optional user command interpreter
	shell: str,
};

A Unix-like password database entry.

Errors

type invalid[link]

type invalid = !void;

An invalid entry was encountered during parsing.

Functions

fn getgid[link]

fn getgid(gid: unix::gid) (grent | void);

Looks up a group by ID in a Unix-like group file. It expects a such file at /etc/group. Aborts if that file doesn't exist or is not properly formatted.

See nextgr for low-level parsing API.

fn getgroup[link]

fn getgroup(name: str) (grent | void);

Looks up a group by name in a Unix-like group file. It expects a such file at /etc/group. Aborts if that file doesn't exist or is not properly formatted.

See nextgr for low-level parsing API.

fn getuid[link]

fn getuid(uid: unix::uid) (pwent | void);

Looks up a user by ID in a Unix-like password file. It expects a password database file at /etc/passwd. Aborts if that file doesn't exist or is not properly formatted. The return value must be freed with pwent_finish.

See nextpw for low-level parsing API.

fn getuser[link]

fn getuser(username: str) (pwent | void);

Looks up a user by name in a Unix-like password file. It expects a password database file at /etc/passwd. Aborts if that file doesn't exist or is not properly formatted. The return value must be freed with pwent_finish.

See nextpw for low-level parsing API.

fn grent_finish[link]

fn grent_finish(ent: *grent) void;

Frees resources associated with grent.

fn nextgr[link]

fn nextgr(in: io::handle) (grent | io::EOF | io::error | invalid);

Reads a Unix-like group entry from an io::handle. The caller must free the return value using grent_finish.

fn nextpw[link]

fn nextpw(in: io::handle) (pwent | io::EOF | io::error | invalid);

Reads a Unix-like password entry from an io::handle. The caller must free the return value using pwent_finish.

fn pwent_finish[link]

fn pwent_finish(ent: *pwent) void;

Frees resources associated with a pwent.