diff options
| author | Emīls <emils@mullvad.net> | 2020-11-17 14:30:34 +0000 |
|---|---|---|
| committer | Emīls <emils@mullvad.net> | 2020-11-19 11:53:23 +0000 |
| commit | 3d6b9f89bd3e7284d22dbc9786beeb596c533940 (patch) | |
| tree | 6015362a869d17a99855b28436fd22e82169838a /talpid-core/src | |
| parent | 5c478b6f6353ff59852e9d54438f127bb557043f (diff) | |
| download | mullvadvpn-3d6b9f89bd3e7284d22dbc9786beeb596c533940.tar.xz mullvadvpn-3d6b9f89bd3e7284d22dbc9786beeb596c533940.zip | |
Simplify systemd-resolved code
Since issues with NM managing DNS via systemd-resolved are fixed, it's
no longer necessary to check if NM is actually using systemd-resolved
before picking systemd-resolved to manage DNS. The end result of these
changes is that the daemon fall back to using NM more often now, but it
shouldn't be an issue.
Diffstat (limited to 'talpid-core/src')
| -rw-r--r-- | talpid-core/src/dns/linux/systemd_resolved.rs | 6 | ||||
| -rw-r--r-- | talpid-core/src/linux/mod.rs | 2 | ||||
| -rw-r--r-- | talpid-core/src/linux/network_manager.rs | 51 |
3 files changed, 3 insertions, 56 deletions
diff --git a/talpid-core/src/dns/linux/systemd_resolved.rs b/talpid-core/src/dns/linux/systemd_resolved.rs index 3345b38a5f..5ebdb34eb9 100644 --- a/talpid-core/src/dns/linux/systemd_resolved.rs +++ b/talpid-core/src/dns/linux/systemd_resolved.rs @@ -83,11 +83,7 @@ impl SystemdResolved { }; systemd_resolved.ensure_resolved_exists()?; - if !crate::linux::network_manager::is_nm_managing_via_resolved( - &systemd_resolved.dbus_connection, - ) { - Self::ensure_resolv_conf_is_resolved_symlink()?; - } + Self::ensure_resolv_conf_is_resolved_symlink()?; Ok(systemd_resolved) } diff --git a/talpid-core/src/linux/mod.rs b/talpid-core/src/linux/mod.rs index 8bc3836ca2..d54656309e 100644 --- a/talpid-core/src/linux/mod.rs +++ b/talpid-core/src/linux/mod.rs @@ -3,8 +3,8 @@ use std::{ io, }; -pub mod network_manager; pub mod dbus; +pub mod network_manager; /// Converts an interface name into the corresponding index. pub fn iface_index(name: &str) -> Result<libc::c_uint, IfaceIndexLookupError> { diff --git a/talpid-core/src/linux/network_manager.rs b/talpid-core/src/linux/network_manager.rs index 8ce4f3db71..6cc811dacb 100644 --- a/talpid-core/src/linux/network_manager.rs +++ b/talpid-core/src/linux/network_manager.rs @@ -107,7 +107,7 @@ pub struct NetworkManager { impl NetworkManager { pub fn new() -> Result<Self> { Ok(Self { - connection: crate::linux::dbus::get_connection()?, + connection: crate::linux::dbus::get_connection()?, }) } @@ -797,52 +797,3 @@ fn eq_file_content<P: AsRef<Path>>(a: &P, b: &P) -> bool { _ => false, }) } - -/// Given a DBus connection, verify that NM is up and running and capable of managing DNS via -/// systemd-resolved. This includes verifying that NM is managing DNS via systemd-resolved and is -/// controlling /etc/resolv.conf -pub fn is_nm_managing_via_resolved(connection: &SyncConnection) -> bool { - let check_nm = || -> std::result::Result<bool, dbus::Error> { - let dns_manager = Proxy::new(NM_BUS, NM_DNS_MANAGER_PATH, RPC_TIMEOUT, connection); - let dns_mode: String = dns_manager.get(NM_DNS_MANAGER, DNS_MODE_KEY)?; - if &dns_mode != "systemd-resolved" { - return Ok(false); - } - - - let rc_management_mode: String = dns_manager.get(NM_DNS_MANAGER, RC_MANAGEMENT_MODE_KEY)?; - - match rc_management_mode.as_str() { - // /etc/resolv.conf is managed via executing a command, can't verify that works, have - // to assume it does - "resolvconf" | "netconfig" => Ok(true), - - "symlink" | "none" | "file" => { - Proxy::new(NM_BUS, NM_MANAGER_PATH, RPC_TIMEOUT, connection).method_call( - NM_MANAGER, - "Reload", - (0x02u32,), - )?; - let result = verify_etc_resolv_conf_contents(); - Ok(result) - } - - // NM doesn't manage DNS at all - "unmanaged" => Ok(false), - unknown_rc_mode => { - log::error!("Unknown resolvconf management mode - {}", unknown_rc_mode); - Ok(false) - } - } - }; - match check_nm() { - Ok(result) => result, - Err(err) => { - log::error!( - "Failed to check if NM is managing DNS via systemd-resolved: {}", - err - ); - false - } - } -} |
