Skip to content

Retain the PS1 across su(1) and sudo(8) - #148

Merged
debarshiray merged 3 commits into
masterfrom
wip/rishi/set-ps1-in-profile.d-toolbox
May 6, 2019
Merged

debarshiray merged 3 commits into
masterfrom
wip/rishi/set-ps1-in-profile.d-toolbox

Conversation

@debarshiray

Copy link
Copy Markdown
Member

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.

@debarshiray

Copy link
Copy Markdown
Member Author

To test, ensure that you have /etc/profile.d/toolbox.sh. If not, then 'sudo cp profile.d/toolbox.sh /etc/profile.d`.

Then, use su - and sudo su - inside a toolbox container and verify that the blue diamond hasn't disappeared from the shell's prompt. It should work with both new and existing containers.

Commit 97f4e07 made /etc/profile.d/toolbox.sh available inside
the toolbox container through a bind mount. However, it only works for
for toolbox containers created after that commit. Older containers
don't have the bind mount.

A subsequent commit will switch to using the /etc/profile.d/toolbox.sh
start-up script to set the PS1 instead of doing it as part of the
'podman exec' invocation. It's necessary to ensure that the start-up
script is available on older containers to avoid breaking the PS1 when
entering them.

https://github.com/debarshiray/toolbox/pull/148
@debarshiray
debarshiray force-pushed the wip/rishi/set-ps1-in-profile.d-toolbox branch from 9fb4a23 to 05732e1 Compare May 3, 2019 18:14
debarshiray referenced this pull request May 3, 2019
This is better than using an environment variable like
TOOLBOX_CONTAINER because it can't be unset by commands like su(1) or
sudo(8). One nice side-effect of doing it inside 'toolbox enter' is
that it will automatically work with older toolbox containers.

A subsequent commit will switch to using the /etc/profile.d/toolbox.sh
start-up script to set the PS1 instead of doing it as part of the
'podman exec' invocation. Having the identification mechanism work with
older toolbox containers is important to avoid breaking the PS1 for
backwards compatibility.

https://github.com/debarshiray/toolbox/pull/148
debarshiray referenced this pull request May 3, 2019
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
@debarshiray
debarshiray force-pushed the wip/rishi/set-ps1-in-profile.d-toolbox branch from 05732e1 to 285d3b6 Compare May 3, 2019 18:21
debarshiray referenced this pull request May 3, 2019
This is better than setting an environment variable like
TOOLBOX_CONTAINER with 'podman create' because it can't be unset later
by commands like su(1) or sudo(8). One nice side-effect of doing it
inside 'toolbox enter' is that it will automatically work with older
toolbox containers.

A subsequent commit will switch to using the /etc/profile.d/toolbox.sh
start-up script to set the PS1 instead of doing it as part of the
'podman exec' invocation. Having the identification mechanism work with
older toolbox containers is important to avoid breaking the PS1 for
backwards compatibility.

https://github.com/debarshiray/toolbox/pull/148
debarshiray referenced this pull request May 3, 2019
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 is better than setting an environment variable like
TOOLBOX_CONTAINER with 'podman create' because, unlike environment
variables, it can't be unset later by commands like su(1) or sudo(8).
One nice side-effect of doing it inside 'toolbox enter' is that it
will automatically work with older toolbox containers.

A subsequent commit will switch to using the /etc/profile.d/toolbox.sh
start-up script to set the PS1 instead of doing it as part of the
'podman exec' invocation. Having the identification mechanism work with
older toolbox containers is important to avoid breaking the PS1 for
backwards compatibility.

This reverts commit c7b7fa1

https://github.com/debarshiray/toolbox/pull/148
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
@debarshiray
debarshiray force-pushed the wip/rishi/set-ps1-in-profile.d-toolbox branch from 285d3b6 to 0e38e7d Compare May 6, 2019 10:51
@debarshiray
debarshiray merged commit 0e38e7d into master May 6, 2019
@debarshiray
debarshiray deleted the wip/rishi/set-ps1-in-profile.d-toolbox branch May 6, 2019 10:52
@debarshiray debarshiray mentioned this pull request May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant