summaryrefslogtreecommitdiff
path: root/cloudinit/distros
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-11-15 12:32:05 -0800
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-11-15 12:32:05 -0800
commitef915a6ec712d89b9e0b3672947571976a49b68f (patch)
tree222ae0bae9e92af954c22b923549207f52ae5968 /cloudinit/distros
parent6aaa0482f44f66f9bb3c89e133c25b3bde755a5e (diff)
downloadvyos-cloud-init-ef915a6ec712d89b9e0b3672947571976a49b68f.tar.gz
vyos-cloud-init-ef915a6ec712d89b9e0b3672947571976a49b68f.zip
Raise a type error when a sudoers rule is not an accepted type.
Diffstat (limited to 'cloudinit/distros')
-rw-r--r--cloudinit/distros/__init__.py5
1 files changed, 4 insertions, 1 deletions
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))