containers / toolbox

Tool for interactive command line environments on Linux
https://containertoolbx.org/
Apache License 2.0
2.39k stars 208 forks source link

pkg/utils: Preserve environment variables for Bash's history facility #1380

Closed debarshiray closed 9 months ago

debarshiray commented 9 months ago

Any system-wide customization to Bash's history facilities done through a custom /etc/profile.d configuration snippet on the host operating system gets lost inside the Toolbx container.

This is because Toolbx doesn't know what name to expect for the custom /etc/profile.d snippet on the host, and, hence, can't give access to it through a bind mount or symbolic link inside the container. The user can definitely set up their own symbolic link inside the container to a snippet inside /run/host/etc/profile.d. However, it's tedious to do that for all containers, and the user may not even know that they are missing the customization until they notice something wrong with the history, which is shared across all containers and the host, and at that point they might have already lost commands that they can't easily reconstruct.

Therefore, it's worth trying to improve the situation by default.

This tries to preserve the environment variables used to customize Bash's history facilities [1] across the host operating system and Toolbx container. It assumes that the Bash start-up scripts inside the container won't overwrite any of the propagated variables, which might not always be the case [2].

[1] https://www.gnu.org/software/bash/manual/html_node/Bash-History-Facilities.html https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html

[2] https://pagure.io/setup/pull-request/48

https://github.com/containers/toolbox/issues/1359

softwarefactory-project-zuul[bot] commented 9 months ago

Build failed. https://softwarefactory-project.io/zuul/t/local/buildset/7e647da594d341fcad110ef7ce052e5d

:heavy_check_mark: unit-test SUCCESS in 8m 52s :heavy_check_mark: unit-test-migration-path-for-coreos-toolbox SUCCESS in 3m 17s :heavy_check_mark: unit-test-restricted SUCCESS in 8m 14s :x: system-test-fedora-rawhide FAILURE in 37m 29s :heavy_check_mark: system-test-fedora-38 SUCCESS in 26m 30s :heavy_check_mark: system-test-fedora-37 SUCCESS in 26m 21s

softwarefactory-project-zuul[bot] commented 9 months ago

Build failed. https://softwarefactory-project.io/zuul/t/local/buildset/a16ac296d4d74a4885e6cf14c232a13f

:heavy_check_mark: unit-test SUCCESS in 9m 00s :heavy_check_mark: unit-test-migration-path-for-coreos-toolbox SUCCESS in 5m 01s :heavy_check_mark: unit-test-restricted SUCCESS in 7m 59s :x: system-test-fedora-rawhide FAILURE in 43m 38s :x: system-test-fedora-38 TIMED_OUT in 40m 24s :x: system-test-fedora-37 TIMED_OUT in 40m 24s

softwarefactory-project-zuul[bot] commented 9 months ago

Build failed. https://softwarefactory-project.io/zuul/t/local/buildset/96497edd8d2c45f5acb1ce2ae4ac32f6

:x: unit-test FAILURE in 8m 58s :x: unit-test-migration-path-for-coreos-toolbox FAILURE in 4m 34s :x: unit-test-restricted FAILURE in 8m 12s :x: system-test-fedora-rawhide FAILURE in 39m 21s :heavy_check_mark: system-test-fedora-38 SUCCESS in 28m 12s :heavy_check_mark: system-test-fedora-37 SUCCESS in 27m 36s

softwarefactory-project-zuul[bot] commented 9 months ago

Build failed. https://softwarefactory-project.io/zuul/t/local/buildset/b523dde90bc44e0990b0a5f20d863b3f

:heavy_check_mark: unit-test SUCCESS in 8m 16s :heavy_check_mark: unit-test-migration-path-for-coreos-toolbox SUCCESS in 3m 25s :heavy_check_mark: unit-test-restricted SUCCESS in 7m 15s :x: system-test-fedora-rawhide FAILURE in 37m 04s :x: system-test-fedora-38 FAILURE in 25m 04s :x: system-test-fedora-37 FAILURE in 25m 24s

softwarefactory-project-zuul[bot] commented 9 months ago

Build failed. https://softwarefactory-project.io/zuul/t/local/buildset/56fa389ff97f48158ed2130aa3a682fb

:heavy_check_mark: unit-test SUCCESS in 8m 34s :heavy_check_mark: unit-test-migration-path-for-coreos-toolbox SUCCESS in 4m 43s :heavy_check_mark: unit-test-restricted SUCCESS in 8m 22s :x: system-test-fedora-rawhide FAILURE in 40m 28s :heavy_check_mark: system-test-fedora-38 SUCCESS in 25m 29s :heavy_check_mark: system-test-fedora-37 SUCCESS in 29m 55s

debarshiray commented 9 months ago

There are still some test failures on Fedora Rawhide. For example:

fedora-rawhide | not ok 3 help: Run command 'help' in 145ms
fedora-rawhide | # (from function `assert_line' in file test/system/libs/bats-assert/src/assert.bash, line 479,
fedora-rawhide | #  in test file test/system/002-help.bats, line 45)
fedora-rawhide | #   `assert_line --index 0 --partial "toolbox(1)"' failed
fedora-rawhide | # /usr/bin/man
fedora-rawhide | #
fedora-rawhide | # -- line does not contain substring --
fedora-rawhide | # index     : 0
fedora-rawhide | # substring : toolbox(1)
fedora-rawhide | # line      : troff:<standard input>:33: warning: cannot select font 'C'
fedora-rawhide | # --

I believe these are because of changes in various other components in Fedora 39, which we need to track down one by one and work out a fix.

In the mean time, I am going to temporarily override these failures.