Reference

peks-passwd(3)

handling user passwords

NAME

peks_edit_passwd_file - handling user passwords

SYNOPSIS

#include <peks.h>

char *peks_edit_passwd_file
       (const peks_key *prv_key, const char *usr_at_host,
        int count, const char *passwd,
        const char *pwd_file);

DESCRIPTION

Peks_edit_passwd_file () manipulates passwords which can be stored together with any kind of user, or host keys. Passwords are tagged as user keys, so the same selection algorithm applies as in peks-keys(3).

If the first argument prv_key and the forth argument passwd are non NULL, the password line selected by the second argument usr_at_host is appended, or replaced respectively with an prv_key-encrypted version of the text

<count> <usr> <passwd>

where count is the letter '0' + count modulo 32 (count is the third argument,) <usr> is the user name part of usr_at_host (looking like "usr@host"), and <passwd> is the text given as the forth argument passwd.

If the first argument prv_key is non NULL but the forth argument passwd is NULL, the passwd line is decoded and returned. With a non-negative third argument count, the three fields

<count> <usr> <passwd>

are returned which is the literal contents of the encrypted password text, stored in the data base. If the argument count is negative, a fourth field is possibly appended as in

<count> <usr> <passwd> <netspecs>

This forth field is a copy of the access specification. Is is the optional host or network part in the user@host:, or user@network: tag stored in the data base (see peks-keyfile(5) for derails on the syntax.)

If the first argument prv_key is NULL, the password line is deleted.

RETURN VALUE

If there was no error, a character string is returned, an NULL otherwise (while the global variable errno is set - see errno(3) for details).

In case that a password line is appended/replaced or deleted, this return value is the empty string "".

Otherwise the password line is returned as a string with the three text fields as indicated above, separated by exactly one space.

ENVIRONMENT VARIABLES

HOME

Used for the key file name expansion when there is a leading tilde-slash as in "~/<pwd_file>".

SEE ALSO

peks-keys(3). peks-keyfile(5), tagsresolve(3), errno(3).

AUTHOR

The peks package where these functions belong to was written by Jordan Hrycaj <[email protected]>, originally to support the nessus security scanner.