Retain the PS1 across su(1) and sudo(8)
The shell start-up scripts are where the PS1 is meant to be set. So far, the absence of a toolbox-specific start-up script was being worked around by setting the PS1 as part of the 'podman exec' invocation. This came with certain limitations. eg., using su(1) or sudo(8) to get a root shell can overwrite the PS1 set during 'podman exec' with a value set by the operating system's existing start-up scripts depending on which environment variables were being retained. Now that the toolbox has it's own /etc/profile.d/toolbox.sh start-up script, it's time to move the PS1 to its rightful home. Since the start-up script and /run/.toolboxenv are present in older toolbox containers, this change should be fully backwards compatible and lead to a more robust PS1 without breaking older containers. https://github.com/debarshiray/toolbox/pull/148
This commit is contained in:
parent
f864d67baf
commit
0e38e7d0b3
|
|
@ -24,23 +24,26 @@ if [ -f /run/ostree-booted ] \
|
|||
fi
|
||||
|
||||
if [ -f /run/.containerenv ] \
|
||||
&& ! [ -f "$toolbox_welcome_stub" ] \
|
||||
&& [ -f /run/.toolboxenv ]; then
|
||||
echo ""
|
||||
echo "Welcome to the Toolbox; a container where you can install and run"
|
||||
echo "all your tools."
|
||||
echo ""
|
||||
echo " - Use DNF in the usual manner to install command line tools."
|
||||
echo " - To create a new tools container, run 'toolbox create'."
|
||||
echo ""
|
||||
printf "For more information, see the "
|
||||
# shellcheck disable=SC1003
|
||||
printf '\033]8;;https://docs.fedoraproject.org/en-US/fedora-silverblue/toolbox/\033\\documentation\033]8;;\033\\'
|
||||
printf ".\n"
|
||||
echo ""
|
||||
PS1="🔹[\u@\h \W]\\$ "
|
||||
|
||||
mkdir -p "$toolbox_config"
|
||||
touch "$toolbox_welcome_stub"
|
||||
if ! [ -f "$toolbox_welcome_stub" ]; then
|
||||
echo ""
|
||||
echo "Welcome to the Toolbox; a container where you can install and run"
|
||||
echo "all your tools."
|
||||
echo ""
|
||||
echo " - Use DNF in the usual manner to install command line tools."
|
||||
echo " - To create a new tools container, run 'toolbox create'."
|
||||
echo ""
|
||||
printf "For more information, see the "
|
||||
# shellcheck disable=SC1003
|
||||
printf '\033]8;;https://docs.fedoraproject.org/en-US/fedora-silverblue/toolbox/\033\\documentation\033]8;;\033\\'
|
||||
printf ".\n"
|
||||
echo ""
|
||||
|
||||
mkdir -p "$toolbox_config"
|
||||
touch "$toolbox_welcome_stub"
|
||||
fi
|
||||
fi
|
||||
|
||||
unset toolbox_config
|
||||
|
|
|
|||
7
toolbox
7
toolbox
|
|
@ -66,7 +66,6 @@ toolbox_container_default=""
|
|||
toolbox_container_old=""
|
||||
toolbox_container_prefix_default=""
|
||||
toolbox_image=""
|
||||
toolbox_prompt="🔹[\u@\h \W]\\$ "
|
||||
user_id_real=$(id -ru 2>&3)
|
||||
verbose=false
|
||||
|
||||
|
|
@ -1107,11 +1106,7 @@ enter()
|
|||
--interactive \
|
||||
--tty \
|
||||
"$toolbox_container" \
|
||||
capsh --caps="" -- -c 'cd "$1"; export PS1="$2"; shift 2; exec "$@"' \
|
||||
/bin/sh \
|
||||
"$PWD" \
|
||||
"$toolbox_prompt" \
|
||||
"$shell_to_exec" -l 2>&3
|
||||
capsh --caps="" -- -c 'cd "$1"; shift; exec "$@"' /bin/sh "$PWD" "$shell_to_exec" -l 2>&3
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue