diff options
author | Ben Arblaster <ben@andatche.com> | 2015-01-20 00:52:04 +0000 |
---|---|---|
committer | Ben Arblaster <ben@andatche.com> | 2015-01-20 00:52:04 +0000 |
commit | 93f5af9f5075a416c65c1d0350c374e16f32f0d5 (patch) | |
tree | 370788bbdbda7c2a2108ca7dc0f194d72311c4a5 /cloudinit/distros | |
parent | fbc01e536cdd023a954703fdc3bbe76df1d9ed1a (diff) | |
download | vyos-cloud-init-93f5af9f5075a416c65c1d0350c374e16f32f0d5.tar.gz vyos-cloud-init-93f5af9f5075a416c65c1d0350c374e16f32f0d5.zip |
More FreeBSD improvements
- Implement set_passwd
- Implement set_timezone
- Use /bin/tcsh as default user shell (FreeBSD default)
- Change default username to freebsd
- Enable set-passwords, package-update-upgrade-install and timezone modules
- Remove trailing whitespace
Diffstat (limited to 'cloudinit/distros')
-rw-r--r-- | cloudinit/distros/freebsd.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/cloudinit/distros/freebsd.py b/cloudinit/distros/freebsd.py index 10f9e7e0..c59a074b 100644 --- a/cloudinit/distros/freebsd.py +++ b/cloudinit/distros/freebsd.py @@ -238,9 +238,21 @@ class Distro(distros.Distro): util.logexc(LOG, "Failed to create user %s", name) raise e - # TODO: def set_passwd(self, user, passwd, hashed=False): - return False + cmd = ['pw', 'usermod', user] + + if hashed: + cmd.append('-H') + else: + cmd.append('-h') + + cmd.append('0') + + try: + util.subp(cmd, passwd, logstring="chpasswd for %s" % user) + except Exception as e: + util.logexc(LOG, "Failed to set password for %s", user) + raise e def lock_passwd(self, name): try: @@ -394,10 +406,10 @@ class Distro(distros.Distro): cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) - util.subp(cmd, env=e, capture=False) + util.subp(cmd, env=e, capture=False) def set_timezone(self, tz): - return + distros.set_etc_timezone(tz=tz, tz_file=self._find_tz_file(tz)) def update_package_sources(self): self._runner.run("update-sources", self.package_command, |