From 0de1713b119eeea01add85051f2db1c12b9dd85a Mon Sep 17 00:00:00 2001 From: cos Date: Fri, 19 Apr 2024 11:00:50 +0200 Subject: wip: Fix become_user with FreeBSD Details at https://www.netizen.se/docs/ansible-chmod --- lib/ansible/plugins/action/__init__.py | 3 +++ lib/ansible/plugins/shell/__init__.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 8f92325395..5f83e29a66 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -820,6 +820,9 @@ class ActionBase(ABC): ''' cmd = self._connection._shell.set_user_facl(paths, user, mode) res = self._low_level_execute_command(cmd, sudoable=sudoable) + if res['rc'] != 0: + cmd = self._connection._shell.set_user_facl_nfs(paths, user, mode) + res = self._low_level_execute_command(cmd, sudoable=sudoable) return res def _execute_remote_stat(self, path, all_vars, follow, tmp=None, checksum=True): diff --git a/lib/ansible/plugins/shell/__init__.py b/lib/ansible/plugins/shell/__init__.py index d5db261f68..766d731652 100644 --- a/lib/ansible/plugins/shell/__init__.py +++ b/lib/ansible/plugins/shell/__init__.py @@ -127,6 +127,14 @@ class ShellBase(AnsiblePlugin): return ' '.join(cmd) + def set_user_facl_nfs(self, paths, user, mode): + """Sets nfs acls for users. Should perhaps be in suffix-less function""" + cmd = ['setfacl', '-m', 'u:%s:%s::allow' % (user, mode)] + cmd.extend(paths) + cmd = [shlex.quote(c) for c in cmd] + + return ' '.join(cmd) + def remove(self, path, recurse=False): path = shlex.quote(path) cmd = 'rm -f ' -- cgit v1.2.3