From d816c5bd4162c3369cecf0f0b82cd7bb2cd4636b Mon Sep 17 00:00:00 2001 From: clement rouault Date: Fri, 25 Jul 2025 10:30:34 +0200 Subject: [PATCH 1/4] modules/capabilities.py: fail & propagate if getcap command error --- plugins/modules/capabilities.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/modules/capabilities.py b/plugins/modules/capabilities.py index b3143df0a4..91f2c5527b 100644 --- a/plugins/modules/capabilities.py +++ b/plugins/modules/capabilities.py @@ -123,6 +123,8 @@ class CapabilitiesModule(object): if ' =' in stdout: # process output of an older version of libcap caps = stdout.split(' =')[1].strip().split() + elif stdout.strip().endswith(")"): # '/foo (Error Message)' + self.module.fail_json(msg="Unable to get capabilities of %s" % path, stdout=stdout.strip(), stderr=stderr) else: # otherwise, we have a newer version here # see original commit message of cap/v0.2.40-18-g177cd41 in libcap.git From 71fdd56c146ad6aa559be0c4036df5ad0c463a54 Mon Sep 17 00:00:00 2001 From: clement rouault Date: Fri, 25 Jul 2025 10:58:40 +0200 Subject: [PATCH 2/4] Fix comment spacing (pep8) --- plugins/modules/capabilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/capabilities.py b/plugins/modules/capabilities.py index 91f2c5527b..08bd2e85ff 100644 --- a/plugins/modules/capabilities.py +++ b/plugins/modules/capabilities.py @@ -123,7 +123,7 @@ class CapabilitiesModule(object): if ' =' in stdout: # process output of an older version of libcap caps = stdout.split(' =')[1].strip().split() - elif stdout.strip().endswith(")"): # '/foo (Error Message)' + elif stdout.strip().endswith(")"): # '/foo (Error Message)' self.module.fail_json(msg="Unable to get capabilities of %s" % path, stdout=stdout.strip(), stderr=stderr) else: # otherwise, we have a newer version here From 20f1a79907a31d52bc13212b3d2d7b8bce44d591 Mon Sep 17 00:00:00 2001 From: clement rouault Date: Sun, 27 Jul 2025 19:49:14 +0200 Subject: [PATCH 3/4] Add changelogs fragment for PR 10455 --- .../fragments/10455-capabilities-improve-error-detection.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/10455-capabilities-improve-error-detection.yml diff --git a/changelogs/fragments/10455-capabilities-improve-error-detection.yml b/changelogs/fragments/10455-capabilities-improve-error-detection.yml new file mode 100644 index 0000000000..44d742a29f --- /dev/null +++ b/changelogs/fragments/10455-capabilities-improve-error-detection.yml @@ -0,0 +1,2 @@ +bugfixes: + - capabilities - Using invalid path (symlink/directory/...) would return unrelated and incoherent error messages (https://github.com/ansible-collections/community.general/issues/5649) \ No newline at end of file From 6193caad66a9636016a8281acb4f2dd3e9bad584 Mon Sep 17 00:00:00 2001 From: hakril Date: Sun, 27 Jul 2025 21:00:26 +0200 Subject: [PATCH 4/4] Update changelogs/fragments/10455-capabilities-improve-error-detection.yml Co-authored-by: Felix Fontein --- .../fragments/10455-capabilities-improve-error-detection.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/10455-capabilities-improve-error-detection.yml b/changelogs/fragments/10455-capabilities-improve-error-detection.yml index 44d742a29f..40337a424b 100644 --- a/changelogs/fragments/10455-capabilities-improve-error-detection.yml +++ b/changelogs/fragments/10455-capabilities-improve-error-detection.yml @@ -1,2 +1,2 @@ bugfixes: - - capabilities - Using invalid path (symlink/directory/...) would return unrelated and incoherent error messages (https://github.com/ansible-collections/community.general/issues/5649) \ No newline at end of file + - capabilities - using invalid path (symlink/directory/...) returned unrelated and incoherent error messages (https://github.com/ansible-collections/community.general/issues/5649, https://github.com/ansible-collections/community.general/pull/10455). \ No newline at end of file