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
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/syauth-presenced/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::{
};

use syauth_core::{Bond, BondStatus, BondStore, bond_key_from_pubkeys, peer_id_from_pubkey};
use syauth_transport::{BOND_KEY_BYTES, DEFAULT_ADAPTER_NAME, FakePeripheral, Peripheral, PersistentPeripheral};
use syauth_transport::{BOND_KEY_BYTES, FakePeripheral, Peripheral, PersistentPeripheral};
use tokio::{
signal::unix::{SignalKind, signal},
sync::mpsc,
Expand Down Expand Up @@ -329,7 +329,7 @@ async fn maybe_spawn_orchestrator(
// spin up on the next reload.
type PairEventRx = tokio::sync::mpsc::Receiver<([u8; 32], [u8; 32])>;
let (peripheral, pair_events): (Arc<dyn Peripheral + Send + Sync>, Option<PairEventRx>) = match config.peripheral_mode {
PeripheralMode::Real => match PersistentPeripheral::new(DEFAULT_ADAPTER_NAME).await {
PeripheralMode::Real => match PersistentPeripheral::new_default().await {
Ok((p, rx)) => (p, Some(rx)),
Err(err) => {
warn_no_orchestrator(&format!("BlueZ adapter open failed: {err}"));
Expand Down
20 changes: 20 additions & 0 deletions crates/syauth-transport/src/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,17 @@ pub struct PersistentPeripheral {
}

impl PersistentPeripheral {
/// Open the available BlueZ default adapter, including renumbered controllers.
pub async fn new_default() -> Result<(Arc<Self>, mpsc::Receiver<([u8; PAIR_PUBKEY_LEN], [u8; PAIR_PUBKEY_LEN])>), PeripheralError> {
let session = bluer::Session::new().await.map_err(|err| PeripheralError::Backend {
reason: format!("default adapter session: {err}"),
})?;
let adapter = session.default_adapter().await.map_err(|err| PeripheralError::Backend {
reason: format!("default adapter selection: {err}"),
})?;
Self::new(adapter.name()).await
}

/// Construct a `PersistentPeripheral` bound to `adapter_id`.
///
/// Opens the BlueZ adapter, powers it on, and registers an empty
Expand Down Expand Up @@ -1248,4 +1259,13 @@ mod tests {
other => panic!("expected PeerAlreadyAdded, got {other:?}"),
}
}

#[tokio::test]
#[ignore = "requires live BlueZ; temporarily registers a GATT application"]
async fn persistent_peripheral_opens_default_bluez_adapter() {
let session = bluer::Session::new().await.expect("system bus");
let expected = session.default_adapter().await.expect("available adapter");
let (peripheral, _events) = PersistentPeripheral::new_default().await.expect("open default adapter");
assert_eq!(peripheral.adapter.name(), expected.name());
}
}
1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ignore = [
{ id = "RUSTSEC-2026-0370", reason = "zvariant is required by secret-service 5; zbus 6 migration is unreleased" },
{ id = "RUSTSEC-2026-0371", reason = "zbus_names is required by secret-service 5; zbus 6 migration is unreleased" },
{ id = "RUSTSEC-2026-0372", reason = "zvariant_derive is required by secret-service 5; zbus 6 migration is unreleased" },
{ id = "RUSTSEC-2026-0374", reason = "Build-only Askama configuration parser, still required by current UniFFI; no patched release exists. Track replacement in BUG-20261031-1221." },
]

# ---------------------------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion deploy/fedora/syauth.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# or via `make rpm` (which gates on `which mock`).

%global package_version 0.1.0
%global rpm_release 4
%global rpm_release 5
%global debug_package %{nil}
%global min_fedora 39

Expand Down Expand Up @@ -163,6 +163,9 @@ fi
%{_mandir}/man8/syauth.8.gz

%changelog
* Sat Oct 31 2026 syauth contributors <maintainers@example.invalid> - 0.1.0-5
- Select the available BlueZ default adapter when starting the presence daemon.

* Tue Oct 20 2026 syauth contributors <maintainers@example.invalid> - 0.1.0-4
- Publish native Linux packages, a signed Android APK, and release checksums.
- Add package-manager installation and published documentation.
Expand Down
2 changes: 1 addition & 1 deletion deploy/version.env
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ PACKAGE_VERSION=0.1.0

# RPM release counter (the `-1` in `syauth-0.1.0-1.fc39.x86_64.rpm`).
# Bump only if a respin is needed without changing the source version.
RPM_RELEASE=4
RPM_RELEASE=5

# Debian revision (the `-1` in `syauth_0.1.0-1_amd64.deb`). Same rule
# as RPM_RELEASE.
Expand Down
6 changes: 6 additions & 0 deletions docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

This page describes the active daemon and PAM configuration. It does not replace the design specification or change the service's authentication policy.

The presence daemon selects BlueZ's available default Bluetooth adapter at
startup. It does not assume the controller is named `hci0`; reinitialized
controllers can appear as `hci1` or later. After controller removal, restarting
the daemon selects the currently available adapter. An RPC status of `up` alone
does not establish that the desktop is advertising or the phone is subscribed.

## Files and ownership

| Path | Owner / use |
Expand Down
95 changes: 95 additions & 0 deletions specs/bugs/BUG-20261031-1221.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# BUG-20261031-1221: Phone discovery fails after Bluetooth adapter renumbering

## Summary

The phone cannot discover the desktop because syauth retains an absent `hci0`
while BlueZ exposes the working controller as `hci1`.

## Reproduction

- Method: live host and radio regression in sibling syauth.
- Commands: `bluetoothctl list`, `bluetoothctl show`,
`journalctl --user -u syauth-presenced.service -n 25 --no-pager`.
- Evidence: powered controller `50:BB:B5:B9:93:AB`, zero active advertisements;
repeated `rotation failed ... advertise: the target object was either not
present or removed`. BlueZ audio logs use `hci0` on October 27 and `hci1` on
October 29–30.
- An approved daemon restart at 12:21:07 produced `orchestrator not started;
daemon will serve socket only ... adapter set_powered: the target object was
either not present or removed`. The status RPC still reported `state: up`.

## Expected

The daemon selects an adapter present in BlueZ and advertises the existing
bond's rotating UUID so the phone reconnects without pairing again.

## Actual

The process and RPC socket remain available with no usable Bluetooth transport.
Enabling Bluetooth on the phone cannot recreate the desktop advertisement.

## Root Cause

Sibling syauth's `crates/syauth-presenced/src/runtime.rs` initializes
`PersistentPeripheral::new(DEFAULT_ADAPTER_NAME)` with the constant `hci0`.
The named bluer adapter handle does not check object existence until a property
operation. Controller renumbering invalidates the retained handle, and even a
restart repeats the absent adapter selection.

## Fix

Select BlueZ's available default adapter for daemon startup. Preserve explicit
adapter selection for callers that request a particular controller. Runtime
recovery after another controller removal remains a separate acceptance concern.

## Traceability

- Radio regression: sibling `crates/syauth-transport/src/peripheral.rs`:
`persistent_peripheral_opens_default_bluez_adapter` (explicitly gated).
- Implementation: sibling transport constructor and presenced runtime.
- Before the change, the live regression failed with `adapter set_powered: the
target object was either not present or removed`. After selecting the BlueZ
default, the same regression passed against the current controller.
- The release binary was exercised for 15 seconds on an isolated socket and
pidfile with the existing bond store. At 12:26:41 it registered GATT and
advertised the rotating UUID; `bluetoothctl show` reported one active
advertisement. At 12:26:53 it logged `phone subscribed via standard
notifications`. The probe drained cleanly on SIGTERM.
- syauth workspace: 474 passing test results, zero failures, 10 ignored;
real-radio regression also passed explicitly. Native package source tests:
14 passed. Clippy and formatting pass. The complete lint target fails at
dependency advisories for basic-toml, ctutils, and Tokio.
- Native RPM `syauth-0.1.0-5.fc44.x86_64` was built from bounded working-tree
source and installed with DNF. The managed service restarted at 12:29:06,
advertised at 12:29:08, and logged a fresh phone subscription at 12:29:10.
`rpm -V syauth` passes; the saved bond-file SHA-256 remains unchanged and
the bond directory retains its user ownership and private modes.
- `timeout 25 sudo -k /usr/bin/true` returned zero. The daemon logged
`outcome=ok` for the 12:29:27.913–12:29:30.386 challenge, and PAM logged
`unlock success reason=granted`. End-to-end phone approval took 2.473 seconds.
A preliminary `sudo -k -n` check refused authentication without invoking the
phone; the actual verification used a PTY and fresh authentication.
- sy workspace: 1,740 passing test results, zero failures, 12 ignored.
`make lint`, `make lint-spark`, and `make test-spark` pass; the bridge has
18 passing tests. The syauth dependency-audit failures above remain open.
- This repair selects an available controller on startup; it does not add
automatic transport reconstruction after a later controller removal.

## CI follow-up

The PR lint job reproduced RustSec failures for `ctutils` 0.4.2, Tokio 1.52.3,
and the unmaintained `basic-toml` parser. Upgrade the first two to patched
releases 0.4.4 and 1.53.3, respectively.

`basic-toml` has no patched release. It is used by Askama to parse template
configuration during UniFFI scaffolding generation, outside the authentication
runtime. Dependency resolution also confirmed that UniFFI 0.32.2 still requires
it through Askama 0.16.1. Keep the existing UniFFI runtime/generator pairing and
record a narrow exception for informational advisory RUSTSEC-2026-0374. Remove
that exception when the supported generator uses a maintained TOML parser.
The vulnerability advisories are resolved by the lockfile updates.

Verification: the complete `make lint` target passes, including Clippy,
formatting, scope discipline, and `cargo deny check`; `make test` passes in the
isolated PR worktree. The original host deployment above predates these
dependency updates.
Loading