← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~alexandru-sirbu/cloud-init/hashed-password-change into lp:cloud-init


Alex Sirbu has proposed merging lp:~alexandru-sirbu/cloud-init/hashed-password-change into lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)

For more details, see:

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. 
Your team cloud init development team is requested to review the proposed merge of lp:~alexandru-sirbu/cloud-init/hashed-password-change into lp:cloud-init.
=== modified file 'cloudinit/distros/__init__.py'
--- cloudinit/distros/__init__.py	2016-03-01 17:30:31 +0000
+++ cloudinit/distros/__init__.py	2016-03-02 09:25:42 +0000
@@ -393,6 +393,10 @@
         if 'plain_text_passwd' in kwargs and kwargs['plain_text_passwd']:
             self.set_passwd(name, kwargs['plain_text_passwd'])
+        # Set password if hashed password is provided and non-empty
+        if 'hashed_passwd' in kwargs and kwargs['hashed_passwd']:
+            self.set_passwd(name, kwargs['hashed_passwd'], True)
         # Default locking down the account.  'lock_passwd' defaults to True.
         # lock account unless lock_password is False.
         if kwargs.get('lock_passwd', True):