From ef915a6ec712d89b9e0b3672947571976a49b68f Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Thu, 15 Nov 2012 12:32:05 -0800 Subject: Raise a type error when a sudoers rule is not an accepted type. --- cloudinit/distros/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 24e6f637..e724a418 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -423,8 +423,11 @@ class Distro(object): if isinstance(rules, (list, tuple)): for rule in rules: lines.append("%s %s" % (user, rule)) - else: + elif isinstance(rules, (basestring, str)): lines.append("%s %s" % (user, rules)) + else: + msg = "Can not create sudoers rule addition with type %r" + raise TypeError(msg % (util.obj_name(rules))) content = "\n".join(lines) self.ensure_sudo_dir(os.path.dirname(sudo_file)) -- cgit v1.2.3