core: use hostnamed to set the transient hostname
authorBeniamino Galvani <bgalvani@redhat.com>
Thu, 18 Feb 2016 17:19:30 +0000 (18:19 +0100)
committerBeniamino Galvani <bgalvani@redhat.com>
Fri, 4 Mar 2016 13:27:09 +0000 (14:27 +0100)
commit4090716d96180caaeb807033e0c9a3b4a3092f9b
tree794a6daf295646528dcc10983c52c983865d950a
parent298ab552252a10d3d1212aba56a7bdbdd543cdb4
core: use hostnamed to set the transient hostname

In commit 6dc35e66d45e ("settings: add hostnamed support") we started
to use systemd-hostnamed for setting the system static hostname
(i.e. the one written to /etc/hostname), but nm-policy.c still called
sethostname() to set the transient (dynamic) hostname when this needs
to be changed, for example after a reverse lookup of our dynamic IP
address.

Thus, when using systemd the hostname change failed because process'
capabilities are restricted and sethostname() requires CAP_SYS_ADMIN.

We should set also the transient hostname through hostnamed when this
is available.

https://bugzilla.redhat.com/show_bug.cgi?id=1308974
src/nm-policy.c
src/settings/nm-settings.c
src/settings/nm-settings.h