Python CSC Electronic Office
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
819 B

import subprocess
import gssapi
_username = None
def get_username():
"""Get the user currently logged into CEO."""
return _username
def krb_check():
Spawns a `kinit` process if no credentials are available or the
credentials have expired.
Stores the username for later use by get_username().
global _username
for _ in range(2):
creds = gssapi.Credentials(usage='initiate')
result = creds.inquire()
princ = str(
_username = princ[:princ.index('@')]
except (gssapi.raw.misc.GSSError, gssapi.raw.exceptions.ExpiredCredentialsError):
raise Exception('could not acquire GSSAPI credentials')
def kinit():['kinit'], check=True)