Skip to content
Open

Win32 #199

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion attic/archive.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ def stat_attrs(self, st, path):
b'mode': st.st_mode,
b'uid': st.st_uid, b'user': uid2user(st.st_uid),
b'gid': st.st_gid, b'group': gid2group(st.st_gid),
b'mtime': int_to_bigint(st_mtime_ns(st))
b'mtime': int_to_bigint(st_mtime_ns(st)),
b'acl_access' : None
}
if self.numeric_owner:
item[b'user'] = item[b'group'] = None
Expand Down
30 changes: 30 additions & 0 deletions attic/platform.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import os
import subprocess
import io
import logging

platform = os.uname()[0]

Expand All @@ -8,6 +11,33 @@
from attic.platform_freebsd import acl_get, acl_set, API_VERSION
elif platform == 'Darwin':
from attic.platform_darwin import acl_get, acl_set, API_VERSION
elif platform.startswith('CYGWIN'):
API_VERSION = 2

def acl_get(path, item, st, numeric_owner=False):
try:
# Using non-numeric names, i.e., group names, has caused problems.
# Hence the -n option
acl_text = subprocess.check_output(['getfacl.exe', '-n', path])
item[b'acl_access'] = acl_text
except CalledProcessError as e:
logging.warning('getfacl.exe failed with error code: ' + e.returncode)

def acl_set(path, item, numeric_owner=False):
try:
acl_access = item[b'acl_access']
except KeyError:
return

buf = io.StringIO(acl_access.decode('utf-8'))

for line in buf:
if len(line.strip()) > 0 and (not line.strip().startswith('#')):
param = ['setfacl.exe', '-m', line.rstrip(), path]
retVal = subprocess.call(param)
if retVal != 0:
raise Exception('ACLs not set successfully')

else:
API_VERSION = 1

Expand Down
2 changes: 1 addition & 1 deletion attic/xattr.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _check(rv, path=None):
raise OSError(get_errno(), path)
return rv

if sys.platform.startswith('linux'):
if sys.platform.startswith('linux') or sys.platform.startswith('cygwin'):
libc.llistxattr.argtypes = (c_char_p, c_char_p, c_size_t)
libc.llistxattr.restype = c_ssize_t
libc.flistxattr.argtypes = (c_int, c_char_p, c_size_t)
Expand Down