mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-05 05:34:22 -07:00
capabilities: command args as list rather than string (#10524)
* capabilities: command args as list rather than string * add changelog frag
This commit is contained in:
parent
a96684ef40
commit
7e2d91e53d
2 changed files with 4 additions and 2 deletions
2
changelogs/fragments/10524-capabilities-cmd-list.yml
Normal file
2
changelogs/fragments/10524-capabilities-cmd-list.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- capabilities - using safer mechanism to run external command (https://github.com/ansible-collections/community.general/pull/10524).
|
|
@ -109,7 +109,7 @@ class CapabilitiesModule(object):
|
|||
|
||||
def getcap(self, path):
|
||||
rval = []
|
||||
cmd = "%s -v %s" % (self.getcap_cmd, path)
|
||||
cmd = [self.getcap_cmd, "-v", path]
|
||||
rc, stdout, stderr = self.module.run_command(cmd)
|
||||
# If file xattrs are set but no caps are set the output will be:
|
||||
# '/foo ='
|
||||
|
@ -144,7 +144,7 @@ class CapabilitiesModule(object):
|
|||
|
||||
def setcap(self, path, caps):
|
||||
caps = ' '.join([''.join(cap) for cap in caps])
|
||||
cmd = "%s '%s' %s" % (self.setcap_cmd, caps, path)
|
||||
cmd = [self.setcap_cmd, caps, path]
|
||||
rc, stdout, stderr = self.module.run_command(cmd)
|
||||
if rc != 0:
|
||||
self.module.fail_json(msg="Unable to set capabilities of %s" % path, stdout=stdout, stderr=stderr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue