[pacman-dev] [PATCH] Fix using run_pacman to invoke -Qi with sudo
Eli Schwartz
eschwartz at archlinux.org
Wed May 16 10:50:12 UTC 2018
On 05/16/2018 12:41 AM, Allan McRae wrote:
> On 16/05/18 01:46, Dave Reisner wrote:
>> On Tue, May 15, 2018 at 11:13:09AM -0400, Eli Schwartz wrote:
>>> In commit 5698d7b66daa2a0bc99cab7a989cef1c806c3bf6 a new non-root use of
>>> pacman was added -- previously we used -T or -Qq, and run_pacman did not
>>> know how to special-case -Qi to skip being prepended with sudo.
>>
>> Can we just be explicit about when we do and don't need elevated
>> privileges rather than trying to guess? Surely the caller knows the
>> requirements a priori.
>
> Are you thinking two functions? One for root, one not? Or a helper
> function as_root() that does the su/sudo part? Or a function parameter
> for root usage?
>
> Either way, I think the current patch is fine for 5.1. Bigger change
> can happen later.
My patch keeps to the spirit of how things are currently done, but for
the future, we should probably consider why it's designed the way it is now.
The function does three things:
- resolve "pacman" to $PACMAN
- interpolate options like --noprogressbar, --noconfirm, and --color=
- heuristically guess whether to try elevating to root.
#3 is currently broken. #2 is interesting because we sometimes don't do
it. Is there a reason for this?
dreisner initially suggested something along the lines of
https://paste.xinu.at/ldn/ with two functions, though as I pointed out
then, the function should be renamed to not clash with "pacman" itself.
An as_root helper should not be necessary, we don't need sudo for
anything except pacman syncing deps or installing built artifacts, so
we'd still need to have a run_pacman for #'s 1 & 2, which is quite indirect.
I don't favor the parameter-based approach... seems awkward to call it.
--
Eli Schwartz
Bug Wrangler and Trusted User
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.archlinux.org/pipermail/pacman-dev/attachments/20180516/d36db44c/attachment-0001.asc>
More information about the pacman-dev
mailing list