|
|
#include <sys/types.h> #include <prot.h>int smp_set_pw(password, checkpw, usrp, pwtriesp, reasonp) char *password; char *checkpw; struct smp_user_info *userp; int *pwtriesp; char **reasonp;
This routine verifies that checkpw, entered by the user, matches the previously entered password specified by password. If the two match, it then encrypts the password, updates the authentication data, sets the last successful password change time, and writes it back into the password and protected password databases. An audit record is written for the password change.
If /bin/yppasswd exists, and is a link to /bin/passwd, /etc/yp/yppwd will be called to update the NIS databases, prior to updating the local databases.
usrp points to an smp_user_info structure which has been created by the previous call to smp_check_user.
If the clear text passwords do not match, the number of retries remaining, pointed to by pwtriesp, is decremented.
reasonp is used with certain return values to store a descriptive message.
NIS password change failedCannot write protected password entry
...
switch (smp_check_user(SMP_LOGIN, gets(line), ttyname(0), 0, &userp,
&pwtries, &reason)) {
...
case SMP_PWREQ:
...
for (;;) {
...
put("re-enter password: ");
switch (smp_set_pw(gets(line), newpw, userp,
&pwtries, &reason)) {
case SMP_NOTAUTH:
echo();
put("\nnot authorised\n"); /* can't write auth database */
exit(1);
case SMP_NOMATCH:
put("\nno match\n");
continue; /* go around again */
case SMP_EXTFAIL:
echo();
put("\n");
put(reason);
put("\n");
exit(1);
case SMP_COMPLETE:
put("\n");
break;
}
break;
}
loginok:
put("\n");
echo();
break;
}
...