Skip to contentSkip to conversation

android-tools: adbd fixes and opt-in access control for Linux systems

PATCH In review Alex Kiernan 2 participants 15 messages Nov 10 – Nov 13

lore
Share & tools
lore
#0 lore raw

cover android-tools: adbd fixes and opt-in access control for Linux systems

adbd built from this recipe runs on Linux devices rather than Android, and several things that Android's init or property service would normally provide are missing. This series fixes the bugs that follow from that, and adds opt-in controls for who may use adbd.

The first five patches are fixes and change behaviour without any opt-in:

- adb reboot recovery / bootloader pass their target to RESTART2 instead of a fixed "adb", so kernels whose reboot-mode driver picks the boot mode from the reason string reboot into the requested mode.
- adb shell starts in the user's home directory and no longer gets Android's TMPDIR=/data/local/tmp.
- On glibc, UsbFfsConnection::StopWorker() no longer spins for ever after a cable pull: it relied on bionic's pthread_kill() behaviour, and the host saw the device as offline until adbd was restarted.
- adbd exits after adb root / adb unroot so the service manager restarts it with the new privilege state; the unit becomes Restart=always.
- Readiness is signalled once functionfs is being serviced, not immediately after the USB thread starts. sd_notify(READY=1) raced open_functionfs(), and 10-adbd-configfs.conf binds the UDC on READY=1 with no delay, so the bind could be dropped and the host never reached CONFIGURED. Builds without systemd can get the same signal through a FIFO named in $ADBD_READY_FIFO.

The next four are opt-in, and change nothing unless enabled:

- PACKAGECONFIG[debuggable-prop]: liblog reads ro.debuggable from the build.prop-style files in ADB_DEBUGGABLE_PROP_FILES rather than reporting every build as debuggable, so adb root can be refused on a production image.
- PACKAGECONFIG[auth-unless-debuggable]: hosts must authenticate unless the build is debuggable, decided per connection. Today the Debian patch lets every host in without a key.
- ADBD_AUTH_KEY_PATHS: where adbd reads trusted host keys, in place of Android's /adb_keys and /data/misc/adb/adb_keys.
- adbd keeps root across a restart only while the build is debuggable, so a root state written while it was does not outlive it. Without debuggable-prop every Linux build is debuggable, so this is a no-op.

The last patch drops killall adbd from android-gadget-cleanup, which runs after adbd has already exited.

---
Alex Kiernan (10):
android-tools: adbd: forward the reboot target to RESTART2
android-tools: adbd: start adb shell in $HOME, without Android's TMPDIR
android-tools: adbd: fix the USB worker hanging on glibc after a cable pull
android-tools: adbd: restart after adb root/unroot
android-tools: adbd: signal readiness once functionfs is serviced
android-tools: add PACKAGECONFIG debuggable-prop
android-tools: add PACKAGECONFIG auth-unless-debuggable
android-tools: add ADBD_AUTH_KEY_PATHS
android-tools: adbd: keep root only while the build is debuggable
android-tools-conf: android-gadget-cleanup: don't killall adbd

 .../android-tools-conf/android-gadget-cleanup      |   4 +-
 ...dbd-forward-the-reboot-target-to-RESTART2.patch |  42 +++++++
 ...start-in-HOME-and-drop-the-Android-only-T.patch |  45 +++++++
 ...-use-pthread_kill-as-a-thread-liveness-pr.patch | 118 ++++++++++++++++++
 ...exit-after-adb-root-unroot-so-an-init-sup.patch |  60 +++++++++
 ...nal-readiness-once-functionfs-is-serviced.patch | 117 +++++++++++++++++
 ...onally-read-ro.debuggable-from-build.prop.patch | 117 +++++++++++++++++
 ...ally-require-authorization-unless-the-bui.patch | 138 +++++++++++++++++++++
 ...h-optionally-take-the-trusted-key-paths-a.patch |  72 +++++++++++
 ...oot-on-Linux-only-while-the-build-is-debu.patch |  51 ++++++++
 .../android-tools/android-tools-adbd.service       |   2 +-
 .../android-tools/android-tools_35.0.2.bb          |  28 ++++-
 12 files changed, 788 insertions(+), 6 deletions(-)

---
base-commit: 33db795031ddef81949db64aedf33070e1330fdd
change-id: 20261106-android-tools-adbd-1c8f4decb0de

Best regards,

Signature · 1 line
Alex Kiernan <[email protected]>
#1 lore raw

PATCH 1/10 android-tools: adbd: forward the reboot target to RESTART2

reboot_device() hard-codes the RESTART2 reason to "adb" on non-Android builds and drops the requested target, so adb reboot recovery and adb reboot bootloader are plain reboots on any board whose kernel picks the boot mode from the reboot reason (reboot-mode, as on Rockchip).

AI-Generated: Claude Opus 5.5 (Claude Code)

---
 ...dbd-forward-the-reboot-target-to-RESTART2.patch | 42 ++++++++++++++++++++++
 .../android-tools/android-tools_35.0.2.bb          |  1 +
 2 files changed, 43 insertions(+)
meta-oe/recipes-devtools/android-tools/android-tools/0016-adbd-forward-the-reboot-target-to-RESTART2.patch new file +42 -0
new file mode 100644
index 000000000000..02b7a44ed802
@@ -0,0 +1,42 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Alex Kiernan <[email protected]>
+Date: Mon, 15 Jun 2026 00:00:00 +0000
+Subject: [PATCH] adbd: forward the reboot target to RESTART2
+
+On non-Android Linux builds reboot_device() hard-codes the RESTART2
+reboot reason to "adb" and throws away the requested target, so
+"adb reboot recovery", "adb reboot bootloader", etc. all collapse to a
+plain reboot.
+
+On Rockchip the reboot reason string is consumed by the kernel
+reboot-mode driver (drivers/power/reset/reboot-mode.c), which strcmp()s
+it against the device-tree "mode-*" entries (mode-recovery,
+mode-bootloader, mode-loader, ...) to pick the boot-mode magic written
+to the PMU syscon register that U-Boot reads on the next boot. With the
+reason fixed to "adb" nothing matches and it falls back to a normal
+boot.
+
+Pass the real target through instead. An empty target (bare
+"adb reboot") becomes "", which the kernel treats as "normal", matching
+the previous behaviour for that case.
+
+Upstream-Status: Pending
+
+Signed-off-by: Alex Kiernan <[email protected]>
+---
+ packages/modules/adb/daemon/services.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/packages/modules/adb/daemon/services.cpp b/packages/modules/adb/daemon/services.cpp
+index 1b2731442a2a..968e9e74ffa4 100644
+--- a/packages/modules/adb/daemon/services.cpp
++++ b/packages/modules/adb/daemon/services.cpp
+@@ -219,7 +219,7 @@ static void remount_service(unique_fd fd) {
+     auto reboot_service = [name](unique_fd fd) {
+         sync();
+         if (syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
+-                    LINUX_REBOOT_CMD_RESTART2, "adb") != 0) {
++                    LINUX_REBOOT_CMD_RESTART2, name.c_str()) != 0) {
+             WriteFdFmt(fd.get(), "reboot (%s) failed: %s\n", name.c_str(), strerror(errno));
+             return;
+         }
meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb +1 -0
index e9785ac235de..4961a13963c4 100644
@@ -60,6 +60,7 @@ SRC_URI = "https://deb.debian.org/debian/pool/main/a/android-platform-tools/andr
            file://0013-adb-sysdeps-provide-pread64-pwrite64-lseek64-fallba.patch \
            file://0014-daemon-auth-vendor-a-portable-b64_pton-for-non-glib.patch \
            file://0015-adbd-make-fs-config-opt-in-on-non-android-builds.patch \
+           file://0016-adbd-forward-the-reboot-target-to-RESTART2.patch \
            "
 
 SRC_URI[orig.md5sum] = "352376965cdef7bd7505d8fefdd43d50"
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/10 android-tools: adbd: start adb shell in $HOME, without Android's TMPDIR

In reply to Alex Kiernan

adbd execs the login shell itself, so adb shell starts in adbd's working directory rather than the user's home, and with TMPDIR=/data/local/tmp, which does not exist on a Linux rootfs.

AI-Generated: Claude Opus 5.5 (Claude Code)

---
 ...start-in-HOME-and-drop-the-Android-only-T.patch | 45 ++++++++++++++++++++++
 .../android-tools/android-tools_35.0.2.bb          |  1 +
 2 files changed, 46 insertions(+)
