(args: &[&str], port: u16, prefix_has_no_command: bool)
| 335 | } |
| 336 | |
| 337 | fn outer_ssh_forward_matches(args: &[&str], port: u16, prefix_has_no_command: bool) -> bool { |
| 338 | let Some(forward_args) = args.strip_suffix(&["sandbox"]) else { |
| 339 | return false; |
| 340 | }; |
| 341 | let mut saw_no_command = prefix_has_no_command; |
| 342 | let mut saw_forward = false; |
| 343 | let mut current = 0; |
| 344 | |
| 345 | while current < forward_args.len() { |
| 346 | let arg = forward_args[current]; |
| 347 | match arg { |
| 348 | "-N" => { |
| 349 | saw_no_command = true; |
| 350 | current += 1; |
| 351 | } |
| 352 | "-f" | "-T" | "-tt" => { |
| 353 | current += 1; |
| 354 | } |
| 355 | "-o" => { |
| 356 | if current + 1 >= forward_args.len() { |
| 357 | return false; |
| 358 | } |
| 359 | current += 2; |
| 360 | } |
| 361 | "-L" => { |
| 362 | let Some(candidate) = forward_args.get(current + 1) else { |
| 363 | return false; |
| 364 | }; |
| 365 | saw_forward |= ssh_forward_arg_matches_openshell_loopback_port(candidate, port); |
| 366 | current += 2; |
| 367 | } |
| 368 | _ if arg.starts_with("-L") => { |
| 369 | let Some(candidate) = arg.strip_prefix("-L").filter(|value| !value.is_empty()) |
| 370 | else { |
| 371 | return false; |
| 372 | }; |
| 373 | saw_forward |= ssh_forward_arg_matches_openshell_loopback_port(candidate, port); |
| 374 | current += 1; |
| 375 | } |
| 376 | _ if arg.starts_with("-o") || arg.starts_with("-v") => { |
| 377 | current += 1; |
| 378 | } |
| 379 | _ => return false, |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | saw_no_command && saw_forward |
| 384 | } |
| 385 | |
| 386 | fn expected_sandbox_id_from_record(record: &ForwardPidRecord) -> Option<&str> { |
| 387 | // Legacy one-field PID files are cleanup records, not signal authority. |
no test coverage detected