>From 87857adfee1384e790ce32fcf0ea341886ea1bc1 Mon Sep 17 00:00:00 2001 From: Rowland Penny Date: Tue, 19 Jan 2016 15:22:11 +0000 Subject: [PATCH] samba-tool: make 'samba-tool user password' a bit more user friendly Signed-off-by: Rowland Penny --- python/samba/netcmd/user.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py index cf640b0..37f93a7 100644 --- a/python/samba/netcmd/user.py +++ b/python/samba/netcmd/user.py @@ -480,14 +480,13 @@ Example4 shows how to set the account expiration so that it will never expire. class cmd_user_password(Command): - """Change password for a user account (the one provided in authentication). -""" + """Allow a user to change their own account password. - synopsis = "%prog [options]" + You do not need to add anything to the command, the user will + be prompted for their old password and then the new password (twice). +""" - takes_options = [ - Option("--newpassword", help="New password", type=str), - ] + synopsis = "%prog" takes_optiongroups = { "sambaopts": options.SambaOptions, @@ -495,8 +494,7 @@ class cmd_user_password(Command): "versionopts": options.VersionOptions, } - def run(self, credopts=None, sambaopts=None, versionopts=None, - newpassword=None): + def run(self, credopts=None, sambaopts=None, versionopts=None): lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) @@ -506,15 +504,13 @@ class cmd_user_password(Command): net = Net(creds, lp, server=credopts.ipaddress) - password = newpassword 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 password == passwordverify: + break + else: + self.outf.write("Sorry, passwords do not match. Try again.\n") try: net.change_password(password) -- 1.7.10.4