Commit graph

1077 commits

Author SHA1 Message Date
Debarshi Ray
f695012faf build: Enforce all the default 'go vet' checks on all Go sources
Currently, only a so-called high-confidence subset of the default checks
in 'go vet' are being run by 'go test' [1].  Since 'go vet' is part of
the core Go tools, it's worth trying to use more of it.  After all,
golangci-lint, which is currently being run through a GitHub Action,
is running the default 'go vet' checks as one of its linters [2].

It's good to have as much of the testing wrapped inside 'meson test', as
possible, because it's easier to run locally and on other non-GitHub CI
environments like those of downstream distributors.

[1] https://pkg.go.dev/cmd/go/internal/test

[2] https://golangci-lint.run/usage/linters/
    https://golangci-lint.run/usage/linters/#govet

https://github.com/containers/toolbox/pull/1186
2022-12-02 11:39:03 +01:00
Debarshi Ray
f0425d4240 build: Rename the 'go test' test for consistency
https://github.com/containers/toolbox/pull/1186
2022-12-02 11:12:21 +01:00
Debarshi Ray
fa1b7e26a2 cmd/initContainer: Limit the scope of the error
Fallout from d323143c46

https://github.com/containers/toolbox/pull/1185
2022-12-01 18:24:59 +01:00
Debarshi Ray
b85ab0a4f1 cmd/initContainer, cmd/run: Restore hints about unreachable code
In the past, before commit d323143c46, there was either had a
dummy 'return' statement or a self-documenting 'panic' that said that
the code should not be reached.  Since neither golangci-lint nor
'go vet' likes those, a comment is the only option left.

Note that the core Go tools like 'go vet' [1], but also 'go lint' [2],
explicitly don't intend to add fine-grained configuration options,
including inline directives or pragmas, to silence specific warnings.
That's something golangci-lint offers [3], to the extent that it's
supported by its linters [4].  However, golangci-lint also uses 'go vet'
as one of those linters, so it's the same problem all over again.

Therefore, between the two extremes of leaving the code difficult to
read and using a very big hammer to disable a needlessly big chuck of
'go vet', a comment is the least worst option.

[1] https://github.com/golang/go/issues/17058
    https://github.com/golang/go/issues/18432

[2] https://github.com/golang/lint/issues/263

[3] https://golangci-lint.run/usage/false-positives/

[4] https://golangci-lint.run/usage/linters/

Fallout from d323143c46

https://github.com/containers/toolbox/pull/1185
2022-12-01 18:24:15 +01:00
Debarshi Ray
d0fe8c45f7 README.md: Clarify that Toolbx isn't a security mechanism
Using the word 'containerized' gives the false impression of heightened
security.  As if it's a mechanism to run untrusted software in a
sandboxed environment without access to the user's private data (such as
$HOME), hardware peripherals (such as cameras and microphones), etc..
That's not what Toolbx is for.

Toolbx aims to offer an interactive command line environment for
development and troubleshooting the host operating system, without
having to install software on the host.  That's all.  It makes no
promise about security beyond what's already available in the usual
command line environment on the host that everybody is familiar with.

https://github.com/containers/toolbox/issues/1020
2022-11-29 17:46:34 +01:00
Debarshi Ray
f5057d782e README.md: Tweak
Mention that Toolbx is meant for system administrators to troubleshoot
the host operating system.  The word 'debugging' is often used in the
context of software development, and hence most readers might not
interpret it as 'troubleshooting'.

https://github.com/containers/toolbox/pull/1182
2022-11-29 17:46:25 +01:00
Debarshi Ray
11d3c6bda5 README.md: Remove trailing newline
Fallout from bafbbe81c9

https://github.com/containers/toolbox/pull/1182
2022-11-29 17:01:06 +01:00
Debarshi Ray
021053716e test/system: Add copyright and license notices
https://github.com/containers/toolbox/pull/1179
2022-11-29 13:54:13 +01:00
Debarshi Ray
ca966e377c .zuul, playbooks: Add copyright and license notices
https://github.com/containers/toolbox/pull/1179
2022-11-28 22:47:15 +01:00
Debarshi Ray
630792e0a1 Update copyright notices
https://github.com/containers/toolbox/pull/1179
2022-11-28 21:01:18 +01:00
Debarshi Ray
f392a69a4b profile.d: Restore compatibility with Z shell
Otherwise, every zsh instance on Fedora Kinoite and Silverblue was
running into:
  /etc/profile.d/toolbox.sh:30: bad substitution

