fix: refuse to connect an agent from a translocated macOS app
A `.dmg` downloaded from the internet keeps its quarantine bit, so Gatekeeper may run the app from a read-only copy under `/private/var/folders/…/AppTranslocation/…` that vanishes when the app closes. Connected from there, an agent would be pointed at a path that will not exist the next time it runs. Connect refuses instead, before a token is made or an agent's list is touched, and says to move the app out of Downloads and open it again (P11a step 6). The rule is on the path the program would give the agent (`start::translocation_refusal` over `this_executable`), so the same check covers the CLI's `connect` and the viewer's Connect. The test stands in for Gatekeeper's copy on any Unix by naming a file under an `AppTranslocation` path in `APPIMAGE`; the agent never runs and no books home is made, while the same program at an ordinary path connects. A unit test holds the marker to a whole path part, not letters in a name.
This commit is contained in:
1 parent
53a233d687
commit
e2754898d8
3 files changed
+176
-1
No files matched your search
@@ -1262,6 +1262,12 @@ pub fn connect_agent(common: &Common, agent: &str, book: &str) -> Result<Vec<Str
|
||||
"{label} isn't installed here (no `{cli}` on the PATH, nor where its installer puts it)"
|
||||
)
|
||||
})?;
|
||||
// A translocated macOS app's path (P11a step 6) is not a place to point
|
||||
// an agent: the copy goes away with the app.
|
||||
let exe = crate::start::this_executable()?;
|
||||
if let Some(why) = crate::start::translocation_refusal(&exe) {
|
||||
return Err(why.to_string());
|
||||
}
|
||||
let mut lines = Vec::new();
|
||||
// The token: kept in its file, or made now.
|
||||
let found =
|
||||
@@ -1279,7 +1285,6 @@ pub fn connect_agent(common: &Common, agent: &str, book: &str) -> Result<Vec<Str
|
||||
));
|
||||
}
|
||||
// The agent's own list: the books' entry made anew.
|
||||
let exe = crate::start::this_executable()?;
|
||||
let name = format!("wanderbooks-{book}");
|
||||
let mut serve: Vec<std::ffi::OsString> = vec![
|
||||
exe.into_os_string(),
|
||||
|
||||
Reference in new issue
Block a user