FS#54682 - [netctl] netctl should set only the "Transient" Hostname
Attached to Project:
Arch Linux
Opened by Stefan (steinwanderer) - Tuesday, 04 July 2017, 05:53 GMT
Last edited by Jouke Witteveen (jouke) - Monday, 31 July 2017, 13:12 GMT
Opened by Stefan (steinwanderer) - Tuesday, 04 July 2017, 05:53 GMT
Last edited by Jouke Witteveen (jouke) - Monday, 31 July 2017, 13:12 GMT
|
Details
Description:
If the "Hostname=" option is used in a profile, netctl uses "hostnamectl" to set the desired hostname. Since no options are given to hostnamectl, it will set all (3) hostnames. e.g: Jul 03 14:47:06 systemd-hostnamed[4521]: Changed pretty host name to 'n/a' Jul 03 14:47:06 systemd-hostnamed[4521]: Changed static host name to 'thinkpad-wls1' Jul 03 14:47:06 systemd-hostnamed[4521]: Changed host name to 'thinkpad-wls1' Jul 03 14:47:06 network[4306]: Started network profile 'wireless-wpa' netctl imo should really not do that and rather set the the "transient hostname" only, like systemd-networkd or network-manager do it for instance. Also if the "pretty hostname" is cleared like that, it messes with your bluetooth. Additional info: * package version(s) netctl 1.12-2 * config and/or log files etc. Jul 03 14:47:06 systemd-hostnamed[4521]: Changed pretty host name to 'n/a' Jul 03 14:47:06 systemd-hostnamed[4521]: Changed static host name to 'thinkpad-wls1' Jul 03 14:47:06 systemd-hostnamed[4521]: Changed host name to 'thinkpad-wls1' Jul 03 14:47:06 network[4306]: Started network profile 'wireless-wpa' Steps to reproduce: 1) setting "Hostname=whatever" in a profile and start it. 2) check the actual hostname with "hostnamectl" IMHO it is trivial to fix: --- src/lib/ip.orig 2017-03-14 18:17:53.000000000 +0100 +++ src/lib/ip 2017-07-04 07:15:47.975289310 +0200 @@ -149,7 +149,7 @@ done if [[ $Hostname ]]; then - if ! do_debug hostnamectl set-hostname "$Hostname"; then + if ! do_debug hostnamectl set-hostname --transient "$Hostname"; then report_error "Cannot set the hostname to '$Hostname'" return 1 fi |
This task depends upon
Closed by Jouke Witteveen (jouke)
Monday, 31 July 2017, 13:12 GMT
Reason for closing: Implemented
Additional comments about closing: b1b03d8
Monday, 31 July 2017, 13:12 GMT
Reason for closing: Implemented
Additional comments about closing: b1b03d8
This sounds reasonable, but we don't want to break existing configurations. Can we be sure that we will not? The following excerpt from the hostnamectl manpage appears of interest:
[T]he transient hostname [...] is a fallback value received from network configuration. If a static hostname is set, and is valid (something other than localhost), then the transient hostname is not used.
I am assuming that we do not want Hostname= to be have no effect when a static hostname is set? Maybe `set-hostname --static --transient "$Hostname"`?
How about getting the hostnamectl stuff out of "/usr/bin/netctl" and putting it into a separately hook instead?
This would give some freedom on how to handle the hostname.
UseHostname= [requires Hostname=]
One of ‘transient’, ‘static’ or ’none’. If not set or empty, all hostnames are set (Default).
In reverting the hostname we could add more complex checks such as
[[ $Hostname == "$(hostnamectl --transient)" ]]
but I prefer to keep it simple/dumb for now. Of course, you could already use hooks for setting hostnames if you want total control.
Thanks for your contribution!
[1] https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/ch-Configure_Host_Names.html