[systemd-devel] systemd-hostnamed/hostnamectl and transient hostname change

Thomas HUMMEL thomas.hummel at pasteur.fr
Mon Apr 27 10:00:36 UTC 2020


On 4/27/20 11:51 AM, Mantas Mikulėnas wrote:

Hello, thanks for your answer.

> On Mon, Apr 20, 2020 at 6:17 PM Thomas HUMMEL <thomas.hummel at pasteur.fr 
> <mailto: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.

That was my understanding as well.

> 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.

But this does not explain why the transient hostname is changed as I 
only changed the static one, does it ? Unless this new instance sets it 
from the static one when it starts ? I mean something has to call 
sethostname(2) to set the transient to the new static one, right ?



>     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.)

Ok. I read about this poll() mechanism to catch a transient hostname 
change indeed.

> In practice, hostnamed does not do that (although several other systemd 
> daemons do). It was probably forgotten to implement.

Ok.

> 
> D-Bus doesn't care about hostnames; it's just a message bus.

Yes I didn't mean that, sorry.

Thanks for your help

--
ThomaS HUMMEL




More information about the systemd-devel mailing list