From 05037076dbbd3d744047840f4c09f77a035c664b Mon Sep 17 00:00:00 2001 From: Henrik Klee Date: Sat, 5 Dec 2026 07:57:20 +0800 Subject: [PATCH 1/2] Linux: ModemManager leaves the device's serial ports alone Orchard's USB rule now sets ID_MM_DEVICE_IGNORE on every stage it covers (DFU, recovery, Pongo, m1n1's proxy, Orchard's systems and their serial consoles): ModemManager probed each new console as a modem and garbled logins and proxy commands. A computer with the older rule is offered the new one once, as for any change to it. Assisted-by: LLM --- crates/cli/src/commands/host.rs | 4 +++- crates/runtime/src/usb_access.rs | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/crates/cli/src/commands/host.rs b/crates/cli/src/commands/host.rs index b896c49..760fb0c 100644 --- a/crates/cli/src/commands/host.rs +++ b/crates/cli/src/commands/host.rs @@ -294,7 +294,9 @@ fn checks(cache: &Path) -> Vec { if cfg!(target_os = "linux") { found.push(tool("usbmuxd", "usbmuxd", "install: reaching a device running iOS on USB (Trust This Computer)")); found.push(service("fwupd", "fwupd", FWUPD, running("fwupd"))); - found.push(service("modemmanager", "ModemManager", MODEMMANAGER, running("ModemManager"))); + // Orchard's USB rule tells ModemManager to leave the device alone. + let in_the_way = running("ModemManager") && !orchard_runtime::usb_access::keeps_modemmanager_away(); + found.push(service("modemmanager", "ModemManager", MODEMMANAGER, in_the_way)); } const PYTHON: &str = "build, inputs: orchard's recipes are Python scripts (3.11 or newer)"; found.push(match orchard_build::python() { diff --git a/crates/runtime/src/usb_access.rs b/crates/runtime/src/usb_access.rs index cc9e1d9..9d9d3a3 100644 --- a/crates/runtime/src/usb_access.rs +++ b/crates/runtime/src/usb_access.rs @@ -2,7 +2,8 @@ //! computer: a udev rule for every stage orchard and the windows talk to //! (DFU, recovery, Pongo, m1n1, and Orchard's own systems with their serial //! consoles), plus write access to the port's `disable` control of a device -//! in DFU, for the USB port reset after checkm8 (replug.rs). +//! in DFU, for the USB port reset after checkm8 (replug.rs). ModemManager +//! is told to leave all of them alone. //! //! Installed with pkexec (a graphical password prompt) when there is a //! desktop session, else sudo. macOS needs none of this. @@ -29,13 +30,22 @@ const INSTALLED: u16 = 0x1014; /// m1n1's proxy, which is a serial port too. const M1N1: (u16, u16) = (0x1209, 0x316d); const DFU: u16 = 0x1227; +/// What tells ModemManager to leave a device alone. +const MM_IGNORE: &str = "ENV{ID_MM_DEVICE_IGNORE}=\"1\""; + +/// Whether the installed rule keeps ModemManager away from the device. +pub fn keeps_modemmanager_away() -> bool { + std::fs::read_to_string(RULES).is_ok_and(|rule| rule.contains(MM_IGNORE)) +} /// The rule file for this group. pub fn rules(group: &str) -> Result { if group.is_empty() || !group.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'_' || b == b'-') { return Err(Error::new(Code::InvalidInput, format!("unsupported group name: {group}"))); } - let access = format!("MODE=\"0660\", GROUP=\"{group}\", TAG+=\"uaccess\""); + // ModemManager probes every new serial port as a modem: on Orchard's + // consoles and m1n1's proxy that garbles logins and proxy commands. + let access = format!("MODE=\"0660\", GROUP=\"{group}\", TAG+=\"uaccess\", {MM_IGNORE}"); let mut lines = vec!["# Orchard: the device's USB stages and m1n1, with their serial consoles, for the logged-in user.".to_owned()]; let devices = PRODUCTS.iter().map(|product| (APPLE, *product, WITH_CONSOLE.contains(product))).chain([(M1N1.0, M1N1.1, true)]); for (vendor, product, console) in devices { @@ -202,6 +212,8 @@ mod tests { // m1n1's proxy and the systems' consoles are serial ports as well. assert!(r.contains("SUBSYSTEM==\"usb\", ATTR{idVendor}==\"1209\", ATTR{idProduct}==\"316d\"")); assert_eq!(r.matches("SUBSYSTEM==\"tty\"").count(), 6); + // ModemManager leaves every one of them alone. + assert_eq!(r.matches("ENV{ID_MM_DEVICE_IGNORE}=\"1\"").count(), r.matches("TAG+=\"uaccess\"").count()); // An installed system's 0x1014 only with an Orchard serial: real Apple // hardware presents it too. assert!(r.contains("SUBSYSTEM==\"usb\", ATTR{idVendor}==\"05ac\", ATTR{idProduct}==\"1014\", ATTR{serial}==\"*BOARD:*\", MODE=\"0660\"")); From d5bc065372ce3fdf383ee8001a129ed1b9071f23 Mon Sep 17 00:00:00 2001 From: Henrik Klee Date: Sat, 5 Dec 2026 08:00:30 +0800 Subject: [PATCH 2/2] CHANGELOG: ModemManager leaves the device alone on Linux Assisted-by: LLM --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c93717..b740159 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,12 @@ is on main, the release is published with that section as its notes (AGENTS.md, - On Linux, running Orchard as root leaves the USB access rule for your regular account in place. +- On Linux, ModemManager no longer probes the device's serial console or + m1n1's port as a modem, which garbled logins and starts: Orchard's USB + rule tells it to leave them alone. Orchard asks once for your password to + update the rule, and `orchard doctor` then no longer flags a running + ModemManager. + ### Command line - The A13 iPhones (iPhone 11, 11 Pro, 11 Pro Max, SE 2nd generation) get