Skip to content
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

Add capabilities list to container specification #2795

Merged
merged 2 commits into from
May 13, 2019

Conversation

olljanat
Copy link
Contributor

@olljanat olljanat commented Dec 15, 2018

- What I did
Add capabilities list to container specification like discussed on moby/moby#26849 (comment)

Second step to solve moby/moby#25885 , moby/moby#24862 and #1030
Replaces #1565

- How to test it
Run test container which prints capabilities to console

./swarmctl service create --image ollijanatuinen/capsh --name test

Add default capabilities

./swarmctl service update <serviceID> \
    --add-capability CHOWN \
    --add-capability DAC_OVERRIDE \
    --add-capability FSETID \
    --add-capability FOWNER \
    --add-capability MKNOD \
    --add-capability NET_RAW \
    --add-capability SETGID \
    --add-capability SETUID \
    --add-capability SETFCAP \
    --add-capability SETPCAP \
    --add-capability NET_BIND_SERVICE \
    --add-capability SYS_CHROOT \
    --add-capability KILL \
    --add-capability AUDIT_WRITE

Remove capabilities:

swarmctl service update <serviceID> --rm-capability AUDIT_WRITE

- Description for the changelog
d9c62e1 bumps docker/docker to same version which docker/cli is using and docker/distribution to same version than is used by moby and docker/cli (and fixes those small incompabilities).

18d9170 contains actual implementation.

@olljanat olljanat changed the title Add capabilities list to container specification WIP: Add capabilities list to container specification Dec 15, 2018
@olljanat olljanat force-pushed the capabilities-support branch from faf2fef to 993b4bc Compare December 16, 2018 16:29
@olljanat olljanat force-pushed the capabilities-support branch from 993b4bc to 280d50e Compare December 16, 2018 19:52
@olljanat olljanat force-pushed the capabilities-support branch from 280d50e to 6124032 Compare January 28, 2019 17:01
@thaJeztah thaJeztah changed the title WIP: Add capabilities list to container specification Add capabilities list to container specification Feb 20, 2019
@thaJeztah
Copy link
Member

@olljanat I removed "WIP' because the moby PR was merged; could you rebase this PR?

and
docker/distribution to 0d3efadf0154c2b8a4e7b6621fff9809655cc580

Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
@olljanat olljanat force-pushed the capabilities-support branch from 5c1fec3 to d9c62e1 Compare April 2, 2019 17:53
@codecov
Copy link

codecov bot commented Apr 2, 2019

Codecov Report

Merging #2795 into master will decrease coverage by 0.14%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #2795      +/-   ##
==========================================
- Coverage   62.19%   62.05%   -0.15%     
==========================================
  Files         139      139              
  Lines       22314    22314              
==========================================
- Hits        13879    13846      -33     
- Misses       6962     6990      +28     
- Partials     1473     1478       +5

@olljanat olljanat force-pushed the capabilities-support branch from 3e29824 to a908d18 Compare April 2, 2019 18:21
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
@olljanat olljanat force-pushed the capabilities-support branch from a908d18 to 18d9170 Compare April 2, 2019 18:41
@olljanat
Copy link
Contributor Author

olljanat commented Apr 2, 2019

@dperny @wk8 This one is ready for first review. PTAL.

/cc @thaJeztah

Copy link
Contributor

@wk8 wk8 left a comment

Choose a reason for hiding this comment

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

LGTM, might be good to have an integration test in moby once this is merged?

@olljanat
Copy link
Contributor Author

@wk8 sure ;)

@dperny @anshulpundir PTAL

@olljanat
Copy link
Contributor Author

olljanat commented May 5, 2019

@dperny ping

Copy link
Collaborator

@dperny dperny left a comment

Choose a reason for hiding this comment

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

question about why pids limit changed to a pointer

@@ -442,7 +443,7 @@ func (c *containerConfig) resources() enginecontainer.Resources {
// set pids limit
pidsLimit := c.spec().PidsLimit
if pidsLimit > 0 {
resources.PidsLimit = pidsLimit
resources.PidsLimit = &pidsLimit
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there a reason that this changed?

Copy link
Contributor Author

@olljanat olljanat May 7, 2019

Choose a reason for hiding this comment

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

It looks to be changed on moby side and it didn't passed build without those (like I said in change log on first message).

EDIT: Most probably it is this one moby/moby#38793 adds need to use pointer here.

@dperny
Copy link
Collaborator

dperny commented May 7, 2019

@justincormack from a security perspective, would this be a safe change to swarmkit? as i understand it, there was a reason we didn't do this from the beginning, which i think you might be familiar with, but i don't remember what it was.

@olljanat
Copy link
Contributor Author

olljanat commented May 7, 2019

@dperny @justincormack as far I have understood it was this one moby/moby#26849 (comment) why original implementation was not approved.

and to be able solve that issue I refactored capabilities handing on moby (with @thaJeztah help) to support for exact list of capabilities on moby/moby#38380 that actually already ships with Docker 19.03.

And this PR is needed to get it working with services.
Btw. complete TODO list is visible on moby/moby#25885 (comment)

@dperny
Copy link
Collaborator

dperny commented May 7, 2019

It LGTM after a quick OK from security folks.

@justincormack
Copy link
Contributor

@dperny lots of things are not "safe", but deciding that Swarm was the right place to make all safety decisions, and then not actually make them, was a mistake.

@dperny dperny merged commit 23cbd3b into moby:master May 13, 2019
dperny added a commit to dperny/docker that referenced this pull request May 24, 2019
Includes the following changes since last vendoring:

moby/swarmkit#2795 - Add capabilities list to container specification
moby/swarmkit#2845 - Fix linting error
moby/swarmkit#2848 - Bump fernet/fernet-go
moby/swarmkit#2856 - Add ListServiceStatuses grpc method
moby/swarmkit#2857 - Use Service Placement Constraints in Enforcer

Signed-off-by: Drew Erny <drew.erny@docker.com>
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this pull request May 26, 2019
Includes the following changes since last vendoring:

moby/swarmkit#2795 - Add capabilities list to container specification
moby/swarmkit#2845 - Fix linting error
moby/swarmkit#2848 - Bump fernet/fernet-go
moby/swarmkit#2856 - Add ListServiceStatuses grpc method
moby/swarmkit#2857 - Use Service Placement Constraints in Enforcer

Signed-off-by: Drew Erny <drew.erny@docker.com>
Upstream-commit: 67e25ec5ac568a893e444891a6a583fd2f996f76
Component: engine
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.

5 participants