pmbootstrap/pmb
Oliver Smith 37a7f3924d
Fix preserving proxy variables (MR 2237)
Fix "pmbootstrap chroot" and others not passing the proxy environment
variables correctly. Thanks to notfound405 for pointing this out!

Instead of only preserving proxy environment variables in
pmb.helpers.run_core, which should never be called directly, do it in
the calling functions:

* pmb.helpers.run.user
* pmb.helpers.run.root
* pmb.chroot.root
* pmb.chroot.user

This fixes that the environment variables were only really passed by
pmb.helpers.run.user, because the other functions would result in
something like:
  HTTP_PROXY=mytestproxy sudo env -i /usr/bin/sh -c '…'
This is needed to either elevate to root, or to elevate to root first
and then enter the chroot as root or user. Due to the "env -i", the
environment intentionally gets cleaned, but unintentionally also removes
the proxy environment variables that were explicitly set.

By adjusting the functions, they now run a variant of:
  sudo env -i /usr/bin/sh -c 'HTTP_PROXY=mytestproxy …'

The escaping is simplified in this example, run "pmbootstrap -v" to see
the not very readable, but proper escaping with shutil.quote().

Remove the previous test for preserving the environment variables in
pmb.helpers.run_core (as it should never be called directly), and test
instead the new behavior.

Fixes: issue 2299
Fixes: 13c4ac42 ("pmb.helpers.run_core: fix proxy env var logic")
2024-01-25 20:12:53 +00:00
..
aportgen aportgen: Only warn if binary version > APKBUILD version 2023-12-10 14:41:53 +01:00
build Guess kbuild out dir for downstreamkernel_package (MR 2231) 2024-01-21 23:05:00 +00:00
chroot Fix preserving proxy variables (MR 2237) 2024-01-25 20:12:53 +00:00
ci Use ruff for linting 2023-06-04 10:56:22 +02:00
config flasher: heimdall-bootimg: add support for '--no-reboot' and '--resume' 2024-01-16 21:16:07 +00:00
data init: allow all locales 2023-06-12 08:46:22 +02:00
export install: rename --sdcard arg to --disk 2023-11-19 20:27:37 +01:00
flasher pmb.flasher.variables: use getattr instead of hasattr (MR 2232) 2024-01-18 23:24:30 +00:00
helpers Fix preserving proxy variables (MR 2237) 2024-01-25 20:12:53 +00:00
install install: initial implementation of flat btrfs layout 2024-01-09 16:55:47 +01:00
netboot chroot: /mnt/pmbootstrap-* -> /mnt/pmbootstrap/* 2023-08-14 09:52:17 +02:00
parse flasher: heimdall-bootimg: add support for '--no-reboot' and '--resume' 2024-01-16 21:16:07 +00:00
qemu treewide: fix typos found with codespell 2023-07-13 10:07:53 +02:00
sideload pmb.helpers.run_core: move flat_cmd here 2023-07-21 08:54:04 +02:00
__init__.py Prepare 2.1.0 release 2023-12-03 20:14:47 +01:00