Merge pull request #36539 from jfindlay/arch_perms

Prefer archive.cmd_unzip
This commit is contained in:
Mike Place 2016-09-26 19:02:11 +09:00 committed by GitHub
commit 4bca246a27
2 changed files with 19 additions and 1 deletions

View file

@ -6,6 +6,7 @@ A module to wrap (non-Windows) archive calls
'''
from __future__ import absolute_import
import os
import logging
import contextlib # For < 2.7 compat
# Import salt libs
@ -20,6 +21,8 @@ __func_alias__ = {
'zip_': 'zip'
}
log = logging.getLogger(__name__)
HAS_ZIPFILE = False
try:
@ -518,6 +521,12 @@ def unzip(zip_file, dest, excludes=None,
salt '*' archive.unzip /tmp/zipfile.zip /home/strongbad/ password='BadPassword'
'''
# https://bugs.python.org/issue15795
log.warning('Due to bug 15795 in python\'s zip lib, the permissions of the'
' extracted files may not be preserved when using archive.unzip')
log.warning('To preserve the permissions of extracted files, use'
' archive.cmd_unzip')
if not excludes:
excludes = []
if runas:

View file

@ -374,7 +374,16 @@ def extracted(name,
log.debug('Extracting {0} to {1}'.format(filename, name))
if archive_format == 'zip':
files = __salt__['archive.unzip'](filename, name, trim_output=trim_output, password=password)
if password is None and salt.utils.which('unzip'):
files = __salt__['archive.cmd_unzip'](filename, name, trim_output=trim_output)
else:
# https://bugs.python.org/issue15795
if password is not None:
log.warning('Password supplied: using archive.unzip')
if not salt.utils.which('unzip'):
log.warning('Cannot find unzip command for archive.cmd_unzip:'
' using archive.unzip instead')
files = __salt__['archive.unzip'](filename, name, trim_output=trim_output, password=password)
elif archive_format == 'rar':
files = __salt__['archive.unrar'](filename, name, trim_output=trim_output)
else: