From d4dc8ce547ee27f94ee90944249cf181b4e7b3c1 Mon Sep 17 00:00:00 2001 From: Jon Maloy Date: Tue, 25 Apr 2023 20:45:42 +0000 Subject: [PATCH] * Tue Apr 25 2023 Jon Maloy - 23.1.1-2 - ci-rhel-make-sure-previous-hostname-file-ends-with-a-ne.patch [bz#2182407] - Resolves: bz#2182407 (cloud-init strips new line from "/etc/hostname" when processing "/var/lib/cloud/data/previous-hostname") --- ...revious-hostname-file-ends-with-a-ne.patch | 65 +++++++++++++++++++ cloud-init.spec | 9 ++- 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 ci-rhel-make-sure-previous-hostname-file-ends-with-a-ne.patch diff --git a/ci-rhel-make-sure-previous-hostname-file-ends-with-a-ne.patch b/ci-rhel-make-sure-previous-hostname-file-ends-with-a-ne.patch new file mode 100644 index 0000000..b0c4a53 --- /dev/null +++ b/ci-rhel-make-sure-previous-hostname-file-ends-with-a-ne.patch @@ -0,0 +1,65 @@ +From 5a3db5dddab530ad45aaaa0e20fdaadc9a82a7c9 Mon Sep 17 00:00:00 2001 +From: Ani Sinha +Date: Tue, 4 Apr 2023 19:59:07 +0530 +Subject: [PATCH] rhel: make sure previous-hostname file ends with a new line + (#2108) + +RH-Author: Ani Sinha +RH-MergeRequest: 97: rhel: make sure previous-hostname file ends with a new line (#2108) +RH-Bugzilla: 2182407 +RH-Acked-by: Emanuele Giuseppe Esposito +RH-Acked-by: Jon Maloy +RH-Commit: [1/1] 126208f85cc3bf5f2264bd5a71524716b28a7686 (anisinha/rhel-cloud-init) + +cloud-init strips new line from "/etc/hostname" on rhel distro when processing +"/var/lib/cloud/data/previous-hostname". Although this does not pose a serious +issue, it is still better if the behavior is similar to other distros like +Ubuntu where /previous-hostname does end with a new line. Fix this issue by +using hostname parser in rhel similar to debian. + +Signed-off-by: Ani Sinha +(cherry picked from commit 6d42aa8e2c1a5454a658ab4e2b9cead2677c77cd) +Signed-off-by: Ani Sinha +--- + cloudinit/distros/rhel.py | 5 ++++- + tools/.github-cla-signers | 1 + + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/cloudinit/distros/rhel.py b/cloudinit/distros/rhel.py +index df7dc3d6..9625709e 100644 +--- a/cloudinit/distros/rhel.py ++++ b/cloudinit/distros/rhel.py +@@ -13,6 +13,7 @@ from cloudinit import distros, helpers + from cloudinit import log as logging + from cloudinit import subp, util + from cloudinit.distros import rhel_util ++from cloudinit.distros.parsers.hostname import HostnameConf + from cloudinit.settings import PER_INSTANCE + + LOG = logging.getLogger(__name__) +@@ -111,7 +112,9 @@ class Distro(distros.Distro): + # systemd will never update previous-hostname for us, so + # we need to do it ourselves + if self.uses_systemd() and filename.endswith("/previous-hostname"): +- util.write_file(filename, hostname) ++ conf = HostnameConf("") ++ conf.set_hostname(hostname) ++ util.write_file(filename, str(conf), 0o644) + elif self.uses_systemd(): + subp.subp(["hostnamectl", "set-hostname", str(hostname)]) + else: +diff --git a/tools/.github-cla-signers b/tools/.github-cla-signers +index d8cca015..457dacf4 100644 +--- a/tools/.github-cla-signers ++++ b/tools/.github-cla-signers +@@ -9,6 +9,7 @@ andgein + andrew-lee-metaswitch + andrewbogott + andrewlukoshko ++ani-sinha + antonyc + aswinrajamannar + beantaxi +-- +2.37.3 + diff --git a/cloud-init.spec b/cloud-init.spec index 856357a..c4c7d51 100644 --- a/cloud-init.spec +++ b/cloud-init.spec @@ -6,7 +6,7 @@ Name: cloud-init Version: 23.1.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Cloud instance init scripts Group: System Environment/Base @@ -21,6 +21,8 @@ Patch0004: 0004-include-NOZEROCONF-yes-in-etc-sysconfig-network.patch Patch0005: 0005-Manual-revert-Use-Network-Manager-and-Netplan-as-def.patch Patch0006: 0006-Revert-Add-native-NetworkManager-support-1224.patch Patch0007: 0007-settings.py-update-settings-for-rhel.patch +# For bz#2182407 - cloud-init strips new line from "/etc/hostname" when processing "/var/lib/cloud/data/previous-hostname" +Patch8: ci-rhel-make-sure-previous-hostname-file-ends-with-a-ne.patch BuildArch: noarch @@ -207,6 +209,11 @@ fi %config(noreplace) %{_sysconfdir}/rsyslog.d/21-cloudinit.conf %changelog +* Tue Apr 25 2023 Jon Maloy - 23.1.1-2 +- ci-rhel-make-sure-previous-hostname-file-ends-with-a-ne.patch [bz#2182407] +- Resolves: bz#2182407 + (cloud-init strips new line from "/etc/hostname" when processing "/var/lib/cloud/data/previous-hostname") + * Fri Apr 21 2023 Jon Maloy - 23.1.1-1 - limit-permissions-on-def_log_file.patch - Resolves bz#1424612