Skip to content

Commit

Permalink
Honor spec.Process.NoNewPrivileges in specconv.CreateLibcontainerConfig
Browse files Browse the repository at this point in the history
The change ensures that the passed in value of NoNewPrivileges under spec.Process
is reflected in the container config generated by specconv.CreateLibcontainerConfig

Closes opencontainers#2397

Signed-off-by: Pradyumna Agrawal <pradyumnaa@vmware.com>
  • Loading branch information
pkagrawal committed May 11, 2020
1 parent 2c8d668 commit 4aa9101
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions libcontainer/specconv/spec_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) {
}
if spec.Process != nil {
config.OomScoreAdj = spec.Process.OOMScoreAdj
config.NoNewPrivileges = spec.Process.NoNewPrivileges
if spec.Process.SelinuxLabel != "" {
config.ProcessLabel = spec.Process.SelinuxLabel
}
Expand Down
5 changes: 5 additions & 0 deletions libcontainer/specconv/spec_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,11 @@ func TestSpecconvExampleValidate(t *testing.T) {
t.Errorf("Couldn't create libcontainer config: %v", err)
}

if config.NoNewPrivileges != spec.Process.NoNewPrivileges {
t.Errorf("specconv NoNewPrivileges mismatch. Expected %v got %v",
spec.Process.NoNewPrivileges, config.NoNewPrivileges)
}

validator := validate.New()
if err := validator.Validate(config); err != nil {
t.Errorf("Expected specconv to produce valid container config: %v", err)
Expand Down

0 comments on commit 4aa9101

Please sign in to comment.