diff options
author | Günther Deschner <gd@samba.org> | 2014-04-30 10:49:14 +0200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2014-08-08 06:02:34 +0200 |
commit | f5ce0ee45a1403484bede07b6596a885246913c8 (patch) | |
tree | 3db605435a4dce7df10f1aee61e8651454d130b3 /lib | |
parent | 5c663685ebbb14cc8eca49e9e9554c2dae2e9764 (diff) | |
download | samba-f5ce0ee45a1403484bede07b6596a885246913c8.tar.gz |
lib/krb5_wrap: add smb_krb5_principal_get_comp_string().
Guenther
Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/krb5_wrap/krb5_samba.c | 37 | ||||
-rw-r--r-- | lib/krb5_wrap/krb5_samba.h | 5 |
2 files changed, 42 insertions, 0 deletions
diff --git a/lib/krb5_wrap/krb5_samba.c b/lib/krb5_wrap/krb5_samba.c index 84a62a69061..ec44f9ade26 100644 --- a/lib/krb5_wrap/krb5_samba.c +++ b/lib/krb5_wrap/krb5_samba.c @@ -871,6 +871,43 @@ done: } #endif +/* + * @brief Get talloced string component of a principal + * + * @param[in] mem_ctx The TALLOC_CTX + * @param[in] context The krb5_context + * @param[in] principal The principal + * @param[in] component The component + * @return string component + * + * Caller must talloc_free if the return value is not NULL. + * + */ + +/* caller has to free returned string with free() */ +char *smb_krb5_principal_get_comp_string(TALLOC_CTX *mem_ctx, + krb5_context context, + krb5_const_principal principal, + unsigned int component) +{ +#if defined(HAVE_KRB5_PRINCIPAL_GET_COMP_STRING) + return talloc_strdup(mem_ctx, krb5_principal_get_comp_string(context, principal, component)); +#else + krb5_data *data; + + if (component >= krb5_princ_size(context, principal)) { + return NULL; + } + + data = krb5_princ_component(context, principal, component); + if (data == NULL) { + return NULL; + } + + return talloc_strndup(mem_ctx, data->data, data->length); +#endif +} + /* Prototypes */ krb5_error_code smb_krb5_renew_ticket(const char *ccache_string, /* FILE:/tmp/krb5cc_0 */ diff --git a/lib/krb5_wrap/krb5_samba.h b/lib/krb5_wrap/krb5_samba.h index f5a2daa0776..5a3d20e1b8e 100644 --- a/lib/krb5_wrap/krb5_samba.h +++ b/lib/krb5_wrap/krb5_samba.h @@ -316,6 +316,11 @@ krb5_boolean smb_krb5_get_allowed_weak_crypto(krb5_context context); #endif #endif +char *smb_krb5_principal_get_comp_string(TALLOC_CTX *mem_ctx, + krb5_context context, + krb5_const_principal principal, + unsigned int component); + #endif /* HAVE_KRB5 */ int cli_krb5_get_ticket(TALLOC_CTX *mem_ctx, |