Commit Graph

8020 Commits

Author SHA1 Message Date
lifubang abf70bab63 libct: skip mount for duplicate masked paths
Co-authored-by: Davanum Srinivas <davanum@gmail.com>
Refactored-by: lifubang <lifubang@acmcoder.com>
Signed-off-by: lifubang <lifubang@acmcoder.com>
2026-05-13 13:05:32 +08:00
Akihiro Suda a0f899b775 Merge pull request #5279 from kolyshkin/fix-fedora-exp
tests/rootless.sh: use command -v instead of which
2026-05-13 13:32:32 +09:00
Kir Kolyshkin 5e78f4a66d tests/rootless.sh: use command -v instead of which
Apparently, lima's experimental/fedora-rawhide image does not include
which rpm, and we don't really want to bother installing it.

Replace "which" with "command -v". Looks like this was the only place;
we already use "command -v" everywhere else.

This should fix lima (experimental/fedora-rawhide) CI.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-12 19:30:41 -07:00
Aleksa Sarai 0811f957a5 merge #5266 into opencontainers/runc:main
Kir Kolyshkin (3):
  runc exec -p: fix adding HOME to nil env
  tests/int/env.bats: add test for runc exec -p
  tests/int: amend runc exec --env test

LGTMs: rata cyphar
2026-05-11 13:50:36 +07:00
Kir Kolyshkin 321073efde runc exec -p: fix adding HOME to nil env
Before commit 7dc24868, when process.env was nil, prepareEnv
returned a flag telling HOME is not set, and it was added.

Commit 7dc24868 moved the functionality of adding HOME into
prepareEnv but did not properly handle nil case. As a result,
runc exec -p with process.json having no env set resulted in
an exec with no HOME set.

Fix this, and add unit and integration tests.

Fixes: 7dc24868 ("libct: switch to numeric UID/GID/groups")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-29 23:15:18 -07:00
Kir Kolyshkin d5307867f9 tests/int/env.bats: add test for runc exec -p
All existing tests check runc run, and there is no single runc exec
environment test except for one in exec.bats.

Add it (no new issues found).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-29 23:15:10 -07:00
Kir Kolyshkin 6210ceb856 tests/int: amend runc exec --env test
This tests checks that "runc exec --env VAR=VAR ..." actually appends
VAR=VAL to the exec's environment.

Add additional checks that:
 - process.env from config.json is also inherited;
 - HOME is set.

Those checks do not reveal any new issues.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-29 23:14:48 -07:00
Rodrigo Campos Catelin eb7eaf19b6 Merge pull request #5256 from kolyshkin/int-hook
Fix flakiness in TestHook
2026-04-22 14:18:23 +02:00
lfbzhm 543ef45b73 Merge pull request #5254 from AkihiroSuda/ci-rawhide
CI: lima: add fedora-rawhide
2026-04-22 18:47:31 +08:00
Kir Kolyshkin 1d12f98f85 tests/int: fix TestHook flakiness
Since commit 3cdda46 the poststart hooks runs after the container
process start, and so they race.

Move the poststart hook check to a separate step after the container
process has exited.

Fixes 5245.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-20 16:35:49 -07:00
Kir Kolyshkin 905958ea65 tests/int: show stderr if command failed part II
This adds a few cases missed by commit bf4fcc30.

Fixes: bf4fcc30
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-18 15:43:03 -07:00
Akihiro Suda f19a9e0917 CI: lima: add fedora-rawhide
For catching potential regressions in kernel, systemd, etc.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2026-04-17 17:45:52 +09:00
Kir Kolyshkin 4ccedcbfe8 Merge pull request #5250 from AkihiroSuda/ci-cache-lima
CI: lima: add template name to cache key
2026-04-16 12:06:58 -07:00
Akihiro Suda ff4470156e CI: lima: add template name to cache key
The cache created for almalinux-8 could be overwritten for almalinux-9

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2026-04-16 22:30:11 +09:00
Rodrigo Campos Catelin 51d0c948d0 Merge pull request #5239 from AkihiroSuda/lima-actions
Complete migration from Cirrus CI to GHA (Lima)
2026-04-16 13:19:09 +02:00
Aleksa Sarai c5077eb39f merge #5243 into opencontainers/runc:main
Rodrigo Campos (1):
  libct/test: Disable GC on test run to catch leaking fds

