Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[component] Ensure consistency across rootful and rootless containers
Currently, if 'sos report' is run inside a rootful Toolbx [1] container with the HOST environment variable set, it creates the report inside the host operating system's /var/tmp, which is at $HOST/var/tmp inside the container: # toolbox enter ⬢# HOST=/run/host sos report ... Your sosreport has been generated and saved in: /run/host/var/tmp/sosreport-toolbox-2023-10-01-trpwqii.tar.xz ... However, if it's run as 'sudo sos report' inside a rootless Toolbx container with the HOST environment variable set, it creates the report inside the container's /var/tmp: $ toolbox enter ⬢$ sudo su - ⬢# HOST=/run/host sos report ... Your sosreport has been generated and saved in: /var/tmp/sosreport-toolbox-2023-10-01-nwjqcff.tar.xz ... Toolbx [1] containers are ultimately Podman containers that are designed to be used as interactive command line environments for development and troubleshooting the host operating system. So, one can replicate the above with a podman(1) invocation as well. This happens because the 'container' environment variable isn't set inside the sudo(8) session. Instead of relying on environment variables, which often go missing in unexpected ways, it will be better to check for the /run/.containerenv and /.dockerenv stamp files that identify Podman and Docker containers respectively. [1] https://containertoolbx.org/ https://github.com/containers/toolbox Signed-off-by: Debarshi Ray <debarshir@gnome.org>
- Loading branch information