1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #1830 from willthames/fix_tilde_path_in_file

Fix behaviour when file handles a path with tilde
This commit is contained in:
Michael DeHaan 2013-01-07 05:03:09 -08:00
commit 3f4847a3ab
2 changed files with 6 additions and 3 deletions

View file

@ -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(':')

View file

@ -139,7 +139,7 @@ def main():
params = module.params
state = params['state']
path = os.path.expanduser(params['path'])
params['path'] = path = os.path.expanduser(params['path'])
# source is both the source of a symlink or an informational passing of the src for a template module
# or copy module, even if this module never uses it, it is needed to key off some things