mirror of https://github.com/borgbackup/borg.git
acl: Added workaround for old Linux systems
Really old Linux systems do not have extended_file_no_follow()
This commit is contained in:
parent
0741aef880
commit
8f4e0f7506
2
CHANGES
2
CHANGES
|
@ -7,7 +7,7 @@ Version 0.14
|
||||||
------------
|
------------
|
||||||
|
|
||||||
(feature release, released on X)
|
(feature release, released on X)
|
||||||
|
- Add workaround for old Linux systems without acl_extended_file_no_follow (#96)
|
||||||
- Add MacPorts' path to the default openssl search path (#101)
|
- Add MacPorts' path to the default openssl search path (#101)
|
||||||
- HashIndex improvements, eliminates unnecessary IO on low memory systems.
|
- HashIndex improvements, eliminates unnecessary IO on low memory systems.
|
||||||
|
|
||||||
|
|
|
@ -354,7 +354,7 @@ class Archive:
|
||||||
item[b'xattrs'] = StableDict(xattrs)
|
item[b'xattrs'] = StableDict(xattrs)
|
||||||
if has_lchflags and st.st_flags:
|
if has_lchflags and st.st_flags:
|
||||||
item[b'bsdflags'] = st.st_flags
|
item[b'bsdflags'] = st.st_flags
|
||||||
item[b'acl'] = acl_get(path, item, self.numeric_owner)
|
acl_get(path, item, st, self.numeric_owner)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
def process_item(self, path, st):
|
def process_item(self, path, st):
|
||||||
|
|
|
@ -76,7 +76,7 @@ def check_extension_modules():
|
||||||
if (attic.hashindex.API_VERSION != 2 or
|
if (attic.hashindex.API_VERSION != 2 or
|
||||||
attic.chunker.API_VERSION != 1 or
|
attic.chunker.API_VERSION != 1 or
|
||||||
attic.crypto.API_VERSION != 2 or
|
attic.crypto.API_VERSION != 2 or
|
||||||
attic.platform.API_VERSION != 1):
|
attic.platform.API_VERSION != 2):
|
||||||
raise ExtensionModuleError
|
raise ExtensionModuleError
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
from attic.helpers import user2uid, group2gid
|
from attic.helpers import user2uid, group2gid
|
||||||
|
|
||||||
API_VERSION = 1
|
API_VERSION = 2
|
||||||
|
|
||||||
cdef extern from "sys/acl.h":
|
cdef extern from "sys/acl.h":
|
||||||
ctypedef struct _acl_t:
|
ctypedef struct _acl_t:
|
||||||
|
@ -48,7 +48,7 @@ def _remove_non_numeric_identifier(acl):
|
||||||
return b'\n'.join(entries)
|
return b'\n'.join(entries)
|
||||||
|
|
||||||
|
|
||||||
def acl_get(path, item, numeric_owner=False):
|
def acl_get(path, item, st, numeric_owner=False):
|
||||||
cdef acl_t acl = NULL
|
cdef acl_t acl = NULL
|
||||||
cdef char *text = NULL
|
cdef char *text = NULL
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
from attic.helpers import posix_acl_use_stored_uid_gid
|
from attic.helpers import posix_acl_use_stored_uid_gid
|
||||||
|
|
||||||
API_VERSION = 1
|
API_VERSION = 2
|
||||||
|
|
||||||
cdef extern from "errno.h":
|
cdef extern from "errno.h":
|
||||||
int errno
|
int errno
|
||||||
|
@ -42,7 +42,7 @@ cdef _get_acl(p, type, item, attribute, int flags):
|
||||||
acl_free(acl)
|
acl_free(acl)
|
||||||
|
|
||||||
|
|
||||||
def acl_get(path, item, numeric_owner=False):
|
def acl_get(path, item, st, numeric_owner=False):
|
||||||
"""Saves ACL Entries
|
"""Saves ACL Entries
|
||||||
|
|
||||||
If `numeric_owner` is True the user/group field is not preserved only uid/gid
|
If `numeric_owner` is True the user/group field is not preserved only uid/gid
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
from stat import S_ISLNK
|
||||||
from attic.helpers import posix_acl_use_stored_uid_gid, user2uid, group2gid
|
from attic.helpers import posix_acl_use_stored_uid_gid, user2uid, group2gid
|
||||||
|
|
||||||
API_VERSION = 1
|
API_VERSION = 2
|
||||||
|
|
||||||
cdef extern from "sys/types.h":
|
cdef extern from "sys/types.h":
|
||||||
int ACL_TYPE_ACCESS
|
int ACL_TYPE_ACCESS
|
||||||
|
@ -20,7 +21,7 @@ cdef extern from "sys/acl.h":
|
||||||
char *acl_to_text(acl_t acl, ssize_t *len)
|
char *acl_to_text(acl_t acl, ssize_t *len)
|
||||||
|
|
||||||
cdef extern from "acl/libacl.h":
|
cdef extern from "acl/libacl.h":
|
||||||
int acl_extended_file_nofollow(const char *path)
|
int acl_extended_file(const char *path)
|
||||||
|
|
||||||
|
|
||||||
_comment_re = re.compile(' *#.*', re.M)
|
_comment_re = re.compile(' *#.*', re.M)
|
||||||
|
@ -75,7 +76,7 @@ cdef acl_numeric_ids(acl):
|
||||||
return ('\n'.join(entries)).encode('ascii')
|
return ('\n'.join(entries)).encode('ascii')
|
||||||
|
|
||||||
|
|
||||||
def acl_get(path, item, numeric_owner=False):
|
def acl_get(path, item, st, numeric_owner=False):
|
||||||
"""Saves ACL Entries
|
"""Saves ACL Entries
|
||||||
|
|
||||||
If `numeric_owner` is True the user/group field is not preserved only uid/gid
|
If `numeric_owner` is True the user/group field is not preserved only uid/gid
|
||||||
|
@ -85,7 +86,7 @@ def acl_get(path, item, numeric_owner=False):
|
||||||
cdef char *default_text = NULL
|
cdef char *default_text = NULL
|
||||||
cdef char *access_text = NULL
|
cdef char *access_text = NULL
|
||||||
|
|
||||||
if acl_extended_file_nofollow(<bytes>os.fsencode(path)) <= 0:
|
if S_ISLNK(st.st_mode) or acl_extended_file(<bytes>os.fsencode(path)) <= 0:
|
||||||
return
|
return
|
||||||
if numeric_owner:
|
if numeric_owner:
|
||||||
converter = acl_numeric_ids
|
converter = acl_numeric_ids
|
||||||
|
|
|
@ -46,7 +46,7 @@ class PlatformLinuxTestCase(AtticTestCase):
|
||||||
|
|
||||||
def get_acl(self, path, numeric_owner=False):
|
def get_acl(self, path, numeric_owner=False):
|
||||||
item = {}
|
item = {}
|
||||||
acl_get(path, item, numeric_owner=numeric_owner)
|
acl_get(path, item, os.stat(path), numeric_owner=numeric_owner)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
def set_acl(self, path, access=None, default=None, numeric_owner=False):
|
def set_acl(self, path, access=None, default=None, numeric_owner=False):
|
||||||
|
@ -84,7 +84,7 @@ class PlatformDarwinTestCase(AtticTestCase):
|
||||||
|
|
||||||
def get_acl(self, path, numeric_owner=False):
|
def get_acl(self, path, numeric_owner=False):
|
||||||
item = {}
|
item = {}
|
||||||
acl_get(path, item, numeric_owner=numeric_owner)
|
acl_get(path, item, os.stat(path), numeric_owner=numeric_owner)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
def set_acl(self, path, acl, numeric_owner=False):
|
def set_acl(self, path, acl, numeric_owner=False):
|
||||||
|
|
Loading…
Reference in New Issue