Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

includedir in suoders can be prefixed by "arroba" #783

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cloudinit/distros/__init__.py
Expand Up @@ -673,7 +673,7 @@ def ensure_sudo_dir(self, path, sudo_base='/etc/sudoers'):
found_include = False
for line in sudoers_contents.splitlines():
line = line.strip()
include_match = re.search(r"^#includedir\s+(.*)$", line)
include_match = re.search(r"^[#|@]includedir\s+(.*)$", line)
if not include_match:
continue
included_dir = include_match.group(1).strip()
Expand Down
13 changes: 13 additions & 0 deletions tests/unittests/test_distros/test_generic.py
Expand Up @@ -119,6 +119,19 @@ def test_sudoers_ensure_append(self):
self.assertIn("josh", contents)
self.assertEqual(2, contents.count("josh"))

def test_sudoers_ensure_only_one_includedir(self):
cls = distros.fetch("ubuntu")
d = cls("ubuntu", {}, None)
self.patchOS(self.tmp)
self.patchUtils(self.tmp)
for char in ['#', '@']:
util.write_file("/etc/sudoers", "{}includedir /b".format(char))
d.ensure_sudo_dir("/b")
contents = util.load_file("/etc/sudoers")
self.assertIn("includedir /b", contents)
self.assertTrue(os.path.isdir("/b"))
self.assertEqual(1, contents.count("includedir /b"))

def test_arch_package_mirror_info_unknown(self):
"""for an unknown arch, we should get back that with arch 'default'."""
arch_mirrors = gapmi(package_mirrors, arch="unknown")
Expand Down