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