From 7a8505612b49d3073d7312d37aa47bb55f16e489 Mon Sep 17 00:00:00 2001 From: Phil Kauffman Date: Sat, 25 Feb 2023 03:02:28 -0700 Subject: [PATCH] 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 ` 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 53f729730bcc95c75354b11d6ad5f999f883fe9d) --- ...legate_admin-fix-zfs-allow-cannot-parse-unknown-uid-gid.yml | 2 ++ plugins/modules/zfs_delegate_admin.py | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 changelogs/fragments/5943-zfs_delegate_admin-fix-zfs-allow-cannot-parse-unknown-uid-gid.yml diff --git a/changelogs/fragments/5943-zfs_delegate_admin-fix-zfs-allow-cannot-parse-unknown-uid-gid.yml b/changelogs/fragments/5943-zfs_delegate_admin-fix-zfs-allow-cannot-parse-unknown-uid-gid.yml new file mode 100644 index 00000000000..f07ca8a9a58 --- /dev/null +++ b/changelogs/fragments/5943-zfs_delegate_admin-fix-zfs-allow-cannot-parse-unknown-uid-gid.yml @@ -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). diff --git a/plugins/modules/zfs_delegate_admin.py b/plugins/modules/zfs_delegate_admin.py index 7891c32672b..0536f1a2833 100644 --- a/plugins/modules/zfs_delegate_admin.py +++ b/plugins/modules/zfs_delegate_admin.py @@ -184,6 +184,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()