-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting ACL entries by user or group name
This adds some logic to allow users to specify `who` in an ACL entry and have backend resolve the name into a numeric ID prior to ACL being written.
- Loading branch information
Showing
4 changed files
with
163 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import os | ||
|
||
from middlewared.test.integration.assets.pool import dataset | ||
from middlewared.test.integration.utils import call | ||
|
||
permset_posix_full = {"READ": True, "WRITE": True, "EXECUTE": True} | ||
permset_nfsv4_full = {"BASIC": "FULL_CONTROL"} | ||
flagset_nfsv4_inherit = {"BASIC": "INHERIT"} | ||
|
||
|
||
def test__posix_by_who(): | ||
with dataset('posix') as ds: | ||
target = os.path.join('/mnt', ds) | ||
the_acl = call('filesystem.getacl', target)['acl'] | ||
the_acl.extend([ | ||
{'tag': 'USER', 'who': 'root', 'perms': permset_posix_full, 'default': False}, | ||
{'tag': 'GROUP', 'who': 'root', 'perms': permset_posix_full, 'default': False}, | ||
]) | ||
|
||
call('filesystem.setacl', {'path': target, 'dacl': the_acl}, job=True) | ||
|
||
new_acl = call('filesystem.getacl', target)['acl'] | ||
saw_user = False | ||
saw_group = False | ||
for entry in new_acl: | ||
if entry['tag'] == 'USER': | ||
assert entry['id'] == 0 | ||
assert entry['perms'] == permset_posix_full | ||
saw_user = True | ||
elif entry['tag'] == 'GROUP': | ||
assert entry['id'] == 0 | ||
assert entry['perms'] == permset_posix_full | ||
saw_group = True | ||
|
||
|
||
assert saw_user, str(new_acl) | ||
assert saw_group, str(new_acl) | ||
|
||
def test__posix_by_who(): | ||
with dataset('posix', data={'share_type': 'SMB'}) as ds: | ||
target = os.path.join('/mnt', ds) | ||
the_acl = call('filesystem.getacl', target)['acl'] | ||
the_acl.extend([ | ||
{'tag': 'USER', 'who': 'root', 'perms': permset_nfsv4_full, 'flags': flagset_nfsv4_inherit, 'type': 'ALLOW'}, | ||
{'tag': 'GROUP', 'who': 'root', 'perms': permset_nfsv4_full, 'flags': flagset_nfsv4_inherit, 'type': 'ALLOW'}, | ||
]) | ||
|
||
call('filesystem.setacl', {'path': target, 'dacl': the_acl}, job=True) | ||
|
||
new_acl = call('filesystem.getacl', target)['acl'] | ||
saw_user = False | ||
saw_group = False | ||
for entry in new_acl: | ||
if entry['tag'] == 'USER': | ||
assert entry['id'] == 0 | ||
assert entry['perms'] == permset_nfsv4_full | ||
saw_user = True | ||
elif entry['tag'] == 'GROUP' and entry['id'] == 0: | ||
assert entry['perms'] == permset_nfsv4_full | ||
saw_group = True | ||
|
||
assert saw_user, str(new_acl) | ||
assert saw_group, str(new_acl) |