Skip to content

Conversation

@dims
Copy link
Contributor

@dims dims commented Aug 9, 2018

- What I did

CertsDir is hardcoded to "/etc/docker/certs.d". On some distros the
/etc/docker directory is locked down (700). So we get a permission
denied error. At this point we can't tell if the directory is actually
present or not. but either way we can't read anything under it.

Please see docker/for-linux#396 for a detailed description

- How I did it

At this point we have 2 options, we fail immediately which is the
current behavior. The other other option is to ignore the permission
denied and hope that the certs are not needed and try to continue. In
this change, we use the 2nd option to allow the process to continue
("docker manifest create"). Added a debug statement to log if we do have
a permission issue so it's easy to spot by using "-D" on the docker CLI
command line.

- How to verify it

This basically helps non-root users be able to execute the "docker
manifest create" without having to "sudo".

- Description for the changelog

Allow non-root users to run some CLI commands even when /etc/docker/certs.d/ directory is not accessible

- A picture of a cute animal (not mandatory but encouraged)

@GordonTheTurtle
Copy link

Please sign your commits following these rules:
https://github.com/moby/moby/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "ignore-permission-error-when-accessing-certs.d-directory" [email protected]:dims/moby.git somewhere
$ cd somewhere
$ git commit --amend -s --no-edit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.

@GordonTheTurtle GordonTheTurtle added dco/no Automatically set by a bot when one of the commits lacks proper signature status/0-triage labels Aug 9, 2018
CertsDir is hardcoded to "/etc/docker/certs.d". On some distros the
/etc/docker directory is locked down (700). So we get a permission
denied error. At this point we can't tell if the directory is actually
present or not. but either way we can't read anything under it.

At this point we have 2 options, we fail immediately which is the
current behavior. The other other option is to ignore the permission
denied and hope that the certs are not needed and try to continue. In
this change, we use the 2nd option to allow the process to continue
("docker manifest create"). Added a debug statement to log if we do have
a permission issue so it's easy to spot by using "-D" on the docker CLI
command line.

This basically helps non-root users be able to execute the "docker
manifest create" without having to "sudo".

Change-Id: I6449372d375bcf67884715caf4ac13c214f135ab
Signed-off-by: Davanum Srinivas <[email protected]>
@dims dims force-pushed the ignore-permission-error-when-accessing-certs.d-directory branch from a602844 to 81fc371 Compare August 9, 2018 20:21
@GordonTheTurtle GordonTheTurtle removed the dco/no Automatically set by a bot when one of the commits lacks proper signature label Aug 9, 2018
@thaJeztah
Copy link
Member

Really wondering if this is the correct approach; note that docker manifest create is a pure client-side implementation, so the logging would be done by the docker cli, not the daemon in this case.

ping @clnperez @silvin-lubecki PTAL

@dims
Copy link
Contributor Author

dims commented Sep 10, 2018

@thaJeztah i am happy to re-work this any way you recommend.

@silvin-lubecki
Copy link

hope that the certs are not needed and try to continue

What happens if the certs are needed? Does it fail too? Or do we have a risk to silently fallback on an unsecured connexion?

@dims
Copy link
Contributor Author

dims commented Sep 11, 2018

@silvin-lubecki if the certs are needed (required by server) then the connection will fail i believe.

@clnperez
Copy link
Contributor

Really wondering if this is the correct approach; note that docker manifest create is a pure client-side >implementation, so the logging would be done by the docker cli, not the daemon in this case.

The cli vendors in some docker/moby registry code so we do get some of the engine logging.

@clnperez
Copy link
Contributor

Also, as seen in docker/cli#1358, the permissions error is logged by the manifest command. For other things, though, this might be useful?

@thaJeztah
Copy link
Member

#37847 was merged, but let's discuss the logging here

@thaJeztah thaJeztah reopened this Sep 18, 2018
@codecov
Copy link

codecov bot commented Sep 18, 2018

Codecov Report

Merging #37619 into master will decrease coverage by 0.23%.
The diff coverage is 0%.

@@            Coverage Diff             @@
##           master   #37619      +/-   ##
==========================================
- Coverage   35.85%   35.61%   -0.24%     
==========================================
  Files         606      611       +5     
  Lines       44704    44965     +261     
==========================================
- Hits        16029    16016      -13     
- Misses      26466    26732     +266     
- Partials     2209     2217       +8

@dims
Copy link
Contributor Author

dims commented Sep 18, 2018

Ack @thaJeztah, thanks!

@thaJeztah @clnperez so what can i change here in this PR?

@clnperez
Copy link
Contributor

Re-reading, I don't think we should ignore the permission error. Logging it more explicitly if it's a permission error could be good, in case the caller does not, since that's something a user can fix themselves. I think it's up the the caller to decide whether or not to ignore the error or not.

BTW, I submitted a PR for manifest inspect to do the right thing when a user wants to allow the cert-checking to be skipped.

@thaJeztah
Copy link
Member

With #37847, and docker/cli#1378, perhaps we don't need to make changes. From the linked issue, the error message would look like this;

$ docker manifest create gcr.io/kubernetes-e2e-test-images/net gcr.io/kubernetes-e2e-test-images/net-ppc64le gcr.io/kubernetes-e2e-test-images/net-arm64  gcr.io/kubernetes-e2e-test-images/net-arm gcr.io/kubernetes-e2e-test-images/net-amd64
open /etc/docker/certs.d/gcr.io: permission denied

Which (I think) is an acceptable error

@olljanat
Copy link
Contributor

olljanat commented Nov 8, 2018

@thaJeztah #37847 and docker/cli#1378 are merged so can we close this one?

@dims
Copy link
Contributor Author

dims commented Nov 8, 2018

@olljanat sounds good to me! thanks

@thaJeztah
Copy link
Member

Yes, I think we should close this one.

Thanks so much for working on this @dims! Sorry that it didn't get merged, but it's really appreciated 🤗

@thaJeztah thaJeztah closed this Nov 8, 2018
@dims
Copy link
Contributor Author

dims commented Nov 8, 2018

@thaJeztah my pleasure! i am glad it help nudge :)

kalinkrustev added a commit to softwaregroup-bg/jenkinsfile that referenced this pull request Sep 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants