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,
};
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
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.
type groupreader
Show undocumented member
type groupreader = struct {
scan: bufio::scanner,
};
type userreader
Show undocumented member
type userreader = struct {
scan: bufio::scanner,
};
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.
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
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
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
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 a grent.
fn grents_free
fn grents_free(ents: []grent) void;
Frees resources associated with a slice of grents.
fn groups_finish
fn groups_finish(rd: *groupreader) void;
Frees resources associated with a groupreader.
fn groups_read
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
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
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
fn pwent_finish(ent: *pwent) void;
Frees resources associated with a pwent.
fn users_finish
fn users_finish(rd: *userreader) void;
Frees resources associated with a groupreader.
fn users_read
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.