summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2024-04-08 10:11:57 +0200
committerDavid Lönnhager <david.l@mullvad.net>2024-04-30 16:22:52 +0200
commit8a8dab16902a562f6b8bc93a546273d0e3a3611a (patch)
tree52bd79eb9c03bcbb5a0586d4f0f712a8fa9d21e6
parentdf2c3e83e550ae020baf885479ea2800a19997fe (diff)
downloadmullvadvpn-8a8dab16902a562f6b8bc93a546273d0e3a3611a.tar.xz
mullvadvpn-8a8dab16902a562f6b8bc93a546273d0e3a3611a.zip
Fail if macOS version is 12 or lower
-rw-r--r--talpid-core/src/split_tunnel/macos/process.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/talpid-core/src/split_tunnel/macos/process.rs b/talpid-core/src/split_tunnel/macos/process.rs
index 52696a7d68..dfb13a0b70 100644
--- a/talpid-core/src/split_tunnel/macos/process.rs
+++ b/talpid-core/src/split_tunnel/macos/process.rs
@@ -19,6 +19,7 @@ use std::{
sync::{Arc, Mutex},
time::Duration,
};
+use talpid_platform_metadata::MacosVersion;
use tokio::io::{AsyncBufReadExt, BufReader};
const SHUTDOWN_TIMEOUT: Duration = Duration::from_secs(3);
@@ -26,6 +27,12 @@ const EARLY_FAIL_TIMEOUT: Duration = Duration::from_millis(500);
#[derive(thiserror::Error, Debug)]
pub enum Error {
+ /// Failed to detect macOS version
+ #[error("Failed to detect macOS version")]
+ DetectMacosVersion(#[source] io::Error),
+ /// Only macOS 13 and later is supported
+ #[error("Unsupported macOS version")]
+ UnsupportedMacosVersion,
/// Failed to start eslogger listener
#[error("Failed to start eslogger")]
StartMonitor(#[source] io::Error),
@@ -57,6 +64,7 @@ pub struct ProcessMonitorHandle {
impl ProcessMonitor {
pub async fn spawn() -> Result<ProcessMonitorHandle, Error> {
+ check_os_version_support()?;
let states = ProcessStates::new()?;
let mut cmd = tokio::process::Command::new("/usr/bin/eslogger");
@@ -456,3 +464,18 @@ fn parse_eslogger_error(stderr_str: &str) -> Option<Error> {
None
}
}
+
+/// Check whether the current macOS version is supported, and return an error otherwise
+fn check_os_version_support() -> Result<(), Error> {
+ match MacosVersion::new().map_err(Error::DetectMacosVersion) {
+ Ok(version) => {
+ if version.major_version() <= 12 {
+ return Err(Error::UnsupportedMacosVersion);
+ }
+ }
+ Err(error) => {
+ log::error!("Failed to detect macOS version: {error}");
+ }
+ }
+ Ok(())
+}