+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 acl_path(pocket):
+ return '/etc/remctl/acl/build-%s' % pocket
+
+@contextlib.contextmanager
+def atomic_write(file):
+ tmp_fd, tmp_name = tempfile.mkstemp()
+ tmp = os.fdopen(tmp_fd, 'r+')
+ yield tmp
+ tmp.close()
+ os.rename(tmp_name, file)
+