diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-11-15 18:48:37 -0800 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-11-15 18:48:37 -0800 |
commit | 2808d703dc79cad0650e4ba52d8d6ce7203329b2 (patch) | |
tree | 222ae0bae9e92af954c22b923549207f52ae5968 /cloudinit | |
parent | 024cd9fecddb4756fd33eaecaa5623ef690485d0 (diff) | |
parent | ef915a6ec712d89b9e0b3672947571976a49b68f (diff) | |
download | vyos-cloud-init-2808d703dc79cad0650e4ba52d8d6ce7203329b2.tar.gz vyos-cloud-init-2808d703dc79cad0650e4ba52d8d6ce7203329b2.zip |
Strings are iterable...
Using collections.iterable means that strings get iterated over
which is not the desired effect when writing a string sudoers rule.
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/distros/__init__.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index ea0bac23..e724a418 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -24,7 +24,6 @@ from StringIO import StringIO import abc -import collections import itertools import os import re @@ -421,11 +420,14 @@ class Distro(object): '', "# User rules for %s" % user, ] - if isinstance(rules, collections.Iterable): + 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)) |