Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/toolbox-create.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ container, SELinux label separation is disabled, and the host file system can
be accessed by the container at /run/host. The container has access to the
host's Kerberos credentials cache if it's configured to use KCM caches.

A Toolbx container can be identified by the `com.github.containers.toolbox`
label or the `/run/.toolboxenv` file.
A Toolbx container can be identified by the
`com.github.containers.toolbox` label or the `/run/.toolbxenv` file.

The entry point of a Toolbx container is the `toolbox init-container` command
which plays a role in setting up the container, along with the options passed
Expand Down
2 changes: 1 addition & 1 deletion profile.d/toolbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if [ -f /run/ostree-booted ] \
fi

if [ -f /run/.containerenv ] \
&& [ -f /run/.toolboxenv ]; then
&& [ -f /run/.toolbxenv ]; then
[ "${BASH_VERSION:-}" != "" ] && PS1=$(printf "\[\033[35m\]⬢ \[\033[0m\]%s" "[\u@\h \W]\\$ ")
[ "${ZSH_VERSION:-}" != "" ] && PS1=$(printf "\033[35m⬢ \033[0m%s" "[%n@%m]%~%# ")

Expand Down
11 changes: 10 additions & 1 deletion src/cmd/initContainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func initContainer(cmd *cobra.Command, args []string) error {

utils.EnsureXdgRuntimeDirIsSet(initContainerFlags.uid)

logrus.Debug("Creating /run/.toolboxenv")
logrus.Debug("Creating legacy /run/.toolboxenv")

toolboxEnvFile, err := os.Create("/run/.toolboxenv")
if err != nil {
Expand All @@ -172,6 +172,15 @@ func initContainer(cmd *cobra.Command, args []string) error {

defer toolboxEnvFile.Close()

logrus.Debug("Creating /run/.toolbxenv")

toolbxEnvFile, err := os.Create("/run/.toolbxenv")
if err != nil {
return errors.New("failed to create /run/.toolbxenv")
}

defer toolbxEnvFile.Close()

if toolbxDelayEntryPoint, ok := getDelayEntryPoint(); ok {
delayString := toolbxDelayEntryPoint.String()
logrus.Debugf("Adding a delay of %s", delayString)
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ func IsInsideContainer() bool {
}

func IsInsideToolboxContainer() bool {
return PathExists("/run/.toolboxenv")
return PathExists("/run/.toolbxenv") || PathExists("/run/.toolboxenv")
}

// ResolveContainerAndImageNames takes care of standardizing names of containers and images.
Expand Down
12 changes: 11 additions & 1 deletion test/system/104-run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ teardown() {
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "run: Ensure that /run/.toolboxenv exists" {
@test "run: Ensure that legacy /run/.toolboxenv exists" {
create_default_container

run --keep-empty-lines --separate-stderr "$TOOLBX" run test -f /run/.toolboxenv
Expand All @@ -230,6 +230,16 @@ teardown() {
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "run: Ensure that /run/.toolbxenv exists" {
create_default_container

run --keep-empty-lines --separate-stderr "$TOOLBX" run test -f /run/.toolbxenv

assert_success
assert [ ${#lines[@]} -eq 0 ]
assert [ ${#stderr_lines[@]} -eq 0 ]
}

@test "run: Ensure that the default container is used" {
test -z "${name+x}"

Expand Down