.TH SECURITY-PASSWORD 2
.SH NAME
password: get, put, setpwfile \- read and write password entries in the password file
.SH SYNOPSIS
.EX
include "keyring.m";
include "security.m";
pw := load Password Password->PATH;

PW: adt {
    id:     string;         # user id
    pw:     array of byte;  # hashed password
    expire: int;            # expiration time
    other:  string;         # about the account
};

get:    fn(id: string): ref PW;
put:    fn(pass: ref PW): int;
setpwfile:   fn(file: string): string;
.EE
.SH DESCRIPTION
This module provides a convenient interface to a server's password file
.RB "(default: " /keydb/password ).
Each entry in the file contains information corresponding to the members of the
.B PW
adt, with the following members:
.TF expire
.PD
.TP
.B id
user identification string
(should be less than
.BR Sys->NAMELEN
bytes)
.TP
.B pw
password hashed by the SHA algorithm
(see
.IR keyring-sha (2))
into a byte array
.TP
.B expire
password entry expiry date expressed as seconds from the epoch
(1 Jan 1970 00:00:00 GMT);
see
.IR daytime (2)
.TP
.B other
arbitrary administrative comment
.PP
The functions provide access to the file.
If user
.I id
has got a corresponding entry in the password file,
.B get
returns a
.B PW
adt with the data from that entry.
Otherwise, it returns a nil reference.
.PP
.B Put
creates or updates the password entry for
.IB pass .id ,
with the data in
.IR pass .
The password file itself is created if necessary.
.PP
The standard system password file is used by default, but
an application might maintain a set of passwords of its own.
It can use the
.B Password
module to access the file, by first calling
.B setpwfile
to name the file to be used by
.B get
and
.BR put .
.SH FILES
.B /keydb/password
.SH SOURCE
.B /appl/lib/password.b
.SH "SEE ALSO"
.IR changelogin (8),
.IR logind (8)
.SH BUGS
Access to the password file is not serialised;
the password file entries should be protected by encryption.
Both problems will be solved by replacing these routines by a file server
to manage the entries.
