Skip to content

Commit

Permalink
archive: Fix check if archive is created in path to be removed (#29420)
Browse files Browse the repository at this point in the history
  • Loading branch information
feran authored and abadger committed Jan 7, 2019
1 parent eb4249c commit 1d3d6a3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/ansible/modules/files/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,13 @@ def main():
arcroot += os.sep

# Don't allow archives to be created anywhere within paths to be removed
if remove and os.path.isdir(path) and dest.startswith(path):
module.fail_json(path=', '.join(paths), msg='Error, created archive can not be contained in source paths when remove=True')
if remove and os.path.isdir(path):
path_dir = path
if path[-1] != '/':
path_dir += '/'

if dest.startswith(path_dir):
module.fail_json(path=', '.join(paths), msg='Error, created archive can not be contained in source paths when remove=True')

if os.path.lexists(path) and path not in expanded_exclude_paths:
archive_paths.append(path)
Expand Down

0 comments on commit 1d3d6a3

Please sign in to comment.