diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2021-04-29 10:40:27 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2021-05-03 22:13:36 +0200 |
commit | fa1f628bce9f82bd4c753d75709203c72fff310c (patch) | |
tree | f1ce6b43e51bde7760c2a46d35bd04b8bfe2ba8d | |
parent | caea7514cb74714077fd372c7264c9582d884c1f (diff) | |
download | NetworkManager-fa1f628bce9f82bd4c753d75709203c72fff310c.tar.gz |
core: force emission of DNS_CONFIG_CHANGED signal on SIGUSR1
If the configuration contains dns=none and resolv.conf is updated
through a dispatcher script, currently there is no way to tell NM that
the content of resolv.conf changed, so that it can restart a hostname
resolution.
Use SIGUSR1 (and SIGHUP) for that.
-rw-r--r-- | man/NetworkManager.xml | 14 | ||||
-rw-r--r-- | src/core/dns/nm-dns-manager.c | 14 |
2 files changed, 18 insertions, 10 deletions
diff --git a/man/NetworkManager.xml b/man/NetworkManager.xml index 8977ae4eed..0092a44f7d 100644 --- a/man/NetworkManager.xml +++ b/man/NetworkManager.xml @@ -224,9 +224,17 @@ <varlistentry> <term><varname>SIGUSR1</varname></term> <listitem><para> - The signal forces a rewrite of DNS configuration. Contrary to - SIGHUP, this does not restart the DNS plugin and will not interrupt - name resolution. + The signal forces a rewrite of DNS configuration. Contrary + to SIGHUP, this does not restart the DNS plugin and will not + interrupt name resolution. + + When NetworkManager is not managing DNS, the signal forces + a restart of operations that depend on the DNS + configuration (like the resolution of the system hostname + via reverse DNS, or the resolution of WireGuard peers); + therefore, it can be used to tell NetworkManager that the + content of resolv.conf was changed externally. + In the future, further actions may be added. A SIGUSR1 means to write out data like resolv.conf, or refresh a cache. It is a subset of what is done for SIGHUP without reloading diff --git a/src/core/dns/nm-dns-manager.c b/src/core/dns/nm-dns-manager.c index 54de1e28e0..d1e2020b39 100644 --- a/src/core/dns/nm-dns-manager.c +++ b/src/core/dns/nm-dns-manager.c @@ -1624,7 +1624,7 @@ _mgr_configs_data_clear(NMDnsManager *self) /*****************************************************************************/ static gboolean -update_dns(NMDnsManager *self, gboolean no_caching, GError **error) +update_dns(NMDnsManager *self, gboolean no_caching, gboolean force_emit, GError **error) { NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self); const char * nis_domain = NULL; @@ -1816,7 +1816,7 @@ plugin_skip:; } /* signal that DNS resolution configs were changed */ - if ((do_update || caching) && result == SR_SUCCESS) + if ((do_update || caching || force_emit) && result == SR_SUCCESS) g_signal_emit(self, signals[CONFIG_CHANGED], 0); nm_clear_pointer(&priv->config_variant, g_variant_unref); @@ -1924,7 +1924,7 @@ changed: if (!priv->updates_queue) { gs_free_error GError *error = NULL; - if (!update_dns(self, FALSE, &error)) + if (!update_dns(self, FALSE, FALSE, &error)) _LOGW("could not commit DNS changes: %s", error->message); } @@ -1965,7 +1965,7 @@ nm_dns_manager_set_hostname(NMDnsManager *self, const char *hostname, gboolean s if (!priv->updates_queue) { gs_free_error GError *error = NULL; - if (!update_dns(self, FALSE, &error)) + if (!update_dns(self, FALSE, FALSE, &error)) _LOGW("could not commit DNS changes: %s", error->message); } } @@ -2012,7 +2012,7 @@ nm_dns_manager_end_updates(NMDnsManager *self, const char *func) /* Commit all the outstanding changes */ _LOGD("(%s): committing DNS changes (%d)", func, priv->updates_queue); - if (!update_dns(self, FALSE, &error)) + if (!update_dns(self, FALSE, FALSE, &error)) _LOGW("could not commit DNS changes: %s", error->message); memset(priv->prev_hash, 0, sizeof(priv->prev_hash)); @@ -2038,7 +2038,7 @@ nm_dns_manager_stop(NMDnsManager *self) if (priv->dns_touched && priv->plugin && NM_IS_DNS_DNSMASQ(priv->plugin)) { gs_free_error GError *error = NULL; - if (!update_dns(self, TRUE, &error)) + if (!update_dns(self, TRUE, FALSE, &error)) _LOGW("could not commit DNS changes on shutdown: %s", error->message); priv->dns_touched = FALSE; @@ -2363,7 +2363,7 @@ config_changed_cb(NMConfig * config, | NM_CONFIG_CHANGE_GLOBAL_DNS_CONFIG)) { gs_free_error GError *error = NULL; - if (!update_dns(self, FALSE, &error)) + if (!update_dns(self, FALSE, TRUE, &error)) _LOGW("could not commit DNS changes: %s", error->message); } } |