Merge lp:~alexandru-sirbu/cloud-init/hashed-password-change into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Alex Sirbu
Status: Merged
Merged at revision: 1174
Proposed branch: lp:~alexandru-sirbu/cloud-init/hashed-password-change
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 14 lines (+4/-0)
1 file modified
cloudinit/distros/__init__.py (+4/-0)
To merge this branch: bzr merge lp:~alexandru-sirbu/cloud-init/hashed-password-change
Reviewer Review Type Date Requested Status
Dan Watkins Approve
Review via email: mp+287755@code.launchpad.net

Description of the change

There was no way to change the password of an already existing user, by providing the new hashed password as an input.

The function def set_passwd(self, user, passwd, hashed=False): from the distros/__init__.py file already has the possibility of changing the password by giving it a hashed string, but this functionality wasn't used anywhere. By adding a new argument, hashed_passwd, to be used in the create_user function in a similar way to the plain_text_passwd, and by using the before mentioned function with the hashed paremeter set to True, the goal of changing the password with a hashed string is met.

To post a comment you must log in.
Revision history for this message
Dan Watkins (oddbloke) wrote :

One minor change requested. :)

review: Needs Fixing
1169. By Alex Sirbu

Used keyword for parameter in order to make it clearer what it represents.

Revision history for this message
Dan Watkins (oddbloke) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cloudinit/distros/__init__.py'
2--- cloudinit/distros/__init__.py 2016-03-01 17:30:31 +0000
3+++ cloudinit/distros/__init__.py 2016-03-02 09:58:22 +0000
4@@ -393,6 +393,10 @@
5 if 'plain_text_passwd' in kwargs and kwargs['plain_text_passwd']:
6 self.set_passwd(name, kwargs['plain_text_passwd'])
7
8+ # Set password if hashed password is provided and non-empty
9+ if 'hashed_passwd' in kwargs and kwargs['hashed_passwd']:
10+ self.set_passwd(name, kwargs['hashed_passwd'], hashed=True)
11+
12 # Default locking down the account. 'lock_passwd' defaults to True.
13 # lock account unless lock_password is False.
14 if kwargs.get('lock_passwd', True):