samba-tool: do a password retype validation check for 'samba-tool user setpassword'
authorStefan Metzmacher <metze@samba.org>
Thu, 2 Jun 2016 12:25:12 +0000 (14:25 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 30 Jun 2016 01:30:24 +0000 (03:30 +0200)
This matches the behavior of 'samba-tool user create' and 'samba-tool user password'.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11441

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/netcmd/user.py

index 2a93a30197e5f7bfda6e54e2c741ff63e5041c93..3caa51820f015a8bfe718b30b3e7d98869c5c6fb 100644 (file)
@@ -597,15 +597,19 @@ Example3 shows how an administrator would reset TestUser3 user's password to pas
         if filter is None and username is None:
             raise CommandError("Either the username or '--filter' must be specified!")
 
+        password = newpassword
+
         if random_password:
             password = generate_random_password(128, 255)
-        else:
-            password = newpassword
 
-        while 1:
+        while True:
             if password is not None and password is not '':
                 break
             password = getpass("New Password: ")
+            passwordverify = getpass("Retype Password: ")
+            if not password == passwordverify:
+                password = None
+                self.outf.write("Sorry, passwords do not match.\n")
 
         if filter is None:
             filter = "(&(objectClass=user)(sAMAccountName=%s))" % (ldb.binary_encode(username))