containerd / containerd/nerdctl
dockerConfigFile.GetCredentialsStore.Store faulty symlink resolution behavior
- Dominant language
- Go
- Stars
- 10.4k
- Forks
- 826
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 44
Description
### Description
When DOCKER_CONFIG points to a directory that does contain a relative, ~~dangling~~ `config.json` symlink, Docker credentials store will (apparently) wrongly resolve the link to the current working directory.
This can be reproduced with the following:
```
mkdir -p /tmp/foo
ln -s doesnotexist /tmp/foo/config.json
cd ~
DOCKER_CONFIG=/tmp/foo nerdctl login
cat ~/doesnotexist
ln -s /tmp/foo
```
This does suggest there is a bug in moby/docker somewhere where readlink is used to resolve against pwd instead of the parent dir (/tmp/foo).
In turn, if, for some reason, the file cannot be created in the current working directory (for example if it is readonly), this will error in a very baffling way with a very confusing message:
```
rename /tmp/TestBrokenCredentialsStore705218110/008/docker-config2430087685/config.json2911426040 doesnotexist: invalid cross-device link
```
First spotted in https://github.com/containerd/nerdctl/pull/3293#pullrequestreview-2231972713 although at the time I was unable to diagnose it.
While this is very likely a docker bug, we need to fix these tests to deal with that.
### Steps to reproduce the issue
_No response_
### Describe the results you received and expected
na
### What version of nerdctl are you using?
main
### Are you using a variant of nerdctl? (e.g., Rancher Desktop)
None
### Host information
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.