pmbootstrap/test
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
..
pmb_test test: specify default git branch 2023-07-13 10:07:53 +02:00
testdata pmb.install: support pmb_recommends for any package 2024-01-09 16:55:47 +01:00
pytest.ini CI: drop support for cached venv + ci runner (MR 2080) 2021-07-04 22:51:53 +02:00
test_apk.py chroot.apk,apk_static: always disable interactive mode 2023-11-13 09:30:30 +01:00
test_apk_static.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_aportgen.py aportgen: Only warn if binary version > APKBUILD version 2023-12-10 14:41:53 +01:00
test_aportgen_device_wizard.py test: dont fail on githook symlinks 2023-07-13 10:07:53 +02:00
test_arguments.py pmb.parse.arguments: add zap --all flag (MR 2117) 2022-02-28 17:09:21 +03:00
test_bootimg.py parse.bootimg: Separate kernel and ramdisk MediaTek headers 2023-11-13 09:30:24 +01:00
test_build_is_necessary.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_build_package.py build: use sccache for rust 2023-08-14 09:52:22 +02:00
test_chroot_interactive_shell.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_chroot_mount.py install: remove /mnt/pmbootstrap at the end 2023-08-14 09:52:22 +02:00
test_config_init.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_config_pmaports.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_config_user.py pmb.helpers.run_core: move flat_cmd here 2023-07-21 08:54:04 +02:00
test_config_workdir.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_envkernel.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_file.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_folder_size.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_frontend.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_helpers_git.py test: specify default git branch 2023-07-13 10:07:53 +02:00
test_helpers_lint.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_helpers_package.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_helpers_pmaports.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_helpers_repo.py chroot: /mnt/pmbootstrap-* -> /mnt/pmbootstrap/* 2023-08-14 09:52:17 +02:00
test_helpers_repo_missing.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_helpers_status.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_helpers_ui.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_install.py pmb.install: support pmb_recommends for any package 2024-01-09 16:55:47 +01:00
test_mount.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_newapkbuild.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_parse_apkbuild.py parse: allow "-r" in pkgver 2023-08-14 09:52:23 +02:00
test_parse_apkindex.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_parse_depends.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_parse_deviceinfo.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_parse_kconfig.py test: rework kconfig check tests 2023-03-24 09:11:47 +01:00
test_pkgrel_bump.py test/test_pkgrel_bump: make sure pmb doesn't cross compile 2023-07-13 10:07:54 +02:00
test_proxy.py Fix preserving proxy variables (MR 2237) 2024-01-25 20:12:53 +00:00
test_qemu_running_processes.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_questions.py parse.bootimg: Separate kernel and ramdisk MediaTek headers 2023-11-13 09:30:24 +01:00
test_run_core.py Fix preserving proxy variables (MR 2237) 2024-01-25 20:12:53 +00:00
test_shell_escape.py pmb.helpers.run_core: move flat_cmd here 2023-07-21 08:54:04 +02:00
test_version.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_version_validate.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
test_zzz_keys.py test/test_zzz_keys.py: move from test/test_keys.py 2023-03-24 09:14:18 +01:00