summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2007-07-21 15:20:11 +0000
committerNarayan Desai <desai@mcs.anl.gov>2007-07-21 15:20:11 +0000
commitcce555384b9269400f8bfd960d65c720b0653cfc (patch)
tree650bc749ecf86655c291eb37832c43854abd6408 /src
parentd9582a3570bb36e4ad05ea22839d973a39e96044 (diff)
downloadbcfg2-cce555384b9269400f8bfd960d65c720b0653cfc.tar.gz
bcfg2-cce555384b9269400f8bfd960d65c720b0653cfc.tar.bz2
bcfg2-cce555384b9269400f8bfd960d65c720b0653cfc.zip
Account plugin improvement from mschick (Resolves Ticket #470)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@3530 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Plugins/Account.py33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/lib/Server/Plugins/Account.py b/src/lib/Server/Plugins/Account.py
index 96d242100..ac2eba836 100644
--- a/src/lib/Server/Plugins/Account.py
+++ b/src/lib/Server/Plugins/Account.py
@@ -52,19 +52,34 @@ class Account(Bcfg2.Server.Plugin.Plugin):
def gen_root_keys_cb(self, entry, metadata):
'''Build root authorized keys file based on current ACLs'''
superusers = self.repository.entries['superusers'].data.split()
- rootlike = [line.split(':', 1) for line in self.repository.entries['rootlike'].data.split()]
- superusers += [user for (user, host) in rootlike if host == metadata.hostname.split('.')[0]]
+ try:
+ rootlike = [line.split(':', 1) for line in \
+ self.repository.entries['rootlike'].data.split()]
+ superusers += [user for (user, host) in rootlike \
+ if host == metadata.hostname.split('.')[0]]
+ except:
+ pass
rdata = self.repository.entries
- entry.text = "".join([rdata["%s.key" % user].data for user in superusers if rdata.has_key("%s.key" % user)])
+ entry.text = "".join([rdata["%s.key" % user].data for user \
+ in superusers if \
+ rdata.has_key("%s.key" % user)])
perms = {'owner':'root', 'group':'0', 'perms':'0600'}
- [entry.attrib.__setitem__(key, value) for (key, value) in perms.iteritems()]
+ [entry.attrib.__setitem__(key, value) for (key, value) \
+ in perms.iteritems()]
def gen_sudoers(self, entry, metadata):
'''Build root authorized keys file based on current ACLs'''
superusers = self.repository.entries['superusers'].data.split()
- rootlike = [line.split(':', 1) for line in self.repository.entries['rootlike'].data.split()]
- superusers += [user for (user, host) in rootlike if host == metadata.hostname.split('.')[0]]
- rdata = self.repository.entries
- entry.text = self.repository.entries['static.sudoers'].data%",".join(superusers)
+ try:
+ rootlike = [line.split(':', 1) for line in \
+ self.repository.entries['rootlike'].data.split()]
+ superusers += [user for (user, host) in rootlike \
+ if host == metadata.hostname.split('.')[0]]
+ except:
+ pass
+ entry.text = self.repository.entries['static.sudoers'].data
+ entry.text += "".join(["%s ALL=(ALL) ALL\n" % uname \
+ for uname in superusers])
perms = {'owner':'root', 'group':'0', 'perms':'0400'}
- [entry.attrib.__setitem__(key, value) for (key, value) in perms.iteritems()]
+ [entry.attrib.__setitem__(key, value) for (key, value) \
+ in perms.iteritems()]