... because case modification with "${VARIANT_ID^}" is undefined in
POSIX shell [1], and doesn't work with Z shell.

Fedora Silverblue got its own PRETTY_NAME (and VARIANT and VARIANT_ID)
starting from Fedora 32 [2].  Therefore, it's better to use PRETTY_NAME
and let the downstream distributor of the host operating system decide
how it should be presented to the user, instead of coming up with a
custom string.  eg., PRETTY_NAME isn't the same as "Fedora $VARIANT" on
Fedora Silverblue.

One nice side-effect of this is that while VARIANT and VARIANT_ID are
optional fields, PRETTY_NAME has a well-defined fallback value of
'Linux' [3].  This makes this a little less specific to Fedora Kinoite
and Silverblue.

The rest of the welcome text was reformatted to prevent it from getting
too wide depending on the contents of PRETTY_NAME.

Fallout from 3641a0032f

[1] https://www.shellcheck.net/wiki/SC3059

[2] https://pagure.io/workstation-ostree-config/c/c18ef957d11862d32f362722931dbfdf1f5beb0d

[3] https://www.freedesktop.org/software/systemd/man/os-release.html

https://github.com/containers/toolbox/issues/1017
2022-11-25 18:36:31 +01:00
Debarshi Ray
5249bf229f profile.d: Don't leak ID and VARIANT_ID into the shell
Commit dcdfa3a1f5 ensured that the rest of the os-release(5)
fields don't get injected into the shell as environment variables, but
missed ID and VARIANT_ID.

Fallout from c6e37cdef3

https://github.com/containers/toolbox/pull/1176
2022-11-24 17:26:03 +01:00
Debarshi Ray
76ef9b3abf profile.d: Style fix
Fallout from 88f2916822 and
dcdfa3a1f5

https://github.com/containers/toolbox/pull/1176
2022-11-24 17:25:59 +01:00
Debarshi Ray
2e437d69db playbooks: Remove unnecessary parameter
The documentation for Ansible's built-in 'package' module [1] says this
about the 'use' parameter:
  You should only use this field if the automatic selection is not
  working for some reason.

[1] https://docs.ansible.com/ansible/latest/collections/ansible/builtin/package_module.html

https://github.com/containers/toolbox/pull/1173
2022-11-19 15:46:46 +01:00
Nieves Montero
9438db2f79 build, playbooks: Add a test that runs codespell
https://github.com/containers/toolbox/issues/1146

Signed-off-by: Nieves Montero <nmontero@redhat.com>
2022-11-19 15:32:13 +01:00
Debarshi Ray
9204d90da4 playbooks: Don't worry about runc(8)
... because it was replaced by crun(1) as Podman's default OCI runtime
during the migration to cgroups v2 in Fedora 31 [1].  eg., on Fedora 36:
  # repoquery --whatrequires runc
  ...
  containerd-0:1.6.1-1.fc36.x86_64
  containerd-0:1.6.9-3.fc36.x86_64
  containers-common-4:1-53.fc36.noarch
  containers-common-extra-4:1-62.fc36.noarch
  moby-engine-0:20.10.12-3.fc36.x86_64
  moby-engine-0:20.10.20-1.fc36.x86_64

... and it doesn't get installed on Fedora 35 either:
  TASK [Check versions of crucial packages]
  ci-node-35 | glibc-gconv-extra-2.34-43.fc35.x86_64
  ci-node-35 | glibc-2.34-43.fc35.x86_64
  ci-node-35 | glibc-common-2.34-43.fc35.x86_64
  ci-node-35 | glibc-langpack-en-2.34-43.fc35.x86_64
  ci-node-35 | kernel-core-6.0.5-100.fc35.x86_64
  ci-node-35 | kernel-core-6.0.7-100.fc35.x86_64
  ci-node-35 | kernel-core-6.0.8-100.fc35.x86_64
  ci-node-35 | kernel-headers-6.0.5-100.fc35.x86_64
  ci-node-35 | glibc-headers-x86-2.34-43.fc35.noarch
  ci-node-35 | glibc-devel-2.34-43.fc35.x86_64
  ci-node-35 | kernel-srpm-macros-1.0-6.fc35.noarch
  ci-node-35 | containernetworking-plugins-1.1.0-1.fc35.x86_64
  ci-node-35 | container-selinux-2.189.0-1.fc35.noarch
  ci-node-35 | conmon-2.1.0-2.fc35.x86_64
  ci-node-35 | golang-1.16.15-3.fc35.x86_64
  ci-node-35 | crun-1.6-2.fc35.x86_64
  ci-node-35 | fuse-overlayfs-1.9-1.fc35.x86_64
  ci-node-35 | containers-common-1-45.fc35.noarch
  ci-node-35 | podman-3.4.7-2.fc35.x86_64
  ci-node-35 | flatpak-session-helper-1.12.7-2.fc35.x86_64
  ci-node-35 | ok: Runtime: 0:00:00.139573

