-
Notifications
You must be signed in to change notification settings - Fork 717
feature: support selinux #4639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feature: support selinux #4639
Conversation
d69b7e0 to
2eaa687
Compare
2eaa687 to
1e356d6
Compare
1e356d6 to
56a8926
Compare
| 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)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/containerd/nerdctl/blob/main/docs/config.md needs to be updated too
56a8926 to
a210aa3
Compare
0077439 to
ec3feb9
Compare
Signed-off-by: ningmingxiao <[email protected]>
ec3feb9 to
977dba6
Compare
| selinux_enabled= true | ||
| ``` | ||
|
|
||
| ## Properties |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not
| testCase.Require = require.Not(nerdtest.NoSelinux) | |
| testCase.Require = nerdtest.SELinux |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 { |
ping @AkihiroSuda