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.

36 lines
819 B

2 years ago
import subprocess
import gssapi
_username = None
def get_username():
"""Get the user currently logged into CEO."""
return _username
2 years ago
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().
2 years ago
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):
2 years ago
raise Exception('could not acquire GSSAPI credentials')
2 years ago
def kinit():['kinit'], check=True)