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
This commit is contained in:
Francesco Giudici 2017-03-20 19:21:05 +01:00
parent 6a77258f4e
commit 3ebe71cf06

View file

@ -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);