Skip to content

Conversation

@ningmingxiao
Copy link
Contributor

@ningmingxiao ningmingxiao commented Dec 6, 2025

@ningmingxiao ningmingxiao force-pushed the selinux_support branch 7 times, most recently from d69b7e0 to 2eaa687 Compare December 6, 2025 15:21
@ningmingxiao ningmingxiao changed the title feature:support selinux use --security-opt label=xxx feature:support selinux Dec 6, 2025
@ningmingxiao ningmingxiao changed the title feature:support selinux feature: support selinux Dec 6, 2025
if err != nil {
output := strings.TrimSpace(string(stdout))
if strings.Contains(output, "container_t") {
t.Fatal(fmt.Errorf("expect label container_t but get %s", output))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The uniqueness of the MCS categories have to be checked too?

Copy link
Contributor Author

@ningmingxiao ningmingxiao Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think how to check? @AkihiroSuda

- :nerd_face: `--host-gateway-ip`: IP address that the special 'host-gateway' string in --add-host resolves to. It has no effect without setting --add-host
- Default: the IP address of the host
- :nerd_face: `--userns-remap=<username>:<groupname>`: Support idmapping of containers. This options is only supported on rootful linux for container create and run if a user name and optionally group name is passed, it does idmapping based on the uidmap and gidmap ranges specified in /etc/subuid and /etc/subgid respectively. Note: `--userns-remap` is not supported for building containers. Nerdctl Build doesn't support userns-remap feature. (format: <name|uid>[:<group|gid>])
- :nerd_face: `--selinux-enabled`: Enable selinux support
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AkihiroSuda AkihiroSuda added this to the v2.3.0 milestone Dec 8, 2025
@ningmingxiao ningmingxiao marked this pull request as draft December 9, 2025 01:52
@ningmingxiao ningmingxiao force-pushed the selinux_support branch 4 times, most recently from 0077439 to ec3feb9 Compare December 10, 2025 08:51
Signed-off-by: ningmingxiao <[email protected]>
@ningmingxiao ningmingxiao marked this pull request as ready for review December 11, 2025 06:06
selinux_enabled= true
```

## Properties
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be updated

},
}

// NoSexlinux marks a test as suitable only for the noselinux enable environment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typo still remains


func TestRunSelinuxWithSecurityOpt(t *testing.T) {
testCase := nerdtest.Setup()
testCase.Require = require.Not(nerdtest.NoSelinux)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not

Suggested change
testCase.Require = require.Not(nerdtest.NoSelinux)
testCase.Require = nerdtest.SELinux

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test has to be skipped on Docker, as Docker lacks --selinux-enabled on the client side

{
Description: "test run with selinux-enabled",
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
return helpers.Command("--selinux-enabled", "run", "-d", "-v", fmt.Sprintf("/%s:/%s:Z", testContainer, testContainer), "--name", testContainer, "sleep", "infinity")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lower z should be tested too
https://docs.docker.com/engine/storage/bind-mounts/#configure-the-selinux-label

The z option indicates that the bind mount content is shared among multiple containers.
The Z option indicates that the bind mount content is private and unshared.

This should be verified by launching multiple containers

case "Z", "z":
specOpts = append(specOpts, func(ctx context.Context, cli oci.Client, c *containers.Container, s *oci.Spec) error {
if s.Linux != nil && s.Linux.MountLabel != "" {
if err := label.Relabel(src, s.Linux.MountLabel, strings.Contains(opt, "z")); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err := label.Relabel(src, s.Linux.MountLabel, strings.Contains(opt, "z")); err != nil {
if err := label.Relabel(src, s.Linux.MountLabel, opt == "z"); err != nil {

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.

2 participants