LGTMs: kolyshkin cyphar
2026-04-16 14:55:36 +10:00
Rodrigo Campos 748af2e285 libct/test: Disable GC on test run to catch leaking fds
This test is racy for a long time now. All the logs I could find in CI
seem to be dangling symlinks, like the test shows "23 -> ". This means
the fd was closed before we did the call to readlink().

Let's try to disable the GC. This should get rid of the "fds are getting
closed before we read them" part.

Updates: #4297

Signed-off-by: Rodrigo Campos <rodrigo@amutable.com>
2026-04-15 17:08:29 -07:00
Rodrigo Campos Catelin 6f42442640 Merge pull request #5232 from kolyshkin/int-wait-stderr
libct/int: better error reporting
2026-04-15 18:22:42 +02:00
Kir Kolyshkin 9970cbfdb6 libct/int: switch from bytes.Buffer to strings.Builder
The latter is simpler and provides just enough functionality to be used
here.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-14 17:05:06 -07:00
Kir Kolyshkin 568a309225 libct/int: remove buffers.Stdin
It is never used.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-14 17:05:06 -07:00
Kir Kolyshkin 54be90bf68 libct/int: use readlink -v
By default, readlink is silent about any errors. Make it verbose so we
can better interpret any test failures.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-14 17:05:05 -07:00
Kir Kolyshkin bf4fcc3002 libct/int: show stderr if command failed
When running a process inside a container, make sure its stderr is not
nil (except for some trivial cases like cat). Modify waitProcess to show
failed command's stderr, if possible.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-14 17:04:18 -07:00
Kir Kolyshkin dd9fda7d60 libct/int: waitProcess: rm dead code
Since Wait returns an ExitError if process' exit status is not 0,
checking process status is redundant and this code is never reached.

Remove it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-14 17:03:56 -07:00
Akihiro Suda 9d697a9222 Complete migration from Cirrus CI to GHA (Lima)
Fix issue 5238

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2026-04-14 19:17:07 +09:00
Kir Kolyshkin edbed618bf Merge pull request #5200 from xujihui1985/fix/rootfs-propagation
fix(libcontainer): preserve rootfs slave propagation for rslave containers
2026-04-12 22:03:54 -07:00
sean 38245cc5ac fix(libcontainer): bats test for rootfs propagation
add bat integration test for rootfs propagation test, expect to
see the mount propagation is slave, the test will create a isolate mntns
to run the test as the test will mutate the rootfs propagation

Signed-off-by: sean <xujihui1985@gmail.com>
2026-04-11 10:23:31 +08:00
sean ec170d8672 fix(libcontainer): preserve rootfs slave propagation
When rootfsPropagation is set to rslave, prepareRoot() was forcing the
rootfs parent mount to MS_PRIVATE before bind-mounting and pivoting into
the rootfs. That breaks the slave relationship needed for HostToContainer
propagation, so later unmount/remount events on host mountpoints under
the rootfs are not reflected inside the running container.

Fix this by keeping the rootfs parent mount as MS_SLAVE for slave-like
rootfs propagation settings, while leaving the final root propagation
remount in place.

