diff options
author | Andreas Schneider <asn@samba.org> | 2022-03-15 07:30:03 +0100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2022-03-17 00:41:33 +0000 |
commit | a84cabf471198b19d24b74c1deae9d49049823dc (patch) | |
tree | ed4ba297b2c53ba74f880978a4d349011f8f88a5 /lib/krb5_wrap | |
parent | 1f24724b24e04ee4ac1bdf44f83a4f4e19497856 (diff) | |
download | samba-a84cabf471198b19d24b74c1deae9d49049823dc.tar.gz |
lib:krb5_wrap: Implement smb_krb5_principal_is_tgs()
This will be used later and allows to remove static implementations.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Diffstat (limited to 'lib/krb5_wrap')
-rw-r--r-- | lib/krb5_wrap/krb5_samba.c | 28 | ||||
-rw-r--r-- | lib/krb5_wrap/krb5_samba.h | 3 |
2 files changed, 31 insertions, 0 deletions
diff --git a/lib/krb5_wrap/krb5_samba.c b/lib/krb5_wrap/krb5_samba.c index e9eaddac75d..2351d172779 100644 --- a/lib/krb5_wrap/krb5_samba.c +++ b/lib/krb5_wrap/krb5_samba.c @@ -3348,6 +3348,34 @@ void smb_krb5_principal_set_type(krb5_context context, #endif } +/** + * @brief Check if a principal is a TGS + * + * @param[in] context The library context + * + * @param[inout] principal The principal to check. + * + * @returns 1 if equal, 0 if not and -1 on error. + */ +int smb_krb5_principal_is_tgs(krb5_context context, + krb5_const_principal principal) +{ + char *p = NULL; + int eq = 1; + + p = smb_krb5_principal_get_comp_string(NULL, context, principal, 0); + if (p == NULL) { + return -1; + } + + eq = krb5_princ_size(context, principal) == 2 && + (strequal(p, KRB5_TGS_NAME)); + + talloc_free(p); + + return eq; +} + #if !defined(HAVE_KRB5_WARNX) /** * @brief Log a Kerberos message diff --git a/lib/krb5_wrap/krb5_samba.h b/lib/krb5_wrap/krb5_samba.h index c8573f52bd9..653cd561406 100644 --- a/lib/krb5_wrap/krb5_samba.h +++ b/lib/krb5_wrap/krb5_samba.h @@ -306,6 +306,9 @@ void smb_krb5_principal_set_type(krb5_context context, krb5_principal principal, int type); +int smb_krb5_principal_is_tgs(krb5_context context, + krb5_const_principal principal); + krb5_error_code smb_krb5_principal_set_realm(krb5_context context, krb5_principal principal, const char *realm); |