Skip to content

Commit c9ee022

Browse files
authored
Merge pull request #1902 from docker/3.0.1-release
3.0.1 release
2 parents 91bc75c + 8649f48 commit c9ee022

File tree

6 files changed

+59
-9
lines changed

6 files changed

+59
-9
lines changed

docker/api/daemon.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def login(self, username, password=None, email=None, registry=None,
139139
if response.status_code == 200:
140140
if 'auths' not in self._auth_configs:
141141
self._auth_configs['auths'] = {}
142-
self._auth_configs[registry or auth.INDEX_NAME] = req_data
142+
self._auth_configs['auths'][registry or auth.INDEX_NAME] = req_data
143143
return self._result(response, json=True)
144144

145145
def ping(self):

docker/utils/utils.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,16 @@ def create_archive(root, files=None, fileobj=None, gzip=False):
9797
for path in files:
9898
full_path = os.path.join(root, path)
9999

100-
if os.lstat(full_path).st_mode & os.R_OK == 0:
101-
raise IOError(
102-
'Can not access file in context: {}'.format(full_path)
103-
)
104100
i = t.gettarinfo(full_path, arcname=path)
105101
if i is None:
106102
# This happens when we encounter a socket file. We can safely
107103
# ignore it and proceed.
108104
continue
109105

106+
# Workaround https://bugs.python.org/issue32713
107+
if i.mtime < 0 or i.mtime > 8**11 - 1:
108+
i.mtime = int(i.mtime)
109+
110110
if constants.IS_WINDOWS_PLATFORM:
111111
# Windows doesn't keep track of the execute bit, so we make files
112112
# and directories executable by default.
@@ -117,7 +117,9 @@ def create_archive(root, files=None, fileobj=None, gzip=False):
117117
with open(full_path, 'rb') as f:
118118
t.addfile(i, f)
119119
except IOError:
120-
t.addfile(i, None)
120+
raise IOError(
121+
'Can not read file in context: {}'.format(full_path)
122+
)
121123
else:
122124
# Directories, FIFOs, symlinks... don't need to be read.
123125
t.addfile(i, None)

docker/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = "3.0.0"
1+
version = "3.0.1"
22
version_info = tuple([int(d) for d in version.split("-")[0].split(".")])

docs/change-log.md

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
Change log
22
==========
33

4+
3.0.1
5+
-----
6+
7+
[List of PRs / issues for this release](https://github.com/docker/docker-py/milestone/43?closed=1)
8+
9+
### Bugfixes
10+
11+
* Fixed a bug where `APIClient.login` didn't populate the `_auth_configs`
12+
dictionary properly, causing subsequent `pull` and `push` operations to fail
13+
* Fixed a bug where some build context files were incorrectly recognized as
14+
being inaccessible.
15+
* Fixed a bug where files with a negative mtime value would
16+
cause errors when included in a build context
17+
418
3.0.0
519
-----
620

tests/unit/api_test.py

+18
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,24 @@ def test_search(self):
212212
timeout=DEFAULT_TIMEOUT_SECONDS
213213
)
214214

215+
def test_login(self):
216+
self.client.login('sakuya', 'izayoi')
217+
fake_request.assert_called_with(
218+
'POST', url_prefix + 'auth',
219+
data=json.dumps({'username': 'sakuya', 'password': 'izayoi'}),
220+
timeout=DEFAULT_TIMEOUT_SECONDS,
221+
headers={'Content-Type': 'application/json'}
222+
)
223+
224+
assert self.client._auth_configs['auths'] == {
225+
'docker.io': {
226+
'email': None,
227+
'password': 'izayoi',
228+
'username': 'sakuya',
229+
'serveraddress': None,
230+
}
231+
}
232+
215233
def test_events(self):
216234
self.client.events()
217235

tests/unit/utils_test.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,10 @@ def test_tar_with_empty_directory(self):
933933
tar_data = tarfile.open(fileobj=archive)
934934
assert sorted(tar_data.getnames()) == ['bar', 'foo']
935935

936-
@pytest.mark.skipif(IS_WINDOWS_PLATFORM, reason='No chmod on Windows')
936+
@pytest.mark.skipif(
937+
IS_WINDOWS_PLATFORM or os.geteuid() == 0,
938+
reason='root user always has access ; no chmod on Windows'
939+
)
937940
def test_tar_with_inaccessible_file(self):
938941
base = tempfile.mkdtemp()
939942
full_path = os.path.join(base, 'foo')
@@ -944,8 +947,9 @@ def test_tar_with_inaccessible_file(self):
944947
with pytest.raises(IOError) as ei:
945948
tar(base)
946949

947-
assert 'Can not access file in context: {}'.format(full_path) in \
950+
assert 'Can not read file in context: {}'.format(full_path) in (
948951
ei.exconly()
952+
)
949953

950954
@pytest.mark.skipif(IS_WINDOWS_PLATFORM, reason='No symlinks on Windows')
951955
def test_tar_with_file_symlinks(self):
@@ -995,6 +999,18 @@ def test_tar_socket_file(self):
995999
tar_data = tarfile.open(fileobj=archive)
9961000
assert sorted(tar_data.getnames()) == ['bar', 'foo']
9971001

1002+
def tar_test_negative_mtime_bug(self):
1003+
base = tempfile.mkdtemp()
1004+
filename = os.path.join(base, 'th.txt')
1005+
self.addCleanup(shutil.rmtree, base)
1006+
with open(filename, 'w') as f:
1007+
f.write('Invisible Full Moon')
1008+
os.utime(filename, (12345, -3600.0))
1009+
with tar(base) as archive:
1010+
tar_data = tarfile.open(fileobj=archive)
1011+
assert tar_data.getnames() == ['th.txt']
1012+
assert tar_data.getmember('th.txt').mtime == -3600
1013+
9981014

9991015
class ShouldCheckDirectoryTest(unittest.TestCase):
10001016
exclude_patterns = [

0 commit comments

Comments
 (0)