You are not logged in.

#1 2021-12-10 10:58:33

Idlusen
Member
From: France
Registered: 2013-05-15
Posts: 21

env_keep += SHLVL for pacman to work correctly via sudo

Here is a problem I had for quite some time that I just addressed and solved, but I wonder why the solution works.

When I run, for instance,

$ sudo pacman -S uglify-js wireshark-cli

I used to get:

[Normal output]
:: Processing package changes...
(1/2) reinstalling uglify-js                              [###############################] 100%
 
 
(2/2) reinstalling wireshark-cli                          [###############################] 100%
Failed to set capabilities on file 'usr/bin/dumpcap': No such file or directory
error: command failed to execute correctly
[Normal output (hooks)]

Whereas if I first

su -l

then

# pacman -S uglify-js wireshark-cli

the blank lines after uglify-js and the non-critical failure after wireshark-cli would not appear, it seemed everything was fine.

I figured it had to do with environment variables so I tested

sudo -E pacman -S …

, with success. I issued

sudo env

and

# env

to compare and I added one by one the differing environment variables to sudoers in

Defaults env_keep += …

.

Finally

sudo pacman -S …

was working fine with only SHLVL added to the env_keep field.

I do not understand why that works, and why I had the problem in the first place since a web search for this issue returned nothing directly related. Any ideas?

Offline

Board footer

Powered by FluxBB