summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Likins <alikins@redhat.com>2016-07-01 13:10:32 -0400
committerAdrian Likins <alikins@redhat.com>2016-07-12 11:01:12 -0400
commitda177b17449e519a77a9971f18b93eac58aee065 (patch)
treebc8304a6a4db96781fa75d5521f413f0d9d4cc07
parent14eb4772dcc84163647264176ad5b85cbce34af2 (diff)
downloadansible-modules-core-da177b17449e519a77a9971f18b93eac58aee065.tar.gz
Fix default perm for apt_repo files. (#4072)
Change the file mode arg to 'raw' ala file args Following the file_common_args model, change the type of the 'mode' arg here to type='raw' with no default arg value. The default mode for file creation is the module constant DEFAULT_SOURCES_PER, and is used if no mode os specified. A default mode of 0644 (and not specified as int or str) would get converted to an octal 420, resulting in the sources file being created with mode '0420' instead of '0644' Fixes #16370
-rw-r--r--packaging/os/apt_repository.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/packaging/os/apt_repository.py b/packaging/os/apt_repository.py
index 55b60987..baf0afb3 100644
--- a/packaging/os/apt_repository.py
+++ b/packaging/os/apt_repository.py
@@ -108,6 +108,7 @@ except ImportError:
distro = None
HAVE_PYTHON_APT = False
+DEFAULT_SOURCES_PERM = int('0644', 8)
VALID_SOURCE_TYPES = ('deb', 'deb-src')
@@ -279,7 +280,7 @@ class SourcesList(object):
# allow the user to override the default mode
if filename in self.new_repos:
- this_mode = self.module.params['mode']
+ this_mode = self.module.params.get('mode', DEFAULT_SOURCES_PERM)
self.module.set_mode_if_different(filename, this_mode, False)
else:
del self.files[filename]
@@ -451,7 +452,7 @@ def main():
argument_spec=dict(
repo=dict(required=True),
state=dict(choices=['present', 'absent'], default='present'),
- mode=dict(required=False, default=0644),
+ mode=dict(required=False, type='raw'),
update_cache = dict(aliases=['update-cache'], type='bool', default='yes'),
filename=dict(required=False, default=None),
# this should not be needed, but exists as a failsafe
@@ -465,6 +466,8 @@ def main():
repo = module.params['repo']
state = module.params['state']
update_cache = module.params['update_cache']
+ # Note: mode is referenced in SourcesList class via the passed in module (self here)
+
sourceslist = None
if not HAVE_PYTHON_APT: