Until we switch to storing krb5 principals in the database, we need to
[invirt/packages/invirt-dev.git] / invirt-build-conf
index f74b05d..4c5039f 100755 (executable)
@@ -14,6 +14,17 @@ from invirt.authz import mech as authz
 from invirt.config import structs as config
 
 
 from invirt.config import structs as config
 
 
+def userToPrinc(user):
+    """Convert an AFS principal to a Kerberos v5 principal."""
+    if '@' in user:
+        (princ, realm) = user.split('@')
+    else:
+        princ = user
+        realm = config.kerberos.realm
+
+    return princ.replace('.', '/') + '@' + realm
+
+
 def main():
     # Python could really use a file-like object that gets written to
     # a temporary path and moved to its final resting place on
 def main():
     # Python could really use a file-like object that gets written to
     # a temporary path and moved to its final resting place on
@@ -25,7 +36,7 @@ def main():
         acl = authz.expandAdmin(getattr(config.git.pockets, pocket).acl, None)
 
         acl_fd = tempfile.NamedTemporaryFile(delete=False)
         acl = authz.expandAdmin(getattr(config.git.pockets, pocket).acl, None)
 
         acl_fd = tempfile.NamedTemporaryFile(delete=False)
-        print >>acl_fd, '\n'.join(acl)
+        print >>acl_fd, '\n'.join(user(a) for a in acl)
 
         acl_path = os.path.join('/etc/remctl/acl/build-%s' % pocket)
 
 
         acl_path = os.path.join('/etc/remctl/acl/build-%s' % pocket)