Linux + iPhone Continuity / iMessage / SMS
fix: bt unit wrong on Fedora blocking bluetoothd start
Zack Bartele76bf41e37b7
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 5ba575c..bcdc9e0 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -141,23 +141,6 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/man/tether.1" "${CMAKE_CURRENT_BINARYinstall(FILES "${CMAKE_CURRENT_BINARY_DIR}/man/tetherd.8"DESTINATION ${CMAKE_INSTALL_MANDIR}/man8)-# bluetoothd's path is distro-specific and the drop-in has to name it. Detected-# for this machine; packagers cross-building for another layout override it.-if(NOT DEFINED BLUETOOTHD_PATH)- if(EXISTS "/usr/libexec/bluetooth/bluetoothd")- set(BLUETOOTHD_PATH "/usr/libexec/bluetooth/bluetoothd")- else()- set(BLUETOOTHD_PATH "/usr/lib/bluetooth/bluetoothd")- endif()-endif()-set(BLUETOOTHD_PATH "${BLUETOOTHD_PATH}" CACHE FILEPATH "Path to the bluetoothd binary named by the drop-in")--configure_file(packaging/systemd/bluetooth-experimental.conf.in- "${CMAKE_CURRENT_BINARY_DIR}/bluetooth-experimental.conf" @ONLY)--# shipped for the user to copy, not ours to decide!-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/bluetooth-experimental.conf"- DESTINATION "${CMAKE_INSTALL_DATADIR}/tether")set(SYSTEMD_UNIT_DIR "lib/systemd/system" CACHE PATH "systemd system unit directory")install(FILES packaging/systemd/[email protected]DESTINATION "${SYSTEMD_UNIT_DIR}")diff --git a/README.md b/README.mdindex fc11c2a..358b0ff 100644--- a/README.md+++ b/README.md@@ -287,9 +287,8 @@ make install- `bluez`, `bluez-utils`, and `bluez-obex` (for messages and notifications)#### Bluetooth (for Messages and Notifications)-- BlueZ 5.86+ must be running with experimental bearer API. Tether ships the- systemd drop-in; `tether --bt-setup` prints the one command that applies it.- Do this **before** pairing.+- BlueZ 5.86+ must be running with experimental bearer API. `tether --bt-setup`+ prints the systemd drop-in command that enables it. Do this **before** pairing.- A controller with BR/EDR, LE, and advertising support.- Notification mirroring does not work on iOS 18 and earlier.diff --git a/docs/BLUETOOTH.md b/docs/BLUETOOTH.mdindex f7732f0..f3477dd 100644--- a/docs/BLUETOOTH.md+++ b/docs/BLUETOOTH.md@@ -54,23 +54,27 @@ sudo systemctl enable --now tether-btclass@hci0class, reads it back, and retries for ten seconds.**BlueZ needs the experimental bearer API** for ANCS, and it must be active-*before* pairing: a bond made without it has no LE half. The package ships the-drop-in, already pointing at this distro's `bluetoothd`:+*before* pairing: a bond made without it has no LE half. `--bt-setup` prints the+drop-in command:```bashsudo mkdir -p /etc/systemd/system/bluetooth.service.d-sudo cp /usr/share/tether/bluetooth-experimental.conf /etc/systemd/system/bluetooth.service.d/+printf '[Service]\nExecStart=\nExecStart=%s --experimental\n' \+ "$(ls /usr/lib/bluetooth/bluetoothd /usr/libexec/bluetooth/bluetoothd 2>/dev/null | head -1)" \+ | sudo tee /etc/systemd/system/bluetooth.service.d/experimental.confsudo systemctl daemon-reload && sudo systemctl restart bluetooth```-It is shipped to `/usr/share` rather than installed into-`bluetooth.service.d` directly, because a drop-in there takes effect the moment-the package lands, and changing how `bluetoothd` runs for the whole machine is-the user's decision.+`ExecStart` must name the `bluetoothd` binary and its path differs by distro+(Arch `/usr/lib`, Debian and Fedora `/usr/libexec`), so the command resolves it+in the user's own shell. A path chosen anywhere else — a drop-in shipped in the+package, baked at build time — is wrong on every distro but the builder's, and+a wrong `ExecStart` leaves `bluetooth.service` failing with `status=203/EXEC`.-A portable build (the AppImage) installs neither the drop-in nor the unit, since-its files live on a mount that goes away with the process. `--bt-setup` prints-commands that write both out inline instead.+Nothing is installed into `bluetooth.service.d` by the package: a drop-in there+takes effect the moment the package lands, and changing how `bluetoothd` runs+for the whole machine is the user's decision. The class unit ships but stays+disabled for the same reason.Without it `bluetoothd` still registers `org.bluez.Bearer.LE1`, but as an emptymarker: no properties, no `Connect()`. So the interface being present is notdiff --git a/packaging/systemd/bluetooth-experimental.conf.in b/packaging/systemd/bluetooth-experimental.conf.indeleted file mode 100644index 3825281..0000000--- a/packaging/systemd/bluetooth-experimental.conf.in+++ /dev/null@@ -1,12 +0,0 @@-# Exposes BlueZ's per-transport Bearer.LE1 interface, which carries the LE half-# of the iPhone bond that ANCS notification mirroring runs over.-#-# Not installed into bluetooth.service.d by the package: it changes how-# bluetoothd runs for everything on this machine, so putting it there is your-# call. `tether --bt-setup` prints the command.-#-# ExecStart must name the bluetoothd binary, and its path differs by distro.-# Configured here for this build; override with -DBLUETOOTHD_PATH=... .-[Service]-ExecStart=-ExecStart=@BLUETOOTHD_PATH@ --experimentaldiff --git a/packaging/tether.install b/packaging/tether.installindex 034c5d6..6ab13ac 100644--- a/packaging/tether.install+++ b/packaging/tether.install@@ -6,9 +6,9 @@ Bluetooth (iPhone messages and notifications) needs one-time system setup.[email protected] is installed but NOT enabled. Enabling it changes howthis machine presents itself over Bluetooth, so that is your call to make.-Notification mirroring also needs a bluetooth.service drop-in, shipped at-/usr/share/tether/bluetooth-experimental.conf and likewise not applied for you.-Apply it BEFORE pairing an iPhone: a bond made without it has no LE half.+Notification mirroring also needs a bluetooth.service drop-in, likewise not+applied for you. Apply it BEFORE pairing an iPhone: a bond made without it has+no LE half.To see exactly what is left, and the commands to run:diff --git a/src/core/src/bluetooth/objects.cpp b/src/core/src/bluetooth/objects.cppindex 1686d3b..c9b77af 100644--- a/src/core/src/bluetooth/objects.cpp+++ b/src/core/src/bluetooth/objects.cpp@@ -285,23 +285,8 @@ namespace tether::bluetooth {return {};}- // Are we flatpak sandboxed?- bool sandboxed() {- std::error_code ec;- return std::filesystem::exists("/.flatpak-info", ec);- }-- // The package ships the drop-in for the user to copy.+ // bluetoothd's path is distro-specific, this command resolves it in the user's shell instead of hardcoding.std::string enable_experimental_command() {- const std::string shipped = std::string(TETHER_DATADIR) + "/bluetooth-experimental.conf";- std::error_code ec;- if (!sandboxed() && std::filesystem::exists(shipped, ec))- return "sudo mkdir -p /etc/systemd/system/bluetooth.service.d\n"- "sudo cp " +- shipped +- " /etc/systemd/system/bluetooth.service.d/\n"- "sudo systemctl daemon-reload && sudo systemctl restart bluetooth";-const std::string found = bluetoothd_path();const std::string binary = found.empty()? "$(ls /usr/lib/bluetooth/bluetoothd /usr/libexec/bluetooth/bluetoothd "diff --git a/test/test_bluetooth_objects.cpp b/test/test_bluetooth_objects.cppindex 3c92104..7522217 100644--- a/test/test_bluetooth_objects.cpp+++ b/test/test_bluetooth_objects.cpp@@ -219,10 +219,10 @@ TEST(Capability, CompatibilityWhenExperimentalIsOff) {EXPECT_EQ(cap.mode, DeliveryMode::Compatibility);EXPECT_EQ(cap.bearer_api, BearerApi::Absent);ASSERT_EQ(cap.setup.size(), 1u);- // Either form of the step -- copying the shipped drop-in or writing one --- // lands in the same place, so that is what is asserted rather than a literal- // flag that only one of the two branches contains.EXPECT_NE(cap.setup[0].command.find("bluetooth.service.d"), std::string::npos);+ // ExecStart must resolve bluetoothd on the machine running the command+ EXPECT_EQ(cap.setup[0].command.find("/usr/share/tether"), std::string::npos) << cap.setup[0].command;+ EXPECT_NE(cap.setup[0].command.find("bluetoothd"), std::string::npos) << cap.setup[0].command;}// Without --experimental bluetoothd registers Bearer.LE1 as an empty marker: no@@ -246,9 +246,6 @@ TEST(Capability, AnEmptyBearerInterfaceIsNotProofOfTheApi) {EXPECT_FALSE(objects.devices[0].has_le_bearer);EXPECT_EQ(cap.bearer_api, BearerApi::Absent);ASSERT_EQ(cap.setup.size(), 1u);- // Either form of the step -- copying the shipped drop-in or writing one --- // lands in the same place, so that is what is asserted rather than a literal- // flag that only one of the two branches contains.EXPECT_NE(cap.setup[0].command.find("bluetooth.service.d"), std::string::npos);}