Skip to content

generate: fix cap add/drop and initialize in privileged mode#464

Merged
mrunalp merged 1 commit intoopencontainers:masterfrom
runcom:slice-mem
Sep 7, 2017
Merged

generate: fix cap add/drop and initialize in privileged mode#464
mrunalp merged 1 commit intoopencontainers:masterfrom
runcom:slice-mem

Conversation

@runcom
Copy link
Copy Markdown
Member

@runcom runcom commented Sep 6, 2017

This patch fixes two things:

  • do not share slice between caps sets or otherwise you get lots of
    troubles when playing with add/drop and slices... (slices are references...)
  • fix cap add by effectively adding caps to all sets...

@mrunalp PTAL asap

Signed-off-by: Antonio Murdaca runcom@redhat.com

@rhatdan
Copy link
Copy Markdown
Contributor

rhatdan commented Sep 6, 2017

LGTM

@mrunalp
Copy link
Copy Markdown
Contributor

mrunalp commented Sep 6, 2017

LGTM

Approved with PullApprove

@mrunalp
Copy link
Copy Markdown
Contributor

mrunalp commented Sep 6, 2017

@Mashimiao PTAL

Comment thread generate/generate.go
g.spec.Process.Capabilities.Effective = append(g.spec.Process.Capabilities.Effective, finalCapList...)
g.spec.Process.Capabilities.Inheritable = append(g.spec.Process.Capabilities.Inheritable, finalCapList...)
g.spec.Process.Capabilities.Permitted = append(g.spec.Process.Capabilities.Permitted, finalCapList...)
g.spec.Process.Capabilities.Ambient = append(g.spec.Process.Capabilities.Ambient, finalCapList...)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Before appending finalCapList, should we clear Capabilities first?
I'm afraid if we use --process-cap-add and --privileged together, this may cause duplicate cap items problem

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed to reset the slice first.

Comment thread generate/generate.go Outdated
g.spec.Process.Capabilities.Inheritable = finalCapList
g.spec.Process.Capabilities.Permitted = finalCapList
g.spec.Process.Capabilities.Ambient = finalCapList
g.spec.Process.Capabilities.Bounding = []string{}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ah, how about taking advantage of ClearProcessCapabilities()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

This patch fixes two things:

- do not share slice between caps sets or otherwise you get lots of
troubles when playing with add/drop and slices...
- fix cap add by effectively adding caps to all sets...

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
@Mashimiao
Copy link
Copy Markdown

Mashimiao commented Sep 7, 2017

LGTM. Thanks!

Approved with PullApprove

@mrunalp
Copy link
Copy Markdown
Contributor

mrunalp commented Sep 7, 2017

LGTM

Approved with PullApprove

@mrunalp mrunalp merged commit d3f7e9e into opencontainers:master Sep 7, 2017
@runcom runcom deleted the slice-mem branch September 7, 2017 14:39
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.

4 participants