mirror of
https://github.com/netbirdio/netbird.git
synced 2025-05-29 14:22:41 +02:00
Check if system is our manager when resolvconf (#590)
Sometimes resolvconf will manage the /etc/resolv.conf file And systemd-resolved still the DNS manager
This commit is contained in:
parent
ae500b63a7
commit
4a30b66503
@ -68,6 +68,16 @@ func getOSDNSManagerType() (osManagerType, error) {
|
|||||||
return systemdManager, nil
|
return systemdManager, nil
|
||||||
}
|
}
|
||||||
if strings.Contains(text, "resolvconf") {
|
if strings.Contains(text, "resolvconf") {
|
||||||
|
if isDbusListenerRunning(systemdResolvedDest, systemdDbusObjectNode) {
|
||||||
|
var value string
|
||||||
|
err = getSystemdDbusProperty(systemdDbusResolvConfModeProperty, &value)
|
||||||
|
if err == nil {
|
||||||
|
if value == systemdDbusResolvConfModeForeign {
|
||||||
|
return systemdManager, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Errorf("got an error while checking systemd resolv conf mode, error: %s", err)
|
||||||
|
}
|
||||||
return resolvConfManager, nil
|
return resolvConfManager, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,13 @@ const (
|
|||||||
systemdDbusObjectNode = "/org/freedesktop/resolve1"
|
systemdDbusObjectNode = "/org/freedesktop/resolve1"
|
||||||
systemdDbusGetLinkMethod = systemdDbusManagerInterface + ".GetLink"
|
systemdDbusGetLinkMethod = systemdDbusManagerInterface + ".GetLink"
|
||||||
systemdDbusFlushCachesMethod = systemdDbusManagerInterface + ".FlushCaches"
|
systemdDbusFlushCachesMethod = systemdDbusManagerInterface + ".FlushCaches"
|
||||||
|
systemdDbusResolvConfModeProperty = systemdDbusManagerInterface + ".ResolvConfMode"
|
||||||
systemdDbusLinkInterface = "org.freedesktop.resolve1.Link"
|
systemdDbusLinkInterface = "org.freedesktop.resolve1.Link"
|
||||||
systemdDbusRevertMethodSuffix = systemdDbusLinkInterface + ".Revert"
|
systemdDbusRevertMethodSuffix = systemdDbusLinkInterface + ".Revert"
|
||||||
systemdDbusSetDNSMethodSuffix = systemdDbusLinkInterface + ".SetDNS"
|
systemdDbusSetDNSMethodSuffix = systemdDbusLinkInterface + ".SetDNS"
|
||||||
systemdDbusSetDefaultRouteMethodSuffix = systemdDbusLinkInterface + ".SetDefaultRoute"
|
systemdDbusSetDefaultRouteMethodSuffix = systemdDbusLinkInterface + ".SetDefaultRoute"
|
||||||
systemdDbusSetDomainsMethodSuffix = systemdDbusLinkInterface + ".SetDomains"
|
systemdDbusSetDomainsMethodSuffix = systemdDbusLinkInterface + ".SetDomains"
|
||||||
|
systemdDbusResolvConfModeForeign = "foreign"
|
||||||
)
|
)
|
||||||
|
|
||||||
type systemdDbusConfigurator struct {
|
type systemdDbusConfigurator struct {
|
||||||
@ -183,3 +185,18 @@ func (s *systemdDbusConfigurator) callLinkMethod(method string, value any) error
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getSystemdDbusProperty(property string, store any) error {
|
||||||
|
obj, closeConn, err := getDbusObject(systemdResolvedDest, systemdDbusObjectNode)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("got error while attempting to retrieve the systemd dns manager object, error: %s", err)
|
||||||
|
}
|
||||||
|
defer closeConn()
|
||||||
|
|
||||||
|
v, e := obj.GetProperty(property)
|
||||||
|
if e != nil {
|
||||||
|
return fmt.Errorf("got an error getting property %s: %v", property, e)
|
||||||
|
}
|
||||||
|
|
||||||
|
return v.Store(store)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user