mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-01 13:59:09 -07:00
Fix behaviour when file handles a path with tilde
Two problems here * unchecked exception handling and erroneous assumption as to why an exception might fire * although the file module expands the path, when using file_args the unexpanded path is passed. Expected result: ~/path/to/file should work fine Actual result: exception is because it doesn't find file with a message about not being able to get the selinux context
This commit is contained in:
parent
4d48daff80
commit
4e50478a05
2 changed files with 6 additions and 3 deletions
|
@ -254,8 +254,11 @@ class AnsibleModule(object):
|
|||
return context
|
||||
try:
|
||||
ret = selinux.lgetfilecon(path)
|
||||
except:
|
||||
self.fail_json(path=path, msg='failed to retrieve selinux context')
|
||||
except OSError, e:
|
||||
if e.errno == errno.ENOENT:
|
||||
self.fail_json(path=path, msg='path %s does not exist' % path)
|
||||
else:
|
||||
self.fail_json(path=path, msg='failed to retrieve selinux context')
|
||||
if ret[0] == -1:
|
||||
return context
|
||||
context = ret[1].split(':')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue