diff options
author | Günther Deschner <gd@samba.org> | 2014-05-08 09:57:21 +0200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2014-08-08 06:02:35 +0200 |
commit | 763cae60c33b06a7ce74e2c7b386cb1b4810c653 (patch) | |
tree | a8be10927253fccc2d7e5e1f7eadfcca8c2c3c47 /lib/krb5_wrap | |
parent | 1a58585a9b912a6b70e37a6b2391d3ca7ddda34f (diff) | |
download | samba-763cae60c33b06a7ce74e2c7b386cb1b4810c653.tar.gz samba-763cae60c33b06a7ce74e2c7b386cb1b4810c653.tar.xz samba-763cae60c33b06a7ce74e2c7b386cb1b4810c653.zip |
lib/krb5_wrap: add smb_krb5_principal_set_realm().
Guenther
Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib/krb5_wrap')
-rw-r--r-- | lib/krb5_wrap/krb5_samba.c | 44 | ||||
-rw-r--r-- | lib/krb5_wrap/krb5_samba.h | 4 |
2 files changed, 48 insertions, 0 deletions
diff --git a/lib/krb5_wrap/krb5_samba.c b/lib/krb5_wrap/krb5_samba.c index d5c0b37d28..8d91e1c074 100644 --- a/lib/krb5_wrap/krb5_samba.c +++ b/lib/krb5_wrap/krb5_samba.c @@ -2313,6 +2313,50 @@ char *smb_krb5_principal_get_realm(krb5_context context, #endif } +/* + * smb_krb5_principal_set_realm + * + * @brief Get realm of a principal + * + * @param[in] context The krb5_context + * @param[in] principal The principal + * @param[in] realm The realm + * @return 0 on success, a krb5_error_code on error. + * + */ + +krb5_error_code smb_krb5_principal_set_realm(krb5_context context, + krb5_principal principal, + const char *realm) +{ +#ifdef HAVE_KRB5_PRINCIPAL_SET_REALM /* Heimdal */ + return krb5_principal_set_realm(context, principal, realm); +#elif defined(krb5_princ_realm) && defined(krb5_princ_set_realm) /* MIT */ + krb5_error_code ret; + krb5_data data; + krb5_data *old_data; + + old_data = krb5_princ_realm(context, principal); + + data.magic = 0; + data.length = strlen(realm); + data.data = malloc(data.length); + if (data.data == NULL) { + return ENOMEM; + } + + /* free realm before setting */ + free(old_data->data); + + krb5_princ_set_realm(context, principal, &data); + + return ret; +#else +#error UNKNOWN_PRINC_SET_REALM_FUNCTION +#endif +} + + /************************************************************************ Routine to get the default realm from the kerberos credentials cache. Caller must free if the return value is not NULL. diff --git a/lib/krb5_wrap/krb5_samba.h b/lib/krb5_wrap/krb5_samba.h index 36b60feebe..03246fd028 100644 --- a/lib/krb5_wrap/krb5_samba.h +++ b/lib/krb5_wrap/krb5_samba.h @@ -254,6 +254,10 @@ krb5_error_code smb_krb5_make_pac_checksum(TALLOC_CTX *mem_ctx, char *smb_krb5_principal_get_realm(krb5_context context, krb5_const_principal principal); +krb5_error_code smb_krb5_principal_set_realm(krb5_context context, + krb5_principal principal, + const char *realm); + char *kerberos_get_principal_from_service_hostname(TALLOC_CTX *mem_ctx, const char *service, const char *remote_name, |