1 """Delegate accounts are used to provide secure access to the XMLRPC API. They are normal Unix accounts with a shell that tunnels XMLRPC requests to the API server."""
6 from pwd import getpwnam
7 from grp import getgrnam
9 class Controller(accounts.Account):
10 SHELL = '/usr/bin/forward_api_calls' # tunneling shell
11 TYPE = 'controller.Controller'
14 def create(name, vref = None):
15 add_shell(Controller.SHELL)
16 group = getgrnam("slices")[2]
17 logger.log_call('/usr/sbin/useradd', '-p', '*', '-g', str(group), '-s', Controller.SHELL, name)
20 def destroy(name): logger.log_call('/usr/sbin/userdel', '-r', name)
23 logger.verbose("Delegate: %s" % self.name)
24 return getpwnam(self.name)[6] == self.SHELL
28 """Add <shell> to /etc/shells if it's not already there."""
29 etc_shells = open('/etc/shells')
30 valid_shells = etc_shells.read().split()
32 if shell not in valid_shells:
33 etc_shells = open('/etc/shells', 'a')
34 print >>etc_shells, shell