Azure / WALinuxAgent

Microsoft Azure Linux Guest Agent
http://azure.microsoft.com/
Apache License 2.0
543 stars 373 forks source link

[BUG] WALinuxAgent removes LF from /etc/hostname. #2742

Open sseiichi opened 1 year ago

sseiichi commented 1 year ago

Describe the bug: A clear and concise description of what the bug is. During the boot sequence, OpenRC changes a hostname according to the /etc/hostname, and waagent also automatically writes the same hostname to /etc/hostname without a line feed (LF). This causes problems because OpenRC assumes /etc/hostname ends with LF.

I think at least waagent should compare a new host name to the content of /etc/hostname, and change /etc/hostname only when necessary.

Distro and WALinuxAgent details: $ waagent --version WALinuxAgent-2.8.0.11 running on gentoo 2.9 Python: 3.10.9 Goal state agent: 2.8.0.11

nkadel commented 1 year ago

That's a booby trap. EOL mishandling can work fine in Python, but confuses other tools. On most contemporary systems, the hostname should be reset with the "hostnamectl" command, not anything that directly edits /etc/hostname.