-
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
|
|
||
| func TestRunSelinuxWithSecurityOpt(t *testing.T) { | ||
| require.Not(nerdtest.NoSelinux) | ||
| base := testutil.NewBase(t) |
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.
NewBase should not be used for new tests
| inspectCmd := base.Cmd("inspect", testContainer, "--format", "{{.State.Pid}}") | ||
| inspectRes := inspectCmd.Run() | ||
| pid := strings.TrimSpace(inspectRes.Stdout()) | ||
| cmd := exec.Command("ps", "-Z", pid) |
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.
You can just read /proc/PID/attr/* without using ps -Z
| defer func() { | ||
| base.Cmd("rm", "-f", testContainer) | ||
| }() | ||
| inspectCmd := base.Cmd("inspect", testContainer, "--format", "{{.State.Pid}}") |
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.
nerdctl container inspect, not nerdctl inspect
pkg/config/config.go
Outdated
| DNSOpts []string `toml:"dns_opts,omitempty"` | ||
| DNSSearch []string `toml:"dns_search,omitempty"` | ||
| DisableHCSystemd bool `toml:"disable_hc_systemd"` | ||
| SexlinuxEnabled bool `toml:"selinux_enabled"` |
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.
Typo
| require.Not(nerdtest.NoSelinux) | ||
| base := testutil.NewBase(t) | ||
| testContainer := testutil.Identifier(t) | ||
| base.Cmd("--selinux-enabled", "run", "--name", testContainer, "-d", testutil.AlpineImage, "sleep", "infinity").AssertOK() |
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.
For docker target, this has to be skipped, or executed with a custom daemon config
| require.Not(nerdtest.NoSelinux) | ||
| base := testutil.NewBase(t) | ||
| testContainer := testutil.Identifier(t) | ||
| base.Cmd("run", "--name", testContainer, "-d", "--security-opt", "label=type:container_t", testutil.AlpineImage, "sleep", "infinity").AssertOK() |
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.
Doesn't this need --selinux-enabled?
| } | ||
| } | ||
|
|
||
| func TestRunSelinux(t *testing.T) { |
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.
Maybe not really useful without :z and :Z mounts
| 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?
| - :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
Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
56a8926 to
a210aa3
Compare
ping @AkihiroSuda