4 """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."""
9 from pwd import getpwnam
10 from grp import getgrnam
12 class Controller(accounts.Account):
13 SHELL = '/usr/bin/forward_api_calls' # tunneling shell
14 TYPE = 'controller.Controller'
17 def create(name, vref = None):
18 add_shell(Controller.SHELL)
19 group = getgrnam("slices")[2]
20 logger.log_call(['/usr/sbin/useradd', '-p', '*', '-g', str(group), '-s', Controller.SHELL, name, ])
23 def destroy(name): logger.log_call(['/usr/sbin/userdel', '-r', name, ])
26 logger.verbose("controller: is_running: %s" % self.name)
27 return getpwnam(self.name)[6] == self.SHELL
31 """Add <shell> to /etc/shells if it's not already there."""
32 etc_shells = open('/etc/shells')
33 valid_shells = etc_shells.read().split()
35 if shell not in valid_shells:
36 etc_shells = open('/etc/shells', 'a')
37 print >>etc_shells, shell