[SCM] Samba Shared Repository - branch master updated
Stefan Metzmacher
metze at samba.org
Tue Jun 28 12:36:03 MDT 2011
The branch, master has been updated
via b005fa1 s4:kdc/mit_samba: disable mit_samba_check_s4u2proxy()
via 73b1e14 s4:kdc: generate the S4U_DELEGATION_INFO in the regenerated pac
via 1909060 krb5pac.idl: add PAC_CONSTRAINED_DELEGATION (S4U_DELEGATION_INFO)
via 020f602 s4:kdc: use KRB5_WINDC_PLUGIN_MINOR define instead of KRB5_WINDC_PLUGING_MINOR
via cef06b5 HEIMDAL:kdc: pass down the delegated_proxy_principal to the verify_pac() function
via 6982ea7 HEIMDAL:kdc/windc_plugin.h: KRB5_WINDC_PLUGIN_MINOR 4 => 5
from 56db9c9 s3-waf: remove s3-waf specific dynconfig.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit b005fa142f2c3846960e39d1977f1cb2ef5a2f35
Author: Stefan Metzmacher <metze at samba.org>
Date: Tue Jun 28 18:22:25 2011 +0200
s4:kdc/mit_samba: disable mit_samba_check_s4u2proxy()
As mit_samba_update_pac_data() doesn't support adding
S4U_DELEGATION_INFO to the pac (and I have no clue how to add that)
we should disable S4U2Proxy until this is implemented.
metze
Autobuild-User: Stefan Metzmacher <metze at samba.org>
Autobuild-Date: Tue Jun 28 20:35:19 CEST 2011 on sn-devel-104
commit 73b1e1466cb3a2f3cadc2865b0226a48b3ff6f27
Author: Stefan Metzmacher <metze at samba.org>
Date: Tue Jun 28 14:46:49 2011 +0200
s4:kdc: generate the S4U_DELEGATION_INFO in the regenerated pac
metze
commit 19090607980c48dc565377dce830310d3a0bca7a
Author: Stefan Metzmacher <metze at samba.org>
Date: Tue Jun 28 14:47:56 2011 +0200
krb5pac.idl: add PAC_CONSTRAINED_DELEGATION (S4U_DELEGATION_INFO)
metze
commit 020f60287ce0389d4f7d838b4d6ded52a7e85453
Author: Stefan Metzmacher <metze at samba.org>
Date: Tue Jun 28 13:13:41 2011 +0200
s4:kdc: use KRB5_WINDC_PLUGIN_MINOR define instead of KRB5_WINDC_PLUGING_MINOR
metze
commit cef06b5ca180654471fa6d4aa0493ae3f53de2ea
Author: Stefan Metzmacher <metze at samba.org>
Date: Tue Jun 28 13:24:50 2011 +0200
HEIMDAL:kdc: pass down the delegated_proxy_principal to the verify_pac()
function
This is needed in order to add the S4U_DELEGATION_INFO to the pac.
metze
commit 6982ea767d2b1ddd2346431a8f2327cc29f45b87
Author: Stefan Metzmacher <metze at samba.org>
Date: Tue Jun 28 13:07:42 2011 +0200
HEIMDAL:kdc/windc_plugin.h: KRB5_WINDC_PLUGIN_MINOR 4 => 5
commit "heimdal Add support for extracting a particular KVNO from the database"
(f469fc6d4922d796f5c61bf43e3efc018e37b680 in heimdal/master
and 9b5e304ccedc8f0f7ce2342e4d9c621417dd1c1e in samba/master)
changed the windc_plugin interface, so we need to change the
version number.
metze
-----------------------------------------------------------------------
Summary of changes:
librpc/idl/krb5pac.idl | 14 ++++-
source4/heimdal/kdc/krb5tgs.c | 51 ++++++++++-----
source4/heimdal/kdc/windc.c | 5 +-
source4/heimdal/kdc/windc_plugin.h | 13 ++--
source4/kdc/mit_samba.c | 11 +++-
source4/kdc/pac-glue.c | 121 +++++++++++++++++++++++++++++++++++-
source4/kdc/pac-glue.h | 10 +++-
source4/kdc/wdc-samba4.c | 31 ++++++++-
8 files changed, 222 insertions(+), 34 deletions(-)
Changeset truncated at 500 lines:
diff --git a/librpc/idl/krb5pac.idl b/librpc/idl/krb5pac.idl
index fcd32c6..8a6540c 100644
--- a/librpc/idl/krb5pac.idl
+++ b/librpc/idl/krb5pac.idl
@@ -4,7 +4,7 @@
#include "idl_types.h"
-import "security.idl", "netlogon.idl", "samr.idl";
+import "security.idl", "lsa.idl", "netlogon.idl", "samr.idl";
[
uuid("12345778-1234-abcd-0000-00000000"),
@@ -32,6 +32,12 @@ interface krb5pac
} PAC_LOGON_INFO;
typedef struct {
+ lsa_String proxy_target;
+ uint32 num_transited_services;
+ [size_is(num_transited_services)] lsa_String *transited_services;
+ } PAC_CONSTRAINED_DELEGATION;
+
+ typedef struct {
[value(2*strlen_m(upn_name))] uint16 upn_size;
uint16 upn_offset;
[value(2*strlen_m(domain_name))] uint16 domain_size;
@@ -48,6 +54,10 @@ interface krb5pac
PAC_LOGON_INFO *info;
} PAC_LOGON_INFO_CTR;
+ typedef [public] struct {
+ PAC_CONSTRAINED_DELEGATION *info;
+ } PAC_CONSTRAINED_DELEGATION_CTR;
+
typedef [public,v1_enum] enum {
PAC_TYPE_LOGON_INFO = 1,
PAC_TYPE_SRV_CHECKSUM = 6,
@@ -66,6 +76,8 @@ interface krb5pac
[case(PAC_TYPE_SRV_CHECKSUM)] PAC_SIGNATURE_DATA srv_cksum;
[case(PAC_TYPE_KDC_CHECKSUM)] PAC_SIGNATURE_DATA kdc_cksum;
[case(PAC_TYPE_LOGON_NAME)] PAC_LOGON_NAME logon_name;
+ [case(PAC_TYPE_CONSTRAINED_DELEGATION)][subcontext(0xFFFFFC01)]
+ PAC_CONSTRAINED_DELEGATION_CTR constrained_delegation;
/* when new PAC info types are added they are supposed to be done
in such a way that they are backwards compatible with existing
servers. This makes it safe to just use a [default] for
diff --git a/source4/heimdal/kdc/krb5tgs.c b/source4/heimdal/kdc/krb5tgs.c
index e4fdb14..55d5d09 100644
--- a/source4/heimdal/kdc/krb5tgs.c
+++ b/source4/heimdal/kdc/krb5tgs.c
@@ -279,6 +279,7 @@ static krb5_error_code
check_PAC(krb5_context context,
krb5_kdc_configuration *config,
const krb5_principal client_principal,
+ const krb5_principal delegated_proxy_principal,
hdb_entry_ex *client,
hdb_entry_ex *server,
hdb_entry_ex *krbtgt,
@@ -336,6 +337,7 @@ check_PAC(krb5_context context,
}
ret = _kdc_pac_verify(context, client_principal,
+ delegated_proxy_principal,
client, server, krbtgt, &pac, &signed_pac);
if (ret) {
krb5_pac_free(context, pac);
@@ -1479,9 +1481,9 @@ tgs_build_reply(krb5_context context,
const struct sockaddr *from_addr)
{
krb5_error_code ret;
- krb5_principal cp = NULL, sp = NULL, tp = NULL;
+ krb5_principal cp = NULL, sp = NULL, tp = NULL, dp = NULL;
krb5_principal krbtgt_principal = NULL;
- char *spn = NULL, *cpn = NULL, *tpn = NULL;
+ char *spn = NULL, *cpn = NULL, *tpn = NULL, *dpn = NULL;
hdb_entry_ex *server = NULL, *client = NULL, *s4u2self_impersonated_client = NULL;
HDB *clientdb, *s4u2self_impersonated_clientdb;
krb5_realm ref_realm = NULL;
@@ -1802,7 +1804,7 @@ server_lookup:
krb5_free_error_message(context, msg);
}
- ret = check_PAC(context, config, cp,
+ ret = check_PAC(context, config, cp, NULL,
client, server, krbtgt,
&tkey_check->key, &tkey_check->key,
ekey, &tkey_sign->key,
@@ -2029,12 +2031,23 @@ server_lookup:
if (ret)
goto out;
+ ret = _krb5_principalname2krb5_principal(context,
+ &dp,
+ t->sname,
+ t->realm);
+ if (ret)
+ goto out;
+
+ ret = krb5_unparse_name(context, dp, &dpn);
+ if (ret)
+ goto out;
+
/* check that ticket is valid */
if (adtkt.flags.forwardable == 0) {
kdc_log(context, config, 0,
"Missing forwardable flag on ticket for "
- "constrained delegation from %s as %s to %s ",
- cpn, tpn, spn);
+ "constrained delegation from %s (%s) as %s to %s ",
+ cpn, dpn, tpn, spn);
ret = KRB5KDC_ERR_BADOPTION;
goto out;
}
@@ -2043,8 +2056,8 @@ server_lookup:
client, server, sp);
if (ret) {
kdc_log(context, config, 0,
- "constrained delegation from %s as %s to %s not allowed",
- cpn, tpn, spn);
+ "constrained delegation from %s (%s) as %s to %s not allowed",
+ cpn, dpn, tpn, spn);
goto out;
}
@@ -2055,12 +2068,10 @@ server_lookup:
krb5_data_free(&rspac);
/*
- * generate the PAC for the user.
- *
- * TODO: pass in t->sname and t->realm and build
- * a S4U_DELEGATION_INFO blob to the PAC.
+ * generate the PAC for the user and pass
+ * dp for the S4U_DELEGATION_INFO blob in the PAC.
*/
- ret = check_PAC(context, config, tp,
+ ret = check_PAC(context, config, tp, dp,
client, server, krbtgt,
&clientkey->key, &tkey_check->key,
ekey, &tkey_sign->key,
@@ -2071,8 +2082,8 @@ server_lookup:
const char *msg = krb5_get_error_message(context, ret);
kdc_log(context, config, 0,
"Verify delegated PAC failed to %s for client"
- "%s as %s from %s with %s",
- spn, cpn, tpn, from, msg);
+ "%s (%s) as %s from %s with %s",
+ spn, cpn, dpn, tpn, from, msg);
krb5_free_error_message(context, msg);
goto out;
}
@@ -2093,15 +2104,15 @@ server_lookup:
const char *msg = krb5_get_error_message(context, ret);
kdc_log(context, config, 0,
"KRB5SignedPath check from service %s failed "
- "for delegation to %s for client %s "
+ "for delegation to %s for client %s (%s)"
"from %s failed with %s",
- spn, tpn, cpn, from, msg);
+ spn, tpn, dpn, cpn, from, msg);
krb5_free_error_message(context, msg);
goto out;
}
kdc_log(context, config, 0, "constrained delegation for %s "
- "from %s to %s", tpn, cpn, spn);
+ "from %s (%s) to %s", tpn, cpn, dpn, spn);
}
/*
@@ -2198,7 +2209,9 @@ out:
free(tpn);
free(spn);
free(cpn);
-
+ if (dpn)
+ free(dpn);
+
krb5_data_free(&rspac);
krb5_free_keyblock_contents(context, &sessionkey);
if(krbtgt_out)
@@ -2214,6 +2227,8 @@ out:
krb5_free_principal(context, tp);
if (cp)
krb5_free_principal(context, cp);
+ if (dp)
+ krb5_free_principal(context, dp);
if (sp)
krb5_free_principal(context, sp);
if (ref_realm)
diff --git a/source4/heimdal/kdc/windc.c b/source4/heimdal/kdc/windc.c
index 6efbeee..a58cebb 100644
--- a/source4/heimdal/kdc/windc.c
+++ b/source4/heimdal/kdc/windc.c
@@ -84,6 +84,7 @@ _kdc_pac_generate(krb5_context context,
krb5_error_code
_kdc_pac_verify(krb5_context context,
const krb5_principal client_principal,
+ const krb5_principal delegated_proxy_principal,
hdb_entry_ex *client,
hdb_entry_ex *server,
hdb_entry_ex *krbtgt,
@@ -96,7 +97,9 @@ _kdc_pac_verify(krb5_context context,
return 0;
ret = windcft->pac_verify(windcctx, context,
- client_principal, client, server, krbtgt, pac);
+ client_principal,
+ delegated_proxy_principal,
+ client, server, krbtgt, pac);
if (ret == 0)
*verified = 1;
return ret;
diff --git a/source4/heimdal/kdc/windc_plugin.h b/source4/heimdal/kdc/windc_plugin.h
index 037fc8c..b328e3f 100644
--- a/source4/heimdal/kdc/windc_plugin.h
+++ b/source4/heimdal/kdc/windc_plugin.h
@@ -57,10 +57,11 @@ typedef krb5_error_code
typedef krb5_error_code
(*krb5plugin_windc_pac_verify)(void *, krb5_context,
- const krb5_principal,
- struct hdb_entry_ex *,
- struct hdb_entry_ex *,
- struct hdb_entry_ex *,
+ const krb5_principal, /* new ticket client */
+ const krb5_principal, /* delegation proxy */
+ struct hdb_entry_ex *,/* client */
+ struct hdb_entry_ex *,/* server */
+ struct hdb_entry_ex *,/* krbtgt */
krb5_pac *);
typedef krb5_error_code
@@ -72,8 +73,8 @@ typedef krb5_error_code
KDC_REQ *, krb5_data *);
-#define KRB5_WINDC_PLUGING_MINOR 4
-#define KRB5_WINDC_PLUGIN_MINOR 4
+#define KRB5_WINDC_PLUGIN_MINOR 6
+#define KRB5_WINDC_PLUGING_MINOR KRB5_WINDC_PLUGIN_MINOR
typedef struct krb5plugin_windc_ftable {
int minor_version;
diff --git a/source4/kdc/mit_samba.c b/source4/kdc/mit_samba.c
index 50b5d1d..06ee46e 100644
--- a/source4/kdc/mit_samba.c
+++ b/source4/kdc/mit_samba.c
@@ -255,7 +255,7 @@ static int mit_samba_update_pac_data(struct mit_samba_context *ctx,
}
nt_status = samba_kdc_update_pac_blob(tmp_ctx, ctx->context,
- &pac, logon_blob);
+ pac, logon_blob);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Building PAC failed: %s\n",
nt_errstr(nt_status)));
@@ -316,6 +316,14 @@ static int mit_samba_check_s4u2proxy(struct mit_samba_context *ctx,
const char *target_name,
bool is_nt_enterprise_name)
{
+#if 1
+ /*
+ * This is disabled because mit_samba_update_pac_data() does not handle
+ * S4U_DELEGATION_INFO
+ */
+
+ return KRB5KDC_ERR_BADOPTION;
+#else
krb5_principal target_principal;
int flags = 0;
int ret;
@@ -338,6 +346,7 @@ static int mit_samba_check_s4u2proxy(struct mit_samba_context *ctx,
krb5_free_principal(ctx->context, target_principal);
return ret;
+#endif
}
struct mit_samba_function_table mit_samba_function_table = {
diff --git a/source4/kdc/pac-glue.c b/source4/kdc/pac-glue.c
index 38db41d..e92a511 100644
--- a/source4/kdc/pac-glue.c
+++ b/source4/kdc/pac-glue.c
@@ -72,9 +72,11 @@ NTSTATUS samba_get_logon_info_pac_blob(TALLOC_CTX *mem_ctx,
krb5_error_code samba_make_krb5_pac(krb5_context context,
DATA_BLOB *pac_blob,
+ DATA_BLOB *deleg_blob,
krb5_pac *pac)
{
krb5_data pac_data;
+ krb5_data deleg_data;
krb5_error_code ret;
/* The user account may be set not to want the PAC */
@@ -87,18 +89,41 @@ krb5_error_code samba_make_krb5_pac(krb5_context context,
return ret;
}
+ ZERO_STRUCT(deleg_data);
+ if (deleg_blob) {
+ ret = krb5_data_copy(&deleg_data,
+ deleg_blob->data,
+ deleg_blob->length);
+ if (ret != 0) {
+ krb5_data_free(&pac_data);
+ return ret;
+ }
+ }
+
ret = krb5_pac_init(context, pac);
if (ret != 0) {
krb5_data_free(&pac_data);
+ krb5_data_free(&deleg_data);
return ret;
}
ret = krb5_pac_add_buffer(context, *pac, PAC_TYPE_LOGON_INFO, &pac_data);
krb5_data_free(&pac_data);
if (ret != 0) {
+ krb5_data_free(&deleg_data);
return ret;
}
+ if (deleg_blob) {
+ ret = krb5_pac_add_buffer(context, *pac,
+ PAC_TYPE_CONSTRAINED_DELEGATION,
+ &deleg_data);
+ krb5_data_free(&deleg_data);
+ if (ret != 0) {
+ return ret;
+ }
+ }
+
return ret;
}
@@ -183,13 +208,13 @@ NTSTATUS samba_kdc_get_pac_blob(TALLOC_CTX *mem_ctx,
NTSTATUS samba_kdc_update_pac_blob(TALLOC_CTX *mem_ctx,
krb5_context context,
- krb5_pac *pac, DATA_BLOB *pac_blob)
+ const krb5_pac pac, DATA_BLOB *pac_blob)
{
struct auth_user_info_dc *user_info_dc;
krb5_error_code ret;
NTSTATUS nt_status;
- ret = kerberos_pac_to_user_info_dc(mem_ctx, *pac,
+ ret = kerberos_pac_to_user_info_dc(mem_ctx, pac,
context, &user_info_dc, NULL, NULL);
if (ret) {
return NT_STATUS_UNSUCCESSFUL;
@@ -201,6 +226,98 @@ NTSTATUS samba_kdc_update_pac_blob(TALLOC_CTX *mem_ctx,
return nt_status;
}
+NTSTATUS samba_kdc_update_delegation_info_blob(TALLOC_CTX *mem_ctx,
+ krb5_context context,
+ const krb5_pac pac,
+ const krb5_principal server_principal,
+ const krb5_principal proxy_principal,
+ DATA_BLOB *new_blob)
+{
+ krb5_data old_data;
+ DATA_BLOB old_blob;
+ krb5_error_code ret;
+ NTSTATUS nt_status;
+ enum ndr_err_code ndr_err;
+ union PAC_INFO info;
+ struct PAC_CONSTRAINED_DELEGATION _d;
+ struct PAC_CONSTRAINED_DELEGATION *d = NULL;
+ char *server = NULL;
+ char *proxy = NULL;
+ uint32_t i;
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+
+ if (tmp_ctx == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ret = krb5_pac_get_buffer(context, pac, PAC_TYPE_CONSTRAINED_DELEGATION, &old_data);
+ if (ret == ENOENT) {
+ ZERO_STRUCT(old_data);
+ } else if (ret) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ old_blob.length = old_data.length;
+ old_blob.data = (uint8_t *)old_data.data;
+
+ ZERO_STRUCT(info);
+ if (old_blob.length > 0) {
+ ndr_err = ndr_pull_union_blob(&old_blob, mem_ctx,
+ &info, PAC_TYPE_CONSTRAINED_DELEGATION,
+ (ndr_pull_flags_fn_t)ndr_pull_PAC_INFO);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ krb5_data_free(&old_data);
+ nt_status = ndr_map_error2ntstatus(ndr_err);
+ DEBUG(0,("can't parse the PAC LOGON_INFO: %s\n", nt_errstr(nt_status)));
+ talloc_free(tmp_ctx);
+ return nt_status;
+ }
+ } else {
+ ZERO_STRUCT(_d);
+ info.constrained_delegation.info = &_d;
+ }
+ krb5_data_free(&old_data);
+
+ ret = krb5_unparse_name(context, server_principal, &server);
+ if (ret) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ ret = krb5_unparse_name_flags(context, proxy_principal,
+ KRB5_PRINCIPAL_UNPARSE_NO_REALM, &proxy);
+ if (ret) {
+ SAFE_FREE(server);
+ talloc_free(tmp_ctx);
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ d = info.constrained_delegation.info;
+ i = d->num_transited_services;
+ d->proxy_target.string = server;
+ d->transited_services = talloc_realloc(mem_ctx, d->transited_services,
+ struct lsa_String, i + 1);
+ d->transited_services[i].string = proxy;
+ d->num_transited_services = i + 1;
+
+ ndr_err = ndr_push_union_blob(new_blob, mem_ctx,
+ &info, PAC_TYPE_CONSTRAINED_DELEGATION,
+ (ndr_push_flags_fn_t)ndr_push_PAC_INFO);
+ SAFE_FREE(server);
+ SAFE_FREE(proxy);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ krb5_data_free(&old_data);
+ nt_status = ndr_map_error2ntstatus(ndr_err);
+ DEBUG(0,("can't parse the PAC LOGON_INFO: %s\n", nt_errstr(nt_status)));
+ talloc_free(tmp_ctx);
+ return nt_status;
+ }
+
+ talloc_free(tmp_ctx);
+ return NT_STATUS_OK;
+}
+
/* this function allocates 'data' using malloc.
* The caller is responsible for freeing it */
void samba_kdc_build_edata_reply(NTSTATUS nt_status, DATA_BLOB *e_data)
diff --git a/source4/kdc/pac-glue.h b/source4/kdc/pac-glue.h
index c5cc661..66c20cd 100644
--- a/source4/kdc/pac-glue.h
+++ b/source4/kdc/pac-glue.h
@@ -23,6 +23,7 @@
krb5_error_code samba_make_krb5_pac(krb5_context context,
DATA_BLOB *pac_blob,
+ DATA_BLOB *deleg_blob,
krb5_pac *pac);
bool samba_princ_needs_pac(struct hdb_entry_ex *princ);
@@ -35,7 +36,14 @@ NTSTATUS samba_kdc_get_pac_blob(TALLOC_CTX *mem_ctx,
NTSTATUS samba_kdc_update_pac_blob(TALLOC_CTX *mem_ctx,
krb5_context context,
- krb5_pac *pac, DATA_BLOB *pac_blob);
+ const krb5_pac pac, DATA_BLOB *pac_blob);
+
+NTSTATUS samba_kdc_update_delegation_info_blob(TALLOC_CTX *mem_ctx,
+ krb5_context context,
+ const krb5_pac pac,
+ const krb5_principal server_principal,
+ const krb5_principal proxy_principal,
+ DATA_BLOB *pac_blob);
void samba_kdc_build_edata_reply(NTSTATUS nt_status, DATA_BLOB *e_data);
diff --git a/source4/kdc/wdc-samba4.c b/source4/kdc/wdc-samba4.c
index 805772f..99ad96a 100644
--- a/source4/kdc/wdc-samba4.c
+++ b/source4/kdc/wdc-samba4.c
@@ -46,7 +46,7 @@ static krb5_error_code samba_wdc_get_pac(void *priv, krb5_context context,
return EINVAL;
}
- ret = samba_make_krb5_pac(context, pac_blob, pac);
+ ret = samba_make_krb5_pac(context, pac_blob, NULL, pac);
talloc_free(mem_ctx);
return ret;
@@ -56,6 +56,7 @@ static krb5_error_code samba_wdc_get_pac(void *priv, krb5_context context,
static krb5_error_code samba_wdc_reget_pac(void *priv, krb5_context context,
const krb5_principal client_principal,
+ const krb5_principal delegated_proxy_principal,
struct hdb_entry_ex *client,
--
Samba Shared Repository
More information about the samba-cvs
mailing list