DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

smp_generate_pw(S)


smp_generate_pw -- provide a password

Syntax

cc . . . -lprot
#include <sys/types.h>
#include <prot.h>

int smp_generate_pw(cleartext, hyphenp, usrp, reasonp) char *cleartext; char **hyphenp; struct smp_user_info *usrp; char **reasonp;

Description

smp_generate_pw can be used to generate a new password for the account specified as name during the previous call to smp_check_user.

The password is generated by first calculating minimum and maximum password lengths. Then get_seed(S) is called to get a seed value and finally randomword(S) is called to generate the password.

smp_generate_pw copies the generated password to a pre-defined array, pointed to by cleartext. A hyphenated version is stored in the pre-defined array pointed to by *hyphenp. usrp points to a smp_user_info structure which has been created by the previous call to smp_check_user.

reasonp is used with certain return values to store a descriptive message.

Return values

Note that this routine also stores its return value for later use in auditing of failures.

SMP_COMPLETE
A password has been successfully generated.

SMP_EXTFAIL
For future use. Not currently returned.

Diagnostics

Normally, all diagnostics are returned as strings pointed to by the argument reasonp. However, in the current implementation no diagnostic messages are returned.

Examples

The following example illustrates the usage of smp_generate_pw :
    ...
    put("login: ");
    switch (smp_check_user(SMP_LOGIN, gets(line), ttyname(0), 0, &usrp,
                      &pwtries, &reason)) {
    ...
    case SMP_PWREQ:
        put("\nmust set password now\n");

if ((pwtype=smp_pw_choice(usrp, &reason)) == SMP_CHOOSE) { put("generate a password? "); if (tolower(*gets(line))=='y') pwtype = SMP_GENERATE; else pwtype = SMP_PICK; } else if (pwtype == SMP_EXTFAIL) { put(reason); put("\n"); exit(1); }

noecho(); for (;;) { if (pwtries < 1) { put("too many tries\n"); echo(); smp_audit_fail(usrp); exit(1); }

noecho(); switch (pwtype) { case SMP_PICK: ... break; case SMP_GENERATE: put("generating a password"); for (;;) { char *hyphen; if (smp_generate_pw(newpw, &hyphen, usrp, &reason) == SMP_EXTFAIL) { echo(); put(reason); put("\n"); exit(1); } put("\npassword: "); put(newpw); put(" hyphenated: "); put(hyphen); put(" enter password:"); if (strcmp(newpw, gets(line)) == 0) break; /* user takes this one */ if (strcmp(line, "quit") == 0) { put("\n"); echo(); smp_audit_fail(usrp); exit(1); } if (*line == '\0') continue; /* just return gets another one */ put("\nno match"); /* and go around again */ } put("\n"); break; } put("re-enter password: "); switch (smp_set_pw(gets(line), newpw, usrp, &pwtries, &reason)) { ... } break; } ... }

Files


/lib/libprot.a
security subsystem library routines

/usr/lib/libp/libprot.a
as above but used for profiling

/usr/include/prot.h
defines the smp_user_info structure

See also

smp_check_user(S), smp_check_pw(S), smp_pw_choice(S), smp_get_messages(S), smp_pw_change(S), smp_set_identity(S), smp_set_pw(S), smp_try_pw(S)

Standards conformance

smp_generate_pw is not part of any currently supported standard; it is an extension of AT&T System V provided by The Santa Cruz Operation, Inc.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003