← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1677205] [NEW] cloud-init eats final EOL of sshd_config

 

Public bug reported:

cloud-init reads in sshd_config, and then writes it out again, but eats
the final newline.

It also changes the file mode to 644, which I don't like since the
original was 600, but I haven't yet found a decent way to change that.

While I'm at it, spellcheck in comment.

HAND


diff --git a/cloudinit/config/cc_set_passwords.py b/cloudinit/config/cc_set_passwords.py
index eb0bdab0..ed30a9d9 100755
--- a/cloudinit/config/cc_set_passwords.py
+++ b/cloudinit/config/cc_set_passwords.py
@@ -215,7 +215,7 @@ def handle(_name, cfg, cloud, log, args):
                                                      pw_auth))

         lines = [str(l) for l in new_lines]
-        util.write_file(ssh_util.DEF_SSHD_CFG, "\n".join(lines))
+        util.write_file(ssh_util.DEF_SSHD_CFG, "\n".join(lines)+"\n")

         try:
             cmd = cloud.distro.init_cmd  # Default service
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 33019579..a8e84da8 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -1691,7 +1691,7 @@ def chmod(path, mode):
 def write_file(filename, content, mode=0o644, omode="wb"):
     """
     Writes a file with the given content and sets the file mode as specified.
-    Resotres the SELinux context if possible.
+    Restores the SELinux context if possible.

     @param filename: The full path of the file to write.
     @param content: The content to write to the file.

** Affects: cloud-init
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1677205

Title:
  cloud-init eats final EOL of sshd_config

Status in cloud-init:
  New

Bug description:
  cloud-init reads in sshd_config, and then writes it out again, but
  eats the final newline.

  It also changes the file mode to 644, which I don't like since the
  original was 600, but I haven't yet found a decent way to change that.

  While I'm at it, spellcheck in comment.

  HAND

  
  diff --git a/cloudinit/config/cc_set_passwords.py b/cloudinit/config/cc_set_passwords.py
  index eb0bdab0..ed30a9d9 100755
  --- a/cloudinit/config/cc_set_passwords.py
  +++ b/cloudinit/config/cc_set_passwords.py
  @@ -215,7 +215,7 @@ def handle(_name, cfg, cloud, log, args):
                                                        pw_auth))

           lines = [str(l) for l in new_lines]
  -        util.write_file(ssh_util.DEF_SSHD_CFG, "\n".join(lines))
  +        util.write_file(ssh_util.DEF_SSHD_CFG, "\n".join(lines)+"\n")

           try:
               cmd = cloud.distro.init_cmd  # Default service
  diff --git a/cloudinit/util.py b/cloudinit/util.py
  index 33019579..a8e84da8 100644
  --- a/cloudinit/util.py
  +++ b/cloudinit/util.py
  @@ -1691,7 +1691,7 @@ def chmod(path, mode):
   def write_file(filename, content, mode=0o644, omode="wb"):
       """
       Writes a file with the given content and sets the file mode as specified.
  -    Resotres the SELinux context if possible.
  +    Restores the SELinux context if possible.

       @param filename: The full path of the file to write.
       @param content: The content to write to the file.

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1677205/+subscriptions


Follow ups