+2002-01-30 Corinna Vinschen <corinna@vinschen.de>
+
+ * passwd.cc (ChangePW): Add parameter to differ between called for
+ checking old password and called for changing password. If called
+ for checking old password, return non-zero only if password is surely
+ incorrect.
+ (main): Call ChangePW() with additional parameter.
+
2002-01-29 Christopher Faylor <cgf@redhat.com>
* dump_setup.cc (parse_filename): Don't consider '_' part of the
}
int
-ChangePW (const char *user, const char *oldpwd, const char *pwd)
+ChangePW (const char *user, const char *oldpwd, const char *pwd, int justcheck)
{
WCHAR name[512], oldpass[512], pass[512];
DWORD ret;
MultiByteToWideChar (CP_ACP, 0, oldpwd, -1, oldpass, 512);
ret = NetUserChangePassword (NULL, name, oldpass, pass);
}
- if (! EvalRet (ret, user))
+ if (justcheck && ret != ERROR_INVALID_PASSWORD)
+ return 0;
+ if (! EvalRet (ret, user) && ! justcheck)
{
eprint (0, "Password changed.");
}
if (li->usri3_priv != USER_PRIV_ADMIN)
{
strcpy (oldpwd, getpass ("Old password: "));
- if (ChangePW (user, oldpwd, oldpwd))
+ if (ChangePW (user, oldpwd, oldpwd, 1))
return 1;
}
strcpy (newpwd, getpass ("New password: "));
if (strcmp (newpwd, getpass ("Re-enter new password: ")))
eprint (0, "Password is not identical.");
- else if (! ChangePW (user, *oldpwd ? oldpwd : NULL, newpwd))
+ else if (! ChangePW (user, *oldpwd ? oldpwd : NULL, newpwd, 0))
ret = 1;
if (! ret && cnt < 2)
eprint (0, "Try again.");