Commit Graph

19 Commits

Author SHA1 Message Date
Nalin Dahyabhai 76c18c8970 chroot: use $PATH when finding commands
Use the $PATH from the runtime config, if it includes one, so that when
the command to run isn't an absolute path and the command isn't being
processed by the shell, exec.Command()'s internal call to
exec.LookPath() will find it.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-09-10 12:55:59 -04:00
Jan Kaluza a0a9ac6380 Switch common, storage and image to monorepo.
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2025-08-29 15:04:28 +02:00
Nalin Dahyabhai 4ea64c3871 Add a dummy "runtime" that just dumps its config file
Add a dummy "runtime" that just dumps its runtime config, either the
entirety of it, or a section of it corresponding to each command line
argument.  Tests can use it to ensure that we set the right thing in the
configuration without also depending on the runtime to do as its asked,
which isn't always something we have control over.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-05-29 14:17:37 -04:00
Nalin Dahyabhai 4adca286fe chroot: on Linux, try to pivot_root before falling back to chroot
Unless --no-pivot or the equivalent API flag is set, try to pivot_root()
to enter the rootfs during Run().  Fall back to using chroot() as before
if that fails for any reason.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-12-12 14:33:12 -05:00
Nalin Dahyabhai 2ff91b8b08 chroot: add newlines at the end of printed error messages
If we print an error message to stderr, end it with a newline.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-09-24 17:11:16 -04:00
Nalin Dahyabhai 8ae99121c1 CI: enable the gofumpt linter
Turn on the gofumpt linter.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-15 13:17:44 -04:00
Kir Kolyshkin 24da18800e *: fix build tags
This change is generated by `go1.23rc2 fix ./...`.

Had to use go1.23rc2, since all released go versions have a bug
preventing it from working with `go 1.22.0` in go.mod (opened
https://github.com/golang/go/issues/68825,
https://github.com/golang/go/issues/68824 for awareness).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-09 17:05:30 -07:00
Nalin Dahyabhai 04847f57f6 Set CONTAINERS_CONF in the chroot-mount-flags integration test
... in an attempt to try to get UID 0 in a user namespace to stop trying
to read files from root's home directory, where the permissions error is
treated as a hard failure.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-02-07 11:48:29 -05:00
Giuseppe Scrivano e8d11201a9
chroot: lock thread before setPdeathsig
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-05-16 20:07:57 +02:00
Chris Evich 46eea31588
Replace io/ioutil calls with os calls
In golang 1.19, `io/ioutil` is fully deprecated preventing Buildah from
compiling.  Replace all calls with equivalent calls from the `os`
package.

Signed-off-by: Chris Evich <cevich@redhat.com>
2022-12-06 14:29:32 -05:00
Daniel J Walsh 8d5d763213
Fix stutters
Podman adds an Error: to every error message. So starting an error
message with "error" ends up being reported to the user as

Error: error ...

This patch removes the stutter.

Also ioutil.ReadFile errors report the Path, so wrapping the err message
with the path causes a stutter.

Signed-off-by: Daniel J Walsh dwalsh@redhat.com

[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-09-19 07:11:44 -04:00
Doug Rabson 309f714b5f chroot: Move isDevNull to run_common.go
Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-01 13:50:48 +01:00
Doug Rabson 363bf9c5bc chroot: Fix setRlimit build on FreeBSD
On FreeBSD, members of the rlimit structure are signed, not unsigned.

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-01 13:50:48 +01:00
Doug Rabson dc49c3cb4d chroot: Move parseRLimits and setRlimits to run_common.go
Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-01 13:50:47 +01:00
Doug Rabson b64d814325 chroot: Fix runUsingChrootExecMain on FreeBSD
This adds no-op stubs for various things and adds an optional override
for creating the container chroot - on FreeBSD we use a jail to allow
setting the container hostname.

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-01 13:50:47 +01:00
Doug Rabson 4d963eb5e1 chroot: Move runUsingChrootExecMain to run_common.go
Again, this breaks the FreeBSD build and this will be addressed by
refactoring in the next commit.

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-01 13:50:47 +01:00
Doug Rabson 0a61e4b280 chroot: Factor out Linux-specific unshare options from runUsingChroot
Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-01 13:50:47 +01:00
Doug Rabson 3b42b51524 chroot: Move runUsingChroot to run_common.go
This intentionally breaks the FreeBSD so that I can move the code
unmodified which will help with future merge conflicts. A subsequent
commit will resolve this by factoring out Linux-specific code.

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-01 13:50:47 +01:00
Doug Rabson 350c509ecf chroot: Move RunUsingChroot and runUsingChrootMain to run_common.go
This leaves runUsingChrootSubprocOptions in the platform-specific file
since syscall.SysProcIDMap isn't available on FreeBSD.

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-01 13:50:47 +01:00