Install scriptlets source root users .bashrc when pacman is run through sudo

brainpower brainpower at mailbox.org
Sat Nov 6 21:43:51 UTC 2021


Am 06.11.21 um 21:34 schrieb Andrew Gregory:
> On 11/06/21 at 09:08pm, brainpower wrote:
>> Am 06.11.21 um 19:15 schrieb Andrew Gregory:
>>> bash thinks it's being run remotely because we connect to the child over
>>> sockets.
>>
>> oh, right, that makes sense... I knew I was missing something rather obvious. :/
>> (I shouldn't have just skimmed the manpage after all... I missed it b/c I was only looking for the word "interactive", which isn't in that paragraph)
>>
>>
>> But what I'm still not quite getting is,
>> what's the difference of pacman being run by sudo vs. directly?
>> Shouldn't bash also think the sockets were remote if pacman is not run using sudo?
>>
>> But it probably can detect somehow that it runs inside a interactive zsh when pacman is run directly,
>> while there is no shell running between sudo and pacman when running it using sudo...
>> or something like that.
>>
>> Well mystery somewhat solved, thanks for pointing me in the right direction.
> 
> I'd guess it's because it also checks for $SHLVL < 2.
> 

It does!
I've checked by adding 'Defaults env_keep += "SHLVL"' to /etc/sudoers.

Would it make sense to export/set SHLVL=1 in _alpm_run_chroot() if SHLVL does not exist
before executing the shell to make sure its non-interactive?

I've first thought of adding --norc, but I think that's a non standard option not all shells users may configure pacman to use support...
Exporting that variable if it does not exist should work with every shell and also should not hurt non-bash shells, I think?

-- 
regards,
brainpower
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://lists.archlinux.org/pipermail/pacman-dev/attachments/20211106/2f5aba08/attachment-0001.sig>


More information about the pacman-dev mailing list