unix::passwd +linux +x86_64

Index

Types

type grent;
type pwent;

Errors

type invalid;

Functions

fn getgid(uint) (grent | void);
fn getgroup(str) (grent | void);
fn getuid(uint) (pwent | void);
fn getuser(str) (pwent | void);
fn grent_finish(*grent) void;
fn nextgr(io::handle) (grent | io::EOF | io::error | invalid);
fn nextpw(io::handle) (pwent | io::EOF | io::error | invalid);
fn pwent_finish(*pwent) void;

Types

type grent[link]

type grent = struct {
	// Name of the group
name: str, // Optional encrypted password
password: str, // Numerical group ID
gid: uint, // 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: uint, // Numerical group ID
gid: uint, // 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: uint) (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: uint) (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(file: 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.