Description
I am trying to run a script that run multiple times a script requiring Kerberos. MainScript.sh
has a loop where it will launch ScriptUsingKerberos.sh
many times over time (more than 600 times per day). Eg:
./MainScript.sh
|-- ScriptUsingKerberos.sh
|-- ScriptUsingKerberos.sh
|-- ...
\-- ScriptUsingKerberos.sh
ScriptUsingKerberos.sh
- Part checking my Kerberos ticket validity:
echo " INFO: Checking the validity of your last Kerberos ticket..."
if ! klist 2>&1 | grep -q "${USER_NAME}@${DOMAIN}"
then
echo "ERROR: User ${USER_NAME} do not match user listed in 'oklist' command, aborting."
exit 1
fi
aKerberosExpirationDate="$(klist 2>&1 | tr '[:blank:]' ' ' | grep -o '[[:blank:]][0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9][[:blank:]][[:blank:]]*oracle' | sed 's/oracle//g' | sed 's/^[[:blank:]]*//g' | sed 's/[[:blank:]]*$//g' | sed -r 's;([0-9][0-9])/([0-9][0-9])/([0-9][0-9]);20\3-\1-\2;g' | while IFS= read -r aLine; do date +%s -d "${aLine}"; done | sort -n | head -n 1)"
aNowDate=$(date +%s)
if [[ -z "${aKerberosExpirationDate}" || ${aKerberosExpirationDate} -le ${aNowDate} ]]
then
if ! 2>/dev/null 1>&2 kinit "${USER_NAME}@${DOMAIN}" <<< "${USER_PASSWORD}"
then
echo "ERROR: Your password in ${FILE_PWD} file seems incorrect or Kerberos token reset failed"
exit 1
fi
fi
Working case
So this works perfectly fine. Example of klist working:
Ticket cache: FILE:/tmp/krb5cc_8522420
Default principal: ********@******.***
Valid starting Expires Service principal
10/27/21 08:42:08 10/27/21 18:42:08 krbtgt/********@******.***@********@******.***
renew until 10/28/21 08:42:08
01/01/70 00:00:00 01/01/70 00:00:00 krb5_ccache_conf_data/pa_type/krbtgt\/********@******.***\@********@******.***@X-CACHECONF:
10/27/21 08:42:08 10/27/21 18:42:08 oracle/********@********@******.***
renew until 10/28/21 08:42:08
Kerberos 4 ticket cache: /tmp/tkt8522420
klist: You have no tickets cached
Here we can see a ticket so I can grep on it to check the valitidy of it
NOT working case
But at some point, after many successful executions, I only get:
Kerberos Utilities for Linux: Version 18.0.0.0.0 - Production on 27-OCT-2021 08:10:17
Copyright (c) 1996, 2017 Oracle. All rights reserved.
Then I cannot check Kerberos ticket validity and I exit guessing there was an error
Questions
- Why klist is not displaying any ticket anymore?
- Is this a normal behavior?
- Is there a way to continue to display outdated ticket as before with klist?
- Is any daemon/program that reset Kerberos tickets validity?