unix::passwd
Index
Types
type grent = struct {
name: str,
password: str,
gid: unix::gid,
userlist: []str,
};
type pwent = struct {
username: str,
password: str,
uid: unix::uid,
gid: unix::gid,
comment: str,
homedir: str,
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
type grent = struct {
name: str,
password: str,
gid: unix::gid,
userlist: []str,
};
A Unix-like group file entry.
type pwent
type pwent = struct {
username: str,
password: str,
uid: unix::uid,
gid: unix::gid,
comment: str,
homedir: str,
shell: str,
};
A Unix-like password database entry.
Errors
type invalid
type invalid = !void;
An invalid entry was encountered during parsing.
Functions
fn getgid
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
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
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
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
fn grent_finish(ent: *grent) void;
Frees resources associated with grent.
fn nextgr
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
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
fn pwent_finish(ent: *pwent) void;
Frees resources associated with a pwent.