[systemd-devel] systemd-hostnamed/hostnamectl and transient hostname change
Mantas Mikulėnas
grawity at gmail.com
Mon Apr 27 09:51:28 UTC 2020
On Mon, Apr 20, 2020 at 6:17 PM Thomas HUMMEL <thomas.hummel at pasteur.fr>
wrote:
> 1. why does the transient hostname change while I stated --static only
> while running hostnamectl ?
>
> 2. why does the change take some time to appear on dbus ?
>
Hostnamed does not implement receiving hostname change notifications from
the kernel, so it always reports you the same hostname that it has seen on
startup.
You're only seeing changes because hostnamed *exits when idle* -- the next
time you're actually talking to a brand new instance of hostnamed, which
has seen the new hostname.
>
> 3. what is supposed to happen the other way around ? i.e. if I change
> the transient hostname (hostname(1) command or writing to
> /proc/sys/kernel/hostname) : is dbus/hostnamectl supposed to see the
> change ? When and how ?
>
In theory, hostnamed should be waiting for poll()
<https://git.kernel.org/linus/f1ecf06854a66ee663f4d4cf029c78cd62a15e04> on
/proc/sys/kernel/hostname. If hostnamed is running when the change happens,
it should receive an event through epoll and re-read the hostname. (If
hostnamed is *not* running, it will simply re-read the hostname on startup
and no special events are needed.)
In practice, hostnamed does not do that (although several other systemd
daemons do). It was probably forgotten to implement.
D-Bus doesn't care about hostnames; it's just a message bus.
--
Mantas Mikulėnas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20200427/d493dcc1/attachment-0001.htm>
More information about the systemd-devel
mailing list