mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* [capabilities] fix for a newer versions of libcap
fixes: #993
* Minor correction for files without caps set.
PS: side note, getcap (per sources) does not set non-zero return code,
even for files which are not found (i.e. wrong filename).
* add changelog fragment
* review/suggested changes
* change comment to explicitly state stderr vs output
(cherry picked from commit 07d123a71a
)
Co-authored-by: Anatoly Pugachev <matorola@gmail.com>
This commit is contained in:
parent
b3cac071fa
commit
22e0fa03b2
2 changed files with 11 additions and 3 deletions
2
changelogs/fragments/993-file-capabilities.yml
Normal file
2
changelogs/fragments/993-file-capabilities.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- capabilities - fix for a newer version of libcap release (https://github.com/ansible-collections/community.general/pull/1061).
|
|
@ -108,12 +108,18 @@ class CapabilitiesModule(object):
|
||||||
# '/foo ='
|
# '/foo ='
|
||||||
# If file xattrs are unset the output will be:
|
# If file xattrs are unset the output will be:
|
||||||
# '/foo'
|
# '/foo'
|
||||||
# If the file does not exist the output will be (with rc == 0...):
|
# If the file does not exist, the stderr will be (with rc == 0...):
|
||||||
# '/foo (No such file or directory)'
|
# '/foo (No such file or directory)'
|
||||||
if rc != 0 or (stdout.strip() != path and stdout.count(' =') != 1):
|
if rc != 0 or stderr != "":
|
||||||
self.module.fail_json(msg="Unable to get capabilities of %s" % path, stdout=stdout.strip(), stderr=stderr)
|
self.module.fail_json(msg="Unable to get capabilities of %s" % path, stdout=stdout.strip(), stderr=stderr)
|
||||||
if stdout.strip() != path:
|
if stdout.strip() != path:
|
||||||
caps = stdout.split(' =')[1].strip().split()
|
if ' =' in stdout:
|
||||||
|
# process output of an older version of libcap
|
||||||
|
caps = stdout.split(' =')[1].strip().split()
|
||||||
|
else:
|
||||||
|
# otherwise, we have a newer version here
|
||||||
|
# see original commit message of cap/v0.2.40-18-g177cd41 in libcap.git
|
||||||
|
caps = stdout.split()[1].strip().split()
|
||||||
for cap in caps:
|
for cap in caps:
|
||||||
cap = cap.lower()
|
cap = cap.lower()
|
||||||
# getcap condenses capabilities with the same op/flags into a
|
# getcap condenses capabilities with the same op/flags into a
|
||||||
|
|
Loading…
Reference in a new issue