From 5cdd30efd3534fd7829056bdcf78c43a35323ae5 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Fri, 29 Sep 2023 15:01:24 +0200 Subject: [PATCH] pkg/utils: Preserve environment variables for Bash's history facility 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 --- src/pkg/utils/utils.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pkg/utils/utils.go b/src/pkg/utils/utils.go index 4992c36..9eb2255 100644 --- a/src/pkg/utils/utils.go +++ b/src/pkg/utils/utils.go @@ -84,6 +84,12 @@ var ( "DBUS_SYSTEM_BUS_ADDRESS", "DESKTOP_SESSION", "DISPLAY", + "HISTCONTROL", + "HISTFILE", + "HISTFILESIZE", + "HISTIGNORE", + "HISTSIZE", + "HISTTIMEFORMAT", "LANG", "SHELL", "SSH_AUTH_SOCK",