Azure / WALinuxAgent

Microsoft Azure Linux Guest Agent

Home Page:http://azure.microsoft.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

sseiichi opened this issue · comments

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

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.