Skip to content

Commit

Permalink
[PR #5943/53f72973 backport][stable-5] zfs_delegate_admin: fix: zfs a…
Browse files Browse the repository at this point in the history
…llow cannot parse unknown uid/gid (#6085)

zfs_delegate_admin: fix: zfs allow cannot parse unknown uid/gid (#5943)

When setting allow permissions for particular users or groups
there will be circumstances when that user is not known to the
host system.

In that case the output of `zfs allow <pool/dataset>`
looks similar to this:

  $ sudo zfs allow tank/test
  ---- Permissions on tank/test ---------------------------------------
  Local+Descendent permissions:
    user (unknown: 1002) hold
    user zfsuser receive

The fix in this commit removes ' (unknown: '+')' from the output
leaving only the uid/gid.

This allows the current parser to continue even if the uid/gid
is not known.

This situation occurs most often when moving a zpool from one system
to another that may not have the same users/groups. Simply adding
permissions to a user/group and then deleting the user/group
from the system will cause this situation to occur.

(cherry picked from commit 53f7297)

Co-authored-by: Phil Kauffman <philip@kauffman.me>
  • Loading branch information
patchback[bot] and papamoose authored Feb 25, 2023
1 parent d96600d commit 5da6dc7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- zfs_delegate_admin - zfs allow output can now be parsed when uids/gids are not known to the host system (https://github.com/ansible-collections/community.general/pull/5943).
3 changes: 3 additions & 0 deletions plugins/modules/storage/zfs/zfs_delegate_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ def current_perms(self):
scope = linemap.get(line, scope)
if not scope:
continue
if ' (unknown: ' in line:
line = line.replace('(unknown: ', '', 1)
line = line.replace(')', '', 1)
try:
if line.startswith('\tuser ') or line.startswith('\tgroup '):
ent_type, ent, cur_perms = line.split()
Expand Down

0 comments on commit 5da6dc7

Please sign in to comment.