I think the change for the permissions would best happen in write_file.
We'd like to say: use existing mode if the file exists, otherwise use X.
maybe an argument: use_existing_mode=True
that would use the existing mode if the file exixsted, otherwise would use 'mode'.
adn default that to False (for backwards compat).
I think the change for the permissions would best happen in write_file.
We'd like to say: use existing mode if the file exists, otherwise use X.
maybe an argument: use_existing_ mode=True
that would use the existing mode if the file exixsted, otherwise would use 'mode'.
adn default that to False (for backwards compat).
A simpler change for *just this* looks like: config/ cc_set_ passwords. py config/ cc_set_ passwords. py
pw_ auth))
--- a/cloudinit/
+++ b/cloudinit/
@@ -215,7 +215,13 @@ def handle(_name, cfg, cloud, log, args):
lines = [str(l) for l in new_lines] file(ssh_ util.DEF_ SSHD_CFG, "\n".join(lines)) exists( ssh_util. DEF_SSHD_ CFG): IMODE(os. lstat(ssh_ util.DEF_ SSHD_CFG) .st_mode) file(ssh_ util.DEF_ SSHD_CFG, "\n".join(lines) + "\n",
- util.write_
+ import os, stat
+ mode = 0o600
+ if os.path.
+ mode = stat.S_
+
+ util.write_
+ mode=mode)
try: init_cmd # Default service
cmd = cloud.distro.