Fix broken sudoers file generation

This commit is contained in:
Garrett Holmstrom 2012-11-21 13:49:33 -08:00
parent e8a08074fe
commit 82213acfcc
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,29 @@
Index: cloud-init-0.7.1/cloudinit/distros/__init__.py
===================================================================
--- cloud-init-0.7.1.orig/cloudinit/distros/__init__.py
+++ cloud-init-0.7.1/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))

View File

@ -12,6 +12,9 @@ Source0: https://launchpad.net/cloud-init/trunk/0.7.1/+download/cloud-ini
Source1: cloud-init-fedora.cfg
Source2: cloud-init-README.fedora
Patch0: cloud-init-0.7.0-fedora.patch
# Fix broken sudoers file generation
# http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/revision/740
Patch1: cloud-init-0.7.1-sudo-iterstr.patch
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -48,6 +51,7 @@ ssh keys and to let the user run various scripts.
%prep
%setup -q -n %{name}-%{version}
%patch0 -p1
%patch1 -p1
cp -p %{SOURCE2} README.fedora
@ -127,6 +131,7 @@ fi
%changelog
* Wed Nov 21 2012 Garrett Holmstrom <gholms@fedoraproject.org> - 0.7.1-1
- Rebased against version 0.7.1
- Fixed broken sudoers file generation
* Tue Oct 9 2012 Garrett Holmstrom <gholms@fedoraproject.org> - 0.7.0-1
- Rebased against version 0.7.0