Closed mindyourlifeguide closed 3 years ago
paru spawns sudo
but exits immediately when it gets SIGINT
. sudo
takes a second before it prints the second line. You can verify this by running and trying to abort sudo
itself.
The commit that closed a similar issue on a different project has a solution, but it's not super simple: https://github.com/casey/just/issues/302
edit: That project has a permissive license. Could possibly just yoink interrupt_{handle,guard}.rs
from it.
Something like this would be the simplest solution:
static mut SIGINT_RECEIVED: bool = false;
#[no_mangle]
extern "C" fn sigint_handler(_: i32) {
unsafe { SIGINT_RECEIVED = true };
std::process::exit(0x82);
}
fn main() {
// ...
unsafe {
signal(Signal::SIGINT, SigHandler::Handler(sigint_handler)).unwrap();
}
// ...
}
@trevorgunn Unless I'm misunderstanding, I don't think that would help. sudo
isn't being run in async or anything, so there's no other thread or process to look at that SIGINT_RECEIVED
flag.
@trevorgunn This is behavior that occurs with SudoLoop
disabled in the configuration.
This fixes it for me: https://github.com/KerfuffleV2/paru/commit/93db172c768d51394f42fb3f841c4dc17518ab94
@Morganamilo Any merit to that approach?
Right, ok. So this is just how sudo
works. One sees the same delay and message just running, for instance, sudo -i
.
But is this something we should be trying to fix? Sudo captures SIGINT for a reason.
Edit: so does Pacman for that matter.
@trevorgunn Well, one way to fix it is to block SIGINT
while running sudo
as a child. Then paru will wait until sudo
exits before exiting itself and random stuff won't end up on the terminal. See the commit I linked about your post ^^^^^
You're right. Sorry, I was too focused on work that I did not read what linked to carefully enough.
I'm not really interested in this because it's way to much code for what seems little benefit.
@mindyourlifeguide Alternative solution is to install something like doas
instead (which I can confirm doesn't have the issue). Just be aware of the security implications of having multiple sudo-type programs installed and how that increases the surface area of potential exploits.
@KerfuffleV2, thanks for the advice! Perhaps I will return to yay - the potential in paru is clearly there, but for everyday use it does not suit me yet.
Thank you all for your help!
But yay does the exact same thing.
no, in yay it works fine.
Not for me
morganamilo@Octavia ~ % yay -R xterm
[sudo] password for morganamilo:
morganamilo@Octavia ~ % sudo: a password is required
@Morganamilo , Indeed, I tried the same behavior. And I realized that on yay I did not notice this - I directly use the yay commands only for updating, namely yay, for the rest of the things I wrapped everything in commands with fzf and everything ends there correctly, most likely due to other utilities.
And can I edit the pkgfile right away? Will it apply my modifications?
@Morganamilo would using "pkexec" instead of "sudo" help ?
Affected Version
paru -V paru v1.5.1 - libalpm v12.0.2
Description
Extra password request after rejection of an operation