From eb5dff76387b6e8305f65e757500967de667e6f6 Mon Sep 17 00:00:00 2001 From: Omarchybot <317366263+omarchybot@users.noreply.github.com> Date: Mon, 12 Oct 2026 11:55:21 +0200 Subject: [PATCH 1/2] Stop the Dropbox status poll from voiding the pending login link `dropbox-cli status` asks an unlinked daemon for a link URL every time, and the daemon answers each ask with a fresh nonce, so the widget's poll replaced the URL Log in had just opened while the user was still signing in. While no account is linked, read whether the daemon is running from its pid file instead, the same check dropbox-cli makes. Fixes #12637 --- shell/plugins/panels/dropbox/status.py | 15 +++++++++- test/shell.d/dropbox-test.sh | 40 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/shell/plugins/panels/dropbox/status.py b/shell/plugins/panels/dropbox/status.py index 70e4a93f151e..3a3d9388281a 100644 --- a/shell/plugins/panels/dropbox/status.py +++ b/shell/plugins/panels/dropbox/status.py @@ -43,6 +43,15 @@ def command_output(command): return completed.returncode, (completed.stdout + completed.stderr).strip() +# The same check `dropbox-cli running` makes, without the CLI's inverted exit code. +def daemon_running(): + try: + pid = int((Path.home() / ".dropbox" / "dropbox.pid").read_text()) + return "dropbox" in Path(f"/proc/{pid}/cmdline").read_text().lower() + except (OSError, ValueError): + return False + + def scan_dropbox(path, limit): total = 0 counter = 0 @@ -98,7 +107,11 @@ def main(): running = False status_text = "Not installed" - if dropbox_cli: + if dropbox_cli and not authenticated: + # `dropbox-cli status` asks an unlinked daemon for a link URL, and each ask voids the one Log in opened. + running = daemon_running() + status_text = "Waiting to be linked to a Dropbox account" if running else "Stopped" + elif dropbox_cli: status_exit, status_output = command_output([dropbox_cli, "status"]) status_text = status_output if status_exit == 0 and status_output else "Stopped" lowered = status_text.lower() diff --git a/test/shell.d/dropbox-test.sh b/test/shell.d/dropbox-test.sh index e2cbb8769bbd..876baceb18f7 100644 --- a/test/shell.d/dropbox-test.sh +++ b/test/shell.d/dropbox-test.sh @@ -32,3 +32,43 @@ assertEqual( 'dropbox file metadata includes relative time and folder' ) JS + +require_command jq +require_command python3 + +test_tmp=$(mktemp -d) +daemon_pid="" +trap '[[ -n $daemon_pid ]] && kill "$daemon_pid" 2>/dev/null; rm -rf "$test_tmp"' EXIT + +mkdir -p "$test_tmp/bin" "$test_tmp/home/.dropbox" +cat >"$test_tmp/bin/dropbox-cli" <<'SH' +#!/bin/bash +echo "$*" >>"$HOME/cli.log" +echo "Up to date" +SH +chmod +x "$test_tmp/bin/dropbox-cli" + +dropbox_status() { + HOME="$test_tmp/home" PATH="$test_tmp/bin:$PATH" python3 "$ROOT/shell/plugins/panels/dropbox/status.py" 25 +} + +# Every `dropbox-cli status` mints a new link URL while unlinked, voiding the one Log in opened. +status=$(dropbox_status) +[[ $(jq -r .running <<<"$status") == "false" && ! -e $test_tmp/home/cli.log ]] || + fail "dropbox status reads an unlinked, stopped daemon without asking it for a link" "$status" +pass "dropbox status reads an unlinked, stopped daemon without asking it for a link" + +(exec -a dropbox sleep 60) & +daemon_pid=$! +echo "$daemon_pid" >"$test_tmp/home/.dropbox/dropbox.pid" +status=$(dropbox_status) +[[ $(jq -r .running <<<"$status") == "true" && $(jq -r .authenticated <<<"$status") == "false" && ! -e $test_tmp/home/cli.log ]] || + fail "dropbox status reads an unlinked, running daemon without asking it for a link" "$status" +pass "dropbox status reads an unlinked, running daemon without asking it for a link" + +mkdir -p "$test_tmp/home/Dropbox" +jq -n --arg path "$test_tmp/home/Dropbox" '{personal: {path: $path, subscription_type: "Plus"}}' >"$test_tmp/home/.dropbox/info.json" +status=$(dropbox_status) +[[ $(jq -r .running <<<"$status") == "true" && $(jq -r .statusText <<<"$status") == "Up to date" && $(<"$test_tmp/home/cli.log") == "status" ]] || + fail "dropbox status asks a linked daemon for its status" "$status" +pass "dropbox status asks a linked daemon for its status" From f44aca4378d3bdcaa9cfa671cef7c154d9f746d5 Mon Sep 17 00:00:00 2001 From: Omarchybot <317366263+omarchybot@users.noreply.github.com> Date: Sat, 17 Oct 2026 06:11:40 +0200 Subject: [PATCH 2/2] Cover a stale info.json naming a missing Dropbox folder info.json can outlive an unlink, so the poll's guard has to rest on the folder existing, not on info.json naming an account; a guard on the account path alone would bring the nonce rotation back while Log in is showing. Co-Authored-By: Codex Medium Co-Authored-By: Claude Opus 5.5 --- test/shell.d/dropbox-test.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/shell.d/dropbox-test.sh b/test/shell.d/dropbox-test.sh index 876baceb18f7..6e779d3f3148 100644 --- a/test/shell.d/dropbox-test.sh +++ b/test/shell.d/dropbox-test.sh @@ -66,6 +66,13 @@ status=$(dropbox_status) fail "dropbox status reads an unlinked, running daemon without asking it for a link" "$status" pass "dropbox status reads an unlinked, running daemon without asking it for a link" +# info.json can outlive an unlink, so naming an account does not prove the daemon has stopped minting links. +jq -n --arg path "$test_tmp/home/Dropbox" '{personal: {path: $path, subscription_type: "Plus"}}' >"$test_tmp/home/.dropbox/info.json" +status=$(dropbox_status) +[[ $(jq -r .authenticated <<<"$status") == "false" && ! -e $test_tmp/home/cli.log ]] || + fail "dropbox status leaves the daemon alone while info.json names a missing folder" "$status" +pass "dropbox status leaves the daemon alone while info.json names a missing folder" + mkdir -p "$test_tmp/home/Dropbox" jq -n --arg path "$test_tmp/home/Dropbox" '{personal: {path: $path, subscription_type: "Plus"}}' >"$test_tmp/home/.dropbox/info.json" status=$(dropbox_status)