aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2002-01-30 11:57:16 +0000
committerCorinna Vinschen <corinna@vinschen.de>2002-01-30 11:57:16 +0000
commit9783296270634b2a1ed09ab4c3fab010c3cdf88b (patch)
tree67bf0df51d7020cc2ad8cb281d3b717f3c5acbb6
parent8e2deb48d66dd5ac1d728582959b0d0a66b737d3 (diff)
downloadnewlib-9783296270634b2a1ed09ab4c3fab010c3cdf88b.zip
newlib-9783296270634b2a1ed09ab4c3fab010c3cdf88b.tar.gz
newlib-9783296270634b2a1ed09ab4c3fab010c3cdf88b.tar.bz2
* 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.
-rw-r--r--winsup/utils/ChangeLog8
-rw-r--r--winsup/utils/passwd.c10
2 files changed, 14 insertions, 4 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog
index 568b8b2..7cfe3e2 100644
--- a/winsup/utils/ChangeLog
+++ b/winsup/utils/ChangeLog
@@ -1,3 +1,11 @@
+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
diff --git a/winsup/utils/passwd.c b/winsup/utils/passwd.c
index e6c9409..9a90f6e 100644
--- a/winsup/utils/passwd.c
+++ b/winsup/utils/passwd.c
@@ -97,7 +97,7 @@ GetPW (const char *user)
}
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;
@@ -116,7 +116,9 @@ ChangePW (const char *user, const char *oldpwd, const char *pwd)
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.");
}
@@ -334,7 +336,7 @@ main (int argc, char **argv)
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;
}
@@ -343,7 +345,7 @@ main (int argc, char **argv)
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.");