From 4e4e0cca176f27ce01b04c7bb47ce0dc02efb1df Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Mon, 29 Sep 2014 18:02:42 -0400 Subject: [PATCH] Fix old ticket #9092 where a playbook can enter in recursion This can be tested with this command : ansible -c local -m copy -a 'src=/etc/group dest=foo/' all This is a corner case of the algorithm used to find how we should copy recursively a folder, and this commit detect it and avoid it. Check https://github.com/ansible/ansible/issues/9092 for the story --- lib/ansible/modules/files/copy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/files/copy.py b/lib/ansible/modules/files/copy.py index ab480bec1f..c5aaa01b5b 100644 --- a/lib/ansible/modules/files/copy.py +++ b/lib/ansible/modules/files/copy.py @@ -181,7 +181,7 @@ def main(): if original_basename and dest.endswith("/"): dest = os.path.join(dest, original_basename) dirname = os.path.dirname(dest) - if not os.path.exists(dirname): + if not os.path.exists(dirname) and '/' in dirname: (pre_existing_dir, new_directory_list) = split_pre_existing_dir(dirname) os.makedirs(dirname) directory_args = module.load_file_common_arguments(module.params)