[1] https://fedoraproject.org/wiki/Changes/CGroupsV2

https://github.com/containers/toolbox/pull/1170
2022-11-18 19:21:50 +01:00
Debarshi Ray
c1ac8bc102 playbooks: Build the shell completions for fish
https://github.com/containers/toolbox/pull/1169
2022-11-18 18:51:52 +01:00
Debarshi Ray
6439b147d3 Revert ".zuul: Run tests only for relevant files"
On a couple of occasions the relevant tests didn't get triggered because
some files weren't listed [1], and on another a commit forgot to update
the list of files [2].

The objective of the CI is to reduce stress for the maintainers, and
make it easy for contributors to find out if their changes work or not.
Missing tests don't help with that, and there's no need to optimize the
tests like this unless there's a real problem to be solved.

[1] Commit deca452b27
    Commit 5c27d73021

[2] Commit b1743c4927

This reverts commit c28d902089.

https://github.com/containers/toolbox/pull/1168
2022-11-18 18:25:45 +01:00
Andre Moreira Magalhaes
34505fd475 profile.d: Give precedence to /etc/os-release over /usr/lib/os-release
Some OSTree based systems, such as Endless OS, don't ship with
/usr/lib/os-release, and the os-release(5) manual says [1]:
  The file /etc/os-release takes precedence over /usr/lib/os-release.
  Applications should check for the former, and exclusively use its data
  if it exists, and only fall back to /usr/lib/os-release if it is
  missing.

[1] https://www.freedesktop.org/software/systemd/man/os-release.html

https://github.com/containers/toolbox/pull/692
2022-11-18 16:41:47 +01:00
Andre Moreira Magalhaes
ac46f54357 profile.d: Hide the Fedora-specific welcome on non-Fedora containers
https://github.com/containers/toolbox/pull/692
2022-11-18 16:39:16 +01:00
Debarshi Ray
deca452b27 .zuul: Trigger ShellCheck when profile.d/toolbox.sh changes
https://github.com/containers/toolbox/pull/692
2022-11-18 16:39:16 +01:00
Nieves Montero
f2b7e440e1 Fix spelling mistakes using codespell
https://github.com/containers/toolbox/pull/1166
https://github.com/containers/toolbox/pull/1149

Signed-off-by: Nieves Montero <nmontero@redhat.com>
2022-11-17 11:56:58 +01:00
Debarshi Ray
ed9f8cd0d9 cmd/completion: Style fixes
https://github.com/containers/toolbox/pull/1165
2022-11-17 11:34:42 +01:00
Debarshi Ray
1b85f711e4 test/system: Test 'completion'
https://github.com/containers/toolbox/pull/1165
2022-11-17 11:34:42 +01:00
Debarshi Ray
685f1f794d test/system: Be more strict when checking the version
https://github.com/containers/toolbox/pull/1165
2022-11-17 11:28:00 +01:00
Ondřej Míchal
fe63222916 cmd/completion: Use RunE instead of Run as elsewhere
Fallout from d69ce6794b

https://github.com/containers/toolbox/pull/1055
https://github.com/containers/toolbox/pull/840
2022-11-17 10:20:01 +01:00
Debarshi Ray
9b7793bd76 cmd/create: Fix typo
Fallout from e935ed893d

https://github.com/containers/toolbox/pull/1164
2022-11-16 23:01:25 +01:00
Debarshi Ray
68d63bf09e test/system: Ensure that the right containers are run
https://github.com/containers/toolbox/pull/1163
2022-11-16 20:46:47 +01:00
Debarshi Ray
a61f88d7b2 test/system: Ensure that /run/.containerenv and /run/.toolboxenv exist
This is a precursor to verifying the names of the containers and
ensuring that the right ones are getting used.

https://github.com/containers/toolbox/pull/1163
2022-11-16 20:46:47 +01:00
Debarshi Ray
0000c68ee6 test/system: Ensure that 'toolbox run false' has exit code 1
This is a precursor to checking that higher valued exit codes from the
command running inside the container are retained, and commands like
test(1) can be used with 'toolbox run ...' in subsequent test cases.

