[Top] [Prev] [Next]

get, put - read and write password entries in the password file

include "keyring.m";
include "security.m";
pw := load Password Password->PATH;

Password: module
{
  PW: adt {
            id:     string;         # user id
            pw:     array of byte;  # password
        expire: int;       # expiration time (epoch seconds)
         other:  string;            # about the account
           };
  get: fn(id: string): ref PW;
  put: fn(pass: ref PW): int;
  PWlen: con 4;

Description

This module provides a convenient interface to the password file (/keydb/password). Each entry in the file contains information corresponding to the members of the PW adt. Those members and their respective sizes (in bytes) are:
id

32

User identification string

pw

Keyring->SHAdlen (20)

Password.

expire

length of int (4)

Expiration data in seconds of epoch (Jan 1 00:00 1970 GMT). See daytime: text, filet, gmt, local, now, time, tm2epoch - time conversions in Chapter 15.

other

72

Arbitrary administrative comment.

Each new entry increases the size of the password file by 128 bytes.

The functions provide access to the file:
get(id)

If user id has an entry in the password file, the get function supplies a PW adt with the corresponding information. Otherwise, a nil reference is returned.

put(pass)

The put function copies the information of the pass adt into the password file. If an entry for pass.id already exists, it is overwritten; otherwise, a new entry is appended to the file. If none exists, the password file is created.

Any members of PW that exceed the corresponding field limit are silently truncated before being written to the password file.

The constant PWlen is currently unused.

Files
/keydb/password

Storage for password entries.

Caveat

Access to the password file is not serialized.

This module transfers data without transformation (except for the truncating of excessively long fields) between the PWD adt and the password file. If some transformation is needed (for example, encryption of the pw value), the caller must make separate arrangements.

See Also
logind - login daemon in Chapter 9

changelogin - command to create/update the password file



[Top] [Prev] [Next]

infernosupport@lucent.com
Copyright © 1996,Lucent Technologies, Inc. All rights reserved.