summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Wozniski <godlygeek@gmail.com>2019-05-10 06:58:36 -0400
committerAlex Grönholm <alex.gronholm@nextday.fi>2019-05-10 13:58:36 +0300
commit0f2b373f97da29efcd09e467cea67377cd34bb5b (patch)
treed640572c20b344efc9107c2fbcc14351e9bc6017
parent9534258081b4abf3af817dab976bc95ecc4bfa30 (diff)
downloadwheel-git-0f2b373f97da29efcd09e467cea67377cd34bb5b.tar.gz
wheelfile: Mask platform specific mode bits (#292)
When creating zip entries for files and directories, only attempt to preserve the subset of mode bits which can be reapplied through chmod, plus the file type bits. This will exclude any bits that are platform- or filesystem-specific, like S_IFJOURNAL on AIX. Fixes #291.
-rw-r--r--wheel/wheelfile.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/wheel/wheelfile.py b/wheel/wheelfile.py
index 93b4bfa..486e17e 100644
--- a/wheel/wheelfile.py
+++ b/wheel/wheelfile.py
@@ -4,6 +4,7 @@ import csv
import hashlib
import os.path
import re
+import stat
import time
from collections import OrderedDict
from distutils import log as logger
@@ -138,14 +139,14 @@ class WheelFile(ZipFile):
data = f.read()
zinfo = ZipInfo(arcname or filename, date_time=get_zipinfo_datetime(st.st_mtime))
- zinfo.external_attr = st.st_mode << 16
+ zinfo.external_attr = (stat.S_IMODE(st.st_mode) | stat.S_IFMT(st.st_mode)) << 16
zinfo.compress_type = ZIP_DEFLATED
self.writestr(zinfo, data, compress_type)
def mkdir(self, filename, arcname):
st = os.stat(filename)
zinfo = ZipInfo(arcname + '/', date_time=get_zipinfo_datetime(st.st_mtime))
- zinfo.external_attr = st.st_mode << 16
+ zinfo.external_attr = (stat.S_IMODE(st.st_mode) | stat.S_IFMT(st.st_mode)) << 16
zinfo.compress_type = ZIP_DEFLATED
self.writestr(zinfo, b'')