mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 16:00:12 +01:00
core: simplify code in nm_dns_manager_set_hostname()
This commit is contained in:
parent
bbff0c9853
commit
20eb6df215
1 changed files with 5 additions and 9 deletions
|
|
@ -2001,22 +2001,18 @@ nm_dns_manager_set_initial_hostname(NMDnsManager *self, const char *hostname)
|
|||
void
|
||||
nm_dns_manager_set_hostname(NMDnsManager *self, const char *hostname, gboolean skip_update)
|
||||
{
|
||||
NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self);
|
||||
const char *filtered = NULL;
|
||||
NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self);
|
||||
|
||||
/* Certain hostnames we don't want to include in resolv.conf 'searches' */
|
||||
if (hostname && nm_utils_is_specific_hostname(hostname) && !strstr(hostname, ".in-addr.arpa")
|
||||
&& strchr(hostname, '.')) {
|
||||
filtered = hostname;
|
||||
}
|
||||
/* pass */
|
||||
} else
|
||||
hostname = NULL;
|
||||
|
||||
if ((!priv->hostname && !filtered)
|
||||
|| (priv->hostname && filtered && !strcmp(priv->hostname, filtered)))
|
||||
if (!nm_strdup_reset(&priv->hostname, hostname))
|
||||
return;
|
||||
|
||||
g_free(priv->hostname);
|
||||
priv->hostname = g_strdup(filtered);
|
||||
|
||||
if (skip_update)
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue