3 """Re-generate the remctl configuration for build submissions.
5 This script generates the remctl ACL and configuration for each build
6 pocket defined in the configuration.
13 from invirt.authz import mech as authz
14 from invirt.config import structs as config
17 def userToPrinc(user):
18 """Convert an AFS principal to a Kerberos v5 principal."""
20 (princ, realm) = user.split('@')
23 realm = config.kerberos.realm
25 return princ.replace('.', '/') + '@' + realm
29 # Python could really use a file-like object that gets written to
30 # a temporary path and moved to its final resting place on
32 conf_fd, conf_name = tempfile.mkstemp()
33 conf = os.fdopen(conf_fd)
34 build_handler = '/usr/sbin/invirt-submit-build'
36 for pocket in config.git.pockets:
37 acl = authz.expandAdmin(getattr(config.git.pockets, pocket).acl, None)
39 acl_fd, acl_name = tempfile.mkstemp()
40 acl_fd = os.fdopen(acl_fd)
41 print >>acl_fd, '\n'.join(userToPrinc(a) for a in acl)
43 acl_path = os.path.join('/etc/remctl/acl/build-%s' % pocket)
45 os.rename(acl_name, acl_path)
46 print >>conf, 'build %s %s %s' % (pocket, build_handler, acl_path)
48 os.rename(conf_name, '/etc/remctl/conf.d/build')
51 if __name__ == '__main__':