mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix a problem where the newly provided mode is a string (#3769)
* Fix a problem where the newly provided mode is a string This fixes #3597 * Implement python3-compatible get_exception() handling
This commit is contained in:
parent
855ca9b204
commit
017eeaea29
1 changed files with 15 additions and 6 deletions
|
@ -441,16 +441,24 @@ class ZipArchive(object):
|
|||
|
||||
# Do not handle permissions of symlinks
|
||||
if ftype != 'L':
|
||||
|
||||
# Use the new mode provided with the action, if there is one
|
||||
if self.file_args['mode']:
|
||||
if isinstance(self.file_args['mode'], int):
|
||||
mode = self.file_args['mode']
|
||||
else:
|
||||
try:
|
||||
mode = int(self.file_args['mode'], 8)
|
||||
except Exception:
|
||||
e = get_exception()
|
||||
self.module.fail_json(path=path, msg="mode %(mode)s must be in octal form" % self.file_args, details=str(e))
|
||||
# Only special files require no umask-handling
|
||||
if ztype == '?':
|
||||
elif ztype == '?':
|
||||
mode = self._permstr_to_octal(permstr, 0)
|
||||
else:
|
||||
mode = self._permstr_to_octal(permstr, umask)
|
||||
if self.file_args['mode'] and self.file_args['mode'] != stat.S_IMODE(st.st_mode):
|
||||
change = True
|
||||
err += 'Path %s differs in permissions (%o vs %o)\n' % (path, self.file_args['mode'], stat.S_IMODE(st.st_mode))
|
||||
itemized[5] = 'p'
|
||||
elif mode != stat.S_IMODE(st.st_mode):
|
||||
|
||||
if mode != stat.S_IMODE(st.st_mode):
|
||||
change = True
|
||||
itemized[5] = 'p'
|
||||
err += 'Path %s differs in permissions (%o vs %o)\n' % (path, mode, stat.S_IMODE(st.st_mode))
|
||||
|
@ -700,6 +708,7 @@ def main():
|
|||
validate_certs = dict(required=False, default=True, type='bool'),
|
||||
),
|
||||
add_file_common_args = True,
|
||||
# check-mode only works for zip files
|
||||
# supports_check_mode = True,
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue