Skip to content

hostname: T6421: enforce explicit CLI priority for host-name and domain-name (backport #3551) #3553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions interface-definitions/system_domain-name.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<leafNode name="domain-name" owner="${vyos_conf_scripts_dir}/system_host-name.py">
<properties>
<help>System domain name</help>
<priority>6</priority>
<constraint>
<validator name="fqdn"/>
</constraint>
Expand Down
1 change: 1 addition & 0 deletions interface-definitions/system_host-name.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<leafNode name="host-name" owner="${vyos_conf_scripts_dir}/system_host-name.py">
<properties>
<help>System host name (default: vyos)</help>
<priority>5</priority>
<constraint>
#include <include/constraint/host-name.xml.i>
</constraint>
Expand Down
12 changes: 7 additions & 5 deletions python/vyos/ifconfig/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from vyos.utils.process import is_systemd_service_active
from vyos.template import is_ipv4
from vyos.template import is_ipv6
from vyos.utils.file import read_file
from vyos.utils.network import is_intf_addr_assigned
from vyos.utils.network import is_ipv6_link_local
from vyos.utils.assertion import assert_boolean
Expand Down Expand Up @@ -1286,12 +1287,13 @@ def set_dhcp(self, enable):
if enable and 'disable' not in self.config:
if dict_search('dhcp_options.host_name', self.config) == None:
# read configured system hostname.
# maybe change to vyos hostd client ???
# maybe change to vyos-hostsd client ???
hostname = 'vyos'
with open('/etc/hostname', 'r') as f:
hostname = f.read().rstrip('\n')
tmp = {'dhcp_options' : { 'host_name' : hostname}}
self.config = dict_merge(tmp, self.config)
hostname_file = '/etc/hostname'
if os.path.isfile(hostname_file):
hostname = read_file(hostname_file)
tmp = {'dhcp_options' : { 'host_name' : hostname}}
self.config = dict_merge(tmp, self.config)

render(systemd_override_file, 'dhcp-client/override.conf.j2', self.config)
render(dhclient_config_file, 'dhcp-client/ipv4.j2', self.config)
Expand Down
Loading