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
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.
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): 'chpasswd' ): ['chpasswd' ], plist_in) splitlines( ).split( ":"): set_passwd( u, p, hashed=hashed)
if util.which(
util.subp(
else:
for u, p in plist_in.
distro.
And then the two places in handle() which call util.subp( ['chpasswd' ])
will use
chpassword( plist_in) plist_in, hashed=True)
chpassword(
And the expire already uses passwd directly.
The result of the changes should pass unittest without any changes, except on the 'chpasswd' ) to False, taking us down the
FreeBSD path, we'd mock out the util.which(
path that calls distro.set_passwd() for each user:pass pair since there's no chpasswd
binary on FreeBSD.
Make sense?