https://github.com/containers/toolbox/pull/1163
2022-11-16 20:46:40 +01:00
Debarshi Ray
78683b38ae test/system: Use long options, instead of their shorter aliases
The long options are easier to grep(1) for in the sources than their
shorter aliases.

https://github.com/containers/toolbox/pull/1162
2022-11-16 19:56:24 +01:00
Debarshi Ray
220164b396 test/system: Shorten the names of the tests and use consistent wording
Currently, some of the names of the tests were too long, and had
inconsistent and verbose wording.  This made it difficult to look at
them and get a gist of all the scenarios being tested.  The names are
like headings.  They shouldn't be too long, should capture the primary
objective of the test and be consistent in their wording.

https://github.com/containers/toolbox/pull/1161
2022-11-16 19:49:56 +01:00
Debarshi Ray
8ec03ab85f test/system: Order the tests by increasing order of the exit code
This is another step towards making it easy to look at the file and get
a gist of all the scenarios being tested.

https://github.com/containers/toolbox/pull/1161
2022-11-16 13:41:43 +01:00
Debarshi Ray
485489867b test/system: Simplify the exit code checks by relying on Bats >= 1.5.0
Commit 978bb524e4 already added a dependency on Bats >= 1.5.0,
which is present in Fedora >= 35.  Therefore, it should be exploited
wherever possible to simplify things.

However, bats_require_minimum_version can't be used, because it's
only available from Bats 1.7.0 [1], which is new enough that it's absent
from Fedora 35.

[1] Bats commit 71d6b71cebc3d32b
    https://github.com/bats-core/bats-core/issues/556
    https://bats-core.readthedocs.io/en/stable/warnings/BW02.html

https://github.com/containers/toolbox/pull/1161
2022-11-16 13:41:39 +01:00
Debarshi Ray
80f9ac754d test/system: Remove redundant assertion
Fallout from 978bb524e4

https://github.com/containers/toolbox/pull/1161
2022-11-16 13:40:36 +01:00
Debarshi Ray
04e94868e0 test/system: Check the line count in the standard error & output streams
https://github.com/containers/toolbox/pull/1160
2022-11-16 12:51:35 +01:00
Debarshi Ray
e8ad1eaad0 test/system: Ensure that error messages go to the standard error stream
Currently, there's no way to get assert_line to use the stderr_lines
array [1].  This is worked around by assigning stderr_lines to the
'lines' array.

[1] https://github.com/bats-core/bats-assert/issues/42

https://github.com/containers/toolbox/pull/1160
2022-11-16 12:36:46 +01:00
Debarshi Ray
8b7511ab6f playbooks/dependencies: Improve the names of the tasks
https://github.com/containers/toolbox/pull/1158
2022-11-16 11:11:18 +01:00
Debarshi Ray
03922893af playbooks: Highlight failures from 'meson compile' and 'meson install'
Currently, 'meson compile' and 'meson install' were being invoked from
pre-run playbooks.  This meant that a genuine build failure from either
of those commands would be shown as a RETRY_LIMIT failure by the CI.

This was misleading.  It made it look as if the failure was caused by
some transient networking problem or that the CI node was too slow due
to momentary heavy load, whereas the failure was actually due to a
problem in the Toolbx sources.  A genuine problem in the sources should
be reflected as a FAILURE, not RETRY_LIMIT.

However, it's worth noting that 'meson compile' invokes 'go build',
which downloads all the Go modules required by the Toolbx sources.  This
is worth retaining in the pre-run playbooks since it primarily depends
on Internet infrastructure beyond the Toolbx sources.

