source: trunk/packages/invirt-dev/invirt-build-conf @ 2582

Last change on this file since 2582 was 2579, checked in by broder, 15 years ago

Update the git user's .k5login in invirt-build-conf.

  • Property svn:executable set to *
File size: 1.7 KB
RevLine 
[2565]1#!/usr/bin/python
2
3"""Re-generate the remctl configuration for build submissions.
4
5This script generates the remctl ACL and configuration for each build
[2579]6pocket defined in the configuration. It also updates the .k5login for
7the git user that developers can push through.
[2565]8"""
9
10
11import os
12import tempfile
13
14from invirt.authz import mech as authz
15from invirt.config import structs as config
16
17
[2566]18def userToPrinc(user):
19    """Convert an AFS principal to a Kerberos v5 principal."""
20    if '@' in user:
21        (princ, realm) = user.split('@')
22    else:
23        princ = user
24        realm = config.kerberos.realm
25
26    return princ.replace('.', '/') + '@' + realm
27
28
[2565]29def main():
[2579]30    all_devs = set()
31
[2565]32    # Python could really use a file-like object that gets written to
33    # a temporary path and moved to its final resting place on
34    # .close(). Oh well.
[2567]35    conf_fd, conf_name = tempfile.mkstemp()
[2569]36    conf = os.fdopen(conf_fd, 'r+')
[2565]37    build_handler = '/usr/sbin/invirt-submit-build'
38
39    for pocket in config.git.pockets:
40        acl = authz.expandAdmin(getattr(config.git.pockets, pocket).acl, None)
41
[2567]42        acl_fd, acl_name = tempfile.mkstemp()
[2569]43        acl_fd = os.fdopen(acl_fd, 'r+')
[2568]44        print >>acl_fd, '\n'.join(userToPrinc(a) for a in acl)
[2565]45
[2579]46        all_devs.update(set(userToPrinc(a) for a in acl))
47
[2565]48        acl_path = os.path.join('/etc/remctl/acl/build-%s' % pocket)
49
[2567]50        os.rename(acl_name, acl_path)
[2565]51        print >>conf, 'build %s %s %s' % (pocket, build_handler, acl_path)
52
[2567]53    os.rename(conf_name, '/etc/remctl/conf.d/build')
[2565]54
[2579]55    k5login_fd, k5login_name = tempfile.mkstemp()
56    k5login = os.fdopen(k5login_fd, 'r+')
57    print >>k5login, '\n'.join(all_devs)
[2565]58
[2579]59
[2565]60if __name__ == '__main__':
61    main()
Note: See TracBrowser for help on using the repository browser.