mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-18 03:40:37 +01:00
ifcfg-rh: fix preserving hostname setting in reader
The writer already got this right, to always ensure that at least one hostname key is set iff the hostname setting is present.
This commit is contained in:
parent
209d48513c
commit
8a12713568
1 changed files with 14 additions and 5 deletions
|
|
@ -2683,16 +2683,25 @@ make_hostname_setting(shvarFile *ifcfg)
|
|||
NMTernary from_dns_lookup;
|
||||
NMTernary only_from_default;
|
||||
int priority;
|
||||
gboolean has_setting = FALSE;
|
||||
|
||||
priority = svGetValueInt64(ifcfg, "HOSTNAME_PRIORITY", 10, G_MININT32, G_MAXINT32, 0);
|
||||
if (!has_setting && errno != ENOKEY)
|
||||
has_setting = TRUE;
|
||||
|
||||
from_dhcp = svGetValueTernary(ifcfg, "HOSTNAME_FROM_DHCP");
|
||||
if (!has_setting && errno != ENOKEY)
|
||||
has_setting = TRUE;
|
||||
|
||||
from_dns_lookup = svGetValueTernary(ifcfg, "HOSTNAME_FROM_DNS_LOOKUP");
|
||||
if (!has_setting && errno != ENOKEY)
|
||||
has_setting = TRUE;
|
||||
|
||||
from_dhcp = svGetValueTernary(ifcfg, "HOSTNAME_FROM_DHCP");
|
||||
from_dns_lookup = svGetValueTernary(ifcfg, "HOSTNAME_FROM_DNS_LOOKUP");
|
||||
only_from_default = svGetValueTernary(ifcfg, "HOSTNAME_ONLY_FROM_DEFAULT");
|
||||
if (!has_setting && errno != ENOKEY)
|
||||
has_setting = TRUE;
|
||||
|
||||
/* Create the setting when at least one key is not default*/
|
||||
if (priority == 0 && from_dhcp == NM_TERNARY_DEFAULT && from_dns_lookup == NM_TERNARY_DEFAULT
|
||||
&& only_from_default == NM_TERNARY_DEFAULT)
|
||||
if (!has_setting)
|
||||
return NULL;
|
||||
|
||||
setting = nm_setting_hostname_new();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue