diff --git a/attic/archive.py b/attic/archive.py old mode 100644 new mode 100755 index d78ce4b8..7099f5a6 --- a/attic/archive.py +++ b/attic/archive.py @@ -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 diff --git a/attic/platform.py b/attic/platform.py old mode 100644 new mode 100755 index 5e0ec917..af02a54b --- a/attic/platform.py +++ b/attic/platform.py @@ -1,4 +1,7 @@ import os +import subprocess +import io +import logging platform = os.uname()[0] @@ -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 diff --git a/attic/xattr.py b/attic/xattr.py old mode 100644 new mode 100755 index e0061015..04ce588e --- a/attic/xattr.py +++ b/attic/xattr.py @@ -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)