From d6305bc93876a8f18390b6a3bd6cafa5164eba8d Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 26 Feb 2015 08:43:24 -0500 Subject: [PATCH] fixed file module to use realpath when following links, readlink could be relative and fail in corner cases as per #852 --- lib/ansible/modules/files/file.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/files/file.py b/lib/ansible/modules/files/file.py index fd06d2d48cd..4eb6cb0b64f 100644 --- a/lib/ansible/modules/files/file.py +++ b/lib/ansible/modules/files/file.py @@ -201,7 +201,7 @@ def main(): if state in ['link','hard']: if follow and state == 'link': # use the current target of the link as the source - src = os.readlink(path) + src = os.path.realpath(path) else: module.fail_json(msg='src and dest are required for creating links') @@ -245,7 +245,7 @@ def main(): if state != prev_state: if follow and prev_state == 'link': # follow symlink and operate on original - path = os.readlink(path) + path = os.path.realpath(path) prev_state = get_state(path) file_args['path'] = path @@ -258,7 +258,7 @@ def main(): elif state == 'directory': if follow and prev_state == 'link': - path = os.readlink(path) + path = os.path.realpath(path) prev_state = get_state(path) if prev_state == 'absent':