diff options
author | Cullum Smith <cullum@sacredheartsc.com> | 2024-09-25 21:38:13 -0400 |
---|---|---|
committer | Cullum Smith <cullum@sacredheartsc.com> | 2024-09-25 21:38:13 -0400 |
commit | cd1ce69f104686bbb33e049c2c4c112e78febd36 (patch) | |
tree | 6654eaf12145b918cd217dcdf9b95a0060a60b7b /lib/60-kerberos | |
parent | 93994080d976d1fd98a22422a549fe371a2bcae3 (diff) | |
download | infrastructure-cd1ce69f104686bbb33e049c2c4c112e78febd36.tar.gz |
finish idm client stuff
Diffstat (limited to 'lib/60-kerberos')
-rw-r--r-- | lib/60-kerberos | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/60-kerberos b/lib/60-kerberos new file mode 100644 index 0000000..a323e94 --- /dev/null +++ b/lib/60-kerberos @@ -0,0 +1,51 @@ +#!/bin/sh + +_boxconf_kadmin() { + case $BOXCONF_OS in + freebsd) _boxconf_kadmin=/usr/local/bin/kadmin ;; + *) _boxconf_kadmin=kadmin ;; + esac + + "$_boxconf_kadmin" -p "$boxconf_username" -w "$boxconf_password" "$@" +} + +_boxconf_kinit(){ + case $BOXCONF_OS in + freebsd) /usr/local/bin/kinit "$@" ;; + *) kinit "$@" ;; + esac +} + +add_principal(){ + # Create a kerberos principal, if it doesn't already exist. + # Arguments are the same as MIT kadmin' add_principal. + # Final argument must be the principal name. + eval "_kap_princ=\$$#" + _boxconf_kadmin get_principal "$_kap_princ" \ + || _boxconf_kadmin add_principal "$@" +} + +ktadd(){ + # Add a principal's keys to a keytab. + # Arguments are the same as MIT kadmin's ktadd. + _kkta_ktarg=false + _kkta_keytab=/etc/krb5.keytab + eval "_kkta_princ=\$$#" + + # Extract the keytab argument from $@. + for _kkta_arg; do + if [ "$_kkta_ktarg" = true ]; then + _kkta_keytab=$_kkta_arg + break + else + case $_kkta_arg in + -k|-keytab) _kkta_ktarg=true ;; + esac + fi + done + + # Check if we can kinit with the keytab. If not, get fresh keys. + if ! _boxconf_kinit -kt "$_kkta_keytab" -c MEMORY: "$_kkta_princ" 2>/dev/null; then + _boxconf_kadmin ktadd "$@" + fi +} |