diff options
-rw-r--r-- | lib/krb5_wrap/krb5_samba.c | 35 | ||||
-rw-r--r-- | lib/krb5_wrap/krb5_samba.h | 10 | ||||
-rw-r--r-- | source3/configure.in | 1 | ||||
-rwxr-xr-x | source4/heimdal_build/wscript_configure | 1 | ||||
-rw-r--r-- | wscript_configure_krb5 | 3 |
5 files changed, 49 insertions, 1 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); diff --git a/source3/configure.in b/source3/configure.in index 8790ea713b..cec0ece343 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -3615,6 +3615,7 @@ if test x"$with_ads_support" != x"no"; then AC_CHECK_FUNC_EXT(krb5_get_host_realm, $KRB5_LIBS) AC_CHECK_FUNC_EXT(krb5_free_host_realm, $KRB5_LIBS) AC_CHECK_FUNC_EXT(krb5_get_init_creds_keytab, $KRB5_LIBS) + AC_CHECK_FUNC_EXT(krb5_build_principal_alloc_va, $KRB5_LIBS) AC_CHECK_FUNC_EXT(gss_krb5_import_cred, $KRB5_LIBS) AC_CHECK_FUNC_EXT(gss_get_name_attribute, $KRB5_LIBS) AC_CHECK_FUNC_EXT(gsskrb5_extract_authz_data_from_sec_context, $KRB5_LIBS) diff --git a/source4/heimdal_build/wscript_configure b/source4/heimdal_build/wscript_configure index 80d772d56b..d993eec4ed 100755 --- a/source4/heimdal_build/wscript_configure +++ b/source4/heimdal_build/wscript_configure @@ -130,6 +130,7 @@ conf.define('HAVE_KRB5_MK_REQ_EXTENDED', 1) conf.define('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM', 1) conf.define('HAVE_KRB5_PRINCIPAL_GET_COMP_STRING', 1) conf.define('HAVE_KRB5_PRINCIPAL_GET_REALM', 1) +conf.define('HAVE_KRB5_MAKE_PRINCIPAL', 1) conf.define('HAVE_KRB5_REALM_TYPE', 1) conf.define('HAVE_KRB5_SET_DEFAULT_IN_TKT_ETYPES', 1) conf.define('HAVE_KRB5_SET_REAL_TIME', 1) diff --git a/wscript_configure_krb5 b/wscript_configure_krb5 index 1faa212e5f..4a483ef702 100644 --- a/wscript_configure_krb5 +++ b/wscript_configure_krb5 @@ -58,7 +58,8 @@ conf.CHECK_FUNCS(''' krb5_enctype_to_string krb5_fwd_tgt_creds krb5_auth_con_set_req_cksumtype krb5_get_creds_opt_alloc krb5_get_creds_opt_set_impersonate krb5_get_creds krb5_get_credentials_for_user krb5_get_host_realm krb5_free_host_realm - krb5_get_init_creds_keyblock krb5_get_init_creds_keytab''', + krb5_get_init_creds_keyblock krb5_get_init_creds_keytab + krb5_make_principal krb5_build_principal_alloc_va''', lib='krb5 k5crypto') conf.CHECK_DECLS('''krb5_get_credentials_for_user krb5_auth_con_set_req_cksumtype''', |