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
This commit is contained in:
parent
20d8103b53
commit
127b854d2c
1 changed files with 5 additions and 2 deletions
|
@ -108,6 +108,7 @@ except ImportError:
|
||||||
distro = None
|
distro = None
|
||||||
HAVE_PYTHON_APT = False
|
HAVE_PYTHON_APT = False
|
||||||
|
|
||||||
|
DEFAULT_SOURCES_PERM = int('0644', 8)
|
||||||
|
|
||||||
VALID_SOURCE_TYPES = ('deb', 'deb-src')
|
VALID_SOURCE_TYPES = ('deb', 'deb-src')
|
||||||
|
|
||||||
|
@ -280,7 +281,7 @@ class SourcesList(object):
|
||||||
|
|
||||||
# allow the user to override the default mode
|
# allow the user to override the default mode
|
||||||
if filename in self.new_repos:
|
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)
|
self.module.set_mode_if_different(filename, this_mode, False)
|
||||||
else:
|
else:
|
||||||
del self.files[filename]
|
del self.files[filename]
|
||||||
|
@ -452,7 +453,7 @@ def main():
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
repo=dict(required=True),
|
repo=dict(required=True),
|
||||||
state=dict(choices=['present', 'absent'], default='present'),
|
state=dict(choices=['present', 'absent'], default='present'),
|
||||||
mode=dict(required=False, default=int('0644',8)),
|
mode=dict(required=False, type='raw'),
|
||||||
update_cache = dict(aliases=['update-cache'], type='bool', default='yes'),
|
update_cache = dict(aliases=['update-cache'], type='bool', default='yes'),
|
||||||
filename=dict(required=False, default=None),
|
filename=dict(required=False, default=None),
|
||||||
# this should not be needed, but exists as a failsafe
|
# this should not be needed, but exists as a failsafe
|
||||||
|
@ -466,6 +467,8 @@ def main():
|
||||||
repo = module.params['repo']
|
repo = module.params['repo']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
update_cache = module.params['update_cache']
|
update_cache = module.params['update_cache']
|
||||||
|
# Note: mode is referenced in SourcesList class via the passed in module (self here)
|
||||||
|
|
||||||
sourceslist = None
|
sourceslist = None
|
||||||
|
|
||||||
if not HAVE_PYTHON_APT:
|
if not HAVE_PYTHON_APT:
|
||||||
|
|
Loading…
Reference in a new issue