meta-oe/recipes-devtools/android-tools/android-tools/0017-adbd-shell-start-in-HOME-and-drop-the-Android-only-T.patch new file +45 -0
new file mode 100644
index 000000000000..d8839d776069
@@ -0,0 +1,45 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Alex Kiernan <[email protected]>
+Date: Fri, 17 Jul 2026 18:20:41 +0100
+Subject: [PATCH] adbd: shell - start in $HOME and drop the Android-only TMPDIR
+
+adbd execs the login shell directly (no login(1)), so it never chdir()s and the
+shell lands in adbd's cwd (/) instead of the user's home. chdir() to the passwd
+home before exec, best-effort. Also drop the hardcoded TMPDIR=/data/local/tmp:
+that path only exists on Android and is wrong on a normal Linux rootfs, where an
+unset TMPDIR correctly falls back to /tmp.
+
+Upstream-Status: Pending
+
+AI-Generated: Claude Opus 4.8 (claude-opus-4-8)
+Signed-off-by: Alex Kiernan <[email protected]>
+---
+ packages/modules/adb/daemon/shell_service.cpp | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/packages/modules/adb/daemon/shell_service.cpp b/packages/modules/adb/daemon/shell_service.cpp
+index dbca4adb61e2..4e9e50edf271 100644
+--- a/packages/modules/adb/daemon/shell_service.cpp
++++ b/packages/modules/adb/daemon/shell_service.cpp
+@@ -274,7 +274,6 @@ bool Subprocess::ForkAndExec(std::string* error) {
+         env["HOSTNAME"] = GetHostName();
+         env["LOGNAME"] = pw->pw_name;
+         env["SHELL"] = pw->pw_shell;
+-        env["TMPDIR"] = "/data/local/tmp";
+         env["USER"] = pw->pw_name;
+     }
+ 
+@@ -386,6 +385,13 @@ bool Subprocess::ForkAndExec(std::string* error) {
+         }
+ #endif
+ 
++        // Start the shell in the user's home dir, like login(1) would - adbd
++        // execs the shell directly (no login), so without this it inherits
++        // adbd's cwd (/). Best-effort: if HOME is missing/unset, stay put.
++        if (pw != nullptr && pw->pw_dir && pw->pw_dir[0]) {
++            (void)chdir(pw->pw_dir);
++        }
++
+         if (command_.empty()) {
+             // Spawn a login shell if we don't have a command.
+             execle(_PATH_BSHELL, "-" _PATH_BSHELL, nullptr, cenv.data());
meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb +1 -0
index 4961a13963c4..b1e66198f88c 100644
@@ -61,6 +61,7 @@ SRC_URI = "https://deb.debian.org/debian/pool/main/a/android-platform-tools/andr
            file://0014-daemon-auth-vendor-a-portable-b64_pton-for-non-glib.patch \
            file://0015-adbd-make-fs-config-opt-in-on-non-android-builds.patch \
            file://0016-adbd-forward-the-reboot-target-to-RESTART2.patch \
+           file://0017-adbd-shell-start-in-HOME-and-drop-the-Android-only-T.patch \
            "
 
 SRC_URI[orig.md5sum] = "352376965cdef7bd7505d8fefdd43d50"
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/10 android-tools: adbd: fix the USB worker hanging on glibc after a cable pull

In reply to Alex Kiernan

UsbFfsConnection::StopWorker() waits for the worker with pthread_kill(handle, 0) == ESRCH, which holds on bionic but not glibc, where an exited, unjoined thread still answers 0. A cable pull ends the worker on its own, StopWorker() then spins for ever, ep0 is never reopened and the host sees the device as offline until adbd is restarted.

AI-Generated: Claude Opus 5.5 (Claude Code)

---
 ...-use-pthread_kill-as-a-thread-liveness-pr.patch | 118 +++++++++++++++++++++
 .../android-tools/android-tools_35.0.2.bb          |   1 +
 2 files changed, 119 insertions(+)
meta-oe/recipes-devtools/android-tools/android-tools/0018-adbd-do-not-use-pthread_kill-as-a-thread-liveness-pr.patch new file +118 -0
new file mode 100644
index 000000000000..0ebe7aba69b5
@@ -0,0 +1,118 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Alex Kiernan <[email protected]>
+Date: Sun, 13 Sep 2026 08:31:56 +0100
+Subject: [PATCH] adbd: do not use pthread_kill as a thread-liveness probe
+
+UsbFfsConnection::StopWorker() polled `pthread_kill(handle, 0) == ESRCH` to ask
+whether the worker had exited. That reads as portable and is not: it relies on
+bionic clearing the thread id on exit, so a signal to a dead thread lands on
+nothing. glibc keeps the thread descriptor valid until join(), so for an
+exited-but-unjoined thread pthread_kill returns 0, the probe answers "still
+running" for ever, and the loop never terminates.
+
+It is not a race on glibc, it is a hang, and the path that reaches it is the
+ordinary one: a cable pull kills the worker on its own with "Cannot send after
+transport endpoint shutdown", so StopWorker is entered with a corpse.
+~UsbFfsConnection then never returns, usb_ffs_open_thread never reopens ep0,
+and the kernel gadget re-enumerates perfectly while the host claims the
+interface and never receives a CNXN. The device shows as `offline` until
+something restarts adbd. On a unit whose only route in is adb, nothing can.
+
+The worker now reports its own exit through an atomic, which is true on both
+libcs. It is set from a scope guard rather than as the lambda's last statement
+because the SubmitRead failure path returns early, and that is precisely a case
+StopWorker must not wait for ever on. The signal is still sent on every pass,
+since interrupting a worker blocked in io_getevents is what the loop is for.
+
+Diagnosed on two RK3308 units, both wedged the first time either had its cable
+pulled since boot: main thread in futex_wait joining the monitor, monitor
+thread in hrtimer_nanosleep at the 100ms spin, the open thread waiting on a
+connection reset that never comes, and no worker thread at all. strace of the
+monitor shows both pthread_kill calls returning success with no tgkill issued.
+
+Upstream-Status: Pending
+
+AI-Generated: Claude Opus 5 (Claude Code)
+Signed-off-by: Alex Kiernan <[email protected]>
+---
+ packages/modules/adb/daemon/usb.cpp | 38 +++++++++++++++++++++--------
+ 1 file changed, 28 insertions(+), 10 deletions(-)
+
+diff --git a/packages/modules/adb/daemon/usb.cpp b/packages/modules/adb/daemon/usb.cpp
+index 1fe2d3aa3215..e44c7b788587 100644
+--- a/packages/modules/adb/daemon/usb.cpp
++++ b/packages/modules/adb/daemon/usb.cpp
+@@ -146,6 +146,7 @@ struct UsbFfsConnection : public Connection {
+     UsbFfsConnection(unique_fd control, unique_fd read, unique_fd write,
+                      std::promise<void> destruction_notifier)
+         : worker_started_(false),
++          worker_exited_(false),
+           stopped_(false),
+           destruction_notifier_(std::move(destruction_notifier)),
+           control_fd_(std::move(control)),
+@@ -406,6 +407,14 @@ struct UsbFfsConnection : public Connection {
+             adb_thread_setname("UsbFfs-worker");
+             LOG(INFO) << "UsbFfs-worker thread spawned";
+ 
++            // On EVERY exit path, not as a final statement: the SubmitRead
++            // failure below returns early, and that is precisely a case
++            // StopWorker() must not wait forever on.
++            struct ExitReporter {
++                std::atomic<bool>* flag;
++                ~ExitReporter() { flag->store(true, std::memory_order_release); }
++            } exit_reporter{&worker_exited_};
++
+             for (size_t i = 0; i < kUsbReadQueueDepth; ++i) {
+                 read_requests_[i] = CreateReadBlock(next_read_id_++);
+                 if (!SubmitRead(&read_requests_[i])) {
+@@ -435,8 +444,23 @@ struct UsbFfsConnection : public Connection {
+             return;
+         }
+ 
++        // NOT pthread_kill(handle, 0) == ESRCH as a liveness probe. That reads
++        // as portable and is not: it relies on bionic clearing the thread id
++        // when a thread exits, so the signal lands on nothing. glibc keeps the
++        // descriptor valid until join(), so for an exited-but-unjoined thread
++        // pthread_kill returns 0 and the probe says "still running" for ever.
++        //
++        // The loop is reached with a dead worker in the one case that matters:
++        // a cable pull kills the worker on its own (transport endpoint
++        // shutdown), and then ~UsbFfsConnection never returns, the ffs
++        // endpoints are never reopened, and the host sees a device that
++        // enumerates but never sends CNXN - offline until adbd is restarted.
++        // On a unit whose only way in IS adb, that is unrecoverable.
++        //
++        // The signal is still sent on every pass, because that is what the loop
++        // is for: interrupting a worker blocked in io_getevents.
+         pthread_t worker_thread_handle = worker_thread_.native_handle();
+-        while (true) {
++        while (!worker_exited_.load(std::memory_order_acquire)) {
+             int rc = pthread_kill(worker_thread_handle, kInterruptionSignal);
+             if (rc != 0) {
+                 LOG(ERROR) << "failed to send interruption signal to worker: " << strerror(rc);
+@@ -444,15 +468,6 @@ struct UsbFfsConnection : public Connection {
+             }
+ 
+             std::this_thread::sleep_for(100ms);
+-
+-            rc = pthread_kill(worker_thread_handle, 0);
+-            if (rc == 0) {
+-                continue;
+-            } else if (rc == ESRCH) {
+-                break;
+-            } else {
+-                LOG(ERROR) << "failed to send interruption signal to worker: " << strerror(rc);
+-            }
+         }
+ 
+         worker_thread_.join();
+@@ -709,6 +724,9 @@ struct UsbFfsConnection : public Connection {
+ 
+     bool worker_started_;
+     std::thread worker_thread_;
++    // Set by the worker itself on the way out. StopWorker() waits on this
++    // rather than probing the thread handle - see the comment there.
++    std::atomic<bool> worker_exited_;
+ 
+     std::atomic<bool> stopped_;
+     std::promise<void> destruction_notifier_;
meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb +1 -0
index b1e66198f88c..9a0bae98dd19 100644
@@ -62,6 +62,7 @@ SRC_URI = "https://deb.debian.org/debian/pool/main/a/android-platform-tools/andr
            file://0015-adbd-make-fs-config-opt-in-on-non-android-builds.patch \
            file://0016-adbd-forward-the-reboot-target-to-RESTART2.patch \
            file://0017-adbd-shell-start-in-HOME-and-drop-the-Android-only-T.patch \
+           file://0018-adbd-do-not-use-pthread_kill-as-a-thread-liveness-pr.patch \
            "
 
 SRC_URI[orig.md5sum] = "352376965cdef7bd7505d8fefdd43d50"
Signature · 1 line
2.43.0
#4 lore raw

PATCH 4/10 android-tools: adbd: restart after adb root/unroot

In reply to Alex Kiernan

adb root and adb unroot write the new privilege state to /run/adbd.root and expect adbd to be restarted to apply it, as Android's init does. Nothing restarted it here, so the client's wait-for-disconnect hung and adbd kept its uid. Have adbd exit after writing the state, and restart the service on any exit, not only on failure.

AI-Generated: Claude Opus 5.5 (Claude Code)

---
 ...exit-after-adb-root-unroot-so-an-init-sup.patch | 60 ++++++++++++++++++++++
 .../android-tools/android-tools-adbd.service       |  2 +-
 .../android-tools/android-tools_35.0.2.bb          |  1 +
 3 files changed, 62 insertions(+), 1 deletion(-)
meta-oe/recipes-devtools/android-tools/android-tools/0019-adb-daemon-exit-after-adb-root-unroot-so-an-init-sup.patch new file +60 -0
new file mode 100644
index 000000000000..a55e4259194c
@@ -0,0 +1,60 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Alex Kiernan <[email protected]>
+Date: Sun, 19 Jul 2026 08:59:06 +0100
+Subject: [PATCH] adb: daemon: exit after adb root/unroot so an init supervisor
+ restarts adbd
+
+On Android, `adb root`/`adb unroot` write the desired privilege state and
+rely on init restarting adbd (via a property trigger) to pick it up. This
+Linux port keeps the "write state file, rely on a restart" model but the
+running adbd never exits, so on a non-Android system with nothing watching
+the state file the daemon keeps its current uid and the client's
+`wait-for-disconnect` hangs (or times out once the USB transport happens to
+drop for unrelated reasons).
+
+Exit after successfully writing the root state, as the classic adbd did,
+so the service manager restarts adbd (systemd with Restart=always, or a
+supervisor such as runit); on restart should_drop_privileges() reads the
+state file and comes back root (root) or drops to the adb user (unroot). A
+short delay lets the reply reach the host over USB before the gadget is
+torn down.
+
+Upstream-Status: Pending
+Signed-off-by: Alex Kiernan <[email protected]>
+---
+ packages/modules/adb/daemon/restart_service.cpp | 15 ++++++++++++++-
+ 1 file changed, 14 insertions(+), 1 deletion(-)
+
+diff --git a/packages/modules/adb/daemon/restart_service.cpp b/packages/modules/adb/daemon/restart_service.cpp
+index 8aee1afeaef8..3c3fd24ed5af 100644
+--- a/packages/modules/adb/daemon/restart_service.cpp
++++ b/packages/modules/adb/daemon/restart_service.cpp
+@@ -65,7 +65,16 @@ void restart_root_service(unique_fd fd) {
+         if (write_root_state(kRootMagic, kRootMagicSize)) {
+             LOG(INFO) << "adbd restarting as root";
+             WriteFdExactly(fd.get(), "restarting adbd as root\n");
+-            return;
++            // Unlike on Android (where init restarts adbd on a property
++            // trigger), on this Linux port nothing watches the root-state
++            // file, so a still-running adbd would keep its current uid and
++            // the client's `wait-for-disconnect` would hang. Exit instead so
++            // the init supervisor restarts us; on restart should_drop_
++            // privileges() reads #ROOT# and we come back as root. Give the
++            // reply time to reach the host over USB before tearing the gadget
++            // down, as the classic adbd did.
++            sleep(1);
++            _exit(0);
+         }
+         usleep(100000);
+     }
+@@ -84,6 +93,10 @@ void restart_unroot_service(unique_fd fd) {
+     }
+     LOG(INFO) << "adbd restarting as nonroot";
+     WriteFdExactly(fd.get(), "restarting adbd as non root\n");
++    // See restart_root_service(): exit so the init supervisor restarts adbd,
++    // which then reads #NOROOT# and drops privileges again.
++    sleep(1);
++    _exit(0);
+ }
+ 
+ void restart_tcp_service(unique_fd fd, int port) {
meta-oe/recipes-devtools/android-tools/android-tools/android-tools-adbd.service +1 -1
index 7c16b5cea20f..355d91517cff 100644
@@ -5,7 +5,7 @@ Before=android-system.service
 
 [Service]
 Type=notify
-Restart=on-failure
+Restart=always
 ExecStartPre=-/usr/bin/android-gadget-setup adb
 ExecStart=/usr/bin/adbd
 
meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb +1 -0
index 9a0bae98dd19..e247cbbafa60 100644
@@ -63,6 +63,7 @@ SRC_URI = "https://deb.debian.org/debian/pool/main/a/android-platform-tools/andr
            file://0016-adbd-forward-the-reboot-target-to-RESTART2.patch \
            file://0017-adbd-shell-start-in-HOME-and-drop-the-Android-only-T.patch \
            file://0018-adbd-do-not-use-pthread_kill-as-a-thread-liveness-pr.patch \
+           file://0019-adb-daemon-exit-after-adb-root-unroot-so-an-init-sup.patch \
            "
 
 SRC_URI[orig.md5sum] = "352376965cdef7bd7505d8fefdd43d50"
Signature · 1 line
2.43.0
#5 lore raw

PATCH 5/10 android-tools: adbd: signal readiness once functionfs is serviced

In reply to Alex Kiernan

adbd sent sd_notify(READY=1) from adbd_main(), but usb_init() has only started the USB thread by then, so READY=1 raced open_functionfs(). 10-adbd-configfs.conf binds the UDC from ExecStartPost with no delay on the strength of READY=1, so a bind that won the race was dropped and the host never reached CONFIGURED. Signal readiness from the USB thread once functionfs is serviced, which is what that drop-in assumes.

Built without systemd, the same point writes a byte to the FIFO named in $ADBD_READY_FIFO instead, if set, for other init systems. It opens the FIFO non-blocking, so adbd never waits on a reader that has given up.

AI-Generated: Claude Opus 5.5 (Claude Code)

---
 ...nal-readiness-once-functionfs-is-serviced.patch | 117 +++++++++++++++++++++
 .../android-tools/android-tools_35.0.2.bb          |   1 +
 2 files changed, 118 insertions(+)
meta-oe/recipes-devtools/android-tools/android-tools/0020-adbd-signal-readiness-once-functionfs-is-serviced.patch new file +117 -0
new file mode 100644
index 000000000000..77527437a4e6
@@ -0,0 +1,117 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Alex Kiernan <[email protected]>
+Date: Fri, 6 Nov 2026 10:03:09 +0000
+Subject: [PATCH] adbd: signal readiness once functionfs is serviced
+
+The gadget's UDC must not be bound until adbd is servicing functionfs:
+bind earlier and the bind is silently dropped, and the host never
+reaches CONFIGURED. adbd_main() sends sd_notify(READY=1) after
+usb_init(), but usb_init() only starts usb_ffs_open_thread, detached, so
+READY=1 races open_functionfs() - and a unit that binds the UDC on
+READY=1 (ExecStartPost with no delay) loses the race.
+
+Signal readiness from the USB thread instead, once the descriptors are
+written and the transport is registered. Built without systemd, the
+same point writes a byte to the FIFO named in $ADBD_READY_FIFO instead,
+if set, for other init systems. The FIFO is opened non-blocking, so
+adbd never waits on a reader that has given up. Readiness is signalled
+once; an adbd that is not on USB still signals it from adbd_main().
+
+Upstream-Status: Pending
+
+AI-Generated: Claude Opus 5.5 (Claude Code)
+Signed-off-by: Alex Kiernan <[email protected]>
+---
+ packages/modules/adb/adb.h           |  6 ++++++
+ packages/modules/adb/daemon/main.cpp | 31 +++++++++++++++++++++++++---
+ packages/modules/adb/daemon/usb.cpp  |  7 +++++++
+ 3 files changed, 41 insertions(+), 3 deletions(-)
+
+diff --git a/packages/modules/adb/adb.h b/packages/modules/adb/adb.h
+index b43bb42ec736..20c002051937 100644
+--- a/packages/modules/adb/adb.h
++++ b/packages/modules/adb/adb.h
+@@ -263,3 +263,9 @@ void adb_set_reject_kill_server(bool reject);
+ #endif
+ 
+ void usb_init();
++#if !ADB_HOST
++// Tell whoever started adbd that it is ready: sd_notify(READY=1) with systemd,
++// otherwise a byte to the FIFO named in $ADBD_READY_FIFO if set. Only the first
++// call does anything.
++void adbd_notify_ready();
++#endif
+diff --git a/packages/modules/adb/daemon/main.cpp b/packages/modules/adb/daemon/main.cpp
+index ac37461f21dc..a5b1d6b3e0eb 100644
+--- a/packages/modules/adb/daemon/main.cpp
++++ b/packages/modules/adb/daemon/main.cpp
+@@ -53,6 +53,8 @@
+ #include <systemd/sd-daemon.h>
+ #endif
+ 
++#include <mutex>
++
+ #include "adb.h"
+ #include "adb_auth.h"
+ #include "adb_listeners.h"
+@@ -244,6 +246,27 @@ static void drop_privileges(int) {
+ }
+ #endif
+ 
++void adbd_notify_ready() {
++    static std::once_flag once;
++    std::call_once(once, [] {
++#if defined(HAVE_SYSTEMD)
++        sd_notify(1, "READY=1");
++#else
++        const char* ready_fifo = getenv("ADBD_READY_FIFO");
++        if (ready_fifo != nullptr && *ready_fifo != '\0') {
++            // O_NONBLOCK: with no reader, open() fails with ENXIO rather than
++            // blocking this thread for ever; the reader has given up and
++            // gone ahead without the signal.
++            int fd = adb_open(ready_fifo, O_WRONLY | O_NONBLOCK | O_CLOEXEC);
++            if (fd >= 0) {
++                TEMP_FAILURE_RETRY(adb_write(fd, "1\n", 2));
++                adb_close(fd);
++            }
++        }
++#endif
++    });
++}
++
+ static void setup_adb(const std::vector<std::string>& addrs) {
+ #if defined(__ANDROID__)
+     // Get the first valid port from addrs and setup mDNS.
+@@ -368,9 +391,11 @@ int adbd_main(int server_port) {
+     init_jdwp();
+     D("adbd_main(): post init_jdwp()");
+ 
+-#if defined(HAVE_SYSTEMD)
+-    sd_notify(1, "READY=1");
+-#endif
++    // On USB, readiness is signalled from the USB thread once functionfs is
++    // serviced; usb_init() has only started that thread.
++    if (!is_usb) {
++        adbd_notify_ready();
++    }
+ 
+     D("Event loop starting");
+     fdevent_loop();
+diff --git a/packages/modules/adb/daemon/usb.cpp b/packages/modules/adb/daemon/usb.cpp
+index e44c7b788587..a970c4e1fd28 100644
+--- a/packages/modules/adb/daemon/usb.cpp
++++ b/packages/modules/adb/daemon/usb.cpp
+@@ -805,6 +805,13 @@ static void usb_ffs_open_thread() {
+                 std::move(control), std::move(bulk_out), std::move(bulk_in),
+                 std::move(destruction_notifier)));
+         register_transport(transport);
++
++        // functionfs descriptors are written and ep0 is being serviced, so the
++        // gadget will now handle FUNCTIONFS_BIND: this is the moment the UDC
++        // may be bound. Binding earlier races this setup, and the bind is
++        // silently dropped.
++        adbd_notify_ready();
++
+         future.wait();
+     }
+ }
meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb +1 -0
index e247cbbafa60..f5ab21262ce5 100644
@@ -64,6 +64,7 @@ SRC_URI = "https://deb.debian.org/debian/pool/main/a/android-platform-tools/andr
            file://0017-adbd-shell-start-in-HOME-and-drop-the-Android-only-T.patch \
            file://0018-adbd-do-not-use-pthread_kill-as-a-thread-liveness-pr.patch \
            file://0019-adb-daemon-exit-after-adb-root-unroot-so-an-init-sup.patch \
+           file://0020-adbd-signal-readiness-once-functionfs-is-serviced.patch \
            "
 
 SRC_URI[orig.md5sum] = "352376965cdef7bd7505d8fefdd43d50"
Signature · 1 line
2.43.0
#6 lore raw

PATCH 6/10 android-tools: add PACKAGECONFIG debuggable-prop

In reply to Alex Kiernan

The non-Android liblog says every build is debuggable, so adbd allows adb root and the root: service everywhere. With debuggable-prop, liblog reads ro.debuggable from the build.prop-style files in ADB_DEBUGGABLE_PROP_FILES (default ${sysconfdir}/build.prop), and the build is debuggable only if one of them sets it to 1.

AI-Generated: Claude Opus 5.5 (Claude Code)

---
 ...onally-read-ro.debuggable-from-build.prop.patch | 117 +++++++++++++++++++++
 .../android-tools/android-tools_35.0.2.bb          |   9 +-
 2 files changed, 125 insertions(+), 1 deletion(-)
meta-oe/recipes-devtools/android-tools/android-tools/0021-liblog-optionally-read-ro.debuggable-from-build.prop.patch new file +117 -0
new file mode 100644
index 000000000000..6cf4f9c8583e
@@ -0,0 +1,117 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Alex Kiernan <[email protected]>
+Date: Fri, 6 Nov 2026 09:38:18 +0000
+Subject: [PATCH] liblog: optionally read ro.debuggable from build.prop-style
+ files
+
+The non-Android stub of __android_log_is_debuggable() returns 1, so on a
+Linux adbd every build is debuggable: `adb root` and the root: service are
+always allowed, and nothing can tell a development image from a production
+one.
+
+When LIBLOG_DEBUGGABLE_PROP_FILES is passed to make - a colon-separated
+list of build.prop-style files - read ro.debuggable from them instead. The build is
+debuggable if any of them has "ro.debuggable=1", and not otherwise,
+including when none of them exists. The files are read on each call rather
+than latched, so one written after the process started (a runtime unlock on
+tmpfs, say) takes effect without a restart.
+
+Without the define nothing changes.
+
+Upstream-Status: Pending
+
+AI-Generated: Claude Opus 5.5 (Claude Code)
+Signed-off-by: Alex Kiernan <[email protected]>
+---
+ debian/system/liblog.mk              |  4 +++
+ system/logging/liblog/properties.cpp | 52 ++++++++++++++++++++++++++++
+ 2 files changed, 56 insertions(+)
+
+diff --git a/debian/system/liblog.mk b/debian/system/liblog.mk
+index 091ccad19c3a..89027bcebacf 100644
+--- a/debian/system/liblog.mk
++++ b/debian/system/liblog.mk
+@@ -26,6 +26,10 @@ CPPFLAGS += \
+   -Isystem/libbase/include \
+   -Isystem/logging/liblog/include \
+ 
++ifneq ($(LIBLOG_DEBUGGABLE_PROP_FILES),)
++CPPFLAGS += -DLIBLOG_DEBUGGABLE_PROP_FILES='"$(LIBLOG_DEBUGGABLE_PROP_FILES)"'
++endif
++
+ LDFLAGS += \
+   -Wl,-rpath='$$ORIGIN' \
+   -Wl,-soname,$(NAME).so.0 \
+diff --git a/system/logging/liblog/properties.cpp b/system/logging/liblog/properties.cpp
+index 657901a34e44..f069ebc4eb22 100644
+--- a/system/logging/liblog/properties.cpp
++++ b/system/logging/liblog/properties.cpp
+@@ -17,7 +17,9 @@
+ #include <log/log_properties.h>
+ 
+ #include <ctype.h>
++#include <limits.h>
+ #include <pthread.h>
++#include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <unistd.h>
+@@ -311,8 +313,58 @@ int __android_log_is_loggable_len(int prio, const char*, size_t, int def) {
+   return __android_log_is_loggable(prio, nullptr, def);
+ }
+ 
++#if defined(LIBLOG_DEBUGGABLE_PROP_FILES)
++// True only if the build.prop-style file at path has the line "<key>=1".
++// Anything else, including the file being absent or unreadable, is false.
++static bool prop_file_is_true(const char* path, size_t pathlen, const char* key) {
++  char buf[PATH_MAX];
++  if (pathlen == 0 || pathlen >= sizeof(buf)) {
++    return false;
++  }
++  memcpy(buf, path, pathlen);
++  buf[pathlen] = '\0';
++  FILE* f = fopen(buf, "re");
++  if (f == nullptr) {
++    return false;
++  }
++  const size_t keylen = strlen(key);
++  char line[256];
++  bool value = false;
++  while (fgets(line, sizeof(line), f) != nullptr) {
++    if (strncmp(line, key, keylen) == 0 && line[keylen] == '=') {
++      const char* v = line + keylen + 1;
++      value = v[0] == '1' && (v[1] == '\0' || v[1] == '\n' || v[1] == '\r');
++      break;
++    }
++  }
++  fclose(f);
++  return value;
++}
++#endif
++
+ int __android_log_is_debuggable() {
++#if defined(LIBLOG_DEBUGGABLE_PROP_FILES)
++  // There is no property service off Android. Read ro.debuggable from a
++  // colon-separated list of build.prop-style files instead, and treat the
++  // build as debuggable if any of them sets it to 1; absent all of them, it is
++  // not. Read on every call, not latched: a file may be written after the
++  // process starts, and the callers are occasional.
++  const char* paths = LIBLOG_DEBUGGABLE_PROP_FILES;
++  while (*paths != '\0') {
++    const char* end = strchr(paths, ':');
++    const size_t len = end != nullptr ? static_cast<size_t>(end - paths) : strlen(paths);
++    if (prop_file_is_true(paths, len, "ro.debuggable")) {
++      return 1;
++    }
++    if (end == nullptr) {
++      break;
++    }
++    paths = end + 1;
++  }
++  return 0;
++#else
+   return 1;
++#endif
+ }
+ 
+ int __android_log_security() {
meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb +8 -1
index f5ab21262ce5..d3d60b514721 100644
@@ -65,6 +65,7 @@ SRC_URI = "https://deb.debian.org/debian/pool/main/a/android-platform-tools/andr
            file://0018-adbd-do-not-use-pthread_kill-as-a-thread-liveness-pr.patch \
            file://0019-adb-daemon-exit-after-adb-root-unroot-so-an-init-sup.patch \
            file://0020-adbd-signal-readiness-once-functionfs-is-serviced.patch \
+           file://0021-liblog-optionally-read-ro.debuggable-from-build.prop.patch \
            "
 
 SRC_URI[orig.md5sum] = "352376965cdef7bd7505d8fefdd43d50"
@@ -208,7 +209,8 @@ do_compile() {
     # Debian replaces Android's Soong build system with hand-written GNU make
     # fragments under debian/system/ and debian/external/.
     for tool in ${PREREQUISITE_core}; do
-        oe_runmake -f ${S}/debian/system/${tool}.mk -C ${S}
+        oe_runmake -f ${S}/debian/system/${tool}.mk -C ${S} \
+            ${@'LIBLOG_DEBUGGABLE_PROP_FILES=' + d.getVar('ADB_DEBUGGABLE_PROP_FILES') if bb.utils.contains('PACKAGECONFIG', 'debuggable-prop', True, False, d) else ''}
     done
 
     if echo " ${TOOLS_TO_BUILD} " | grep -q " fastboot "; then
@@ -266,8 +268,13 @@ FILES:${PN}-adbd = " \
 BBCLASSEXTEND = "native"
 
 PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
+ADB_DEBUGGABLE_PROP_FILES ?= "${sysconfdir}/build.prop"
 # Apply Android's fs_config ownership/mode tables to files pushed by adbd to
 # /system, /vendor and /oem. Off by default: the tables describe Android
 # partition images and are meaningless on a generic Linux rootfs.
 PACKAGECONFIG[fs-config] = ""
+# Read ro.debuggable from ADB_DEBUGGABLE_PROP_FILES (colon-separated,
+# build.prop format), so `adb root` is refused unless one of them sets
+# ro.debuggable=1. Off by default: every build is debuggable.
+PACKAGECONFIG[debuggable-prop] = ""
 PACKAGECONFIG[systemd] = ",,systemd"
Signature · 1 line
2.43.0
#7 lore raw

PATCH 7/10 android-tools: add PACKAGECONFIG auth-unless-debuggable

In reply to Alex Kiernan

Debian's adbd never asks a host for a key on Linux. With auth-unless-debuggable a host must authenticate unless the build is debuggable, checked for each connection so that a debuggable state that appears while adbd runs applies at once. It needs debuggable-prop to mean anything.

AI-Generated: Claude Opus 5.5 (Claude Code)

---
 ...ally-require-authorization-unless-the-bui.patch | 138 +++++++++++++++++++++
 .../android-tools/android-tools_35.0.2.bb          |   8 +-
 2 files changed, 145 insertions(+), 1 deletion(-)
meta-oe/recipes-devtools/android-tools/android-tools/0022-adbd-optionally-require-authorization-unless-the-bui.patch new file +138 -0
new file mode 100644
index 000000000000..e4115348fd31
@@ -0,0 +1,138 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Alex Kiernan <[email protected]>
+Date: Fri, 6 Nov 2026 09:38:18 +0000
+Subject: [PATCH] adbd: optionally require authorization unless the build is
+ debuggable
+
+On a Linux build adbd accepts every connection without a key check:
+Debian's "don't require authorization on Linux" sets auth_required to
+false unconditionally, because there is no property service to relax it
+on development builds the way Android does.
+
+When make is given ADBD_AUTH_UNLESS_DEBUGGABLE=1, leave auth_required alone
+and decide per connection instead: a host must authenticate unless
+__android_log_is_debuggable() says the build is debuggable. Deciding per
+connection rather than once at startup lets a debuggable state that
+appears while adbd runs (LIBLOG_DEBUGGABLE_PROP_FILES re-reads its files)
+take effect without a restart. The TLS client-certificate checks make
+the same decision.
+
+Without the define nothing changes.
+
+Upstream-Status: Pending
+
+AI-Generated: Claude Opus 5.5 (Claude Code)
+Signed-off-by: Alex Kiernan <[email protected]>
+---
+ debian/system/adbd.mk                |  4 ++++
+ packages/modules/adb/adb.cpp         |  2 +-
+ packages/modules/adb/adb_auth.h      |  4 ++++
+ packages/modules/adb/daemon/auth.cpp | 17 +++++++++++++++--
+ packages/modules/adb/daemon/main.cpp |  2 +-
+ 5 files changed, 25 insertions(+), 4 deletions(-)
+
+diff --git a/debian/system/adbd.mk b/debian/system/adbd.mk
+index a3f88f169b9b..5e2c5ccaea30 100644
+--- a/debian/system/adbd.mk
++++ b/debian/system/adbd.mk
+@@ -109,6 +109,10 @@ LDFLAGS += -lsystemd
+ CPPFLAGS += -DHAVE_SYSTEMD
+ endif
+ 
++ifeq ($(ADBD_AUTH_UNLESS_DEBUGGABLE),1)
++CPPFLAGS += -DADBD_AUTH_UNLESS_DEBUGGABLE
++endif
++
+ STATIC_LIBS = \
+   debian/out/system/libadb.a \
+   debian/out/system/libcrypto_utils.a \
+diff --git a/packages/modules/adb/adb.cpp b/packages/modules/adb/adb.cpp
+index 78bbfb6df48f..6e753484971c 100644
+--- a/packages/modules/adb/adb.cpp
++++ b/packages/modules/adb/adb.cpp
+@@ -392,7 +392,7 @@ static void handle_new_connection(atransport* t, apacket* p) {
+         // we'll just not verify the client's certificate. This should be the
+         // first packet the client receives to indicate the new protocol.
+         send_tls_request(t);
+-    } else if (!auth_required) {
++    } else if (!adbd_connection_auth_required()) {
+         LOG(INFO) << "authentication not required";
+         handle_online(t);
+         send_connect(t);
+diff --git a/packages/modules/adb/adb_auth.h b/packages/modules/adb/adb_auth.h
+index 38312211f3ad..e23ad2b089c7 100644
+--- a/packages/modules/adb/adb_auth.h
++++ b/packages/modules/adb/adb_auth.h
+@@ -51,6 +51,10 @@ void adb_auth_tls_handshake(atransport* t);
+ extern bool auth_required;
+ extern bool socket_access_allowed;
+ 
++// Whether a connection made now must authenticate. auth_required is decided
++// once at startup; this can also depend on state that changes while adbd runs.
++bool adbd_connection_auth_required();
++
+ void adbd_auth_init();
+ void adbd_auth_verified(atransport *t);
+ 
+diff --git a/packages/modules/adb/daemon/auth.cpp b/packages/modules/adb/daemon/auth.cpp
+index 7df15aedd58a..2bb0fa65aad5 100644
+--- a/packages/modules/adb/daemon/auth.cpp
++++ b/packages/modules/adb/daemon/auth.cpp
+@@ -37,6 +37,7 @@
+ #include <adb/tls/adb_ca_list.h>
+ #include <adbd_auth.h>
+ #include <android-base/file.h>
++#include <log/log_properties.h>
+ #include <android-base/no_destructor.h>
+ #include <android-base/strings.h>
+ #include <crypto_utils/android_pubkey.h>
+@@ -157,6 +158,18 @@ static uint32_t transport_auth_id = 0;
+ bool auth_required = true;
+ bool socket_access_allowed = true;
+ 
++bool adbd_connection_auth_required() {
++#if !defined(__ANDROID__) && defined(ADBD_AUTH_UNLESS_DEBUGGABLE)
++    // Off Android there is no property service to relax auth_required at
++    // startup, and whether the build is debuggable can change while adbd runs
++    // (see LIBLOG_DEBUGGABLE_PROP_FILES), so decide per connection: a
++    // debuggable build accepts any host, and anything else authenticates.
++    return auth_required && !__android_log_is_debuggable();
++#else
++    return auth_required;
++#endif
++}
++
+ static void* transport_to_callback_arg(atransport* transport) {
+     uint32_t id = transport_auth_id++;
+     (*transports)[id] = transport->weak();
+@@ -196,7 +209,7 @@ static void IteratePublicKeys(std::function<bool(std::string_view public_key)> f
+ }
+ 
+ bssl::UniquePtr<STACK_OF(X509_NAME)> adbd_tls_client_ca_list() {
+-    if (!auth_required) {
++    if (!adbd_connection_auth_required()) {
+         return nullptr;
+     }
+ 
+@@ -390,7 +403,7 @@ void adbd_notify_framework_connected_key(atransport* t) {
+ }
+ 
+ int adbd_tls_verify_cert(X509_STORE_CTX* ctx, std::string* auth_key) {
+-    if (!auth_required) {
++    if (!adbd_connection_auth_required()) {
+         // Any key will do.
+         LOG(INFO) << __func__ << ": auth not required";
+         return 1;
+diff --git a/packages/modules/adb/daemon/main.cpp b/packages/modules/adb/daemon/main.cpp
+index a5b1d6b3e0eb..d309e235b947 100644
+--- a/packages/modules/adb/daemon/main.cpp
++++ b/packages/modules/adb/daemon/main.cpp
+@@ -313,7 +313,7 @@ int adbd_main(int server_port) {
+         auth_required = android::base::GetBoolProperty("ro.adb.secure", false);
+ #endif
+     }
+-#else
++#elif !defined(ADBD_AUTH_UNLESS_DEBUGGABLE)
+     auth_required = false;
+ #endif
+ 
meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb +7 -1
index d3d60b514721..1a939b503601 100644
@@ -66,6 +66,7 @@ SRC_URI = "https://deb.debian.org/debian/pool/main/a/android-platform-tools/andr
            file://0019-adb-daemon-exit-after-adb-root-unroot-so-an-init-sup.patch \
            file://0020-adbd-signal-readiness-once-functionfs-is-serviced.patch \
            file://0021-liblog-optionally-read-ro.debuggable-from-build.prop.patch \
+           file://0022-adbd-optionally-require-authorization-unless-the-bui.patch \
            "
 
 SRC_URI[orig.md5sum] = "352376965cdef7bd7505d8fefdd43d50"
@@ -221,7 +222,8 @@ do_compile() {
 
     for tool in ${TOOLS_TO_BUILD}; do
         oe_runmake -f ${S}/debian/system/${tool}.mk -C ${S} \
-            ${@'HAVE_SYSTEMD=1' if bb.utils.contains('PACKAGECONFIG', 'systemd', True, False, d) else ''}
+            ${@'HAVE_SYSTEMD=1' if bb.utils.contains('PACKAGECONFIG', 'systemd', True, False, d) else ''} \
+            ${@'ADBD_AUTH_UNLESS_DEBUGGABLE=1' if bb.utils.contains('PACKAGECONFIG', 'auth-unless-debuggable', True, False, d) else ''}
     done
 }
 
@@ -277,4 +279,8 @@ PACKAGECONFIG[fs-config] = ""
 # build.prop format), so `adb root` is refused unless one of them sets
 # ro.debuggable=1. Off by default: every build is debuggable.
 PACKAGECONFIG[debuggable-prop] = ""
+# Require hosts to authenticate unless the build is debuggable, decided per
+# connection. Off by default, as in Debian: no host is asked for a key. Only
+# meaningful with debuggable-prop, without which every build is debuggable.
+PACKAGECONFIG[auth-unless-debuggable] = ""
 PACKAGECONFIG[systemd] = ",,systemd"
Signature · 1 line
2.43.0
#8 lore raw

PATCH 8/10 android-tools: add ADBD_AUTH_KEY_PATHS

In reply to Alex Kiernan

adbd looks for trusted host keys only in Android's /adb_keys and /data/misc/adb/adb_keys, so a Linux adbd that requires authorization has nowhere sensible to be given one. ADBD_AUTH_KEY_PATHS, colon-separated, replaces that list.

AI-Generated: Claude Opus 5.5 (Claude Code)

---
 ...h-optionally-take-the-trusted-key-paths-a.patch | 72 ++++++++++++++++++++++
 .../android-tools/android-tools_35.0.2.bb          |  7 ++-
 2 files changed, 78 insertions(+), 1 deletion(-)
meta-oe/recipes-devtools/android-tools/android-tools/0023-libadbd_auth-optionally-take-the-trusted-key-paths-a.patch new file +72 -0
new file mode 100644
index 000000000000..581ecc85ce09
@@ -0,0 +1,72 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Alex Kiernan <[email protected]>
+Date: Fri, 6 Nov 2026 09:38:18 +0000
+Subject: [PATCH] libadbd_auth: optionally take the trusted-key paths at build
+ time
+
+libadbd_auth reads trusted host keys from /adb_keys and
+/data/misc/adb/adb_keys, which are Android's locations and rarely exist
+on a Linux system - so a Linux adbd that requires authorization has
+nowhere to be given a key.
+
+When ADBD_AUTH_KEY_PATHS is passed to make - a colon-separated list -
+read keys from those files instead. They are still read on every attempt, so a key
+file that appears after adbd started is picked up.
+
+Without the define nothing changes.
+
+Upstream-Status: Pending
+
+AI-Generated: Claude Opus 5.5 (Claude Code)
+Signed-off-by: Alex Kiernan <[email protected]>
+---
+ debian/system/adbd.mk                         |  4 ++++
+ .../native/libs/adbd_auth/adbd_auth.cpp       | 19 ++++++++++++++++---
+ 2 files changed, 20 insertions(+), 3 deletions(-)
+
+diff --git a/debian/system/adbd.mk b/debian/system/adbd.mk
+index 5e2c5ccaea30..dc82b998e77a 100644
+--- a/debian/system/adbd.mk
++++ b/debian/system/adbd.mk
+@@ -113,6 +113,10 @@ ifeq ($(ADBD_AUTH_UNLESS_DEBUGGABLE),1)
+ CPPFLAGS += -DADBD_AUTH_UNLESS_DEBUGGABLE
+ endif
+ 
++ifneq ($(ADBD_AUTH_KEY_PATHS),)
++CPPFLAGS += -DADBD_AUTH_KEY_PATHS='"$(ADBD_AUTH_KEY_PATHS)"'
++endif
++
+ STATIC_LIBS = \
+   debian/out/system/libadb.a \
+   debian/out/system/libcrypto_utils.a \
+diff --git a/frameworks/native/libs/adbd_auth/adbd_auth.cpp b/frameworks/native/libs/adbd_auth/adbd_auth.cpp
+index 78896ed553c4..9b76c17b1b39 100644
+--- a/frameworks/native/libs/adbd_auth/adbd_auth.cpp
++++ b/frameworks/native/libs/adbd_auth/adbd_auth.cpp
+@@ -390,10 +390,23 @@ public:
+         }
+     }
+ 
+-    static constexpr const char* key_paths[] = {"/adb_keys", "/data/misc/adb/adb_keys"};
++#if defined(ADBD_AUTH_KEY_PATHS)
++    // A colon-separated list, for systems where AOSP's locations mean nothing.
++    // Read on every attempt, so a file that appears after adbd started counts.
++    static std::vector<std::string> KeyPaths() {
++        return android::base::Split(ADBD_AUTH_KEY_PATHS, ":");
++    }
++#else
++    static std::vector<std::string> KeyPaths() {
++        return {"/adb_keys", "/data/misc/adb/adb_keys"};
++    }
++#endif
+     void IteratePublicKeys(bool (*callback)(void*, const char*, size_t), void* opaque) {
+-        for (const auto& path : key_paths) {
+-            if (access(path, R_OK) == 0) {
++        for (const auto& path : KeyPaths()) {
++            if (path.empty()) {
++                continue;
++            }
++            if (access(path.c_str(), R_OK) == 0) {
+                 LOG(INFO) << "adbd_auth: loading keys from " << path;
+                 std::string content;
+                 if (!android::base::ReadFileToString(path, &content)) {
meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb +6 -1
index 1a939b503601..b17d92d6e9bb 100644
@@ -67,6 +67,7 @@ SRC_URI = "https://deb.debian.org/debian/pool/main/a/android-platform-tools/andr
            file://0020-adbd-signal-readiness-once-functionfs-is-serviced.patch \
            file://0021-liblog-optionally-read-ro.debuggable-from-build.prop.patch \
            file://0022-adbd-optionally-require-authorization-unless-the-bui.patch \
+           file://0023-libadbd_auth-optionally-take-the-trusted-key-paths-a.patch \
            "
 
 SRC_URI[orig.md5sum] = "352376965cdef7bd7505d8fefdd43d50"
@@ -223,7 +224,8 @@ do_compile() {
     for tool in ${TOOLS_TO_BUILD}; do
         oe_runmake -f ${S}/debian/system/${tool}.mk -C ${S} \
             ${@'HAVE_SYSTEMD=1' if bb.utils.contains('PACKAGECONFIG', 'systemd', True, False, d) else ''} \
-            ${@'ADBD_AUTH_UNLESS_DEBUGGABLE=1' if bb.utils.contains('PACKAGECONFIG', 'auth-unless-debuggable', True, False, d) else ''}
+            ${@'ADBD_AUTH_UNLESS_DEBUGGABLE=1' if bb.utils.contains('PACKAGECONFIG', 'auth-unless-debuggable', True, False, d) else ''} \
+            ${@'ADBD_AUTH_KEY_PATHS=' + d.getVar('ADBD_AUTH_KEY_PATHS') if d.getVar('ADBD_AUTH_KEY_PATHS') else ''}
     done
 }
 
@@ -271,6 +273,9 @@ BBCLASSEXTEND = "native"
 
 PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
 ADB_DEBUGGABLE_PROP_FILES ?= "${sysconfdir}/build.prop"
+# Where adbd reads trusted host keys, colon-separated. Empty keeps Android's
+# /adb_keys and /data/misc/adb/adb_keys.
+ADBD_AUTH_KEY_PATHS ?= ""
 # Apply Android's fs_config ownership/mode tables to files pushed by adbd to
 # /system, /vendor and /oem. Off by default: the tables describe Android
 # partition images and are meaningless on a generic Linux rootfs.
Signature · 1 line
2.43.0
#9 lore raw

PATCH 9/10 android-tools: adbd: keep root only while the build is debuggable

In reply to Alex Kiernan

adbd on Linux restarts as root whenever /run/adbd.root says so, without asking whether the build is still debuggable. With debuggable-prop that can change while the file survives, so honour it only while __android_log_is_debuggable() is true.

AI-Generated: Claude Opus 5.5 (Claude Code)

---
 ...oot-on-Linux-only-while-the-build-is-debu.patch | 51 ++++++++++++++++++++++
 .../android-tools/android-tools_35.0.2.bb          |  1 +
 2 files changed, 52 insertions(+)
meta-oe/recipes-devtools/android-tools/android-tools/0024-adbd-keep-root-on-Linux-only-while-the-build-is-debu.patch new file +51 -0
new file mode 100644
index 000000000000..f94bde14f3b1
@@ -0,0 +1,51 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Alex Kiernan <[email protected]>
+Date: Sat, 7 Nov 2026 16:00:25 +0000
+Subject: [PATCH] adbd: keep root on Linux only while the build is debuggable
+
+`adb root` is refused unless __android_log_is_debuggable(), but the root
+state it writes to /run/adbd.root is honoured on every restart without
+asking again. A unit that stops being debuggable while that file
+survives keeps a root adbd. Drop privileges whenever the build is not
+debuggable, whatever the file says; drop_privileges() then rewrites it
+as #NOROOT#.
+
+Without LIBLOG_DEBUGGABLE_PROP_FILES the build is always debuggable on
+Linux, so nothing changes.
+
+Upstream-Status: Pending
+
+AI-Generated: Claude Opus 5.5 (Claude Code)
+Signed-off-by: Alex Kiernan <[email protected]>
+---
+ packages/modules/adb/daemon/main.cpp | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/packages/modules/adb/daemon/main.cpp b/packages/modules/adb/daemon/main.cpp
+index d309e235b947..9da530d18d27 100644
+--- a/packages/modules/adb/daemon/main.cpp
++++ b/packages/modules/adb/daemon/main.cpp
+@@ -40,9 +40,10 @@
+ #include <android-base/stringprintf.h>
+ #include <android-base/strings.h>
+ 
++#include <log/log_properties.h>
++
+ #if defined(__ANDROID__)
+ #include <libminijail.h>
+-#include <log/log_properties.h>
+ #include <scoped_minijail.h>
+ 
+ #include <private/android_filesystem_config.h>
+@@ -200,6 +201,11 @@ static void drop_privileges(int server_port) {
+ 
+ #if !defined(__ANDROID__)
+ static bool should_drop_privileges() {
++    // The root state file outlives the debuggable state that allowed it to be
++    // written, so only honour it while the build is still debuggable.
++    if (!__android_log_is_debuggable()) {
++        return true;
++    }
+     int f = unix_open(kAdbRootStatePath, O_RDONLY | O_CLOEXEC | O_NOFOLLOW);
+     if (f < 0) {
+         return true;
meta-oe/recipes-devtools/android-tools/android-tools_35.0.2.bb +1 -0
index b17d92d6e9bb..2ecfbe49d146 100644
@@ -68,6 +68,7 @@ SRC_URI = "https://deb.debian.org/debian/pool/main/a/android-platform-tools/andr
            file://0021-liblog-optionally-read-ro.debuggable-from-build.prop.patch \
            file://0022-adbd-optionally-require-authorization-unless-the-bui.patch \
            file://0023-libadbd_auth-optionally-take-the-trusted-key-paths-a.patch \
+           file://0024-adbd-keep-root-on-Linux-only-while-the-build-is-debu.patch \
            "
 
 SRC_URI[orig.md5sum] = "352376965cdef7bd7505d8fefdd43d50"
Signature · 1 line
2.43.0
#10 lore raw

PATCH 10/10 android-tools-conf: android-gadget-cleanup: don't killall adbd

In reply to Alex Kiernan

android-gadget-cleanup runs as the service's ExecStopPost, once adbd has exited, so there is nothing left for killall adbd to stop. Under a supervisor that respawns adbd it is worse than redundant: the new adbd starts into a gadget that is being torn down. busybox builds without killall also fail on it silently. Drop it, and stop quietly if there is no adb gadget to clean up.

AI-Generated: Claude Opus 5.5 (Claude Code)

---
 .../android-tools/android-tools-conf/android-gadget-cleanup           | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-cleanup +1 -3
index f27d77df5120..5d32dbd2bcb1 100644
@@ -4,12 +4,10 @@
 
 cd /sys/kernel/config/usb_gadget
 
-cd adb
+cd adb || exit 0
 
 echo -n "" > UDC || true
 
-killall adbd || true
-
 umount /dev/usb-ffs/adb
 
 rm configs/c.1/ffs.usb0
Signature · 1 line
2.43.0
#11 lore raw
In reply to Alex Kiernan

This is significant amount of patches to carry with Pending status, could you update on your upstreaming effort around this into android-tools itself ?

Quoted 94 lines · Alex Kiernan via openembedded-devel

adbd built from this recipe runs on Linux devices rather than Android, and several things that Android's init or property service would normally provide are missing. This series fixes the bugs that follow from that, and adds opt-in controls for who may use adbd.

The first five patches are fixes and change behaviour without any opt-in:

- adb reboot recovery / bootloader pass their target to RESTART2 instead of a fixed "adb", so kernels whose reboot-mode driver picks the boot mode from the reason string reboot into the requested mode.
- adb shell starts in the user's home directory and no longer gets Android's TMPDIR=/data/local/tmp.
- On glibc, UsbFfsConnection::StopWorker() no longer spins for ever after a cable pull: it relied on bionic's pthread_kill() behaviour, and the host saw the device as offline until adbd was restarted.
- adbd exits after adb root / adb unroot so the service manager restarts it with the new privilege state; the unit becomes Restart=always.
- Readiness is signalled once functionfs is being serviced, not immediately after the USB thread starts. sd_notify(READY=1) raced open_functionfs(), and 10-adbd-configfs.conf binds the UDC on READY=1 with no delay, so the bind could be dropped and the host never reached CONFIGURED. Builds without systemd can get the same signal through a FIFO named in $ADBD_READY_FIFO.

The next four are opt-in, and change nothing unless enabled:

- PACKAGECONFIG[debuggable-prop]: liblog reads ro.debuggable from the build.prop-style files in ADB_DEBUGGABLE_PROP_FILES rather than reporting every build as debuggable, so adb root can be refused on a production image.
- PACKAGECONFIG[auth-unless-debuggable]: hosts must authenticate unless the build is debuggable, decided per connection. Today the Debian patch lets every host in without a key.
- ADBD_AUTH_KEY_PATHS: where adbd reads trusted host keys, in place of Android's /adb_keys and /data/misc/adb/adb_keys.
- adbd keeps root across a restart only while the build is debuggable, so a root state written while it was does not outlive it. Without debuggable-prop every Linux build is debuggable, so this is a no-op.

The last patch drops killall adbd from android-gadget-cleanup, which runs after adbd has already exited.

---
Alex Kiernan (10):
android-tools: adbd: forward the reboot target to RESTART2
android-tools: adbd: start adb shell in $HOME, without Android's
TMPDIR
android-tools: adbd: fix the USB worker hanging on glibc after a
cable pull
android-tools: adbd: restart after adb root/unroot
android-tools: adbd: signal readiness once functionfs is serviced
android-tools: add PACKAGECONFIG debuggable-prop
android-tools: add PACKAGECONFIG auth-unless-debuggable
android-tools: add ADBD_AUTH_KEY_PATHS
android-tools: adbd: keep root only while the build is debuggable
android-tools-conf: android-gadget-cleanup: don't killall adbd

 .../android-tools-conf/android-gadget-cleanup      |   4 +-
 ...dbd-forward-the-reboot-target-to-RESTART2.patch |  42 +++++++
 ...start-in-HOME-and-drop-the-Android-only-T.patch |  45 +++++++
 ...-use-pthread_kill-as-a-thread-liveness-pr.patch | 118
++++++++++++++++++
 ...exit-after-adb-root-unroot-so-an-init-sup.patch |  60 +++++++++
 ...nal-readiness-once-functionfs-is-serviced.patch | 117 +++++++++++++++++
 ...onally-read-ro.debuggable-from-build.prop.patch | 117 +++++++++++++++++
 ...ally-require-authorization-unless-the-bui.patch | 138
+++++++++++++++++++++
 ...h-optionally-take-the-trusted-key-paths-a.patch |  72 +++++++++++
 ...oot-on-Linux-only-while-the-build-is-debu.patch |  51 ++++++++
 .../android-tools/android-tools-adbd.service       |   2 +-
 .../android-tools/android-tools_35.0.2.bb          |  28 ++++-
 12 files changed, 788 insertions(+), 6 deletions(-)

---
base-commit: 33db795031ddef81949db64aedf33070e1330fdd
change-id: 20261106-android-tools-adbd-1c8f4decb0de

Best regards,
--
Alex Kiernan <[email protected]>

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#132097):
https://lists.openembedded.org/g/openembedded-devel/message/132097
Mute This Topic: https://lists.openembedded.org/mt/122197686/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#12 lore raw

That's fair...

I guess the right thing at this point is to drop the series as I've not engaged (and really don't have the time at this point) with the Debian maintainers to try and land it there and I suspect some wouldn't fit with their goals (thinking things like using build.prop to gate authentication) and almost certainly none of it would be able to land upstream in Google as it's irrelevant to Android. Also they've got significant divergence in later releases (things like libadbusb look like might solve a load of problems).

That what we have right now has no authentication just scares me, but it is what it is.

Alex

Quoted 92 lines · Khem Raj

This is significant amount of patches to carry with Pending status, could you update on your upstreaming effort around this into android-tools itself ?

Quoted 88 lines · Alex Kiernan via openembedded-devel

adbd built from this recipe runs on Linux devices rather than Android, and several things that Android's init or property service would normally provide are missing. This series fixes the bugs that follow from that, and adds opt-in controls for who may use adbd.

The first five patches are fixes and change behaviour without any opt-in:

- adb reboot recovery / bootloader pass their target to RESTART2 instead of a fixed "adb", so kernels whose reboot-mode driver picks the boot mode from the reason string reboot into the requested mode.
- adb shell starts in the user's home directory and no longer gets Android's TMPDIR=/data/local/tmp.
- On glibc, UsbFfsConnection::StopWorker() no longer spins for ever after a cable pull: it relied on bionic's pthread_kill() behaviour, and the host saw the device as offline until adbd was restarted.
- adbd exits after adb root / adb unroot so the service manager restarts it with the new privilege state; the unit becomes Restart=always.
- Readiness is signalled once functionfs is being serviced, not immediately after the USB thread starts. sd_notify(READY=1) raced open_functionfs(), and 10-adbd-configfs.conf binds the UDC on READY=1 with no delay, so the bind could be dropped and the host never reached CONFIGURED. Builds without systemd can get the same signal through a FIFO named in $ADBD_READY_FIFO.

The next four are opt-in, and change nothing unless enabled:

- PACKAGECONFIG[debuggable-prop]: liblog reads ro.debuggable from the build.prop-style files in ADB_DEBUGGABLE_PROP_FILES rather than reporting every build as debuggable, so adb root can be refused on a production image.
- PACKAGECONFIG[auth-unless-debuggable]: hosts must authenticate unless the build is debuggable, decided per connection. Today the Debian patch lets every host in without a key.
- ADBD_AUTH_KEY_PATHS: where adbd reads trusted host keys, in place of Android's /adb_keys and /data/misc/adb/adb_keys.
- adbd keeps root across a restart only while the build is debuggable, so a root state written while it was does not outlive it. Without debuggable-prop every Linux build is debuggable, so this is a no-op.

The last patch drops killall adbd from android-gadget-cleanup, which runs after adbd has already exited.

---
Alex Kiernan (10):
android-tools: adbd: forward the reboot target to RESTART2
android-tools: adbd: start adb shell in $HOME, without Android's TMPDIR
android-tools: adbd: fix the USB worker hanging on glibc after a cable pull
android-tools: adbd: restart after adb root/unroot
android-tools: adbd: signal readiness once functionfs is serviced
android-tools: add PACKAGECONFIG debuggable-prop
android-tools: add PACKAGECONFIG auth-unless-debuggable
android-tools: add ADBD_AUTH_KEY_PATHS
android-tools: adbd: keep root only while the build is debuggable
android-tools-conf: android-gadget-cleanup: don't killall adbd

 .../android-tools-conf/android-gadget-cleanup      |   4 +-
 ...dbd-forward-the-reboot-target-to-RESTART2.patch |  42 +++++++
 ...start-in-HOME-and-drop-the-Android-only-T.patch |  45 +++++++
 ...-use-pthread_kill-as-a-thread-liveness-pr.patch | 118 ++++++++++++++++++
 ...exit-after-adb-root-unroot-so-an-init-sup.patch |  60 +++++++++
 ...nal-readiness-once-functionfs-is-serviced.patch | 117 +++++++++++++++++
 ...onally-read-ro.debuggable-from-build.prop.patch | 117 +++++++++++++++++
 ...ally-require-authorization-unless-the-bui.patch | 138 +++++++++++++++++++++
 ...h-optionally-take-the-trusted-key-paths-a.patch |  72 +++++++++++
 ...oot-on-Linux-only-while-the-build-is-debu.patch |  51 ++++++++
 .../android-tools/android-tools-adbd.service       |   2 +-
 .../android-tools/android-tools_35.0.2.bb          |  28 ++++-
 12 files changed, 788 insertions(+), 6 deletions(-)

---
base-commit: 33db795031ddef81949db64aedf33070e1330fdd
change-id: 20261106-android-tools-adbd-1c8f4decb0de

Best regards,
--
Alex Kiernan <[email protected]>

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#132097): https://lists.openembedded.org/g/openembedded-devel/message/132097
Mute This Topic: https://lists.openembedded.org/mt/122197686/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

--
Alex Kiernan

#13 lore raw
Quoted 11 lines · Alex Kiernan

That's fair...

I guess the right thing at this point is to drop the series as I've not engaged (and really don't have the time at this point) with the Debian maintainers to try and land it there and I suspect some wouldn't fit with their goals (thinking things like using build.prop to gate authentication) and almost certainly none of it would be able to land upstream in Google as it's irrelevant to Android. Also they've got significant divergence in later releases (things like libadbusb look like might solve a load of problems).

Upgrading might be a better option here, adding patches diverges us more

Quoted 123 lines

That what we have right now has no authentication just scares me, but it is what it is.

Alex

Quoted 2 lines · Khem Raj

This is significant amount of patches to carry with Pending status,

could you update on your upstreaming effort around this into android-tools itself ?

Quoted 2 lines

On Tue, Nov 10, 2026 at 9:35 AM Alex Kiernan via openembedded-devel

Quoted 2 lines · <[email protected]> wrote:
Quoted 2 lines

adbd built from this recipe runs on Linux devices rather than Android,

and

Quoted 2 lines
Quoted 2 lines

several things that Android's init or property service would normally provide are missing. This series fixes the bugs that follow from that,

and

Quoted 3 lines
Quoted 3 lines

adds opt-in controls for who may use adbd.

The first five patches are fixes and change behaviour without any

opt-in:

Quoted 3 lines
Quoted 3 lines

- adb reboot recovery / bootloader pass their target to RESTART2 instead of a fixed "adb", so kernels whose reboot-mode driver picks

the

Quoted 5 lines
Quoted 5 lines

boot mode from the reason string reboot into the requested mode.
- adb shell starts in the user's home directory and no longer gets Android's TMPDIR=/data/local/tmp.
- On glibc, UsbFfsConnection::StopWorker() no longer spins for ever after a cable pull: it relied on bionic's pthread_kill() behaviour,

and

Quoted 8 lines
Quoted 8 lines

the host saw the device as offline until adbd was restarted.
- adbd exits after adb root / adb unroot so the service manager restarts it with the new privilege state; the unit becomes Restart=always.
- Readiness is signalled once functionfs is being serviced, not immediately after the USB thread starts. sd_notify(READY=1) raced open_functionfs(), and 10-adbd-configfs.conf binds the UDC on READY=1 with no delay, so the bind could be dropped and the host never

reached

Quoted 8 lines
Quoted 8 lines

CONFIGURED. Builds without systemd can get the same signal through a FIFO named in $ADBD_READY_FIFO.

The next four are opt-in, and change nothing unless enabled:

- PACKAGECONFIG[debuggable-prop]: liblog reads ro.debuggable from the build.prop-style files in ADB_DEBUGGABLE_PROP_FILES rather than reporting every build as debuggable, so adb root can be refused on

a

Quoted 3 lines
Quoted 3 lines

production image.
- PACKAGECONFIG[auth-unless-debuggable]: hosts must authenticate unless the build is debuggable, decided per connection. Today the Debian

patch

Quoted 7 lines
Quoted 7 lines

lets every host in without a key.
- ADBD_AUTH_KEY_PATHS: where adbd reads trusted host keys, in place of Android's /adb_keys and /data/misc/adb/adb_keys.
- adbd keeps root across a restart only while the build is debuggable, so a root state written while it was does not outlive it. Without debuggable-prop every Linux build is debuggable, so this is a no-op.

Quoted 8 lines
Quoted 8 lines

The last patch drops killall adbd from android-gadget-cleanup, which runs after adbd has already exited.

---
Alex Kiernan (10):
android-tools: adbd: forward the reboot target to RESTART2
android-tools: adbd: start adb shell in $HOME, without Android's

TMPDIR

Quoted 1 line
Quoted 1 line

android-tools: adbd: fix the USB worker hanging on glibc after a

cable pull

Quoted 8 lines
Quoted 8 lines

android-tools: adbd: restart after adb root/unroot
android-tools: adbd: signal readiness once functionfs is serviced
android-tools: add PACKAGECONFIG debuggable-prop
android-tools: add PACKAGECONFIG auth-unless-debuggable
android-tools: add ADBD_AUTH_KEY_PATHS
android-tools: adbd: keep root only while the build is debuggable
android-tools-conf: android-gadget-cleanup: don't killall adbd

Quoted 4 lines
Quoted 4 lines
 .../android-tools-conf/android-gadget-cleanup      |   4 +-
 ...dbd-forward-the-reboot-target-to-RESTART2.patch |  42 +++++++
 ...start-in-HOME-and-drop-the-Android-only-T.patch |  45 +++++++
 ...-use-pthread_kill-as-a-thread-liveness-pr.patch | 118

++++++++++++++++++

Quoted 2 lines
Quoted 2 lines
 ...exit-after-adb-root-unroot-so-an-init-sup.patch |  60 +++++++++
 ...nal-readiness-once-functionfs-is-serviced.patch | 117

+++++++++++++++++

Quoted 1 line
Quoted 1 line
 ...onally-read-ro.debuggable-from-build.prop.patch | 117

+++++++++++++++++

Quoted 1 line
Quoted 1 line
 ...ally-require-authorization-unless-the-bui.patch | 138

+++++++++++++++++++++

Quoted 9 lines
Quoted 9 lines
 ...h-optionally-take-the-trusted-key-paths-a.patch |  72 +++++++++++
 ...oot-on-Linux-only-while-the-build-is-debu.patch |  51 ++++++++
 .../android-tools/android-tools-adbd.service       |   2 +-
 .../android-tools/android-tools_35.0.2.bb          |  28 ++++-
 12 files changed, 788 insertions(+), 6 deletions(-)

---
base-commit: 33db795031ddef81949db64aedf33070e1330fdd
change-id: 20261106-android-tools-adbd-1c8f4decb0de

Quoted 8 lines
Quoted 8 lines

Best regards,
--
Alex Kiernan <[email protected]>

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#132097):

https://lists.openembedded.org/g/openembedded-devel/message/132097

Quoted 3 lines
Quoted 3 lines

Mute This Topic: https://lists.openembedded.org/mt/122197686/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub

[[email protected]]

Quoted 2 lines
Quoted 2 lines

-=-=-=-=-=-=-=-=-=-=-=-

--
Alex Kiernan

#14 lore raw
Quoted 17 lines · Khem Raj
Quoted 11 lines · Alex Kiernan

That's fair...

I guess the right thing at this point is to drop the series as I've not engaged (and really don't have the time at this point) with the Debian maintainers to try and land it there and I suspect some wouldn't fit with their goals (thinking things like using build.prop to gate authentication) and almost certainly none of it would be able to land upstream in Google as it's irrelevant to Android. Also they've got significant divergence in later releases (things like libadbusb look like might solve a load of problems).

Quoted 2 lines

Upgrading might be a better option here, adding patches diverges us more

Debian is still shipping 34.x, their 35.x is an experimental branch, Android is on 37.x (but appears to have stopped tagging it separately from the Android base release).

That said, bumping it up looks like it may not be that bad (though libadbusb looks like it's a dead end anway as it's host side and not obviously published anywhere).

This is where I got to (well Claude with direction from everything I already had...):

https://github.com/A-Squared-Projects/meta-android-platform-tools

Still trying to chase down the failures on cable pulls, which I currently have covered with a watcher script (yuck!)

Signature · 1 line
Alex Kiernan