As a nice side-effect, the CI no longer gets mysteriously stuck like
this while the Go modules are being downloaded:
  TASK [Build Toolbox]
  ci-node-36 | ninja: Entering directory
    `/home/zuul-worker/src/github.com/containers/toolbox/builddir'
  ...
  ci-node-36 | [8/13] Generating doc/toolbox-rmi.1 with a custom command
  ci-node-36 | [9/13] Generating doc/toolbox-run.1 with a custom command
  ci-node-36 | [10/13] Generating doc/toolbox.conf.5 with a custom
    command
  ci-node-36 | [11/13] Generating src/toolbox with a custom command

https://github.com/containers/toolbox/pull/1158
2022-11-16 11:11:01 +01:00
Debarshi Ray
9bf9f97e2c test/system: Ensure that 'toolbox run --preserve-fds ...' works
Note that file descriptors 3 and 4 are reserved by Bats.  The former is
used for adding custom text to the Test Anything Protocol (or TAP)
stream [1] and the latter for tracing [2].

[1] https://bats-core.readthedocs.io/en/stable/writing-tests.html#file-descriptor-3-read-this-if-bats-hangs
    https://bats-core.readthedocs.io/en/stable/writing-tests.html#printing-to-the-terminal

[2] Bats commit 635700cd2282b754
    https://github.com/bats-core/bats-core/pull/467
    https://github.com/bats-core/bats-core/pull/488

https://github.com/containers/toolbox/issues/1066
2022-11-14 23:10:29 +01:00
Allison Karlitskaya
d4213c2358 Support leaking additional file descriptors to the container
This mirrors the --preserve-fds option of Podman.

Converting an unsigned 'uint', which is what Podman uses for its
--preserve-fds option, to a string is surprisingly annoying.
strconv.Itoa [1] takes a signed 'int', which would require a cast, and
there's no unsigned counterpart.  There's strconv.FormatUint [2] which
takes an unsigned 'uint64', which is better, but would still require a
cast.

So, fmt.Sprint [3] it is, if the cast is to be avoided.  It's more
expensive than the other two functions, but there's no need to worry
unless it's proven to be a performance bottle neck.

Some changes by Debarshi Ray.

[1] https://pkg.go.dev/strconv#Itoa

[2] https://pkg.go.dev/strconv#FormatUint

[3] https://pkg.go.dev/fmt#Sprint

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

Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
2022-11-14 22:28:27 +01:00
Debarshi Ray
f779c798f0 test/system: Remove workaround for carriage return without a terminal
Commit a22d7821cb ensured that a nested pseudo-terminal device is
only created for the process running inside the container, if the Toolbx
binary's standard input and output streams are connected to a terminal.

Therefore, 'echo ...' no longer ends with an unwanted extra carriage
return when terminal devices are absent - there's only a line feed for
the trailing newline.  Hence, there's no need to use the -n flag to skip
the trailing newline.

This reverts parts of commit 16b0c5d88f.

https://github.com/containers/toolbox/issues/157
2022-11-10 19:28:54 +01:00
Debarshi Ray
190a76ac0a test/system: Group the test cases somewhat logically
It seems that as new test cases got developed they got appended towards
the end of the file.  Now that there are a non-trivial number of test
cases, it's difficult to look at the file and get a gist of all the
scenarios being tested.

It will be better to have some logical grouping -- starting with the
most basic functionality, then moving on to more advanced features,
and then finally the errors.

This is a step towards that.

https://github.com/containers/toolbox/pull/1155
2022-11-10 18:09:19 +01:00
Debarshi Ray
12940e0b45 cmd/run: Suppress errors from Podman when interactive and not verbose
Here's some historical context to understand what's going on.

In the past, before commit a22d7821cb, Podman's standard error
stream was only revealed when --verbose was used.

During that time, the standard error and output streams of the process
running inside the Toolbx container, but not 'podman exec ...' itself,
were merged into the standard output stream read and revealed by the
Toolbx binary.

Then commit a22d7821cb ensured that a nested pseudo-terminal
device is only created for the process running inside the container, if
the Toolbx binary's standard input and output streams are connected to a
terminal.  This meant that the standard error stream of the container
process stayed separate from the standard output stream received by the
Toolbx binary, when terminal devices were absent.  The errors from
'podman exec ...' itself continued to be separate as before.

However, Toolbx only read and revealed the standard error stream of the
spawned 'podman exec ...' process when --verbose was used.  This meant
that all the errors from the container process got lost in the absence
of --verbose.  This was an unintended change in behaviour caused by
commit a22d7821cb that got addressed in the subsequent commit
7cba807e45, but with yet another unintended change in behaviour.

Commit 7cba807e45 started reading and revealing the standard
error stream of the spawned 'podman exec ...' process unconditionally.
This caused the errors from both Podman and the container process to be
revealed unconditionally, which is a problem.

Podman is an implementation detail of Toolbx.  Therefore, Toolbx users
shouldn't be directly exposed to errors from Podman, unless they are
using --verbose to debug a problem.  On the other hand, the container
process is the outcome of a command specified by the user.  So, the user
does expect to see what's going on with it.

That's the unintended change in behaviour this commit tries to fix.

Unfortunately, when Toolbx is being used non-interactively (ie., no
terminal devices), the errors from the process running inside the
Toolbx container and the errors from 'podman exec ...' itself are part
of the same standard error stream received by Toolbx.  It's impossible
to distinguish between the two without deeper changes.

Hence, this commit only focuses on interactive use (ie., terminals are
present), which is where the visual appearance and presentation of error
messages really matter.  Non-interactive use is programmatic use, so the
visuals don't matter so much.

Fallout from 7cba807e45

https://github.com/containers/toolbox/pull/1154
2022-11-10 16:45:43 +01:00
Debarshi Ray
1fc1f08405 cmd/run: Style fixes
In particular, the --env options had gotten shuffled by mistake in
commit 2da4cc4634.
2022-11-10 15:08:32 +01:00
Debarshi Ray
67849e03a4 cmd/run: Don't check the stdin and stdout in a loop in the fallback case
The outcome of checking whether the standard input and output of the
current invocation of toolbox are connected to a terminal device is
going to stay constant for the life cycle of the process.  So, checking
it repeatedly in a loop when falling back to a different command or
working directory is wasteful.

Secondly, it prevents secondary logic like this from intermingling with
the code that actually assembles the list of arguments.  This makes it
easier to get a quick gist of the final command and its structure.

Fallout from a22d7821cb
2022-11-10 15:08:32 +01:00
Debarshi Ray
741603c64e test/system: Ensure that $HOME is used as a fallback working directory
This needs a directory that's going to be present on the host operating
system across various configurations of all supported distributions,
such as the hosts running the CI, but not inside the Toolbx containers.

It looks like /etc/kernel is present on both Debian and Fedora, but
absent from the fedora-toolbox images.  On a Debian 10 server, it's
owned by several packages:
  $ dpkg-query --search /etc/kernel
  dkms, systemd, grub2-common, initramfs-tools, apt: /etc/kernel

... while on Fedora 36 Workstation:
  $ rpm --file --query /etc/kernel
  systemd-udev-250.8-1.fc36.x86_64

Currently, there's no way to get assert_line to use the stderr_lines
array [1].  This is worked around by assigning stderr_lines to the
'lines' array.

[1] https://github.com/bats-core/bats-assert/issues/42

https://github.com/containers/toolbox/pull/1153
2022-11-10 12:28:14 +01:00
Debarshi Ray
3326dda259 test/system: Group the test cases somewhat logically
It seems that as new test cases got developed they got appended towards
the end of the file.  Now that there are a non-trivial number of test
cases, it's difficult to look at the file and get a gist of all the
scenarios being tested.

It will be better to have some logical grouping -- starting with the
most basic functionality, then moving on to more advanced features,
and then finally the errors.

This a step towards that.

https://github.com/containers/toolbox/pull/1152
2022-11-08 20:06:11 +01:00
Debarshi Ray
1ce59a6a2d cmd/run: Ensure that 'run' has the same container environment as 'enter'
Currently, commands invoked using 'toolbox run' have a different
environment than the interactive environment offered by 'toolbox enter'.
This is because 'toolbox run' was invoking the commands using something
like this:
  $ bash -c 'exec "$@"' bash [COMMAND]

... whereas, 'toolbox enter' was using something like this:
  $ bash -c 'exec "$@"' bash bash --login

In the first case, the helper Bash shell is a non-interactive non-login
shell.  This means that it doesn't read any of the usual start-up files,
and, hence, it doesn't pick up anything that's specified in them.  It
runs with the default environment variables set up by Podman and the
Toolbx image, plus the environment variables set by Toolbx itself.

In the second case, even though the helper Bash shell is still the same
as the first, it eventually invokes a login shell, which runs the usual
set of start-up files and picks up everything that's specified in them.

Therefore, to ensure parity, 'toolbox run' should always have a login
shell in the call chain inside the Toolbx container.

The easiest option is to always use a helper shell that's a login shell
with 'toolbox run', but not 'toolbox enter' so as to avoid reading the
same start-up files twice, due to two login shells in the call chain.
It will still end up reading the same start-up files twice, if someone
tried to invoke a login shell through 'toolbox run', which is fine.
It's very difficult to be sure that the user is invoking a login shell
through 'toolbox run', and it's not what most users will be doing.

https://github.com/containers/toolbox/issues/1076
2022-10-25 16:56:20 +02:00
Debarshi Ray
fd3bd05b4a cmd/run: Split out the code to construct the arguments to capsh(1)
This will be used by the subsequent commit to conditionally use a login
shell as the helper shell invoked by capsh(1).

https://github.com/containers/toolbox/issues/1076
2022-10-25 16:50:28 +02:00