From 3ebe71cf064b2ccfa5b4a9423a9725b11f603ffa Mon Sep 17 00:00:00 2001 From: Francesco Giudici Date: Mon, 20 Mar 2017 19:21:05 +0100 Subject: dns: avoid cleaning resolv.conf on exit if not needed When rc-manager=file other services may overwrite resolv.conf at any time. We don't support merging configurations in resolv.conf but we can be more tolerant avoiding updating resolv.conf when not strictly needed. In this case, if the last write of resolv.conf had no nameservers (nor options), reset the "dns_touched" flag in order to avoid resetting resolv.conf when quitting (so, potentially overwriting some other service configuration there). https://bugzilla.redhat.com/show_bug.cgi?id=1426748 --- src/dns/nm-dns-manager.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c index 9b848bab80..baea47b07e 100644 --- a/src/dns/nm-dns-manager.c +++ b/src/dns/nm-dns-manager.c @@ -1186,6 +1186,10 @@ update_dns (NMDnsManager *self, case NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE: result = update_resolv_conf (self, searches, nameservers, options, error, priv->rc_manager); resolv_conf_updated = TRUE; + /* If we have ended with no nameservers avoid updating again resolv.conf + * on stop, as some external changes may be applied to it in the meanwhile */ + if (!nameservers && !options) + priv->dns_touched = FALSE; break; case NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF: result = dispatch_resolvconf (self, searches, nameservers, options, error); -- cgit v1.2.1