diff options
author | Simo Sorce <idra@samba.org> | 2012-04-26 17:21:22 -0400 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2012-05-04 16:51:29 +0200 |
commit | b776bc5f72efac87244393a2bf1e5c9278bdaf15 (patch) | |
tree | 00e22053469553a1c0acf4681f24c1b3583e7fca /lib/krb5_wrap | |
parent | 205b032061bffe68fd784ebdc33d485acd57a5b1 (diff) | |
download | samba-b776bc5f72efac87244393a2bf1e5c9278bdaf15.tar.gz samba-b776bc5f72efac87244393a2bf1e5c9278bdaf15.tar.bz2 samba-b776bc5f72efac87244393a2bf1e5c9278bdaf15.zip |
krb5samba: Add compat krb5_make_principal for MIT build
Diffstat (limited to 'lib/krb5_wrap')
-rw-r--r-- | lib/krb5_wrap/krb5_samba.c | 35 | ||||
-rw-r--r-- | lib/krb5_wrap/krb5_samba.h | 10 |
2 files changed, 45 insertions, 0 deletions
diff --git a/lib/krb5_wrap/krb5_samba.c b/lib/krb5_wrap/krb5_samba.c index 482684fc11..4bfc2531c6 100644 --- a/lib/krb5_wrap/krb5_samba.c +++ b/lib/krb5_wrap/krb5_samba.c @@ -2093,6 +2093,41 @@ krb5_error_code kerberos_kinit_s4u2_cc(krb5_context ctx, } #endif +#if !defined(HAVE_KRB5_MAKE_PRINCIPAL) && defined(HAVE_KRB5_BUILD_PRINCIPAL_ALLOC_VA) +krb5_error_code smb_krb5_make_principal(krb5_context context, + krb5_principal *principal, + const char *_realm, ...) +{ + krb5_error_code code; + bool free_realm; + char *realm; + va_list ap; + + if (_realm) { + realm = _realm; + free_realm = false; + } else { + code = krb5_get_default_realm(context, &realm); + if (code) { + return code; + } + free_realm = true; + } + + va_start(ap, _realm); + code = krb5_build_principal_alloc_va(context, principal, + strlen(realm), realm, + ap); + va_end(ap); + + if (free_realm) { + krb5_free_default_realm(context, &realm); + } + + return code; +} +#endif + /* * smb_krb5_principal_get_realm * diff --git a/lib/krb5_wrap/krb5_samba.h b/lib/krb5_wrap/krb5_samba.h index a60be35a98..d9f61e7338 100644 --- a/lib/krb5_wrap/krb5_samba.h +++ b/lib/krb5_wrap/krb5_samba.h @@ -230,6 +230,16 @@ krb5_error_code kerberos_kinit_s4u2_cc(krb5_context ctx, time_t *expire_time, time_t *kdc_time); #endif + +#if defined(HAVE_KRB5_MAKE_PRINCIPAL) +#define smb_krb5_make_principal krb5_make_principal +#elif defined(HAVE_KRB5_BUILD_PRINCIPAL_ALLOC_VA) +krb5_error_code smb_krb5_make_principal(krb5_context context, + krb5_principal *principal, + const char *realm, ...); +#else +#error krb5_make_principal not available +#endif char *smb_krb5_principal_get_realm(krb5_context context, krb5_principal principal); |