James Hogarth 9c0928
From b9ee0c547797f253771489542f0f5ac08bf04bf6 Mon Sep 17 00:00:00 2001
James Hogarth 9c0928
From: Timo Benk <benk@b1-systems.de>
James Hogarth 9c0928
Date: Wed, 19 Apr 2017 20:15:20 +0200
James Hogarth 9c0928
Subject: [PATCH] fix ansible galaxy file mangling (#23703)
James Hogarth 1535cd
James Hogarth 9c0928
without this patch, ansible-galaxy will mangle files containing
James Hogarth 9c0928
the archive parent directory name, eg 'owncloud/files/owncloud.cron'
James Hogarth 9c0928
will become 'owncloud/files/.cron'.
James Hogarth 9c0928
James Hogarth 9c0928
The previous code could affect the entire path and even filenames.
James Hogarth 9c0928
If a file path has the top level dir name as a substring, galaxy
James Hogarth 9c0928
replaces it with ''. In one example, the archive top level dir
James Hogarth 9c0928
is 'go', so 'files/go-bin.sh' becomes 'files/-bin.sh'.
James Hogarth 9c0928
James Hogarth 9c0928
Fixes #22572, #23694, #23623
James Hogarth 9c0928
(cherry picked from commit 79943b86a1ee9338049149824bbb12f99d8186ee)
James Hogarth 1535cd
---
James Hogarth 1535cd
 lib/ansible/galaxy/role.py | 2 +-
James Hogarth 1535cd
 1 file changed, 1 insertion(+), 1 deletion(-)
James Hogarth 1535cd
James Hogarth 1535cd
diff --git a/lib/ansible/galaxy/role.py b/lib/ansible/galaxy/role.py
James Hogarth 9c0928
index 67bdc95..3b89176 100644
James Hogarth 1535cd
--- a/lib/ansible/galaxy/role.py
James Hogarth 1535cd
+++ b/lib/ansible/galaxy/role.py
James Hogarth 1535cd
@@ -316,7 +316,7 @@ def install(self):
James Hogarth 1535cd
                             # bits that might be in the file for security purposes
James Hogarth 1535cd
                             # and drop any containing directory, as mentioned above
James Hogarth 1535cd
                             if member.isreg() or member.issym():
James Hogarth 1535cd
-                                parts = member.name.replace(archive_parent_dir, "").split(os.sep)
James Hogarth 9c0928
+                                parts = member.name.replace(archive_parent_dir, "", 1).split(os.sep)
James Hogarth 1535cd
                                 final_parts = []
James Hogarth 1535cd
                                 for part in parts:
James Hogarth 1535cd
                                     if part != '..' and '~' not in part and '$' not in part: