Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion crates/cli/src/commands/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ fn checks(cache: &Path) -> Vec<Check> {
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() {
Expand Down
16 changes: 14 additions & 2 deletions crates/runtime/src/usb_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<String> {
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 {
Expand Down Expand Up @@ -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\""));
Expand Down
Loading