From 21bde02e045469472f4c269b96308a36a55c073b Mon Sep 17 00:00:00 2001 From: Dan Collins Date: Fri, 31 Jul 2026 16:53:13 -0400 Subject: [PATCH 1/2] retry interactive authorization Acquire authorization before running privileged transactions and retry ordinary authentication failures. Abort promptly on Ctrl-C and detailed authorization errors, and retain authorization across long-running builds. --- src/cli.vala | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/src/cli.vala b/src/cli.vala index a9c9d00..714d36e 100644 --- a/src/cli.vala +++ b/src/cli.vala @@ -24,6 +24,7 @@ namespace Pamac { Database database; bool trans_cancellable; bool cloning; + bool authorizing; Cancellable cancellable; GenericSet already_checked_aur_dep; public Subprocess pkttyagent; @@ -969,6 +970,11 @@ namespace Pamac { init_database (); } transaction = new TransactionCli (database); + transaction.emit_error.connect ((message, details) => { + if (authorizing && details.length > 0) { + authorizing = false; + } + }); transaction.start_waiting.connect (() => { trans_cancellable = true; }); @@ -999,6 +1005,13 @@ namespace Pamac { } bool trans_cancel () { + if (authorizing) { + authorizing = false; + exit_status = 130; + transaction.cancel (); + stdout.printf ("\n"); + return true; + } if (cloning) { cloning = false; cancellable.cancel (); @@ -2842,17 +2855,33 @@ namespace Pamac { transaction.add_pkg_to_build (name, clone_build_files, clone_deps_build_files); } transaction.install_if_needed = false; - run_transaction (); + run_transaction (false); + } + + async bool run_transaction_async (bool authorization_required) { + if (Posix.geteuid () != 0 && !transaction.dry_run && authorization_required) { + authorizing = true; + while (authorizing) { + if (yield transaction.get_authorization_async ()) { + authorizing = false; + bool success = yield transaction.run_async (); + transaction.remove_authorization (); + return success; + } + } + return false; + } + return yield transaction.run_async (); } - void run_transaction () { + void run_transaction (bool authorization_required = true) { var loop = new MainLoop (); if (Posix.geteuid () != 0) { // let's time to pkttyagent to get registred Timeout.add (200, () => { - transaction.run_async.begin ((obj, res) => { - bool success = transaction.run_async.end (res); - if (!success) { + run_transaction_async.begin (authorization_required, (obj, res) => { + bool success = run_transaction_async.end (res); + if (!success && exit_status == 0) { exit_status = 1; } loop.quit (); @@ -2860,9 +2889,9 @@ namespace Pamac { return false; }); } else { - transaction.run_async.begin ((obj, res) => { - bool success = transaction.run_async.end (res); - if (!success) { + run_transaction_async.begin (authorization_required, (obj, res) => { + bool success = run_transaction_async.end (res); + if (!success && exit_status == 0) { exit_status = 1; } loop.quit (); From 041bb7daf6dfdc9bab53d9b7cff4728bbc609015 Mon Sep 17 00:00:00 2001 From: Dan Collins Date: Fri, 31 Jul 2026 16:53:55 -0400 Subject: [PATCH 2/2] refactor transaction startup Use one timeout-based launch path for root and non-root transactions while preserving the existing delay for terminal Polkit agent registration. --- src/cli.vala | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/cli.vala b/src/cli.vala index 714d36e..c90ba8a 100644 --- a/src/cli.vala +++ b/src/cli.vala @@ -2876,19 +2876,8 @@ namespace Pamac { void run_transaction (bool authorization_required = true) { var loop = new MainLoop (); - if (Posix.geteuid () != 0) { - // let's time to pkttyagent to get registred - Timeout.add (200, () => { - run_transaction_async.begin (authorization_required, (obj, res) => { - bool success = run_transaction_async.end (res); - if (!success && exit_status == 0) { - exit_status = 1; - } - loop.quit (); - }); - return false; - }); - } else { + uint delay = Posix.geteuid () == 0 ? 0 : 200; + Timeout.add (delay, () => { run_transaction_async.begin (authorization_required, (obj, res) => { bool success = run_transaction_async.end (res); if (!success && exit_status == 0) { @@ -2896,7 +2885,8 @@ namespace Pamac { } loop.quit (); }); - } + return false; + }); loop.run (); }