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, separated by commas
	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,
};

// Undocumented types:
type groupreader = struct {
	scan: bufio::scanner,
};
type userreader = struct {
	scan: bufio::scanner,
};

Errors

type invalid = !void;

Functions

fn getgid(gid: unix::gid) (grent | void);
fn getgroup(name: str) (grent | void);
fn getgroups(name: str) []grent;
fn getuid(uid: unix::uid) (pwent | void);
fn getuser(username: str) (pwent | void);
fn grent_finish(ent: *grent) void;
fn grents_free(ents: []grent) void;
fn groups_finish(rd: *groupreader) void;
fn groups_read(in: io::handle) groupreader;
fn nextgr(rd: *groupreader) (grent | io::EOF | io::error | invalid);
fn nextpw(rd: *userreader) (pwent | io::EOF | io::error | invalid);
fn pwent_finish(ent: *pwent) void;
fn users_finish(rd: *userreader) void;
fn users_read(in: io::handle) userreader;

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, separated by commas
	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.

type groupreader[link]

Show undocumented member
type groupreader = struct {
	scan: bufio::scanner,
};

type userreader[link]

Show undocumented member
type userreader = struct {
	scan: bufio::scanner,
};

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.

The user must pass the return value to grent_finish to free resources associated with the group.

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.

The user must pass the return value to grent_finish to free resources associated with the group.

See nextgr for low-level parsing API.

fn getgroups[link]

fn getgroups(name: str) []grent;

Looks up groups by user 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. The caller must pass the return value to grents_finish.

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 a grent.

fn grents_free[link]

fn grents_free(ents: []grent) void;

Frees resources associated with a slice of grents.

fn groups_finish[link]

fn groups_finish(rd: *groupreader) void;

Frees resources associated with a groupreader.

fn groups_read[link]

fn groups_read(in: io::handle) groupreader;

Creates a parser for an /etc/groups-formatted file. Use nextgr to enumerate the groups, and groups_finish to free resources associated with the reader.

fn nextgr[link]

fn nextgr(rd: *groupreader) (grent | io::EOF | io::error | invalid);

Reads a Unix-like group entry from a grreader. The return value is borrowed from the scanner.

fn nextpw[link]

fn nextpw(rd: *userreader) (pwent | io::EOF | io::error | invalid);

Reads a Unix-like password entry from an io::handle. The return value is borrowed from the reader.

fn pwent_finish[link]

fn pwent_finish(ent: *pwent) void;

Frees resources associated with a pwent.

fn users_finish[link]

fn users_finish(rd: *userreader) void;

Frees resources associated with a groupreader.

fn users_read[link]

fn users_read(in: io::handle) userreader;

Creates a parser for an /etc/passwd-formatted file. Use nextpw to enumerate the users, and users_finish to free resources associated with the reader.