Linux + iPhone Continuity / iMessage / SMS
fix: gtk-layer-shell error
Zack Bartele3374d12fbeb
diff --git a/PKGBUILD b/PKGBUILDindex 012488b..ffd2341 100644--- a/PKGBUILD+++ b/PKGBUILD@@ -5,7 +5,7 @@ pkgdesc="Bridge an iPhone to the Linux desktop: clipboard, files, messages, andarch=('x86_64')url="https://github.com/zackb/tether"license=('MIT')-depends=('gtk3' 'libnotify' 'openssl' 'wayland' 'avahi' 'glib2' 'bluez' 'bluez-utils' 'bluez-obex')+depends=('gtk3' 'gtk-layer-shell' 'libnotify' 'openssl' 'wayland' 'avahi' 'glib2' 'bluez' 'bluez-utils' 'bluez-obex')makedepends=('cmake' 'ninja' 'git')provides=('tether' 'tether-bin')conflicts=('tether' 'tether-bin')diff --git a/docs/BLUETOOTH.md b/docs/BLUETOOTH.mdindex a31fce3..93e1ced 100644--- a/docs/BLUETOOTH.md+++ b/docs/BLUETOOTH.md@@ -156,6 +156,7 @@ checks the daemon does not make.| MAP or PBAP reports `forbidden` | The matching toggle on the phone is off | Turn it on. This is not a pairing failure || Pairing never starts, and the only log line is a profile connect refused with `Connection refused (111)` | `Device1.Connect()` induces pairing only as a side effect of a profile connect, and this phone refuses that profile from an unbonded device | Nothing. Tether retries the transaction as an explicit `Device1.Pair()` on its own. To go straight there, `tether --bt-pair <addr> --explicit-pair` || The phone shows a pairing code, then "Pairing Unsuccessful" a moment later, and the daemon reports the transaction failed about 90s after `confirm` | `tetherd` has no display, so the confirmation dialog could not be shown, and an unshowable dialog used to count as a refusal | Fixed. The comparison now goes to whichever client started the pairing -- the CLI prompts on the terminal, the GTK app opens its own dialog. On an older build, start `tetherd` from a graphical session so it inherits `DISPLAY` or `WAYLAND_DISPLAY` |+| Pairing fails a few hundred ms after `confirm`, and `tetherd.log` says `tether-dialog: error while loading shared libraries: libgtk-layer-shell.so.0` | `tether-dialog` is linked against `gtk-layer-shell`, which the package did not depend on, so it died in the dynamic loader with exit 127 -- read as the user refusing | Install `gtk-layer-shell`. Fixed in the package dependencies, and a dialog that cannot run now routes the comparison to the client that started the pairing instead of declining it -- see 2026-08-29 below || MAP reports `busy`, or the transport says `Connection refused (111)` on an already-paired phone | Another computer holds the iPhone's single MAP session | Stop the other client || Pairing fails with `br-connection-key-missing` | A stale bond on one side, or the adapter is not `Pairable` | Delete the computer's entry on the phone (Forget This Device) and `tether --bt-unpair <addr>` locally, then pair again || The phone shows two entries for this computer | A failed pairing left both a Classic and an LE record | Delete both on the phone before retrying |@@ -1292,3 +1293,50 @@ Three things were wrong, and all three are fixed:If neither a dialog nor a client can be reached, the result now says so and names the fix,rather than reporting a rejection that never happened.+++### 2026-08-29 - A missing library declined every pairing++| | |+|---|---|+| Controller | Realtek `0bda:a728` (reporter) |+| BlueZ | 5.87, running with `--experimental` |+| Compositor | niri (Wayland), Arch Linux |+| Package | `tether-bin` 0.2.17 |+| Phone | iPhone SE, iOS 27.0 beta |++Issue #49, resolved. The reporter's `tetherd.log` showed, on every attempt, immediately after+`confirm <code>`:++```+tether-dialog: error while loading shared libraries: libgtk-layer-shell.so.0: cannot open shared+object file: No such file or directory+```++`tether-bin` did not list `gtk-layer-shell` in `depends`, so `/usr/bin/tether-dialog` never started:+the dynamic loader killed it with exit 127 in milliseconds. `confirm_with_dialog()` treated only+exit 3 and a signal as "could not ask", so 127 counted as a refusal and the agent answered BlueZ+"Rejected by the user" ~400 ms after the phone showed its code. The 90s the reporter saw was+Tether's own `PAIR_TIMEOUT_SECONDS` poll running out after the failure, not a stall.++`bluetoothctl` bonded on the same hardware throughout the thread because it uses its own agent and+never launches `tether-dialog`. The controller was never the problem.++After `pacman -S gtk-layer-shell`, `tether --bt-pair <addr> --explicit-pair` bonded on the first+attempt, with MAP and PBAP both working and contact names resolved.++Fixed:++- `gtk-layer-shell` is declared in both PKGBUILDs. The DEB and RPM dependency lists already had it.+- Only exit 0, 1 and 2 -- accept, reject, timeout -- now count as an answer. Every other exit, and+ any signal, means the dialog answered nothing, which routes the comparison to the CLI or GTK+ client. The previous fix only covered the one exit code it knew about.+- `tether-dialog` checks `gtk_layer_is_supported()` before `gtk_layer_init_for_window()`, which+ otherwise aborts where the compositor has no `wlr-layer-shell`, and falls back to an ordinary+ centered window.++**Explicit-pair bond, captured:** the bond came up `BR/EDR only` -- MAP and PBAP work, the LE half+did not derive. This is the first capture of what a `Device1.Pair()` bond yields, and it matches+what the `ConnectFirst` comment in `config.hpp` claimed without evidence. One sample, on a+controller whose cross-transport derivation is already known to be flaky, so it is not yet proof+that explicit-pair cannot produce a dual bond.diff --git a/src/core/include/tether/bluetooth/pairing.hpp b/src/core/include/tether/bluetooth/pairing.hppindex 342a991..319c9d6 100644--- a/src/core/include/tether/bluetooth/pairing.hpp+++ b/src/core/include/tether/bluetooth/pairing.hpp@@ -31,6 +31,9 @@ namespace tether::bluetooth {// at all. Device1.Pair() involves no profile.bool should_fall_back(AuthStrategy tried, bool paired, bool confirmation_failed);+ // Whether a finished tether-dialog answered one way or another.+ bool dialog_answered(int wait_status);+// Whether a D-Bus error names an authentication BlueZ already failed. No bond can appear afterwards.bool is_authentication_failure(const std::string& err);diff --git a/src/core/src/bluetooth/pairing.cpp b/src/core/src/bluetooth/pairing.cppindex dd35b2f..809a2fc 100644--- a/src/core/src/bluetooth/pairing.cpp+++ b/src/core/src/bluetooth/pairing.cpp@@ -504,10 +504,8 @@ namespace tether::bluetooth {unavailable = true;return false;}- // Exit 0 is the only acceptance. A dialog that could not be shown at all exits 3- if (!WIFEXITED(status) || WEXITSTATUS(status) == 3)- unavailable = true;- return WIFEXITED(status) && WEXITSTATUS(status) == 0;+ unavailable = !dialog_answered(status);+ return !unavailable && WEXITSTATUS(status) == 0;}nlohmann::json to_json(const PairResult& result) {@@ -522,6 +520,13 @@ namespace tether::bluetooth {};}+ bool dialog_answered(int wait_status) {+ if (!WIFEXITED(wait_status))+ return false;+ const int code = WEXITSTATUS(wait_status);+ return code == 0 || code == 1 || code == 2;+ }+bool is_authentication_failure(const std::string& err) {static const char* const NAMES[] = {"AuthenticationFailed", "AuthenticationRejected", "AuthenticationCanceled", "AuthenticationTimeout"};diff --git a/src/core/src/net.cpp b/src/core/src/net.cppindex 87b1ced..f28ae93 100644--- a/src/core/src/net.cpp+++ b/src/core/src/net.cpp@@ -1670,7 +1670,14 @@ namespace tether {ofs << pending.dump(4);}} else {- debug::log(INFO, "[Pairing Rejected] {} (exit code {})", info.device_name, exit_code);++ if (!bluetooth::dialog_answered(status))+ debug::log(ERR,+ "[Pairing Denied] {}: the confirmation dialog could not run (exit code {})",+ info.device_name,+ exit_code);+ else+ debug::log(INFO, "[Pairing Rejected] {} (exit code {})", info.device_name, exit_code);auto remote_it = connected_remote_clients.find(info.client_fd);auto ssl_it = active_ssl_.find(info.client_fd);diff --git a/src/dialog/main.cpp b/src/dialog/main.cppindex bad8dc6..b283f18 100644--- a/src/dialog/main.cpp+++ b/src/dialog/main.cpp@@ -148,13 +148,17 @@ int main(int argc, char** argv) {gtk_window_set_default_size(GTK_WINDOW(window), 380, -1);gtk_window_set_decorated(GTK_WINDOW(window), FALSE);- // Layer shell setup- gtk_layer_init_for_window(GTK_WINDOW(window));- gtk_layer_set_layer(GTK_WINDOW(window), GTK_LAYER_SHELL_LAYER_OVERLAY);- gtk_layer_set_keyboard_mode(GTK_WINDOW(window), GTK_LAYER_SHELL_KEYBOARD_MODE_EXCLUSIVE);- gtk_layer_set_namespace(GTK_WINDOW(window), "tether-dialog");-- // Center on screen (no anchors = centered)+ // Layer shell setup. fall back to an ordinary centered window.+ if (gtk_layer_is_supported()) {+ gtk_layer_init_for_window(GTK_WINDOW(window));+ gtk_layer_set_layer(GTK_WINDOW(window), GTK_LAYER_SHELL_LAYER_OVERLAY);+ gtk_layer_set_keyboard_mode(GTK_WINDOW(window), GTK_LAYER_SHELL_KEYBOARD_MODE_EXCLUSIVE);+ gtk_layer_set_namespace(GTK_WINDOW(window), "tether-dialog");+ // No anchors = centered+ } else {+ gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);+ gtk_window_set_keep_above(GTK_WINDOW(window), TRUE);+ }// Main containerGtkWidget* frame = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);diff --git a/test/test_bluetooth_pairing.cpp b/test/test_bluetooth_pairing.cppindex c9c8ba3..e58e7b6 100644--- a/test/test_bluetooth_pairing.cpp+++ b/test/test_bluetooth_pairing.cpp@@ -1,4 +1,6 @@+#include <csignal>#include <gtest/gtest.h>+#include <sys/wait.h>#include <tether/bluetooth/agent.hpp>#include <tether/bluetooth/config.hpp>#include <tether/bluetooth/pairing.hpp>@@ -107,6 +109,22 @@ TEST(FallbackPolicy, DoesNotRetryAUserRejection) {EXPECT_FALSE(should_fall_back(AuthStrategy::ConnectFirst, /*paired=*/false, /*user_rejected=*/true));}+// tether-dialog dies in the dynamic loader with 127 when gtk-layer-shell is+// missing. Reading that as a refusal declined every pairing -- see issue #49.+TEST(DialogAnswer, OnlyAcceptRejectAndTimeoutAreAnswers) {+ EXPECT_TRUE(dialog_answered(W_EXITCODE(0, 0)));+ EXPECT_TRUE(dialog_answered(W_EXITCODE(1, 0)));+ EXPECT_TRUE(dialog_answered(W_EXITCODE(2, 0)));+}++TEST(DialogAnswer, ADialogThatCouldNotRunAnsweredNothing) {+ EXPECT_FALSE(dialog_answered(W_EXITCODE(3, 0))); // bad args or no display+ EXPECT_FALSE(dialog_answered(W_EXITCODE(126, 0))); // not executable+ EXPECT_FALSE(dialog_answered(W_EXITCODE(127, 0))); // shared library missing+ EXPECT_FALSE(dialog_answered(W_EXITCODE(0, SIGSEGV)));+ EXPECT_FALSE(dialog_answered(W_EXITCODE(0, SIGABRT)));+}+// BlueZ reporting a failed authentication is terminal: polling for a bond after// it only buries when the transaction actually broke -- see issue #49.TEST(AuthenticationFailure, RecognizesBlueZErrorNames) {