Until we switch to storing krb5 principals in the database, we need to
authorEvan Broder <broder@mit.edu>
Thu, 26 Nov 2009 04:43:21 +0000 (23:43 -0500)
committerEvan Broder <broder@mit.edu>
Thu, 26 Nov 2009 04:43:21 +0000 (23:43 -0500)
convert the AFS-style principals in the database to krb5 principals.

Hopefully this code can be torn out one of these days in the
not-so-distant future.

svn path=/trunk/packages/invirt-dev/; revision=2566

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
 
 
+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
@@ -25,7 +36,7 @@ def main():
         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)