cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #04210
[Merge] ~harrykas/cloud-init:freebsd_improvement into cloud-init:master
Serhii Kharchenko has proposed merging ~harrykas/cloud-init:freebsd_improvement into cloud-init:master.
Requested reviews:
cloud-init commiters (cloud-init-dev)
For more details, see:
https://code.launchpad.net/~harrykas/cloud-init/+git/cloud-init/+merge/337761
--
Your team cloud-init commiters is requested to review the proposed merge of ~harrykas/cloud-init:freebsd_improvement into cloud-init:master.
diff --git a/cloudinit/config/cc_resizefs.py b/cloudinit/config/cc_resizefs.py
index cec22bb..431f495 100644
--- a/cloudinit/config/cc_resizefs.py
+++ b/cloudinit/config/cc_resizefs.py
@@ -81,7 +81,7 @@ def _resize_xfs(mount_point, devpth):
def _resize_ufs(mount_point, devpth):
- return ('growfs', devpth)
+ return ('growfs', '-y', devpth)
def _get_dumpfs_output(mount_point):
diff --git a/cloudinit/config/cc_set_passwords.py b/cloudinit/config/cc_set_passwords.py
index bb24d57..1bf3d75 100755
--- a/cloudinit/config/cc_set_passwords.py
+++ b/cloudinit/config/cc_set_passwords.py
@@ -134,24 +134,46 @@ def handle(_name, cfg, cloud, log, args):
ch_in = '\n'.join(plist_in) + '\n'
if users:
- try:
- log.debug("Changing password for %s:", users)
- util.subp(['chpasswd'], ch_in)
- except Exception as e:
- errors.append(e)
- util.logexc(
- log, "Failed to set passwords with chpasswd for %s", users)
+ if util.is_FreeBSD():
+ for line in plist_in:
+ u, p = line.split(':', 1)
+ try:
+ log.debug("Changing password for %s:", u)
+ util.subp(['pw', 'usermod', u, '-h', '0'], data=p)
+ except Exception as e:
+ errors.append(e)
+ util.logexc(
+ log, "Failed to set passwords with 'pw usermod -h 0' for %s", u)
+ else:
+ try:
+ log.debug("Changing password for %s:", users)
+ util.subp(['chpasswd'], ch_in)
+ except Exception as e:
+ errors.append(e)
+ util.logexc(
+ log, "Failed to set passwords with chpasswd for %s", users)
hashed_ch_in = '\n'.join(hashed_plist_in) + '\n'
if hashed_users:
- try:
- log.debug("Setting hashed password for %s:", hashed_users)
- util.subp(['chpasswd', '-e'], hashed_ch_in)
- except Exception as e:
- errors.append(e)
- util.logexc(
- log, "Failed to set hashed passwords with chpasswd for %s",
- hashed_users)
+ if util.is_FreeBSD():
+ for line in hashed_plist_in:
+ u, p = line.split(':', 1)
+ try:
+ log.debug("Changing password for %s:", u)
+ util.subp(['pw', 'usermod', u, '-H', '0'], data=p)
+ except Exception as e:
+ errors.append(e)
+ util.logexc(
+ log, "Failed to set passwords with 'pw usermod -H 0' for %s", u)
+ else:
+ try:
+ log.debug("Setting hashed password for %s:", hashed_users)
+ util.subp(['chpasswd', '-e'], hashed_ch_in)
+ except Exception as e:
+ errors.append(e)
+ util.logexc(
+ log, "Failed to set hashed passwords with chpasswd for %s",
+ hashed_users)
if len(randlist):
blurb = ("Set the following 'random' passwords\n",
@@ -162,7 +184,11 @@ def handle(_name, cfg, cloud, log, args):
expired_users = []
for u in users:
try:
- util.subp(['passwd', '--expire', u])
+ if util.is_FreeBSD():
+ util.subp(['pw', 'usermod', u, '-p', '+1s'])
+ else:
+ util.subp(['passwd', '--expire', u])
+
expired_users.append(u)
except Exception as e:
errors.append(e)
Follow ups