Code review comment for ~goneri/cloud-init:freebsd_set_password

Revision history for this message
Ryan Harper (raharper) wrote :

OK. If the core issue is that freebsd doesn't have a chpasswd, which takes a list of users to modify, rather than a single user (like passwd). Then I think we need a different interface.

In cc_set_password, something like:

def chpassword(plist_in, hashed=False):
    if util.which('chpasswd'):
 util.subp(['chpasswd'], plist_in)
    else:
 for u, p in plist_in.splitlines().split(":"):
     distro.set_passwd(u, p, hashed=hashed)

And then the two places in handle() which call util.subp(['chpasswd'])
will use

chpassword(plist_in)
chpassword(plist_in, hashed=True)

And the expire already uses passwd directly.

The result of the changes should pass unittest without any changes, except on the
FreeBSD path, we'd mock out the util.which('chpasswd') to False, taking us down the
path that calls distro.set_passwd() for each user:pass pair since there's no chpasswd
binary on FreeBSD.

Make sense?

review: Needs Fixing

« Back to merge proposal