|
|
#include <sys/types.h> #include prot.hint smp_check_pw(password, usrp, reasonp) char *password; struct smp_user_info *usrp; char **reasonp;
usrp points to an smp_user_info structure which has been created by a previous call to smp_check_user. If an encrypted password exists, password is compared using bigcrypt(S). It is possible that the previously saved account information may be null (resulting from SMP_BADUSER returned from a previous call to smp_check_user(S)). In both the case of a mismatched password or in the above case, smp_check_pw will return SMP_NOPWMATCH. This enables smp_check_pw to be called even if the user name is invalid.
In the case where the password is valid, smp_check_pw copies password into storage for later use and performs the following additional checks:
reasonp is used with certain return values to store a descriptive message.
However, in all of the above cases the ``root on console'' flag has been previously set by smp_check_user and login should be permitted to correct the problem. reasonp points to a character string explaining the type of failure.
Account lockedTerminal lockedAccount retired...
switch (smp_check_user(SMP_LOGIN, gets(line), ttyname(0), 0, &usrp,
&pwtry, &reason)) {
...
case SMP_BADUSER:
case SMP_HASPW:
noecho();
put("password: ");
switch (smp_check_pw(gets(line), userp, &reason)) {
case SMP_EXTFAIL:
echo();
put("\n");
put(reason);
put("\n");
exit(1);
case SMP_NOPWMATCH:
echo();
put("\nlogin incorrect\n");
smp_audit_fail(userp);
exit(1);
case SMP_ACCTLOCK:
echo();
put("\naccount locked\n");
smp_audit_fail(userp);
exit(1);
case SMP_RETIRED:
echo();
put("\naccount retired\n");
smp_audit_fail(userp);
exit(1);
case SMP_OVERRIDE:
put(reason);
put("\nroot login on console is allowed\n");
case SMP_CANCHANGE:
case SMP_CANTCHANGE:
goto loginok;
case SMP_MUSTCHANGE:
put("\npassword has expired"); /* fall through to set new pw */
}
echo();
case SMP_PWREQ:
put("\nmust set password now\n");
if ((pwtype=smp_pw_choice(userp, &reason)) == SMP_CHOOSE) {
...
}
...
}
...
}
...
loginok: