DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

smp_generate_pw(S-osr5)


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-osr5) is called to get a seed value and finally randomword(S-osr5) 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-osr5), smp_check_pw(S-osr5), smp_pw_choice(S-osr5), smp_get_messages(S-osr5), smp_pw_change(S-osr5), smp_set_identity(S-osr5), smp_set_pw(S-osr5), smp_try_pw(S-osr5)

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.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005