summaryrefslogtreecommitdiff
path: root/docker/utils/utils.py
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-02-05 13:11:19 -0800
committerJoffrey F <joffrey@docker.com>2018-02-05 13:11:19 -0800
commit58639aecfa50e0bcfbd1415dc8bab2b4448f4d81 (patch)
treebd44d3317859f2cdb6bf5b122fd44def1c986caa /docker/utils/utils.py
parent05d34ed1fbaa8233a4cf51a0f52b67aef99a9521 (diff)
downloaddocker-py-1899-create_archive_fix.tar.gz
Rewrite access check in create_archive with EAFP1899-create_archive_fix
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'docker/utils/utils.py')
-rw-r--r--docker/utils/utils.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py
index e4e2c0d..b86a3f0 100644
--- a/docker/utils/utils.py
+++ b/docker/utils/utils.py
@@ -97,10 +97,6 @@ def create_archive(root, files=None, fileobj=None, gzip=False):
for path in files:
full_path = os.path.join(root, path)
- if os.lstat(full_path).st_mode & os.R_OK == 0:
- raise IOError(
- 'Can not access file in context: {}'.format(full_path)
- )
i = t.gettarinfo(full_path, arcname=path)
if i is None:
# This happens when we encounter a socket file. We can safely
@@ -117,7 +113,9 @@ def create_archive(root, files=None, fileobj=None, gzip=False):
with open(full_path, 'rb') as f:
t.addfile(i, f)
except IOError:
- t.addfile(i, None)
+ raise IOError(
+ 'Can not read file in context: {}'.format(full_path)
+ )
else:
# Directories, FIFOs, symlinks... don't need to be read.
t.addfile(i, None)