Signed-off-by: sean <xujihui1985@gmail.com>
2026-04-11 10:22:16 +08:00
Kir Kolyshkin 506a568da5 Merge pull request #5234 from opencontainers/dependabot/github_actions/actions/github-script-9
build(deps): bump actions/github-script from 8 to 9
2026-04-10 18:05:19 -07:00
dependabot[bot] ce9d995115 build(deps): bump actions/github-script from 8 to 9
Bumps [actions/github-script](https://github.com/actions/github-script) from 8 to 9.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/v8...v9)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-version: '9'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-11 08:41:23 +08:00
lfbzhm b7e727f9a6 Merge pull request #5235 from opencontainers/dependabot/go_modules/golang.org/x/net-0.53.0
build(deps): bump golang.org/x/net from 0.52.0 to 0.53.0
2026-04-11 08:32:10 +08:00
Kir Kolyshkin 23072fd8ab Merge pull request #5224 from RedMakeUp/cirrus-unsafe-env
ci: propagate RUNC_ALLOW_UNSAFE_TESTS to ssh session
2026-04-10 16:59:25 -07:00
dependabot[bot] 727fae3012 build(deps): bump golang.org/x/net from 0.52.0 to 0.53.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.52.0 to 0.53.0.
- [Commits](https://github.com/golang/net/compare/v0.52.0...v0.53.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.53.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-10 18:19:02 +00:00
Kir Kolyshkin 4b97e12fcc Merge pull request #5233 from opencontainers/dependabot/go_modules/golang.org/x/sys-0.43.0
build(deps): bump golang.org/x/sys from 0.42.0 to 0.43.0
2026-04-10 11:17:57 -07:00
lfbzhm 780fd713fd Merge pull request #5222 from kolyshkin/drop-extra-cr
tests/int/checkpoint: drop unneeded tests
2026-04-09 19:21:51 +08:00
RedMakeUp 8178af4930 ci: propagate RUNC_ALLOW_UNSAFE_TESTS to ssh session
The RUNC_ALLOW_UNSAFE_TESTS variable set in the Cirrus CI env block
does not reach the integration tests because they are executed via
"ssh -tt localhost make ...", which starts a new login shell that
does not inherit the caller's environment. As a result, unsafe tests
are always skipped in Cirrus CI even though the intent is to run them.

Fix this by exporting the variable in /root/.bashrc (same way we
already handle PATH), so the ssh session picks it up.

See #5212 (comment).

Fixes: 9932ad19 ("tests/int: introduce the concept of unsafe tests")
Signed-off-by: RedMakeUp <girafeeblue@gmail.com>
2026-04-09 10:03:37 +00:00
dependabot[bot] ebc6fd6ad1 build(deps): bump golang.org/x/sys from 0.42.0 to 0.43.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.42.0 to 0.43.0.
- [Commits](https://github.com/golang/sys/compare/v0.42.0...v0.43.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-version: 0.43.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-09 04:52:33 +00:00
Kir Kolyshkin 2cd4782b70 tests/int/checkpoint: drop unneeded tests
Those tests were added by commit 8d180e96 ("Add support for Linux
Network Devices"), apparently by copy-pasting the test cases which
call simple_cr (all four of them).

While different simple_cr tests make sense as they cover different
code paths in runc and/or check for various regression, the same
variations with netdevice do not make sense, as having a net device
is orthogonal to e.g. bind mount, --debug, or cgroupns.

Remove those.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-08 11:07:42 -07:00
lfbzhm 65bf6dc661 Merge pull request #5226 from kolyshkin/fix-rootless-systemd-idmap
tests/rootless.sh: fix skipping idmap tests for systemd
2026-04-08 19:05:36 +08:00
Rodrigo Campos Catelin d57a45eb78 Merge pull request #5227 from cyphar/internal-cmsg-package
libct: move cmsg helpers to new internal/cmsg package
2026-04-08 11:36:32 +02:00
Rodrigo Campos Catelin 4c8d72d54d Merge pull request #5186 from kolyshkin/poststart
Move poststart hook from runc create to runc start
2026-04-08 11:35:17 +02:00
Kir Kolyshkin 3e0829d195 tests/rootless.sh: fix skipping idmap tests for systemd
When RUNC_USE_SYSTEMD is set, tests/rootless.sh is using

	ssh -tt rootless@localhost

to run tests as rootless user. In this case, local environment is not
passed to the user's ssh session (unless explicitly specified), and so
the tests do not get ROOTLESS_FEATURES.

As a result, idmap-related tests are skipped when running as rootless
using systemd cgroup driver:

	integration test (systemd driver)
	...
	[02] run rootless tests ... (idmap)
	...
	ok 286 runc run detached ({u,g}id != 0) # skip test requires rootless_idmap
	...

Fix this by creating a list of environment variables needed by the
tests, and adding those to ssh command line (in case of ssh) or
exporting (in case of sudo) so both cases work similarly.

Also, modify disable_idmap to unset variables set in enable_idmap so
they are not exported at all if idmap is not in features.

Fixes: bf15cc99 ("cgroup v2: support rootless systemd")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-07 11:27:48 -07:00
Kir Kolyshkin ac2a53be8e tests: rename AUX_{DIR,UID} to ROOTLESS_AUX_*
Also, fix the typo (AUX_DIX) in cleanup.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-07 10:53:37 -07:00
Aleksa Sarai ca509e76ff libct: move cmsg helpers to new internal/cmsg package
These helpers all make more sense as a self-contained package and moving
them has the added benefit of removing an unneeded libpathrs dependency
(from libcontainer/utils's import of pathrs-lite) from several test
binaries.

Signed-off-by: Aleksa Sarai <aleksa@amutable.com>
2026-04-08 01:21:41 +10:00
Kir Kolyshkin 80fc1cd34e Merge pull request #5223 from thaJeztah/gofix
libcontainer/devices: add '//go:fix inline' directives
2026-04-06 11:08:29 -07:00
Aleksa Sarai 4f2090fd31 Merge pull request #5212 from kolyshkin/unsafe_test
tests/int: introduce the concept of unsafe tests
2026-04-05 10:24:07 +10:00
Sebastiaan van Stijn ba83c7c7d7 libcontainer/devices: add '//go:fix inline' directives
This allows users to automaticaly migrate to the new location
using `go fix`. It has some limitations, but can help smoothen
the transition; for example, taking this file;

```
package main

import (
	"github.com/opencontainers/runc/libcontainer/devices"
)

func main() {
	_, _ = devices.DeviceFromPath("a", "b")
	_, _ = devices.HostDevices()
	_, _ = devices.GetDevices("a")
}
```

Running `go fix -mod=readonly ./...` will migrate the code;

```
package main

import (
	devices0 "github.com/moby/sys/devices"
)

func main() {
	_, _ = devices0.DeviceFromPath("a", "b")
	_, _ = devices0.HostDevices()
	_, _ = devices0.GetDevices("a")
}
```

updates b345c78dca

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-04-04 19:36:43 +02:00
Kir Kolyshkin 9932ad19be tests/int: introduce the concept of unsafe tests
Some of runc integration tests may do something that I would not like
when running those on my development laptop. Examples include

 - changing the root mount propagation [1];
 - replacing /root/runc [2];
 - changing the file in /etc (see checkpoint.bats).

Yet it is totally fine to do all that in a throwaway CI environment,
or inside a Docker container.

Introduce a mechanism to skip specific "unsafe" tests unless an
environment variable, RUNC_ALLOW_UNSAFE_TESTS, is set. Use it
from a specific checkpoint/restore test which modifies
/etc/criu/default.conf.

[1]: https://github.com/opencontainers/runc/pull/5200
[2]: https://github.com/opencontainers/runc/pull/5207

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-02 20:03:47 -07:00
Kir Kolyshkin 7a1cae6dd0 Merge pull request #5142 from cyphar/deprecate-libct-devices
libct: deprecate libcontainer/devices in favour of moby/sys/devices
2026-04-02 17:58:00 -07:00
Kir Kolyshkin 3cdda464fa Move poststart hook from runc create to runc start
The runtime-spec [1] currently says:

> 6. Runtime's start command is invoked with the unique identifier of
>    the container.
> 7. The startContainer hooks MUST be invoked by the runtime. If any
>    startContainer hook fails, the runtime MUST generate an error, stop
>    the container, and continue the lifecycle at step 12.
> 8. The runtime MUST run the user-specified program, as specified by
>    process.
> 9. The poststart hooks MUST be invoked by the runtime. If any
>    poststart hook fails, the runtime MUST generate an error, stop the
>    container, and continue the lifecycle at step 12.
> ...
> 11. Runtime's delete command is invoked with the unique identifier of
>     the container.
> 12. The container MUST be destroyed by undoing the steps performed
>     during create phase (step 2).
> 13. The poststop hooks MUST be invoked by the runtime. If any poststop
>     hook fails, the runtime MUST log a warning, but the remaining hooks
>     and lifecycle continue as if the hook had succeeded.

Currently, we do 9 before 8 (heck, even before 6), which is clearly
against the spec and results in issues like the one described in [2].

Let's move running poststart hook to after the user-specified process
has started.

NOTE this patch only fixes the order and does not implement removing
the container when the poststart hook failed (as this part of the spec
is controversial -- destroy et al and should probably be, and currently
are, part of "runc delete").

[1]: https://github.com/opencontainers/runtime-spec/blob/main/runtime.md#lifecycle
[2]: https://github.com/opencontainers/runc/issues/5182

Reported-by: ningmingxiao <ning.mingxiao@zte.com.cn>
Reported-by: Erik Sjölund <erik.sjolund@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-02 12:28:54 -07:00
Kir Kolyshkin 2253475660 libct: factor handleFifo out of c.exec
No functional change. To be used by the next patch.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-02 10:22:22 -07:00