You are not logged in.
Pages: 1
How is it possible to ommit sudo if sudo was added to a command within the lifetime of a sudo session. Currently, i have to add sudo for each command which requires sudo. Assume the following scenario and assume the lifetime of sudo is 5 minutes
1. Run "sudo pacman -Syu"
2. Run "pacman -Syu"
3. Wait 6 minutes
4. Run "pacman -Syu"
So, currently, step 2 and 4 fails because of the following error: error: you cannot perform this operation unless you are root. But i only want that step 3 fails.
Offline
You cannot run sudo without calling sudo.
"sudo pacman -Syu" runs pacman as root.
"pacman -Syu" runs pacman as whatever user is running the command (i.e. you).
If you want to run things as root without prefixing each command with 'sudo', become root. e.g.
sudo -i
pacman -SyuSakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
You could wrap pacman in a local script or function that checks the parameters and injects sudo if $UID != 0
sudo takes care of credential caching but iirc it defaults to 5 minutes, you'd have to extend that in your sudoers
Offline
If you're talking specifically "pacman -Syu", you can add an alias to ~/.bashrc: `alias syu='sudo pacman -Syu'`. Then calling `syu` will always invoke `sudo pacman -Syu`.
Offline
I wanted it to work this way with all commands, pacman was only an example. I thought it worked that way in Ubuntu but i might be mistaken.
Offline
You cannot run sudo without calling sudo.
"sudo pacman -Syu" runs pacman as root.
"pacman -Syu" runs pacman as whatever user is running the command (i.e. you).
Why not? Since the sudo session is still active, the command can simply become the root user. I mean i don't have to type in the password anyways, so why is there a need to add "sudo"?
Offline
I really doubt it did. That would be a MASSIVE security and safety issue, to just run any random command as root because the password was used a bit ago.
Offline
I wanted it to work this way with all commands, pacman was only an example … I mean i don't have to type in the password anyways, so why is there a need to add "sudo"?
Because something needs to elevate the privilege.
That can be
* you
* the process (which has several implications, see below)
* you via a local script/alias/whatever
Processes can detect that they're run as unprivileged user and know that they require UID0 privileges (pacman does that)
They can then promt the user to authorize elevation (eg. systemctl does that, using polkit)
The problem is that the process either needs to hard depend on an elevation approach (sudo, doas, pkexec, su, …) or mandate a configuration for that and at this point you're equivalent to
You could wrap [foo] in a local script or function that checks the parameters and injects sudo if $UID != 0
I thought it worked that way in Ubuntu but i might be mistaken.
Ubuntu *might* have patched such self-elevation into a limited set of specific processes but I believe that when I see it.
In case of sudo it would also be necessary to check for a tty and either abort or use sudo -S and some GUI input for the password prompt.
Offline
IIRC Ubuntu used the 'wheel' group a lot and also pre-configured elevation systems to make it appear as if you could run root-privileged tools as non-root.
In the off-chance that this is more of an X/Y problem: do you actually just despise typing five extra characters or are you running into some kind of scripting / configuration issue where the `sudo ` prefix is problematic?
Offline
Fwwi, I'm pretty sure ubuntu added you to %wheel and set that to "ALL = NOPASSWD: ALL" but I'm not sure they injected automatic sudo leverages into random commands (it's been a couple of years, though)
Offline
// --- edit: well - had to cut it down a bit
How is it possible to ommit sudo if sudo was added to a command within the lifetime of a sudo session.
it isn't - because that's what history came up and stuck with - if you don't want to use sudo don't use linux - but go use windows
Offline
Ftr, you can use su, doas, pkexec and, if need be, run0 (though it's not strictly a privilege escalation tool and has more implications) instead of sudo.
The only way to automatically run a process as root is to set the SUID bit on a root owned binary, which is generally a TERRIBLE IDEA and I'm just bringing this up to tell you to under no circumstances consider that a valid approach in case you're researching the topic.
Offline
Pages: 1