hostnamed: allow networkd to set the transient hostname
authorMartin Pitt <martin.pitt@ubuntu.com>
Fri, 18 Nov 2016 15:17:01 +0000 (16:17 +0100)
committerMartin Pitt <martin.pitt@ubuntu.com>
Sun, 20 Nov 2016 11:19:21 +0000 (12:19 +0100)
commite8c0de91271331ddbae872de63d0a267d4f71e12
tree766e05a6536acd6c0cb3dc82a18fbbd261680d3d
parent9e0c296a168a7c6aca0c877eb6758ff244325e61
hostnamed: allow networkd to set the transient hostname

systemd-networkd runs as user "systemd-network" and thus is not privileged to
set the transient hostname:

  systemd-networkd[516]: ens3: Could not set hostname: Interactive authentication required.

Standard polkit *.policy files do not have a syntax for granting privileges to
a user, so ship a pklocalauthority (for polkit < 106) and a JavaScript rules
file (for polkit >= 106) that grants the "systemd-network" system user that
privilege.

Add DnsmasqClientTest.test_transient_hostname() test to networkd-test.py to
cover this. Make do_test() a bit more flexible by interpreting "coldplug==None"
as "test sets up the interface by itself". Change DnsmasqClientTest to set up
test_eth42 with a fixed MAC address so that we can configure dnsmasq to send a
special host name for that.

Fixes #4646
Makefile.am
src/hostname/systemd-networkd-hostname.pkla [new file with mode: 0644]
src/hostname/systemd-networkd-hostname.rules [new file with mode: 0644]
test/networkd-test.py