Skip to content

Commit

Permalink
Allow more systemd-resovled config paths
Browse files Browse the repository at this point in the history
  • Loading branch information
pinkisemils committed Sep 3, 2020
1 parent 554be9c commit 64c1e89
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions talpid-core/src/dns/linux/systemd_resolved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ pub enum Error {
lazy_static! {
static ref RESOLVED_STUB_PATHS: Vec<&'static Path> = vec![
Path::new("/run/systemd/resolve/stub-resolv.conf"),
Path::new("/run/systemd/resolve/resolv.conf"),
Path::new("/var/run/systemd/resolve/stub-resolv.conf"),
Path::new("/var/run/systemd/resolve/resolv.conf"),
];
}

Expand All @@ -77,17 +79,25 @@ pub struct SystemdResolved {

impl SystemdResolved {
pub fn new() -> Result<Self> {
let dbus_connection =
dbus::Connection::get_private(BusType::System).map_err(Error::ConnectDBus)?;
let systemd_resolved = SystemdResolved {
dbus_connection,
interface_link: None,
};
let result = (|| {
let dbus_connection =
dbus::Connection::get_private(BusType::System).map_err(Error::ConnectDBus)?;
let systemd_resolved = SystemdResolved {
dbus_connection,
interface_link: None,
};

systemd_resolved.ensure_resolved_exists()?;
Self::ensure_resolv_conf_is_resolved_symlink()?;
Ok(systemd_resolved)
})();

if let Err(err) = &result {
log::error!("systemd-resolved is not being used because: {}", err);
}

systemd_resolved.ensure_resolved_exists()?;
Self::ensure_resolv_conf_is_resolved_symlink()?;

Ok(systemd_resolved)
result
}

fn ensure_resolved_exists(&self) -> Result<()> {
Expand Down

0 comments on commit 64c1e89

Please sign in to comment.