mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-23 06:31:58 +00:00
s/numeric_owner/numeric_ids/g
This commit is contained in:
parent
251ce11fd8
commit
6f9b9e5a53
9 changed files with 70 additions and 70 deletions
|
@ -397,7 +397,7 @@ class IncompatibleFilesystemEncodingError(Error):
|
|||
"""Failed to encode filename "{}" into file system encoding "{}". Consider configuring the LANG environment variable."""
|
||||
|
||||
def __init__(self, repository, key, manifest, name, cache=None, create=False,
|
||||
checkpoint_interval=1800, numeric_owner=False, noatime=False, noctime=False,
|
||||
checkpoint_interval=1800, numeric_ids=False, noatime=False, noctime=False,
|
||||
noflags=False, noacls=False, noxattrs=False,
|
||||
progress=False, chunker_params=CHUNKER_PARAMS, start=None, start_monotonic=None, end=None,
|
||||
consider_part_files=False, log_json=False):
|
||||
|
@ -413,7 +413,7 @@ def __init__(self, repository, key, manifest, name, cache=None, create=False,
|
|||
self.name_in_manifest = name # can differ from .name later (if borg check fixed duplicate archive names)
|
||||
self.comment = None
|
||||
self.checkpoint_interval = checkpoint_interval
|
||||
self.numeric_owner = numeric_owner
|
||||
self.numeric_ids = numeric_ids
|
||||
self.noatime = noatime
|
||||
self.noctime = noctime
|
||||
self.noflags = noflags
|
||||
|
@ -827,7 +827,7 @@ def restore_attrs(self, path, item, symlink=False, fd=None):
|
|||
Does not access the repository.
|
||||
"""
|
||||
backup_io.op = 'attrs'
|
||||
uid, gid = get_item_uid_gid(item, numeric=self.numeric_owner)
|
||||
uid, gid = get_item_uid_gid(item, numeric=self.numeric_ids)
|
||||
# This code is a bit of a mess due to os specific differences
|
||||
if not is_win32:
|
||||
try:
|
||||
|
@ -870,7 +870,7 @@ def restore_attrs(self, path, item, symlink=False, fd=None):
|
|||
# some systems don't support calling utime on a symlink
|
||||
pass
|
||||
if not self.noacls:
|
||||
acl_set(path, item, self.numeric_owner, fd=fd)
|
||||
acl_set(path, item, self.numeric_ids, fd=fd)
|
||||
if not self.noxattrs:
|
||||
# chown removes Linux capabilities, so set the extended attributes at the end, after chown, since they include
|
||||
# the Linux capabilities in the "security.capability" attribute.
|
||||
|
@ -1057,10 +1057,10 @@ def defer_if_necessary(item1, item2):
|
|||
|
||||
|
||||
class MetadataCollector:
|
||||
def __init__(self, *, noatime, noctime, nobirthtime, numeric_owner, noflags, noacls, noxattrs):
|
||||
def __init__(self, *, noatime, noctime, nobirthtime, numeric_ids, noflags, noacls, noxattrs):
|
||||
self.noatime = noatime
|
||||
self.noctime = noctime
|
||||
self.numeric_owner = numeric_owner
|
||||
self.numeric_ids = numeric_ids
|
||||
self.noflags = noflags
|
||||
self.noacls = noacls
|
||||
self.noxattrs = noxattrs
|
||||
|
@ -1083,7 +1083,7 @@ def stat_simple_attrs(self, st):
|
|||
if not self.nobirthtime and hasattr(st, 'st_birthtime'):
|
||||
# sadly, there's no stat_result.st_birthtime_ns
|
||||
attrs['birthtime'] = safe_ns(int(st.st_birthtime * 10**9))
|
||||
if self.numeric_owner:
|
||||
if self.numeric_ids:
|
||||
attrs['user'] = attrs['group'] = None
|
||||
else:
|
||||
attrs['user'] = uid2user(st.st_uid)
|
||||
|
@ -1096,7 +1096,7 @@ def stat_ext_attrs(self, st, path, fd=None):
|
|||
flags = 0 if self.noflags else get_flags(path, st, fd=fd)
|
||||
xattrs = {} if self.noxattrs else xattr.get_all(fd or path, follow_symlinks=False)
|
||||
if not self.noacls:
|
||||
acl_get(path, attrs, st, self.numeric_owner, fd=fd)
|
||||
acl_get(path, attrs, st, self.numeric_ids, fd=fd)
|
||||
if xattrs:
|
||||
attrs['xattrs'] = StableDict(xattrs)
|
||||
if flags:
|
||||
|
|
|
@ -187,7 +187,7 @@ def with_archive(method):
|
|||
@functools.wraps(method)
|
||||
def wrapper(self, args, repository, key, manifest, **kwargs):
|
||||
archive = Archive(repository, key, manifest, args.location.archive,
|
||||
numeric_owner=getattr(args, 'numeric_owner', False),
|
||||
numeric_ids=getattr(args, 'numeric_ids', False),
|
||||
noflags=getattr(args, 'nobsdflags', False) or getattr(args, 'noflags', False),
|
||||
noacls=getattr(args, 'noacls', False),
|
||||
noxattrs=getattr(args, 'noxattrs', False),
|
||||
|
@ -650,13 +650,13 @@ def create_inner(archive, cache, fso):
|
|||
cache_mode=args.files_cache_mode) as cache:
|
||||
archive = Archive(repository, key, manifest, args.location.archive, cache=cache,
|
||||
create=True, checkpoint_interval=args.checkpoint_interval,
|
||||
numeric_owner=args.numeric_owner, noatime=not args.atime, noctime=args.noctime,
|
||||
numeric_ids=args.numeric_ids, noatime=not args.atime, noctime=args.noctime,
|
||||
progress=args.progress,
|
||||
chunker_params=args.chunker_params, start=t0, start_monotonic=t0_monotonic,
|
||||
log_json=args.log_json)
|
||||
metadata_collector = MetadataCollector(noatime=not args.atime, noctime=args.noctime,
|
||||
noflags=args.nobsdflags or args.noflags, noacls=args.noacls, noxattrs=args.noxattrs,
|
||||
numeric_owner=args.numeric_owner, nobirthtime=args.nobirthtime)
|
||||
numeric_ids=args.numeric_ids, nobirthtime=args.nobirthtime)
|
||||
cp = ChunksProcessor(cache=cache, key=key,
|
||||
add_item=archive.add_item, write_checkpoint=archive.write_checkpoint,
|
||||
checkpoint_interval=args.checkpoint_interval, rechunkify=False)
|
||||
|
@ -2828,9 +2828,9 @@ def define_borg_mount(parser):
|
|||
help='stay in foreground, do not daemonize')
|
||||
parser.add_argument('-o', dest='options', type=str,
|
||||
help='Extra mount options')
|
||||
parser.add_argument('--numeric-owner', dest='numeric_owner', action='store_true',
|
||||
parser.add_argument('--numeric-owner', dest='numeric_ids', action='store_true',
|
||||
help='deprecated, use ``--numeric-ids`` instead')
|
||||
parser.add_argument('--numeric-ids', dest='numeric_owner', action='store_true',
|
||||
parser.add_argument('--numeric-ids', dest='numeric_ids', action='store_true',
|
||||
help='use numeric user and group identifiers from archive(s)')
|
||||
define_archive_filters_group(parser)
|
||||
parser.add_argument('paths', metavar='PATH', nargs='*', type=str,
|
||||
|
@ -3381,9 +3381,9 @@ def define_borg_mount(parser):
|
|||
fs_group = subparser.add_argument_group('Filesystem options')
|
||||
fs_group.add_argument('-x', '--one-file-system', dest='one_file_system', action='store_true',
|
||||
help='stay in the same file system and do not store mount points of other file systems. This might behave different from your expectations, see the docs.')
|
||||
fs_group.add_argument('--numeric-owner', dest='numeric_owner', action='store_true',
|
||||
fs_group.add_argument('--numeric-owner', dest='numeric_ids', action='store_true',
|
||||
help='deprecated, use ``--numeric-ids`` instead')
|
||||
fs_group.add_argument('--numeric-ids', dest='numeric_owner', action='store_true',
|
||||
fs_group.add_argument('--numeric-ids', dest='numeric_ids', action='store_true',
|
||||
help='only store numeric user and group identifiers')
|
||||
# --noatime is the default now and the flag is deprecated. args.noatime is not used any more.
|
||||
# use --atime if you want to store the atime (default behaviour before borg 1.2.0a7)..
|
||||
|
@ -3713,9 +3713,9 @@ def define_borg_mount(parser):
|
|||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
help='find differences in archive contents')
|
||||
subparser.set_defaults(func=self.do_diff)
|
||||
subparser.add_argument('--numeric-owner', dest='numeric_owner', action='store_true',
|
||||
subparser.add_argument('--numeric-owner', dest='numeric_ids', action='store_true',
|
||||
help='deprecated, use ``--numeric-ids`` instead')
|
||||
subparser.add_argument('--numeric-ids', dest='numeric_owner', action='store_true',
|
||||
subparser.add_argument('--numeric-ids', dest='numeric_ids', action='store_true',
|
||||
help='only consider numeric user and group identifiers')
|
||||
subparser.add_argument('--same-chunker-params', dest='same_chunker_params', action='store_true',
|
||||
help='Override check of chunker parameters.')
|
||||
|
@ -3819,9 +3819,9 @@ def define_borg_mount(parser):
|
|||
help='output verbose list of items (files, dirs, ...)')
|
||||
subparser.add_argument('-n', '--dry-run', dest='dry_run', action='store_true',
|
||||
help='do not actually change any files')
|
||||
subparser.add_argument('--numeric-owner', dest='numeric_owner', action='store_true',
|
||||
subparser.add_argument('--numeric-owner', dest='numeric_ids', action='store_true',
|
||||
help='deprecated, use ``--numeric-ids`` instead')
|
||||
subparser.add_argument('--numeric-ids', dest='numeric_owner', action='store_true',
|
||||
subparser.add_argument('--numeric-ids', dest='numeric_ids', action='store_true',
|
||||
help='only obey numeric user and group identifiers')
|
||||
subparser.add_argument('--nobsdflags', dest='nobsdflags', action='store_true',
|
||||
help='deprecated, use ``--noflags`` instead')
|
||||
|
|
|
@ -241,7 +241,7 @@ class FuseBackend(object):
|
|||
def __init__(self, key, manifest, repository, args, decrypted_repository):
|
||||
self.repository_uncached = repository
|
||||
self._args = args
|
||||
self.numeric_owner = args.numeric_owner
|
||||
self.numeric_ids = args.numeric_ids
|
||||
self._manifest = manifest
|
||||
self.key = key
|
||||
# Maps inode numbers to Item instances. This is used for synthetic inodes, i.e. file-system objects that are
|
||||
|
@ -588,7 +588,7 @@ def _getattr(self, inode, ctx=None):
|
|||
entry.attr_timeout = 300
|
||||
entry.st_mode = item.mode & ~self.umask
|
||||
entry.st_nlink = item.get('nlink', 1)
|
||||
entry.st_uid, entry.st_gid = get_item_uid_gid(item, numeric=self.numeric_owner,
|
||||
entry.st_uid, entry.st_gid = get_item_uid_gid(item, numeric=self.numeric_ids,
|
||||
uid_default=self.default_uid, gid_default=self.default_gid,
|
||||
uid_forced=self.uid_forced, gid_forced=self.gid_forced)
|
||||
entry.st_rdev = item.get('rdev', 0)
|
||||
|
|
|
@ -412,10 +412,10 @@ class ItemDiff:
|
|||
It does not include extended or time attributes in the comparison.
|
||||
"""
|
||||
|
||||
def __init__(self, item1, item2, chunk_iterator1, chunk_iterator2, numeric_owner=False, can_compare_chunk_ids=False):
|
||||
def __init__(self, item1, item2, chunk_iterator1, chunk_iterator2, numeric_ids=False, can_compare_chunk_ids=False):
|
||||
self._item1 = item1
|
||||
self._item2 = item2
|
||||
self._numeric_owner = numeric_owner
|
||||
self._numeric_ids = numeric_ids
|
||||
self._can_compare_chunk_ids = can_compare_chunk_ids
|
||||
self.equal = self._equal(chunk_iterator1, chunk_iterator2)
|
||||
changes = []
|
||||
|
@ -450,7 +450,7 @@ class ItemDiff:
|
|||
return True
|
||||
|
||||
attr_list = ['deleted', 'mode', 'source']
|
||||
attr_list += ['uid', 'gid'] if self._numeric_owner else ['user', 'group']
|
||||
attr_list += ['uid', 'gid'] if self._numeric_ids else ['user', 'group']
|
||||
for attr in attr_list:
|
||||
if self._item1.get(attr) != self._item2.get(attr):
|
||||
return False
|
||||
|
@ -499,7 +499,7 @@ class ItemDiff:
|
|||
return ({"type": 'added directory'}, 'added directory')
|
||||
|
||||
def _owner_diff(self):
|
||||
u_attr, g_attr = ('uid', 'gid') if self._numeric_owner else ('user', 'group')
|
||||
u_attr, g_attr = ('uid', 'gid') if self._numeric_ids else ('user', 'group')
|
||||
u1, g1 = self._item1.get(u_attr), self._item1.get(g_attr)
|
||||
u2, g2 = self._item2.get(u_attr), self._item2.get(g_attr)
|
||||
if (u1, g1) != (u2, g2):
|
||||
|
|
|
@ -62,19 +62,19 @@ def setxattr(path, name, value, *, follow_symlinks=False):
|
|||
"""
|
||||
|
||||
|
||||
def acl_get(path, item, st, numeric_owner=False, fd=None):
|
||||
def acl_get(path, item, st, numeric_ids=False, fd=None):
|
||||
"""
|
||||
Saves ACL Entries
|
||||
|
||||
If `numeric_owner` is True the user/group field is not preserved only uid/gid
|
||||
If `numeric_ids` is True the user/group field is not preserved only uid/gid
|
||||
"""
|
||||
|
||||
|
||||
def acl_set(path, item, numeric_owner=False, fd=None):
|
||||
def acl_set(path, item, numeric_ids=False, fd=None):
|
||||
"""
|
||||
Restore ACL Entries
|
||||
|
||||
If `numeric_owner` is True the stored uid/gid is used instead
|
||||
If `numeric_ids` is True the stored uid/gid is used instead
|
||||
of the user/group names
|
||||
"""
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ def _remove_non_numeric_identifier(acl):
|
|||
return safe_encode('\n'.join(entries))
|
||||
|
||||
|
||||
def acl_get(path, item, st, numeric_owner=False, fd=None):
|
||||
def acl_get(path, item, st, numeric_ids=False, fd=None):
|
||||
cdef acl_t acl = NULL
|
||||
cdef char *text = NULL
|
||||
if isinstance(path, str):
|
||||
|
@ -125,7 +125,7 @@ def acl_get(path, item, st, numeric_owner=False, fd=None):
|
|||
text = acl_to_text(acl, NULL)
|
||||
if text == NULL:
|
||||
return
|
||||
if numeric_owner:
|
||||
if numeric_ids:
|
||||
item['acl_extended'] = _remove_non_numeric_identifier(text)
|
||||
else:
|
||||
item['acl_extended'] = text
|
||||
|
@ -134,12 +134,12 @@ def acl_get(path, item, st, numeric_owner=False, fd=None):
|
|||
acl_free(acl)
|
||||
|
||||
|
||||
def acl_set(path, item, numeric_owner=False, fd=None):
|
||||
def acl_set(path, item, numeric_ids=False, fd=None):
|
||||
cdef acl_t acl = NULL
|
||||
acl_text = item.get('acl_extended')
|
||||
if acl_text is not None:
|
||||
try:
|
||||
if numeric_owner:
|
||||
if numeric_ids:
|
||||
acl = acl_from_text(acl_text)
|
||||
else:
|
||||
acl = acl_from_text(<bytes>_remove_numeric_id_if_possible(acl_text))
|
||||
|
|
|
@ -120,10 +120,10 @@ cdef _get_acl(p, type, item, attribute, flags, fd=None):
|
|||
acl_free(acl)
|
||||
|
||||
|
||||
def acl_get(path, item, st, numeric_owner=False, fd=None):
|
||||
def acl_get(path, item, st, numeric_ids=False, fd=None):
|
||||
"""Saves ACL Entries
|
||||
|
||||
If `numeric_owner` is True the user/group field is not preserved only uid/gid
|
||||
If `numeric_ids` is True the user/group field is not preserved only uid/gid
|
||||
"""
|
||||
cdef int flags = ACL_TEXT_APPEND_ID
|
||||
if isinstance(path, str):
|
||||
|
@ -131,7 +131,7 @@ def acl_get(path, item, st, numeric_owner=False, fd=None):
|
|||
ret = lpathconf(path, _PC_ACL_NFS4)
|
||||
if ret < 0 and errno == EINVAL:
|
||||
return
|
||||
flags |= ACL_TEXT_NUMERIC_IDS if numeric_owner else 0
|
||||
flags |= ACL_TEXT_NUMERIC_IDS if numeric_ids else 0
|
||||
if ret > 0:
|
||||
_get_acl(path, ACL_TYPE_NFS4, item, 'acl_nfs4', flags, fd=fd)
|
||||
else:
|
||||
|
@ -139,13 +139,13 @@ def acl_get(path, item, st, numeric_owner=False, fd=None):
|
|||
_get_acl(path, ACL_TYPE_DEFAULT, item, 'acl_default', flags, fd=fd)
|
||||
|
||||
|
||||
cdef _set_acl(p, type, item, attribute, numeric_owner=False, fd=None):
|
||||
cdef _set_acl(p, type, item, attribute, numeric_ids=False, fd=None):
|
||||
cdef acl_t acl
|
||||
text = item.get(attribute)
|
||||
if text:
|
||||
if numeric_owner and type == ACL_TYPE_NFS4:
|
||||
if numeric_ids and type == ACL_TYPE_NFS4:
|
||||
text = _nfs4_use_stored_uid_gid(text)
|
||||
elif numeric_owner and type in(ACL_TYPE_ACCESS, ACL_TYPE_DEFAULT):
|
||||
elif numeric_ids and type in(ACL_TYPE_ACCESS, ACL_TYPE_DEFAULT):
|
||||
text = posix_acl_use_stored_uid_gid(text)
|
||||
acl = acl_from_text(<bytes>text)
|
||||
if acl:
|
||||
|
@ -170,14 +170,14 @@ cdef _nfs4_use_stored_uid_gid(acl):
|
|||
return safe_encode('\n'.join(entries))
|
||||
|
||||
|
||||
def acl_set(path, item, numeric_owner=False, fd=None):
|
||||
def acl_set(path, item, numeric_ids=False, fd=None):
|
||||
"""Restore ACL Entries
|
||||
|
||||
If `numeric_owner` is True the stored uid/gid is used instead
|
||||
If `numeric_ids` is True the stored uid/gid is used instead
|
||||
of the user/group names
|
||||
"""
|
||||
if isinstance(path, str):
|
||||
path = os.fsencode(path)
|
||||
_set_acl(path, ACL_TYPE_NFS4, item, 'acl_nfs4', numeric_owner, fd=fd)
|
||||
_set_acl(path, ACL_TYPE_ACCESS, item, 'acl_access', numeric_owner, fd=fd)
|
||||
_set_acl(path, ACL_TYPE_DEFAULT, item, 'acl_default', numeric_owner, fd=fd)
|
||||
_set_acl(path, ACL_TYPE_NFS4, item, 'acl_nfs4', numeric_ids, fd=fd)
|
||||
_set_acl(path, ACL_TYPE_ACCESS, item, 'acl_access', numeric_ids, fd=fd)
|
||||
_set_acl(path, ACL_TYPE_DEFAULT, item, 'acl_default', numeric_ids, fd=fd)
|
||||
|
|
|
@ -227,7 +227,7 @@ cdef acl_numeric_ids(acl):
|
|||
return safe_encode('\n'.join(entries))
|
||||
|
||||
|
||||
def acl_get(path, item, st, numeric_owner=False, fd=None):
|
||||
def acl_get(path, item, st, numeric_ids=False, fd=None):
|
||||
cdef acl_t default_acl = NULL
|
||||
cdef acl_t access_acl = NULL
|
||||
cdef char *default_text = NULL
|
||||
|
@ -242,7 +242,7 @@ def acl_get(path, item, st, numeric_owner=False, fd=None):
|
|||
or
|
||||
fd is None and acl_extended_file(path) <= 0):
|
||||
return
|
||||
if numeric_owner:
|
||||
if numeric_ids:
|
||||
converter = acl_numeric_ids
|
||||
else:
|
||||
converter = acl_append_numeric_ids
|
||||
|
@ -269,7 +269,7 @@ def acl_get(path, item, st, numeric_owner=False, fd=None):
|
|||
acl_free(access_acl)
|
||||
|
||||
|
||||
def acl_set(path, item, numeric_owner=False, fd=None):
|
||||
def acl_set(path, item, numeric_ids=False, fd=None):
|
||||
cdef acl_t access_acl = NULL
|
||||
cdef acl_t default_acl = NULL
|
||||
|
||||
|
@ -279,7 +279,7 @@ def acl_set(path, item, numeric_owner=False, fd=None):
|
|||
|
||||
if fd is None and isinstance(path, str):
|
||||
path = os.fsencode(path)
|
||||
if numeric_owner:
|
||||
if numeric_ids:
|
||||
converter = posix_acl_use_stored_uid_gid
|
||||
else:
|
||||
converter = acl_use_local_uid_gid
|
||||
|
|
|
@ -81,25 +81,25 @@ def setUp(self):
|
|||
def tearDown(self):
|
||||
shutil.rmtree(self.tmpdir)
|
||||
|
||||
def get_acl(self, path, numeric_owner=False):
|
||||
def get_acl(self, path, numeric_ids=False):
|
||||
item = {}
|
||||
acl_get(path, item, os.stat(path), numeric_owner=numeric_owner)
|
||||
acl_get(path, item, os.stat(path), numeric_ids=numeric_ids)
|
||||
return item
|
||||
|
||||
def set_acl(self, path, access=None, default=None, numeric_owner=False):
|
||||
def set_acl(self, path, access=None, default=None, numeric_ids=False):
|
||||
item = {'acl_access': access, 'acl_default': default}
|
||||
acl_set(path, item, numeric_owner=numeric_owner)
|
||||
acl_set(path, item, numeric_ids=numeric_ids)
|
||||
|
||||
@unittest.skipIf(not are_acls_working(), 'ACLs do not work')
|
||||
def test_access_acl(self):
|
||||
file = tempfile.NamedTemporaryFile()
|
||||
self.assert_equal(self.get_acl(file.name), {})
|
||||
self.set_acl(file.name, access=b'user::rw-\ngroup::r--\nmask::rw-\nother::---\nuser:root:rw-:9999\ngroup:root:rw-:9999\n', numeric_owner=False)
|
||||
self.set_acl(file.name, access=b'user::rw-\ngroup::r--\nmask::rw-\nother::---\nuser:root:rw-:9999\ngroup:root:rw-:9999\n', numeric_ids=False)
|
||||
self.assert_in(b'user:root:rw-:0', self.get_acl(file.name)['acl_access'])
|
||||
self.assert_in(b'group:root:rw-:0', self.get_acl(file.name)['acl_access'])
|
||||
self.assert_in(b'user:0:rw-:0', self.get_acl(file.name, numeric_owner=True)['acl_access'])
|
||||
self.assert_in(b'user:0:rw-:0', self.get_acl(file.name, numeric_ids=True)['acl_access'])
|
||||
file2 = tempfile.NamedTemporaryFile()
|
||||
self.set_acl(file2.name, access=b'user::rw-\ngroup::r--\nmask::rw-\nother::---\nuser:root:rw-:9999\ngroup:root:rw-:9999\n', numeric_owner=True)
|
||||
self.set_acl(file2.name, access=b'user::rw-\ngroup::r--\nmask::rw-\nother::---\nuser:root:rw-:9999\ngroup:root:rw-:9999\n', numeric_ids=True)
|
||||
self.assert_in(b'user:9999:rw-:9999', self.get_acl(file2.name)['acl_access'])
|
||||
self.assert_in(b'group:9999:rw-:9999', self.get_acl(file2.name)['acl_access'])
|
||||
|
||||
|
@ -125,19 +125,19 @@ def test_non_ascii_acl(self):
|
|||
group_entry = 'group:übel:rw-:666'.encode('utf-8')
|
||||
group_entry_numeric = 'group:666:rw-:666'.encode('ascii')
|
||||
acl = b'\n'.join([nothing_special, user_entry, group_entry])
|
||||
self.set_acl(file.name, access=acl, numeric_owner=False)
|
||||
acl_access = self.get_acl(file.name, numeric_owner=False)['acl_access']
|
||||
self.set_acl(file.name, access=acl, numeric_ids=False)
|
||||
acl_access = self.get_acl(file.name, numeric_ids=False)['acl_access']
|
||||
self.assert_in(user_entry, acl_access)
|
||||
self.assert_in(group_entry, acl_access)
|
||||
acl_access_numeric = self.get_acl(file.name, numeric_owner=True)['acl_access']
|
||||
acl_access_numeric = self.get_acl(file.name, numeric_ids=True)['acl_access']
|
||||
self.assert_in(user_entry_numeric, acl_access_numeric)
|
||||
self.assert_in(group_entry_numeric, acl_access_numeric)
|
||||
file2 = tempfile.NamedTemporaryFile()
|
||||
self.set_acl(file2.name, access=acl, numeric_owner=True)
|
||||
acl_access = self.get_acl(file2.name, numeric_owner=False)['acl_access']
|
||||
self.set_acl(file2.name, access=acl, numeric_ids=True)
|
||||
acl_access = self.get_acl(file2.name, numeric_ids=False)['acl_access']
|
||||
self.assert_in(user_entry, acl_access)
|
||||
self.assert_in(group_entry, acl_access)
|
||||
acl_access_numeric = self.get_acl(file.name, numeric_owner=True)['acl_access']
|
||||
acl_access_numeric = self.get_acl(file.name, numeric_ids=True)['acl_access']
|
||||
self.assert_in(user_entry_numeric, acl_access_numeric)
|
||||
self.assert_in(group_entry_numeric, acl_access_numeric)
|
||||
|
||||
|
@ -159,26 +159,26 @@ def setUp(self):
|
|||
def tearDown(self):
|
||||
shutil.rmtree(self.tmpdir)
|
||||
|
||||
def get_acl(self, path, numeric_owner=False):
|
||||
def get_acl(self, path, numeric_ids=False):
|
||||
item = {}
|
||||
acl_get(path, item, os.stat(path), numeric_owner=numeric_owner)
|
||||
acl_get(path, item, os.stat(path), numeric_ids=numeric_ids)
|
||||
return item
|
||||
|
||||
def set_acl(self, path, acl, numeric_owner=False):
|
||||
def set_acl(self, path, acl, numeric_ids=False):
|
||||
item = {'acl_extended': acl}
|
||||
acl_set(path, item, numeric_owner=numeric_owner)
|
||||
acl_set(path, item, numeric_ids=numeric_ids)
|
||||
|
||||
@unittest.skipIf(not are_acls_working(), 'ACLs do not work')
|
||||
def test_access_acl(self):
|
||||
file = tempfile.NamedTemporaryFile()
|
||||
file2 = tempfile.NamedTemporaryFile()
|
||||
self.assert_equal(self.get_acl(file.name), {})
|
||||
self.set_acl(file.name, b'!#acl 1\ngroup:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000000:staff:0:allow:read\nuser:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000:root:0:allow:read\n', numeric_owner=False)
|
||||
self.set_acl(file.name, b'!#acl 1\ngroup:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000000:staff:0:allow:read\nuser:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000:root:0:allow:read\n', numeric_ids=False)
|
||||
self.assert_in(b'group:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000014:staff:20:allow:read', self.get_acl(file.name)['acl_extended'])
|
||||
self.assert_in(b'user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000:root:0:allow:read', self.get_acl(file.name)['acl_extended'])
|
||||
self.set_acl(file2.name, b'!#acl 1\ngroup:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000000:staff:0:allow:read\nuser:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000:root:0:allow:read\n', numeric_owner=True)
|
||||
self.set_acl(file2.name, b'!#acl 1\ngroup:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000000:staff:0:allow:read\nuser:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000:root:0:allow:read\n', numeric_ids=True)
|
||||
self.assert_in(b'group:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000000:wheel:0:allow:read', self.get_acl(file2.name)['acl_extended'])
|
||||
self.assert_in(b'group:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000000::0:allow:read', self.get_acl(file2.name, numeric_owner=True)['acl_extended'])
|
||||
self.assert_in(b'group:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000000::0:allow:read', self.get_acl(file2.name, numeric_ids=True)['acl_extended'])
|
||||
|
||||
|
||||
@unittest.skipUnless(sys.platform.startswith(('linux', 'freebsd', 'darwin')), 'POSIX only tests')
|
||||
|
|
Loading…
Reference in a new issue