From e0ac659917066dbf7f8fdbcc7684ce2b49dd04d9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 26 Nov 2003 01:16:41 +0000 Subject: signed DCERPC over TCP now works ! * moved ntlmssp code into libcli/auth/, and updated to latest ntlmssp code from samba3 (thanks Andrew! the new interface is great) * added signing/ntlmssp support in the dcerpc code * added a dcerpc_auth.c module for the various dcerpc auth mechanisms (This used to be commit c18c9b5585a3e5f7868562820c14f7cb529cdbcd) --- source4/librpc/rpc/dcerpc_auth.c | 130 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 source4/librpc/rpc/dcerpc_auth.c (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c new file mode 100644 index 0000000000..32fdcb0b86 --- /dev/null +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -0,0 +1,130 @@ +/* + Unix SMB/CIFS implementation. + + dcerpc authentication operations + + Copyright (C) Andrew Tridgell 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* + do a simple ntlm style authentication on a dcerpc pipe +*/ +NTSTATUS dcerpc_bind_auth_ntlm(struct dcerpc_pipe *p, + const char *uuid, unsigned version, + const char *domain, + const char *username, + const char *password) +{ + NTSTATUS status; + struct ntlmssp_state *state; + TALLOC_CTX *mem_ctx; + + mem_ctx = talloc_init("dcerpc_bind_auth_ntlm"); + if (!mem_ctx) { + return NT_STATUS_NO_MEMORY; + } + + status = ntlmssp_client_start(&state); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + status = ntlmssp_set_domain(state, domain); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + + status = ntlmssp_set_username(state, username); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + + status = ntlmssp_set_password(state, password); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + + p->auth_info = talloc(p->mem_ctx, sizeof(*p->auth_info)); + if (!p->auth_info) { + status = NT_STATUS_NO_MEMORY; + goto done; + } + + p->auth_info->auth_type = DCERPC_AUTH_TYPE_NTLMSSP; + p->auth_info->auth_level = DCERPC_AUTH_LEVEL_INTEGRITY; + p->auth_info->auth_pad_length = 0; + p->auth_info->auth_reserved = 0; + p->auth_info->auth_context_id = random(); + p->auth_info->credentials = data_blob(NULL, 0); + p->ntlmssp_state = NULL; + + status = ntlmssp_update(state, + p->auth_info->credentials, + &p->auth_info->credentials); + if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + goto done; + } + status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + + status = ntlmssp_update(state, + p->auth_info->credentials, + &p->auth_info->credentials); + if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + goto done; + } + + status = dcerpc_auth3(p, mem_ctx); + p->ntlmssp_state = state; + p->auth_info->credentials = data_blob(NULL, 0); + + ntlmssp_sign_init(state); + +done: + talloc_destroy(mem_ctx); + + if (!NT_STATUS_IS_OK(status)) { + p->ntlmssp_state = NULL; + } + + return status; +} + + +/* + do a non-athenticated dcerpc bind +*/ +NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, + const char *uuid, unsigned version) +{ + TALLOC_CTX *mem_ctx; + NTSTATUS status; + + mem_ctx = talloc_init("dcerpc_bind_auth_ntlm"); + if (!mem_ctx) { + return NT_STATUS_NO_MEMORY; + } + + status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version); + talloc_destroy(mem_ctx); + + return status; +} -- cgit From c123c8454142d17d2884ae9dd951b7f2a0b1a343 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 26 Nov 2003 02:08:41 +0000 Subject: fixed some memory leaks in the dcerpc use of ntlmssp signing (This used to be commit abbc9993b8f7eb9f57e079db1d0b170d0b9aa443) --- source4/librpc/rpc/dcerpc_auth.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 32fdcb0b86..103a3c70d8 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -34,6 +34,7 @@ NTSTATUS dcerpc_bind_auth_ntlm(struct dcerpc_pipe *p, NTSTATUS status; struct ntlmssp_state *state; TALLOC_CTX *mem_ctx; + DATA_BLOB credentials; mem_ctx = talloc_init("dcerpc_bind_auth_ntlm"); if (!mem_ctx) { @@ -76,27 +77,44 @@ NTSTATUS dcerpc_bind_auth_ntlm(struct dcerpc_pipe *p, status = ntlmssp_update(state, p->auth_info->credentials, - &p->auth_info->credentials); + &credentials); if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { goto done; } + + p->auth_info->credentials = data_blob_talloc(mem_ctx, + credentials.data, + credentials.length); + data_blob_free(&credentials); + status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version); if (!NT_STATUS_IS_OK(status)) { goto done; } + status = ntlmssp_update(state, p->auth_info->credentials, - &p->auth_info->credentials); + &credentials); if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { goto done; } + p->auth_info->credentials = data_blob_talloc(mem_ctx, + credentials.data, + credentials.length); + data_blob_free(&credentials); + status = dcerpc_auth3(p, mem_ctx); + + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + p->ntlmssp_state = state; - p->auth_info->credentials = data_blob(NULL, 0); - ntlmssp_sign_init(state); + /* setup for signing */ + status = ntlmssp_sign_init(state); done: talloc_destroy(mem_ctx); -- cgit From 1ca1b85c4c0bcf3315ef82316289fe03ecf11737 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 26 Nov 2003 12:29:08 +0000 Subject: by default sign RPC over TCP but not RPC over SMB. I will add command line control soon (This used to be commit 215852116c1fb8c0d8ef559155a3dd55346f0c31) --- source4/librpc/rpc/dcerpc_auth.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 103a3c70d8..5850ec6979 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -68,7 +68,17 @@ NTSTATUS dcerpc_bind_auth_ntlm(struct dcerpc_pipe *p, } p->auth_info->auth_type = DCERPC_AUTH_TYPE_NTLMSSP; - p->auth_info->auth_level = DCERPC_AUTH_LEVEL_INTEGRITY; + + if (p->flags & DCERPC_SEAL) { + p->auth_info->auth_level = DCERPC_AUTH_LEVEL_PRIVACY; + state->neg_flags |= NTLMSSP_NEGOTIATE_SIGN | NTLMSSP_NEGOTIATE_SEAL; + } else if (p->flags & DCERPC_SIGN) { + state->neg_flags |= NTLMSSP_NEGOTIATE_SIGN; + p->auth_info->auth_level = DCERPC_AUTH_LEVEL_INTEGRITY; + } else { + state->neg_flags &= ~(NTLMSSP_NEGOTIATE_SIGN | NTLMSSP_NEGOTIATE_SEAL); + p->auth_info->auth_level = DCERPC_AUTH_LEVEL_NONE; + } p->auth_info->auth_pad_length = 0; p->auth_info->auth_reserved = 0; p->auth_info->auth_context_id = random(); @@ -113,8 +123,13 @@ NTSTATUS dcerpc_bind_auth_ntlm(struct dcerpc_pipe *p, p->ntlmssp_state = state; - /* setup for signing */ - status = ntlmssp_sign_init(state); + switch (p->auth_info->auth_level) { + case DCERPC_AUTH_LEVEL_PRIVACY: + case DCERPC_AUTH_LEVEL_INTEGRITY: + /* setup for signing */ + status = ntlmssp_sign_init(state); + break; + } done: talloc_destroy(mem_ctx); -- cgit From a9203bf02b61180049bc60e7010acaff07c73947 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 27 Nov 2003 04:02:15 +0000 Subject: a couple of tidyups * don't try to map the epmapper uuid ! * some preliminary support for alter context pdus (This used to be commit f9857e56850cabfac06534fb33ff7a7a04346a9b) --- source4/librpc/rpc/dcerpc_auth.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 5850ec6979..99ea03c216 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -136,6 +136,7 @@ done: if (!NT_STATUS_IS_OK(status)) { p->ntlmssp_state = NULL; + p->auth_info = NULL; } return status; -- cgit From 078cced5ec1026432f5df275a7023db70a62693e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Feb 2004 10:22:12 +0000 Subject: - modified the dcerpc client security code to be generic, so ntlmssp and schannel are both instances of possible security modules - added schannel sign and sign/seal support to the dcerpc client code. You select it with binding options of "schannel,sign" or "schannel,seal". (This used to be commit 05db0b9d942cad8f1dd574dc35b759e5e79d4195) --- source4/librpc/rpc/dcerpc_auth.c | 121 --------------------------------------- 1 file changed, 121 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 99ea03c216..2b01ad2d4e 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -22,127 +22,6 @@ #include "includes.h" -/* - do a simple ntlm style authentication on a dcerpc pipe -*/ -NTSTATUS dcerpc_bind_auth_ntlm(struct dcerpc_pipe *p, - const char *uuid, unsigned version, - const char *domain, - const char *username, - const char *password) -{ - NTSTATUS status; - struct ntlmssp_state *state; - TALLOC_CTX *mem_ctx; - DATA_BLOB credentials; - - mem_ctx = talloc_init("dcerpc_bind_auth_ntlm"); - if (!mem_ctx) { - return NT_STATUS_NO_MEMORY; - } - - status = ntlmssp_client_start(&state); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - status = ntlmssp_set_domain(state, domain); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - status = ntlmssp_set_username(state, username); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - status = ntlmssp_set_password(state, password); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - p->auth_info = talloc(p->mem_ctx, sizeof(*p->auth_info)); - if (!p->auth_info) { - status = NT_STATUS_NO_MEMORY; - goto done; - } - - p->auth_info->auth_type = DCERPC_AUTH_TYPE_NTLMSSP; - - if (p->flags & DCERPC_SEAL) { - p->auth_info->auth_level = DCERPC_AUTH_LEVEL_PRIVACY; - state->neg_flags |= NTLMSSP_NEGOTIATE_SIGN | NTLMSSP_NEGOTIATE_SEAL; - } else if (p->flags & DCERPC_SIGN) { - state->neg_flags |= NTLMSSP_NEGOTIATE_SIGN; - p->auth_info->auth_level = DCERPC_AUTH_LEVEL_INTEGRITY; - } else { - state->neg_flags &= ~(NTLMSSP_NEGOTIATE_SIGN | NTLMSSP_NEGOTIATE_SEAL); - p->auth_info->auth_level = DCERPC_AUTH_LEVEL_NONE; - } - p->auth_info->auth_pad_length = 0; - p->auth_info->auth_reserved = 0; - p->auth_info->auth_context_id = random(); - p->auth_info->credentials = data_blob(NULL, 0); - p->ntlmssp_state = NULL; - - status = ntlmssp_update(state, - p->auth_info->credentials, - &credentials); - if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { - goto done; - } - - p->auth_info->credentials = data_blob_talloc(mem_ctx, - credentials.data, - credentials.length); - data_blob_free(&credentials); - - status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - - status = ntlmssp_update(state, - p->auth_info->credentials, - &credentials); - if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { - goto done; - } - - p->auth_info->credentials = data_blob_talloc(mem_ctx, - credentials.data, - credentials.length); - data_blob_free(&credentials); - - status = dcerpc_auth3(p, mem_ctx); - - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - p->ntlmssp_state = state; - - switch (p->auth_info->auth_level) { - case DCERPC_AUTH_LEVEL_PRIVACY: - case DCERPC_AUTH_LEVEL_INTEGRITY: - /* setup for signing */ - status = ntlmssp_sign_init(state); - break; - } - -done: - talloc_destroy(mem_ctx); - - if (!NT_STATUS_IS_OK(status)) { - p->ntlmssp_state = NULL; - p->auth_info = NULL; - } - - return status; -} - - /* do a non-athenticated dcerpc bind */ -- cgit From 770e3307ce3da928762e15a136c562df86a9c799 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 1 Jun 2004 10:12:52 +0000 Subject: r962: convert 'unsigned' and 'unsigned int' to uint_t metze (This used to be commit 57151e80eb1090281401930c8fe25b20a8cf3a38) --- source4/librpc/rpc/dcerpc_auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 2b01ad2d4e..3faf0603ce 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -26,7 +26,7 @@ do a non-athenticated dcerpc bind */ NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, - const char *uuid, unsigned version) + const char *uuid, uint_t version) { TALLOC_CTX *mem_ctx; NTSTATUS status; -- cgit From c0871cb0c13599039f4e8243bd8d60d472653930 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 7 Jun 2004 12:30:22 +0000 Subject: r1068: make the dcerpc client side auth/crypto code much more generic metze (This used to be commit 1706ff88a72c6578a109c2cf24f2f009812c3892) --- source4/librpc/rpc/dcerpc_auth.c | 99 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 3faf0603ce..021249847a 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -41,3 +41,102 @@ NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, return status; } + +const struct dcesrv_security_ops *dcerpc_security_by_authtype(uint8_t auth_type) +{ + switch (auth_type) { + case DCERPC_AUTH_TYPE_SCHANNEL: + return dcerpc_schannel_security_get_ops(); + + case DCERPC_AUTH_TYPE_NTLMSSP: + return dcerpc_ntlmssp_security_get_ops(); + } + + return NULL; +} + +NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, + const char *uuid, uint_t version, + const char *domain, + const char *username, + const char *password) +{ + NTSTATUS status; + TALLOC_CTX *mem_ctx; + DATA_BLOB credentials; + + mem_ctx = talloc_init("dcerpc_bind_auth"); + if (!mem_ctx) { + return NT_STATUS_NO_MEMORY; + } + + p->security_state.ops = dcerpc_security_by_authtype(auth_type); + if (!p->security_state.ops) { + status = NT_STATUS_INVALID_PARAMETER; + goto done; + } + + p->security_state.user.domain = domain; + p->security_state.user.name = username; + p->security_state.user.password = password; + + status = p->security_state.ops->start(p, &p->security_state); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + p->security_state.auth_info = talloc(p->mem_ctx, sizeof(*p->security_state.auth_info)); + if (!p->security_state.auth_info) { + status = NT_STATUS_NO_MEMORY; + goto done; + } + + p->security_state.auth_info->auth_type = auth_type; + p->security_state.auth_info->auth_pad_length = 0; + p->security_state.auth_info->auth_reserved = 0; + p->security_state.auth_info->auth_context_id = random(); + p->security_state.auth_info->credentials = data_blob(NULL, 0); + + if (p->flags & DCERPC_SEAL) { + p->security_state.auth_info->auth_level = DCERPC_AUTH_LEVEL_PRIVACY; + } else if (p->flags & DCERPC_SIGN) { + p->security_state.auth_info->auth_level = DCERPC_AUTH_LEVEL_INTEGRITY; + } else { + p->security_state.auth_info->auth_level = DCERPC_AUTH_LEVEL_NONE; + } + + status = p->security_state.ops->update(&p->security_state, mem_ctx, + p->security_state.auth_info->credentials, + &credentials); + + if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + goto done; + } + + p->security_state.auth_info->credentials = credentials; + + status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + + status = p->security_state.ops->update(&p->security_state, mem_ctx, + p->security_state.auth_info->credentials, + &credentials); + + if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + goto done; + } + + p->security_state.auth_info->credentials = credentials; + + status = dcerpc_auth3(p, mem_ctx); +done: + talloc_destroy(mem_ctx); + + if (!NT_STATUS_IS_OK(status)) { + ZERO_STRUCT(p->security_state); + } + + return status; +} -- cgit From be081037e09bb78c0308cd6c7a5d7ae563678b7c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 20 Jun 2004 00:58:09 +0000 Subject: r1200: Add 'gensec', our generic security layer. This layer is used for DCERPC security, as well as ntlm_auth at this time. It expect things like SASL and the CIFS layer to use it as well. The particular purpose of this layer is to introduce SPENGO, which needs generic access to the actual implementation mechanisms. Schannel, due to it's 'interesting' setup properties is in GENSEC, but is only in the RPC code. Andrew Bartlett (This used to be commit 902af49006fb8cfecaadd3cc0c10e2e542083fb1) --- source4/librpc/rpc/dcerpc_auth.c | 63 ++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 38 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 021249847a..e5fad1f082 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -1,9 +1,11 @@ /* Unix SMB/CIFS implementation. - dcerpc authentication operations + Generic Authentication Interface Copyright (C) Andrew Tridgell 2003 + Copyright (C) Andrew Bartlett 2004 + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -42,24 +44,8 @@ NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, return status; } -const struct dcesrv_security_ops *dcerpc_security_by_authtype(uint8_t auth_type) -{ - switch (auth_type) { - case DCERPC_AUTH_TYPE_SCHANNEL: - return dcerpc_schannel_security_get_ops(); - - case DCERPC_AUTH_TYPE_NTLMSSP: - return dcerpc_ntlmssp_security_get_ops(); - } - - return NULL; -} - NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, - const char *uuid, uint_t version, - const char *domain, - const char *username, - const char *password) + const char *uuid, uint_t version) { NTSTATUS status; TALLOC_CTX *mem_ctx; @@ -69,20 +55,19 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, if (!mem_ctx) { return NT_STATUS_NO_MEMORY; } - - p->security_state.ops = dcerpc_security_by_authtype(auth_type); - if (!p->security_state.ops) { - status = NT_STATUS_INVALID_PARAMETER; - goto done; - } - - p->security_state.user.domain = domain; - p->security_state.user.name = username; - p->security_state.user.password = password; - - status = p->security_state.ops->start(p, &p->security_state); - if (!NT_STATUS_IS_OK(status)) { - return status; + + if (!p->security_state.generic_state.ops) { + + p->security_state.generic_state.ops = gensec_security_by_authtype(auth_type); + if (!p->security_state.generic_state.ops) { + status = NT_STATUS_INVALID_PARAMETER; + goto done; + } + + status = p->security_state.generic_state.ops->client_start(&p->security_state.generic_state); + if (!NT_STATUS_IS_OK(status)) { + return status; + } } p->security_state.auth_info = talloc(p->mem_ctx, sizeof(*p->security_state.auth_info)); @@ -105,9 +90,9 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, p->security_state.auth_info->auth_level = DCERPC_AUTH_LEVEL_NONE; } - status = p->security_state.ops->update(&p->security_state, mem_ctx, - p->security_state.auth_info->credentials, - &credentials); + status = p->security_state.generic_state.ops->update(&p->security_state.generic_state, mem_ctx, + p->security_state.auth_info->credentials, + &credentials); if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { goto done; @@ -120,9 +105,9 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, goto done; } - status = p->security_state.ops->update(&p->security_state, mem_ctx, - p->security_state.auth_info->credentials, - &credentials); + status = p->security_state.generic_state.ops->update(&p->security_state.generic_state, mem_ctx, + p->security_state.auth_info->credentials, + &credentials); if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { goto done; @@ -140,3 +125,5 @@ done: return status; } + + -- cgit From dc9f55dbec5f892b39d924d5fd033b5eec1e14e4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 29 Jun 2004 09:40:10 +0000 Subject: r1294: A nice, large, commit... This implements gensec for Samba's server side, and brings gensec up to the standards of a full subsystem. This means that use of the subsystem is by gensec_* functions, not function pointers in structures (this is internal). This causes changes in all the existing gensec users. Our RPC server no longer contains it's own generalised security scheme, and now calls gensec directly. Gensec has also taken over the role of auth/auth_ntlmssp.c An important part of gensec, is the output of the 'session_info' struct. This is now reference counted, so that we can correctly free it when a pipe is closed, no matter if it was inherited, or created by per-pipe authentication. The schannel code is reworked, to be in the same file for client and server. ntlm_auth is reworked to use gensec. The major problem with this code is the way it relies on subsystem auto-initialisation. The primary reason for this commit now.is to allow these problems to be looked at, and fixed. There are problems with the new code: - I've tested it with smbtorture, but currently don't have VMware and valgrind working (this I'll fix soon). - The SPNEGO code is client-only at this point. - We still do not do kerberos. Andrew Bartlett (This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec) --- source4/librpc/rpc/dcerpc_auth.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index e5fad1f082..07601e4724 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -56,15 +56,14 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, return NT_STATUS_NO_MEMORY; } - if (!p->security_state.generic_state.ops) { - - p->security_state.generic_state.ops = gensec_security_by_authtype(auth_type); - if (!p->security_state.generic_state.ops) { - status = NT_STATUS_INVALID_PARAMETER; - goto done; + if (!p->security_state.generic_state) { + status = gensec_client_start(&p->security_state.generic_state); + if (!NT_STATUS_IS_OK(status)) { + return status; } - status = p->security_state.generic_state.ops->client_start(&p->security_state.generic_state); + status = gensec_start_mech_by_authtype(p->security_state.generic_state, auth_type); + if (!NT_STATUS_IS_OK(status)) { return status; } @@ -90,10 +89,10 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, p->security_state.auth_info->auth_level = DCERPC_AUTH_LEVEL_NONE; } - status = p->security_state.generic_state.ops->update(&p->security_state.generic_state, mem_ctx, - p->security_state.auth_info->credentials, - &credentials); - + status = gensec_update(p->security_state.generic_state, mem_ctx, + p->security_state.auth_info->credentials, + &credentials); + if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { goto done; } @@ -105,9 +104,9 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, goto done; } - status = p->security_state.generic_state.ops->update(&p->security_state.generic_state, mem_ctx, - p->security_state.auth_info->credentials, - &credentials); + status = gensec_update(p->security_state.generic_state, mem_ctx, + p->security_state.auth_info->credentials, + &credentials); if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { goto done; -- cgit From 25f396edfbaa313d63d775a4621245236750ec29 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 6 Jul 2004 02:20:45 +0000 Subject: r1354: Make it clear that the first gensec_update takes a NULL data_blob. Andrew Bartlett (This used to be commit 842a5dfc1f313b771fef14a484be6eea8c6eedf8) --- source4/librpc/rpc/dcerpc_auth.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 07601e4724..92f1a88485 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -50,6 +50,7 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, NTSTATUS status; TALLOC_CTX *mem_ctx; DATA_BLOB credentials; + DATA_BLOB null_data_blob = data_blob(NULL, 0); mem_ctx = talloc_init("dcerpc_bind_auth"); if (!mem_ctx) { @@ -79,7 +80,7 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, p->security_state.auth_info->auth_pad_length = 0; p->security_state.auth_info->auth_reserved = 0; p->security_state.auth_info->auth_context_id = random(); - p->security_state.auth_info->credentials = data_blob(NULL, 0); + p->security_state.auth_info->credentials = null_data_blob; if (p->flags & DCERPC_SEAL) { p->security_state.auth_info->auth_level = DCERPC_AUTH_LEVEL_PRIVACY; @@ -90,7 +91,7 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, } status = gensec_update(p->security_state.generic_state, mem_ctx, - p->security_state.auth_info->credentials, + null_data_blob, &credentials); if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { -- cgit From b119ebeab0699910f717384591903651d0621886 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Jul 2004 12:26:34 +0000 Subject: r1419: spnego inside of dcerpc using alter_context/alter_context_resp instead of auth3 metze (This used to be commit 19b0567ee533744a0f2778bf8549636a25d96526) --- source4/librpc/rpc/dcerpc_auth.c | 88 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 92f1a88485..43b2212d60 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -44,7 +44,7 @@ NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, return status; } -NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, +NTSTATUS dcerpc_bind_auth3(struct dcerpc_pipe *p, uint8_t auth_type, const char *uuid, uint_t version) { NTSTATUS status; @@ -126,4 +126,90 @@ done: return status; } +NTSTATUS dcerpc_bind_alter(struct dcerpc_pipe *p, uint8_t auth_type, + const char *uuid, uint_t version) +{ + NTSTATUS status; + TALLOC_CTX *mem_ctx; + DATA_BLOB credentials; + DATA_BLOB null_data_blob = data_blob(NULL, 0); + + mem_ctx = talloc_init("dcerpc_bind_auth"); + if (!mem_ctx) { + return NT_STATUS_NO_MEMORY; + } + + if (!p->security_state.generic_state) { + status = gensec_client_start(&p->security_state.generic_state); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + status = gensec_start_mech_by_authtype(p->security_state.generic_state, auth_type); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + } + + p->security_state.auth_info = talloc(p->mem_ctx, sizeof(*p->security_state.auth_info)); + if (!p->security_state.auth_info) { + status = NT_STATUS_NO_MEMORY; + goto done; + } + + p->security_state.auth_info->auth_type = auth_type; + p->security_state.auth_info->auth_pad_length = 0; + p->security_state.auth_info->auth_reserved = 0; + p->security_state.auth_info->auth_context_id = random(); + p->security_state.auth_info->credentials = null_data_blob; + + if (p->flags & DCERPC_SEAL) { + p->security_state.auth_info->auth_level = DCERPC_AUTH_LEVEL_PRIVACY; + } else if (p->flags & DCERPC_SIGN) { + p->security_state.auth_info->auth_level = DCERPC_AUTH_LEVEL_INTEGRITY; + } else { + p->security_state.auth_info->auth_level = DCERPC_AUTH_LEVEL_NONE; + } + + status = gensec_update(p->security_state.generic_state, mem_ctx, + null_data_blob, + &credentials); + + if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + goto done; + } + + p->security_state.auth_info->credentials = credentials; + + status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + while(1) { + status = gensec_update(p->security_state.generic_state, mem_ctx, + p->security_state.auth_info->credentials, + &credentials); + + if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + goto done; + } + + p->security_state.auth_info->credentials = credentials; + + status = dcerpc_alter(p, mem_ctx); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + } + +done: + talloc_destroy(mem_ctx); + + if (!NT_STATUS_IS_OK(status)) { + ZERO_STRUCT(p->security_state); + } + + return status; +} -- cgit From fa5a99b7a6e4f9bffa82eed1393e8e5e1f6404dc Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 25 Aug 2004 02:25:20 +0000 Subject: r2041: Fix NTLMSSP RPC sealing, client -> win2k3 server. The bug (found by tridge) is that Win2k3 is being tighter about the NTLMSSP flags. If we don't negotiate sealing, we can't use it. We now have a way to indicate to the GENSEC implementation mechanisms what things we want for a connection. Andrew Bartlett (This used to be commit 86f61568ea44c5719f9b583beeeefb12e0c26f4c) --- source4/librpc/rpc/dcerpc_auth.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 43b2212d60..6ae6a80596 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -44,7 +44,7 @@ NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, return status; } -NTSTATUS dcerpc_bind_auth3(struct dcerpc_pipe *p, uint8_t auth_type, +NTSTATUS dcerpc_bind_auth3(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth_level, const char *uuid, uint_t version) { NTSTATUS status; @@ -63,7 +63,7 @@ NTSTATUS dcerpc_bind_auth3(struct dcerpc_pipe *p, uint8_t auth_type, return status; } - status = gensec_start_mech_by_authtype(p->security_state.generic_state, auth_type); + status = gensec_start_mech_by_authtype(p->security_state.generic_state, auth_type, auth_level); if (!NT_STATUS_IS_OK(status)) { return status; @@ -77,19 +77,12 @@ NTSTATUS dcerpc_bind_auth3(struct dcerpc_pipe *p, uint8_t auth_type, } p->security_state.auth_info->auth_type = auth_type; + p->security_state.auth_info->auth_level = auth_level; p->security_state.auth_info->auth_pad_length = 0; p->security_state.auth_info->auth_reserved = 0; p->security_state.auth_info->auth_context_id = random(); p->security_state.auth_info->credentials = null_data_blob; - if (p->flags & DCERPC_SEAL) { - p->security_state.auth_info->auth_level = DCERPC_AUTH_LEVEL_PRIVACY; - } else if (p->flags & DCERPC_SIGN) { - p->security_state.auth_info->auth_level = DCERPC_AUTH_LEVEL_INTEGRITY; - } else { - p->security_state.auth_info->auth_level = DCERPC_AUTH_LEVEL_NONE; - } - status = gensec_update(p->security_state.generic_state, mem_ctx, null_data_blob, &credentials); @@ -126,7 +119,7 @@ done: return status; } -NTSTATUS dcerpc_bind_alter(struct dcerpc_pipe *p, uint8_t auth_type, +NTSTATUS dcerpc_bind_alter(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth_level, const char *uuid, uint_t version) { NTSTATUS status; @@ -145,7 +138,8 @@ NTSTATUS dcerpc_bind_alter(struct dcerpc_pipe *p, uint8_t auth_type, return status; } - status = gensec_start_mech_by_authtype(p->security_state.generic_state, auth_type); + status = gensec_start_mech_by_authtype(p->security_state.generic_state, + auth_type, auth_level); if (!NT_STATUS_IS_OK(status)) { return status; @@ -159,19 +153,12 @@ NTSTATUS dcerpc_bind_alter(struct dcerpc_pipe *p, uint8_t auth_type, } p->security_state.auth_info->auth_type = auth_type; + p->security_state.auth_info->auth_level = auth_level; p->security_state.auth_info->auth_pad_length = 0; p->security_state.auth_info->auth_reserved = 0; p->security_state.auth_info->auth_context_id = random(); p->security_state.auth_info->credentials = null_data_blob; - if (p->flags & DCERPC_SEAL) { - p->security_state.auth_info->auth_level = DCERPC_AUTH_LEVEL_PRIVACY; - } else if (p->flags & DCERPC_SIGN) { - p->security_state.auth_info->auth_level = DCERPC_AUTH_LEVEL_INTEGRITY; - } else { - p->security_state.auth_info->auth_level = DCERPC_AUTH_LEVEL_NONE; - } - status = gensec_update(p->security_state.generic_state, mem_ctx, null_data_blob, &credentials); -- cgit From e7f36ff1a5ec909573ef398d215608e7c9aa71fe Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 30 Aug 2004 03:10:43 +0000 Subject: r2100: rework the dcerpc client side library so that it is async. We now generate a separate *_send() async function for every RPC call, and there is a single dcerpc_ndr_request_recv() call that processes the receive side of any rpc call. The caller can use dcerpc_event_context() to get a pointer to the event context for the pipe so that events can be waited for asynchronously. The only part that remains synchronous is the initial bind calls. These could also be made async if necessary, although I suspect most applications won't need them to be. (This used to be commit f5d004d8eb8c76c03342cace1976b27266cfa1f0) --- source4/librpc/rpc/dcerpc_auth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 6ae6a80596..9587fb9390 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -70,7 +70,7 @@ NTSTATUS dcerpc_bind_auth3(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t aut } } - p->security_state.auth_info = talloc(p->mem_ctx, sizeof(*p->security_state.auth_info)); + p->security_state.auth_info = talloc(p, sizeof(*p->security_state.auth_info)); if (!p->security_state.auth_info) { status = NT_STATUS_NO_MEMORY; goto done; @@ -146,7 +146,7 @@ NTSTATUS dcerpc_bind_alter(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t aut } } - p->security_state.auth_info = talloc(p->mem_ctx, sizeof(*p->security_state.auth_info)); + p->security_state.auth_info = talloc(p, sizeof(*p->security_state.auth_info)); if (!p->security_state.auth_info) { status = NT_STATUS_NO_MEMORY; goto done; -- cgit From 909c9b681a0718b8701e05addbad08c0aec87113 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 11 Sep 2004 15:11:36 +0000 Subject: r2284: Thanks to some great detective work by tridge, NTLM2 signing now works. This means that 'require NTLMv2 session security' now works for RPC pipe signing. We don't yet have sealing, but it can't be much further. This is almost all tridge's code, munged into a form that can work with the GENSEC API. This commit also includes more lsakey fixes - that key is used for all DCE-RPC level authenticated connections, even over CIFS/ncacn_np. No doubt I missed something, but I'm going to get some sleep :-) Andrew Bartlett (This used to be commit a1fe175eec884280fb7e9ca8f528134cf4600beb) --- source4/librpc/rpc/dcerpc_auth.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 9587fb9390..0966b70338 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -107,13 +107,16 @@ NTSTATUS dcerpc_bind_auth3(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t aut } p->security_state.auth_info->credentials = credentials; - + status = dcerpc_auth3(p, mem_ctx); done: talloc_destroy(mem_ctx); if (!NT_STATUS_IS_OK(status)) { ZERO_STRUCT(p->security_state); + } else { + /* Authenticated connections use the generic session key */ + p->security_state.session_key = dcerpc_generic_session_key; } return status; @@ -196,6 +199,9 @@ done: if (!NT_STATUS_IS_OK(status)) { ZERO_STRUCT(p->security_state); + } else { + /* Authenticated connections use the generic session key */ + p->security_state.session_key = dcerpc_generic_session_key; } return status; -- cgit From c5f4378361b9671e39fa83b043f28c972ab30b70 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 25 Sep 2004 12:08:57 +0000 Subject: r2629: convert gensec to the new talloc model by making our gensec structures a talloc child of the open connection we can be sure that it will be destroyed when the connection is dropped. (This used to be commit f12ee2f241aab1549bc1d9ca4c35a35a1ca0d09d) --- source4/librpc/rpc/dcerpc_auth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 0966b70338..af138ffe2c 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -58,7 +58,7 @@ NTSTATUS dcerpc_bind_auth3(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t aut } if (!p->security_state.generic_state) { - status = gensec_client_start(&p->security_state.generic_state); + status = gensec_client_start(p, &p->security_state.generic_state); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -136,7 +136,7 @@ NTSTATUS dcerpc_bind_alter(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t aut } if (!p->security_state.generic_state) { - status = gensec_client_start(&p->security_state.generic_state); + status = gensec_client_start(p, &p->security_state.generic_state); if (!NT_STATUS_IS_OK(status)) { return status; } -- cgit From 692e1a214c8478ea9199542920b7083138f90691 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 29 Nov 2004 14:46:17 +0000 Subject: r4001: fix segfault fix auth failed metze (This used to be commit 6a7eee1d9917e0884072354dddae568645798da5) --- source4/librpc/rpc/dcerpc_auth.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index af138ffe2c..7e581992fa 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -113,6 +113,7 @@ done: talloc_destroy(mem_ctx); if (!NT_STATUS_IS_OK(status)) { + gensec_end(&p->security_state.generic_state); ZERO_STRUCT(p->security_state); } else { /* Authenticated connections use the generic session key */ -- cgit From 58c326809a816703dc516c3022c9c4dbb9d09445 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 3 Dec 2004 06:24:38 +0000 Subject: r4052: fixed a bunch of code to use the type safe _p allocation macros (This used to be commit 80d15fa3402a9d1183467463f6b21c0b674bc442) --- source4/librpc/rpc/dcerpc_auth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 7e581992fa..844746e322 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -70,7 +70,7 @@ NTSTATUS dcerpc_bind_auth3(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t aut } } - p->security_state.auth_info = talloc(p, sizeof(*p->security_state.auth_info)); + p->security_state.auth_info = talloc_p(p, struct dcerpc_auth); if (!p->security_state.auth_info) { status = NT_STATUS_NO_MEMORY; goto done; @@ -150,7 +150,7 @@ NTSTATUS dcerpc_bind_alter(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t aut } } - p->security_state.auth_info = talloc(p, sizeof(*p->security_state.auth_info)); + p->security_state.auth_info = talloc_p(p, struct dcerpc_auth); if (!p->security_state.auth_info) { status = NT_STATUS_NO_MEMORY; goto done; -- cgit From 0f1444b77232d59aaa025fa44e5b88c4aabaf877 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 24 Dec 2004 23:02:39 +0000 Subject: r4358: At metze's request, the Christmas elves have removed gensec_end in favor of talloc_free(). Andrew Bartlett (This used to be commit 1933cd12fbaed56e13f2386b19de6ade99bf9478) --- source4/librpc/rpc/dcerpc_auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 844746e322..1c5556ccee 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -113,7 +113,7 @@ done: talloc_destroy(mem_ctx); if (!NT_STATUS_IS_OK(status)) { - gensec_end(&p->security_state.generic_state); + talloc_free(p->security_state.generic_state); ZERO_STRUCT(p->security_state); } else { /* Authenticated connections use the generic session key */ -- cgit From 799b5764d1452c7ec15c8b74b33c83cb2db4702b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 25 Dec 2004 14:06:55 +0000 Subject: r4360: destroy the gensec context metze (This used to be commit a25770983b34bac5bd7dcce69241716386dc8509) --- source4/librpc/rpc/dcerpc_auth.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 1c5556ccee..36e4ba6eea 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -199,6 +199,7 @@ done: talloc_destroy(mem_ctx); if (!NT_STATUS_IS_OK(status)) { + talloc_free(p->security_state.generic_state); ZERO_STRUCT(p->security_state); } else { /* Authenticated connections use the generic session key */ -- cgit From 6836f5d0b167027908da9a08b9b219520997b563 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 9 Jan 2005 08:34:05 +0000 Subject: r4616: the first phase in the addition of proper support for dcerpc_alter_context and multiple context_ids in the dcerpc client library. This stage does the following: - split "struct dcerpc_pipe" into two parts, the main part being "struct dcerpc_connection", which contains all the parts not dependent on the context, and "struct dcerpc_pipe" which has the context dependent part. This is similar to the layering in libcli_*() for SMB - disable the current dcerpc_alter code. I've used a #warning until i get the 2nd phase finished. I don't know how portable #warning is, but it won't be long before I add full alter context support anyway, so it won't last long - cleanup the allocation of dcerpc_pipe structures. The previous code was quite awkward. (This used to be commit 4004c69937be7e5dae56f9567ca607f982d395d3) --- source4/librpc/rpc/dcerpc_auth.c | 84 +++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 40 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 36e4ba6eea..9d43218e4b 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -45,7 +45,7 @@ NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, } NTSTATUS dcerpc_bind_auth3(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth_level, - const char *uuid, uint_t version) + const char *uuid, uint_t version) { NTSTATUS status; TALLOC_CTX *mem_ctx; @@ -57,33 +57,34 @@ NTSTATUS dcerpc_bind_auth3(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t aut return NT_STATUS_NO_MEMORY; } - if (!p->security_state.generic_state) { - status = gensec_client_start(p, &p->security_state.generic_state); + if (!p->conn->security_state.generic_state) { + status = gensec_client_start(p, &p->conn->security_state.generic_state); if (!NT_STATUS_IS_OK(status)) { return status; } - status = gensec_start_mech_by_authtype(p->security_state.generic_state, auth_type, auth_level); + status = gensec_start_mech_by_authtype(p->conn->security_state.generic_state, + auth_type, auth_level); if (!NT_STATUS_IS_OK(status)) { return status; } } - p->security_state.auth_info = talloc_p(p, struct dcerpc_auth); - if (!p->security_state.auth_info) { + p->conn->security_state.auth_info = talloc(p, struct dcerpc_auth); + if (!p->conn->security_state.auth_info) { status = NT_STATUS_NO_MEMORY; goto done; } - p->security_state.auth_info->auth_type = auth_type; - p->security_state.auth_info->auth_level = auth_level; - p->security_state.auth_info->auth_pad_length = 0; - p->security_state.auth_info->auth_reserved = 0; - p->security_state.auth_info->auth_context_id = random(); - p->security_state.auth_info->credentials = null_data_blob; + p->conn->security_state.auth_info->auth_type = auth_type; + p->conn->security_state.auth_info->auth_level = auth_level; + p->conn->security_state.auth_info->auth_pad_length = 0; + p->conn->security_state.auth_info->auth_reserved = 0; + p->conn->security_state.auth_info->auth_context_id = random(); + p->conn->security_state.auth_info->credentials = null_data_blob; - status = gensec_update(p->security_state.generic_state, mem_ctx, + status = gensec_update(p->conn->security_state.generic_state, mem_ctx, null_data_blob, &credentials); @@ -91,38 +92,40 @@ NTSTATUS dcerpc_bind_auth3(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t aut goto done; } - p->security_state.auth_info->credentials = credentials; + p->conn->security_state.auth_info->credentials = credentials; status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version); if (!NT_STATUS_IS_OK(status)) { goto done; } - status = gensec_update(p->security_state.generic_state, mem_ctx, - p->security_state.auth_info->credentials, + status = gensec_update(p->conn->security_state.generic_state, mem_ctx, + p->conn->security_state.auth_info->credentials, &credentials); if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { goto done; } - p->security_state.auth_info->credentials = credentials; + p->conn->security_state.auth_info->credentials = credentials; - status = dcerpc_auth3(p, mem_ctx); + status = dcerpc_auth3(p->conn, mem_ctx); done: talloc_destroy(mem_ctx); if (!NT_STATUS_IS_OK(status)) { - talloc_free(p->security_state.generic_state); - ZERO_STRUCT(p->security_state); + talloc_free(p->conn->security_state.generic_state); + ZERO_STRUCT(p->conn->security_state); } else { /* Authenticated connections use the generic session key */ - p->security_state.session_key = dcerpc_generic_session_key; + p->conn->security_state.session_key = dcerpc_generic_session_key; } return status; } +#warning "bind_alter not implemented" +#if 0 NTSTATUS dcerpc_bind_alter(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth_level, const char *uuid, uint_t version) { @@ -136,13 +139,13 @@ NTSTATUS dcerpc_bind_alter(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t aut return NT_STATUS_NO_MEMORY; } - if (!p->security_state.generic_state) { - status = gensec_client_start(p, &p->security_state.generic_state); + if (!p->conn->security_state.generic_state) { + status = gensec_client_start(p, &p->conn->security_state.generic_state); if (!NT_STATUS_IS_OK(status)) { return status; } - status = gensec_start_mech_by_authtype(p->security_state.generic_state, + status = gensec_start_mech_by_authtype(p->conn->security_state.generic_state, auth_type, auth_level); if (!NT_STATUS_IS_OK(status)) { @@ -150,20 +153,20 @@ NTSTATUS dcerpc_bind_alter(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t aut } } - p->security_state.auth_info = talloc_p(p, struct dcerpc_auth); - if (!p->security_state.auth_info) { + p->conn->security_state.auth_info = talloc_p(p, struct dcerpc_auth); + if (!p->conn->security_state.auth_info) { status = NT_STATUS_NO_MEMORY; goto done; } - p->security_state.auth_info->auth_type = auth_type; - p->security_state.auth_info->auth_level = auth_level; - p->security_state.auth_info->auth_pad_length = 0; - p->security_state.auth_info->auth_reserved = 0; - p->security_state.auth_info->auth_context_id = random(); - p->security_state.auth_info->credentials = null_data_blob; + p->conn->security_state.auth_info->auth_type = auth_type; + p->conn->security_state.auth_info->auth_level = auth_level; + p->conn->security_state.auth_info->auth_pad_length = 0; + p->conn->security_state.auth_info->auth_reserved = 0; + p->conn->security_state.auth_info->auth_context_id = random(); + p->conn->security_state.auth_info->credentials = null_data_blob; - status = gensec_update(p->security_state.generic_state, mem_ctx, + status = gensec_update(p->conn->security_state.generic_state, mem_ctx, null_data_blob, &credentials); @@ -171,7 +174,7 @@ NTSTATUS dcerpc_bind_alter(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t aut goto done; } - p->security_state.auth_info->credentials = credentials; + p->conn->security_state.auth_info->credentials = credentials; status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version); if (!NT_STATUS_IS_OK(status)) { @@ -179,15 +182,15 @@ NTSTATUS dcerpc_bind_alter(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t aut } while(1) { - status = gensec_update(p->security_state.generic_state, mem_ctx, - p->security_state.auth_info->credentials, + status = gensec_update(p->conn->security_state.generic_state, mem_ctx, + p->conn->security_state.auth_info->credentials, &credentials); if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { goto done; } - p->security_state.auth_info->credentials = credentials; + p->conn->security_state.auth_info->credentials = credentials; status = dcerpc_alter(p, mem_ctx); if (!NT_STATUS_IS_OK(status)) { @@ -199,12 +202,13 @@ done: talloc_destroy(mem_ctx); if (!NT_STATUS_IS_OK(status)) { - talloc_free(p->security_state.generic_state); - ZERO_STRUCT(p->security_state); + talloc_free(p->conn->security_state.generic_state); + ZERO_STRUCT(p->conn->security_state); } else { /* Authenticated connections use the generic session key */ - p->security_state.session_key = dcerpc_generic_session_key; + p->conn->security_state.session_key = dcerpc_generic_session_key; } return status; } +#endif -- cgit From e74b3ed6f195e66cb5fa0f387cea0f59fb66711b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 9 Jan 2005 11:32:12 +0000 Subject: r4618: - tidied up the alter_context client code a bit - there is no alter_nak or alter_ack packet, its all done in an alter_response - auto-allocated the contex_ids - tried to fix up the dcom code to work again with alter_context. Jelmer, please take a look :) (This used to be commit dd1c54add8884376601f2f8a56c01bfb8add030c) --- source4/librpc/rpc/dcerpc_auth.c | 89 ---------------------------------------- 1 file changed, 89 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 9d43218e4b..4ff8fe549e 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -123,92 +123,3 @@ done: return status; } - -#warning "bind_alter not implemented" -#if 0 -NTSTATUS dcerpc_bind_alter(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth_level, - const char *uuid, uint_t version) -{ - NTSTATUS status; - TALLOC_CTX *mem_ctx; - DATA_BLOB credentials; - DATA_BLOB null_data_blob = data_blob(NULL, 0); - - mem_ctx = talloc_init("dcerpc_bind_auth"); - if (!mem_ctx) { - return NT_STATUS_NO_MEMORY; - } - - if (!p->conn->security_state.generic_state) { - status = gensec_client_start(p, &p->conn->security_state.generic_state); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - status = gensec_start_mech_by_authtype(p->conn->security_state.generic_state, - auth_type, auth_level); - - if (!NT_STATUS_IS_OK(status)) { - return status; - } - } - - p->conn->security_state.auth_info = talloc_p(p, struct dcerpc_auth); - if (!p->conn->security_state.auth_info) { - status = NT_STATUS_NO_MEMORY; - goto done; - } - - p->conn->security_state.auth_info->auth_type = auth_type; - p->conn->security_state.auth_info->auth_level = auth_level; - p->conn->security_state.auth_info->auth_pad_length = 0; - p->conn->security_state.auth_info->auth_reserved = 0; - p->conn->security_state.auth_info->auth_context_id = random(); - p->conn->security_state.auth_info->credentials = null_data_blob; - - status = gensec_update(p->conn->security_state.generic_state, mem_ctx, - null_data_blob, - &credentials); - - if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { - goto done; - } - - p->conn->security_state.auth_info->credentials = credentials; - - status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - while(1) { - status = gensec_update(p->conn->security_state.generic_state, mem_ctx, - p->conn->security_state.auth_info->credentials, - &credentials); - - if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { - goto done; - } - - p->conn->security_state.auth_info->credentials = credentials; - - status = dcerpc_alter(p, mem_ctx); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - } - -done: - talloc_destroy(mem_ctx); - - if (!NT_STATUS_IS_OK(status)) { - talloc_free(p->conn->security_state.generic_state); - ZERO_STRUCT(p->conn->security_state); - } else { - /* Authenticated connections use the generic session key */ - p->conn->security_state.session_key = dcerpc_generic_session_key; - } - - return status; -} -#endif -- cgit From 5da3f75a5975c09dc1db0b1ad146acf1d5f3ae41 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 10 Jan 2005 07:14:12 +0000 Subject: r4627: - simplified the dcerpc auth code using a common function - added support for "spnego" in binding strings. This enables SPNEGO auth in the dcerpc client code, using as many allter_context calls as are needed To try SPNEGO do this: smbtorture ncacn_ip_tcp:SERVER[spnego,seal] -Uadministrator%password RPC-SAMR (This used to be commit 9c0a3423f03111c110d21c0d3910e16aa1a8bf87) --- source4/librpc/rpc/dcerpc_auth.c | 61 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 31 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 4ff8fe549e..228a99d5c5 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -30,45 +30,33 @@ NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, const char *uuid, uint_t version) { - TALLOC_CTX *mem_ctx; + TALLOC_CTX *tmp_ctx = talloc_new(p); NTSTATUS status; - mem_ctx = talloc_init("dcerpc_bind_auth_ntlm"); - if (!mem_ctx) { - return NT_STATUS_NO_MEMORY; - } - - status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version); - talloc_destroy(mem_ctx); + status = dcerpc_bind_byuuid(p, tmp_ctx, uuid, version); + talloc_free(tmp_ctx); return status; } -NTSTATUS dcerpc_bind_auth3(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth_level, +/* + perform a multi-part authenticated bind +*/ +NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth_level, const char *uuid, uint_t version) { NTSTATUS status; - TALLOC_CTX *mem_ctx; + TALLOC_CTX *tmp_ctx = talloc_new(p); DATA_BLOB credentials; DATA_BLOB null_data_blob = data_blob(NULL, 0); - mem_ctx = talloc_init("dcerpc_bind_auth"); - if (!mem_ctx) { - return NT_STATUS_NO_MEMORY; - } - if (!p->conn->security_state.generic_state) { status = gensec_client_start(p, &p->conn->security_state.generic_state); - if (!NT_STATUS_IS_OK(status)) { - return status; - } + if (!NT_STATUS_IS_OK(status)) goto done; status = gensec_start_mech_by_authtype(p->conn->security_state.generic_state, auth_type, auth_level); - - if (!NT_STATUS_IS_OK(status)) { - return status; - } + if (!NT_STATUS_IS_OK(status)) goto done; } p->conn->security_state.auth_info = talloc(p, struct dcerpc_auth); @@ -84,34 +72,44 @@ NTSTATUS dcerpc_bind_auth3(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t aut p->conn->security_state.auth_info->auth_context_id = random(); p->conn->security_state.auth_info->credentials = null_data_blob; - status = gensec_update(p->conn->security_state.generic_state, mem_ctx, + status = gensec_update(p->conn->security_state.generic_state, tmp_ctx, null_data_blob, &credentials); - if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { goto done; } p->conn->security_state.auth_info->credentials = credentials; - status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version); + status = dcerpc_bind_byuuid(p, tmp_ctx, uuid, version); if (!NT_STATUS_IS_OK(status)) { goto done; } - status = gensec_update(p->conn->security_state.generic_state, mem_ctx, + status = gensec_update(p->conn->security_state.generic_state, tmp_ctx, p->conn->security_state.auth_info->credentials, &credentials); - if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { goto done; } - p->conn->security_state.auth_info->credentials = credentials; - - status = dcerpc_auth3(p->conn, mem_ctx); + do { + p->conn->security_state.auth_info->credentials = credentials; + + if (auth_type == DCERPC_AUTH_TYPE_SPNEGO) { + status = dcerpc_alter_context(p, tmp_ctx, &p->syntax, &p->transfer_syntax); + if (NT_STATUS_IS_OK(status)) { + status = gensec_update(p->conn->security_state.generic_state, tmp_ctx, + p->conn->security_state.auth_info->credentials, + &credentials); + } + } else { + status = dcerpc_auth3(p->conn, tmp_ctx); + } + } while (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)); + done: - talloc_destroy(mem_ctx); + talloc_free(tmp_ctx); if (!NT_STATUS_IS_OK(status)) { talloc_free(p->conn->security_state.generic_state); @@ -123,3 +121,4 @@ done: return status; } + -- cgit From 7db9de3ea9d0b3693aea08b3050f378a4ca9cf0b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 10 Jan 2005 10:48:19 +0000 Subject: r4635: Fix NTLMSSP to return NT_STATUS_OK when it has constructed the auth token in the client (the final token in the negotiation). Consequential fixes in the SPNEGO code, which now uses the out.length as the indicator of 'I need to send something to the other side'. Merge the NTLM and SPNEGO DCE-RPC authentication routines in the client. Fix the RPC-MULTIBIND test consequent to this merge. Andrew Bartlett (This used to be commit 43e3516fc03008e97ebb4ad1a0cde464303f43c6) --- source4/librpc/rpc/dcerpc_auth.c | 105 +++++++++++++++++++++++++++++++++------ 1 file changed, 91 insertions(+), 14 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 228a99d5c5..1c73bde6e4 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -5,7 +5,7 @@ Copyright (C) Andrew Tridgell 2003 Copyright (C) Andrew Bartlett 2004 - + Copyright (C) Stefan Metzmacher 2004 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -86,27 +86,33 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth goto done; } - status = gensec_update(p->conn->security_state.generic_state, tmp_ctx, - p->conn->security_state.auth_info->credentials, - &credentials); - if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { - goto done; - } + while (1) { + status = gensec_update(p->conn->security_state.generic_state, tmp_ctx, + p->conn->security_state.auth_info->credentials, + &credentials); + if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + break; + } - do { - p->conn->security_state.auth_info->credentials = credentials; + if (!credentials.length) { + break; + } + p->conn->security_state.auth_info->credentials = credentials; + if (auth_type == DCERPC_AUTH_TYPE_SPNEGO) { status = dcerpc_alter_context(p, tmp_ctx, &p->syntax, &p->transfer_syntax); - if (NT_STATUS_IS_OK(status)) { - status = gensec_update(p->conn->security_state.generic_state, tmp_ctx, - p->conn->security_state.auth_info->credentials, - &credentials); + if (!NT_STATUS_IS_OK(status)) { + break; } } else { status = dcerpc_auth3(p->conn, tmp_ctx); + credentials = data_blob(NULL, 0); + if (!NT_STATUS_IS_OK(status)) { + break; + } } - } while (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)); + }; done: talloc_free(tmp_ctx); @@ -122,3 +128,74 @@ done: return status; } +/* + setup GENSEC on a DCE-RPC pipe +*/ +NTSTATUS dcerpc_bind_auth_password(struct dcerpc_pipe *p, + const char *uuid, uint_t version, + const char *domain, + const char *username, + const char *password, + uint8_t auth_type) +{ + NTSTATUS status; + + if (!(p->conn->flags & (DCERPC_SIGN | DCERPC_SEAL))) { + p->conn->flags |= DCERPC_CONNECT; + } + + status = gensec_client_start(p, &p->conn->security_state.generic_state); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("Failed to start GENSEC client mode: %s\n", nt_errstr(status))); + return status; + } + + status = gensec_set_domain(p->conn->security_state.generic_state, domain); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("Failed to start set GENSEC client domain to %s: %s\n", + domain, nt_errstr(status))); + return status; + } + + status = gensec_set_username(p->conn->security_state.generic_state, username); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("Failed to start set GENSEC client username to %s: %s\n", + username, nt_errstr(status))); + return status; + } + + status = gensec_set_password(p->conn->security_state.generic_state, password); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("Failed to start set GENSEC client password: %s\n", + nt_errstr(status))); + return status; + } + + status = gensec_set_target_hostname(p->conn->security_state.generic_state, + p->conn->transport.peer_name(p->conn)); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("Failed to start set GENSEC target hostname: %s\n", + nt_errstr(status))); + return status; + } + + status = gensec_start_mech_by_authtype(p->conn->security_state.generic_state, + auth_type, + dcerpc_auth_level(p->conn)); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("Failed to start set GENSEC client mechanism %s: %s\n", + gensec_get_name_by_authtype(auth_type), nt_errstr(status))); + return status; + } + + status = dcerpc_bind_auth(p, auth_type, + dcerpc_auth_level(p->conn), + uuid, version); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(2, ("Failed to bind to pipe with %s: %s\n", + gensec_get_name_by_authtype(auth_type), nt_errstr(status))); + return status; + } + + return status; +} -- cgit From e2c71f0bf5c8555e902ee2660a47433f6199f45a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 10 Jan 2005 11:09:31 +0000 Subject: r4636: Per tridge's wish (and probably correct behaviour), don't key off a specific GENSEC mech type, but on the behaviour of the mech. Andrew Bartlett (This used to be commit f2bd7a5a699b91d99d7dc2a0b3b6c7006274a59c) --- source4/librpc/rpc/dcerpc_auth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 1c73bde6e4..c506c8fd4c 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -100,12 +100,14 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth p->conn->security_state.auth_info->credentials = credentials; - if (auth_type == DCERPC_AUTH_TYPE_SPNEGO) { + if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + /* We are demanding a reply, so use a request that will get us one */ status = dcerpc_alter_context(p, tmp_ctx, &p->syntax, &p->transfer_syntax); if (!NT_STATUS_IS_OK(status)) { break; } } else { + /* NO reply expected, so just send it */ status = dcerpc_auth3(p->conn, tmp_ctx); credentials = data_blob(NULL, 0); if (!NT_STATUS_IS_OK(status)) { -- cgit From 52e90022bf95f215c35b66c8177437b9f70873bd Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 11 Jan 2005 20:09:59 +0000 Subject: r4691: Make the DCE-RPC bind code compleatly generic to the number of passes that the GENSEC mechanism wishes to select. It is of course up to the GENSEC mech and the remote server to actually support this however... Andrew Bartlett (This used to be commit 7200a01545e14a8b0c90fadf3c27933dd1f4359f) --- source4/librpc/rpc/dcerpc_auth.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index c506c8fd4c..c0b72b6842 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -75,14 +75,21 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth status = gensec_update(p->conn->security_state.generic_state, tmp_ctx, null_data_blob, &credentials); - if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { - goto done; - } p->conn->security_state.auth_info->credentials = credentials; - status = dcerpc_bind_byuuid(p, tmp_ctx, uuid, version); - if (!NT_STATUS_IS_OK(status)) { + if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + /* We are demanding a reply, so use a request that will get us one */ + status = dcerpc_bind_byuuid(p, tmp_ctx, uuid, version); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + } else if (NT_STATUS_IS_OK(status)) { + /* We don't care for the reply, so jump to the end */ + status = dcerpc_bind_byuuid(p, tmp_ctx, uuid, version); + goto done; + } else { + /* Something broke in GENSEC - bail */ goto done; } @@ -90,7 +97,8 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth status = gensec_update(p->conn->security_state.generic_state, tmp_ctx, p->conn->security_state.auth_info->credentials, &credentials); - if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + if (!NT_STATUS_IS_OK(status) + && !NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { break; } -- cgit From 4a3ca96fb44a62867ef565d1eeb6c0a16418e505 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 1 Mar 2005 16:08:36 +0000 Subject: r5603: add "authservice()" property to the interface property list so we can specify allowed target service names in the idl file the default is "host" metze (This used to be commit bf40d5321f3257bf9354a42d31265f1a9b0d53ad) --- source4/librpc/rpc/dcerpc_auth.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index c0b72b6842..1bcf4224c4 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -146,7 +146,8 @@ NTSTATUS dcerpc_bind_auth_password(struct dcerpc_pipe *p, const char *domain, const char *username, const char *password, - uint8_t auth_type) + uint8_t auth_type, + const char *service) { NTSTATUS status; @@ -189,6 +190,15 @@ NTSTATUS dcerpc_bind_auth_password(struct dcerpc_pipe *p, return status; } + if (service) { + status = gensec_set_target_service(p->conn->security_state.generic_state, service); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("Failed to start set GENSEC target service: %s\n", + nt_errstr(status))); + return status; + } + } + status = gensec_start_mech_by_authtype(p->conn->security_state.generic_state, auth_type, dcerpc_auth_level(p->conn)); -- cgit From df643022136a4b229aca817f5b57f7302a97f852 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 19 Mar 2005 08:34:43 +0000 Subject: r5902: A rather large change... I wanted to add a simple 'workstation' argument to the DCERPC authenticated binding calls, but this patch kind of grew from there. With SCHANNEL, the 'workstation' name (the netbios name of the client) matters, as this is what ties the session between the NETLOGON ops and the SCHANNEL bind. This changes a lot of files, and these will again be changed when jelmer does the credentials work. I also correct some schannel IDL to distinguish between workstation names and account names. The distinction matters for domain trust accounts. Issues in handling this (issues with lifetime of talloc pointers) caused me to change the 'creds_CredentialsState' and 'struct dcerpc_binding' pointers to always be talloc()ed pointers. In the schannel DB, we now store both the domain and computername, and query on both. This should ensure we fault correctly when the domain is specified incorrectly in the SCHANNEL bind. In the RPC-SCHANNEL test, I finally fixed a bug that vl pointed out, where the comment claimed we re-used a connection, but in fact we made a new connection. This was achived by breaking apart some of the dcerpc_secondary_connection() logic. The addition of workstation handling was also propogated to NTLMSSP and GENSEC, for completeness. The RPC-SAMSYNC test has been cleaned up a little, using a loop over usernames/passwords rather than manually expanded tests. This will be expanded further (the code in #if 0 in this patch) to use a newly created user account for testing. In making this test pass test_rpc.sh, I found a bug in the RPC-ECHO server, caused by the removal of [ref] and the assoicated pointer from the IDL. This has been re-added, until the underlying pidl issues are solved. (This used to be commit 824289dcc20908ddec957a4a892a103eec2da9b9) --- source4/librpc/rpc/dcerpc_auth.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 1bcf4224c4..ac74788ba6 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -143,6 +143,7 @@ done: */ NTSTATUS dcerpc_bind_auth_password(struct dcerpc_pipe *p, const char *uuid, uint_t version, + const char *workstation, const char *domain, const char *username, const char *password, @@ -161,6 +162,13 @@ NTSTATUS dcerpc_bind_auth_password(struct dcerpc_pipe *p, return status; } + status = gensec_set_workstation(p->conn->security_state.generic_state, workstation); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("Failed to start set GENSEC client workstation name to %s: %s\n", + workstation, nt_errstr(status))); + return status; + } + status = gensec_set_domain(p->conn->security_state.generic_state, domain); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Failed to start set GENSEC client domain to %s: %s\n", -- cgit From 05bc2d7b2c11a3583a6d1221cfbd618eb6730518 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 21 Mar 2005 21:22:07 +0000 Subject: r5928: Use cli_credentials in: - gtk+ (returned by GtkHostBindingDialog as well now) - torture/ - librpc/ - lib/com/dcom/ (This used to be commit ccefd782335e01e8e6ecb2bcd28a4f999c53b1a6) --- source4/librpc/rpc/dcerpc_auth.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index ac74788ba6..c5bfe150bd 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -143,10 +143,7 @@ done: */ NTSTATUS dcerpc_bind_auth_password(struct dcerpc_pipe *p, const char *uuid, uint_t version, - const char *workstation, - const char *domain, - const char *username, - const char *password, + struct cli_credentials *credentials, uint8_t auth_type, const char *service) { @@ -162,28 +159,32 @@ NTSTATUS dcerpc_bind_auth_password(struct dcerpc_pipe *p, return status; } - status = gensec_set_workstation(p->conn->security_state.generic_state, workstation); + status = gensec_set_workstation(p->conn->security_state.generic_state, + cli_credentials_get_workstation(credentials)); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Failed to start set GENSEC client workstation name to %s: %s\n", - workstation, nt_errstr(status))); + cli_credentials_get_workstation(credentials), nt_errstr(status))); return status; } - status = gensec_set_domain(p->conn->security_state.generic_state, domain); + status = gensec_set_domain(p->conn->security_state.generic_state, + cli_credentials_get_domain(credentials)); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Failed to start set GENSEC client domain to %s: %s\n", - domain, nt_errstr(status))); + cli_credentials_get_domain(credentials), nt_errstr(status))); return status; } - status = gensec_set_username(p->conn->security_state.generic_state, username); + status = gensec_set_username(p->conn->security_state.generic_state, + cli_credentials_get_username(credentials)); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Failed to start set GENSEC client username to %s: %s\n", - username, nt_errstr(status))); + cli_credentials_get_username(credentials), nt_errstr(status))); return status; } - status = gensec_set_password(p->conn->security_state.generic_state, password); + status = gensec_set_password(p->conn->security_state.generic_state, + cli_credentials_get_password(credentials)); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Failed to start set GENSEC client password: %s\n", nt_errstr(status))); -- cgit From 2eb3d680625286431a3a60e37b75f47e0738f253 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 24 Mar 2005 04:14:06 +0000 Subject: r6028: A MAJOR update to intergrate the new credentails system fully with GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'. GENSEC now no longer has it's own handling of 'set username' etc, instead it uses cli_credentials calls. In order to link the credentails code right though Samba, a lot of interfaces have changed to remove 'username, domain, password' arguments, and these have been replaced with a single 'struct cli_credentials'. In the session setup code, a new parameter 'workgroup' contains the client/server current workgroup, which seems unrelated to the authentication exchange (it was being filled in from the auth info). This allows in particular kerberos to only call back for passwords when it actually needs to perform the kinit. The kerberos code has been modified not to use the SPNEGO provided 'principal name' (in the mechListMIC), but to instead use the name the host was connected to as. This better matches Microsoft behaviour, is more secure and allows better use of standard kerberos functions. To achieve this, I made changes to our socket code so that the hostname (before name resolution) is now recorded on the socket. In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now in libcli/auth/schannel.c, and it looks much more like a standard GENSEC module. The actual sign/seal code moved to libcli/auth/schannel_sign.c in a previous commit. The schannel credentails structure is now merged with the rest of the credentails, as many of the values (username, workstation, domain) where already present there. This makes handling this in a generic manner much easier, as there is no longer a custom entry-point. The auth_domain module continues to be developed, but is now just as functional as auth_winbind. The changes here are consequential to the schannel changes. The only removed function at this point is the RPC-LOGIN test (simulating the load of a WinXP login), which needs much more work to clean it up (it contains copies of too much code from all over the torture suite, and I havn't been able to penetrate its 'structure'). Andrew Bartlett (This used to be commit 2301a4b38a21aa60917973451687063d83d18d66) --- source4/librpc/rpc/dcerpc_auth.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index c5bfe150bd..ae0a89910e 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -4,7 +4,7 @@ Generic Authentication Interface Copyright (C) Andrew Tridgell 2003 - Copyright (C) Andrew Bartlett 2004 + Copyright (C) Andrew Bartlett 2004-2005 Copyright (C) Stefan Metzmacher 2004 This program is free software; you can redistribute it and/or modify @@ -159,34 +159,10 @@ NTSTATUS dcerpc_bind_auth_password(struct dcerpc_pipe *p, return status; } - status = gensec_set_workstation(p->conn->security_state.generic_state, - cli_credentials_get_workstation(credentials)); + status = gensec_set_credentials(p->conn->security_state.generic_state, + credentials); if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("Failed to start set GENSEC client workstation name to %s: %s\n", - cli_credentials_get_workstation(credentials), nt_errstr(status))); - return status; - } - - status = gensec_set_domain(p->conn->security_state.generic_state, - cli_credentials_get_domain(credentials)); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("Failed to start set GENSEC client domain to %s: %s\n", - cli_credentials_get_domain(credentials), nt_errstr(status))); - return status; - } - - status = gensec_set_username(p->conn->security_state.generic_state, - cli_credentials_get_username(credentials)); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("Failed to start set GENSEC client username to %s: %s\n", - cli_credentials_get_username(credentials), nt_errstr(status))); - return status; - } - - status = gensec_set_password(p->conn->security_state.generic_state, - cli_credentials_get_password(credentials)); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("Failed to start set GENSEC client password: %s\n", + DEBUG(1, ("Failed to start set GENSEC client credentails: %s\n", nt_errstr(status))); return status; } -- cgit From af237084ecd4f9928c6c282b9c5c73598d5c73d6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 16 Jun 2005 11:36:09 +0000 Subject: r7633: this patch started as an attempt to make the dcerpc code use a given event_context for the socket_connect() call, so that when things that use dcerpc are running alongside anything else it doesn't block the whole process during a connect. Then of course I needed to change any code that created a dcerpc connection (such as the auth code) to also take an event context, and anything that called that and so on .... thus the size of the patch. There were 3 places where I punted: - abartlet wanted me to add a gensec_set_event_context() call instead of adding it to the gensec init calls. Andrew, my apologies for not doing this. I didn't do it as adding a new parameter allowed me to catch all the callers with the compiler. Now that its done, we could go back and use gensec_set_event_context() - the ejs code calls auth initialisation, which means it should pass in the event context from the web server. I punted on that. Needs fixing. - I used a NULL event context in dcom_get_pipe(). This is equivalent to what we did already, but should be fixed to use a callers event context. Jelmer, can you think of a clean way to do that? I also cleaned up a couple of things: - libnet_context_destroy() makes no sense. I removed it. - removed some unused vars in various places (This used to be commit 3a3025485bdb8f600ab528c0b4b4eef0c65e3fc9) --- source4/librpc/rpc/dcerpc_auth.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index ae0a89910e..7aa563cb9d 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -51,7 +51,8 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth DATA_BLOB null_data_blob = data_blob(NULL, 0); if (!p->conn->security_state.generic_state) { - status = gensec_client_start(p, &p->conn->security_state.generic_state); + status = gensec_client_start(p, &p->conn->security_state.generic_state, + p->conn->event_ctx); if (!NT_STATUS_IS_OK(status)) goto done; status = gensec_start_mech_by_authtype(p->conn->security_state.generic_state, @@ -153,7 +154,8 @@ NTSTATUS dcerpc_bind_auth_password(struct dcerpc_pipe *p, p->conn->flags |= DCERPC_CONNECT; } - status = gensec_client_start(p, &p->conn->security_state.generic_state); + status = gensec_client_start(p, &p->conn->security_state.generic_state, + p->conn->event_ctx); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Failed to start GENSEC client mode: %s\n", nt_errstr(status))); return status; -- cgit From ba90b652d918fb34f1e43083f8283f669c73c340 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 23 Aug 2005 05:29:37 +0000 Subject: r9505: Work on GENSEC and the code that calls it, for tighter interface requirements, and for better error reporting. In particular, the composite session setup (extended security/SPNEGO) code now returns errors, rather than NT_STATUS_NO_MEMORY. This is seen particularly when GENSEC fails to start. The tighter interface rules apply to NTLMSSP, which must be called exactly the right number of times. This is to match some of our other less-tested modules, where adding flexablity is harder. (and this is security code, so let's just get it right). As such, the DCE/RPC and LDAP clients have been updated. Andrew Bartlett (This used to be commit 134550cf752b9edad66c3368750bfb4bbd9d55d1) --- source4/librpc/rpc/dcerpc_auth.c | 59 +++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 28 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 7aa563cb9d..8ad3be4ecd 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -50,6 +50,8 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth DATA_BLOB credentials; DATA_BLOB null_data_blob = data_blob(NULL, 0); + int num_passes = 0; + if (!p->conn->security_state.generic_state) { status = gensec_client_start(p, &p->conn->security_state.generic_state, p->conn->event_ctx); @@ -73,33 +75,27 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth p->conn->security_state.auth_info->auth_context_id = random(); p->conn->security_state.auth_info->credentials = null_data_blob; - status = gensec_update(p->conn->security_state.generic_state, tmp_ctx, - null_data_blob, - &credentials); - - p->conn->security_state.auth_info->credentials = credentials; - - if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { - /* We are demanding a reply, so use a request that will get us one */ - status = dcerpc_bind_byuuid(p, tmp_ctx, uuid, version); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - } else if (NT_STATUS_IS_OK(status)) { - /* We don't care for the reply, so jump to the end */ - status = dcerpc_bind_byuuid(p, tmp_ctx, uuid, version); - goto done; - } else { - /* Something broke in GENSEC - bail */ - goto done; - } - while (1) { + num_passes++; status = gensec_update(p->conn->security_state.generic_state, tmp_ctx, p->conn->security_state.auth_info->credentials, &credentials); + + /* The status value here, from GENSEC is vital to the security + * of the system. Even if the other end accepts, if GENSEC + * claims 'MORE_PROCESSING_REQUIRED' then you must keep + * feeding it blobs, or else the remote host/attacker might + * avoid mutal authentication requirements. + * + * Likewise, you must not feed GENSEC too much (after the OK), + * it doesn't like that either + */ + if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + DEBUG(1, ("Failed DCERPC client gensec_update with mechanism %s: %s\n", + gensec_get_name_by_authtype(auth_type), nt_errstr(status))); + break; } @@ -110,18 +106,25 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth p->conn->security_state.auth_info->credentials = credentials; if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { - /* We are demanding a reply, so use a request that will get us one */ - status = dcerpc_alter_context(p, tmp_ctx, &p->syntax, &p->transfer_syntax); + if (num_passes == 1) { + status = dcerpc_bind_byuuid(p, tmp_ctx, uuid, version); + } else { + /* We are demanding a reply, so use a request that will get us one */ + status = dcerpc_alter_context(p, tmp_ctx, &p->syntax, &p->transfer_syntax); + } if (!NT_STATUS_IS_OK(status)) { break; } - } else { + } else if (NT_STATUS_IS_OK(status)) { /* NO reply expected, so just send it */ - status = dcerpc_auth3(p->conn, tmp_ctx); - credentials = data_blob(NULL, 0); - if (!NT_STATUS_IS_OK(status)) { - break; + if (num_passes == 1) { + status = dcerpc_bind_byuuid(p, tmp_ctx, uuid, version); + } else { + status = dcerpc_auth3(p->conn, tmp_ctx); } + break; + } else { + break; } }; -- cgit From 46685f3e205d4a9d284ebfd070633d128fae05a1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Nov 2005 22:31:26 +0000 Subject: r11804: Asyncify the anonymous bind, convert the calls in xplogin.c. Tridge et al, please take a close look at this. It survives my basic rpc-login test as well as rpc-lsa, but this is critical I think. Volker (This used to be commit bf1a55f44c84d9bb8b2f83f5d25727550ca8fcf2) --- source4/librpc/rpc/dcerpc_auth.c | 48 ++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 8ad3be4ecd..4c22b61519 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -23,20 +23,54 @@ */ #include "includes.h" +#include "libcli/composite/composite.h" /* do a non-athenticated dcerpc bind */ -NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, - const char *uuid, uint_t version) + +struct composite_context *dcerpc_bind_auth_none_send(TALLOC_CTX *mem_ctx, + struct dcerpc_pipe *p, + const char *uuid, + uint_t version) { - TALLOC_CTX *tmp_ctx = talloc_new(p); - NTSTATUS status; + struct dcerpc_syntax_id syntax; + struct dcerpc_syntax_id transfer_syntax; - status = dcerpc_bind_byuuid(p, tmp_ctx, uuid, version); - talloc_free(tmp_ctx); + struct composite_context *c; - return status; + c = talloc_zero(mem_ctx, struct composite_context); + if (c == NULL) return NULL; + + c->status = dcerpc_init_syntaxes(uuid, &syntax, &transfer_syntax, + version); + if (!NT_STATUS_IS_OK(c->status)) { + DEBUG(2,("Invalid uuid string in " + "dcerpc_bind_auth_none_send\n")); + goto failed; + } + + /* c was only allocated as a container for a possible error */ + talloc_free(c); + + return dcerpc_bind_send(p, mem_ctx, &syntax, &transfer_syntax); + + failed: + composite_trigger_error(c); + return c; +} + +NTSTATUS dcerpc_bind_auth_none_recv(struct composite_context *ctx) +{ + return dcerpc_bind_recv(ctx); +} + +NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, + const char *uuid, uint_t version) +{ + struct composite_context *ctx; + ctx = dcerpc_bind_auth_none_send(p, p, uuid, version); + return dcerpc_bind_auth_none_recv(ctx); } /* -- cgit From 82b4335dd28ddf2da46eb642f31e60593f2efd58 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Nov 2005 22:34:46 +0000 Subject: r11805: dcerpc_bind_auth is only used in dcerpc_bind_auth_password (This used to be commit 16bc6b64f9053df3d08a05e7b7cfe77be6580d2b) --- source4/librpc/rpc/dcerpc_auth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 4c22b61519..a5a90052ae 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -76,8 +76,8 @@ NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, /* perform a multi-part authenticated bind */ -NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth_level, - const char *uuid, uint_t version) +static NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth_level, + const char *uuid, uint_t version) { NTSTATUS status; TALLOC_CTX *tmp_ctx = talloc_new(p); -- cgit From 957869d2f473a5c63ea1e52ee628b929ad2208e7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Nov 2005 22:36:19 +0000 Subject: r11806: Minor cleanup (This used to be commit e75080b26d76199a6006fb076cf816ac023254ee) --- source4/librpc/rpc/dcerpc_auth.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index a5a90052ae..117112c197 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -47,17 +47,14 @@ struct composite_context *dcerpc_bind_auth_none_send(TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(c->status)) { DEBUG(2,("Invalid uuid string in " "dcerpc_bind_auth_none_send\n")); - goto failed; + composite_trigger_error(c); + return c; } /* c was only allocated as a container for a possible error */ talloc_free(c); return dcerpc_bind_send(p, mem_ctx, &syntax, &transfer_syntax); - - failed: - composite_trigger_error(c); - return c; } NTSTATUS dcerpc_bind_auth_none_recv(struct composite_context *ctx) -- cgit From f2dedc629ca0d15a59de38812abb0b290fed0a37 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Nov 2005 16:28:39 +0000 Subject: r11809: Make dcerpc_bind_auth async. This also removes dcerpc_bind_auth_password, the only user of dcerpc_bind_auth. And this was not only passwords anyway. Andrew Bartlett, as usual: Please take a close look. Thanks, Volker (This used to be commit 2ff2dae3d035af6cb0c131573cfd983fc9a58eee) --- source4/librpc/rpc/dcerpc_auth.c | 332 +++++++++++++++++++++++---------------- 1 file changed, 193 insertions(+), 139 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 117112c197..29ab80da7a 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -42,8 +42,8 @@ struct composite_context *dcerpc_bind_auth_none_send(TALLOC_CTX *mem_ctx, c = talloc_zero(mem_ctx, struct composite_context); if (c == NULL) return NULL; - c->status = dcerpc_init_syntaxes(uuid, &syntax, &transfer_syntax, - version); + c->status = dcerpc_init_syntaxes(uuid, version, + &syntax, &transfer_syntax); if (!NT_STATUS_IS_OK(c->status)) { DEBUG(2,("Invalid uuid string in " "dcerpc_bind_auth_none_send\n")); @@ -70,173 +70,227 @@ NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, return dcerpc_bind_auth_none_recv(ctx); } -/* - perform a multi-part authenticated bind -*/ -static NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth_level, - const char *uuid, uint_t version) -{ - NTSTATUS status; - TALLOC_CTX *tmp_ctx = talloc_new(p); +struct bind_auth_state { + struct dcerpc_pipe *pipe; DATA_BLOB credentials; - DATA_BLOB null_data_blob = data_blob(NULL, 0); + BOOL more_processing; +}; - int num_passes = 0; +static void bind_auth_recv_alter(struct composite_context *creq); - if (!p->conn->security_state.generic_state) { - status = gensec_client_start(p, &p->conn->security_state.generic_state, - p->conn->event_ctx); - if (!NT_STATUS_IS_OK(status)) goto done; +static void bind_auth_next_step(struct composite_context *c) +{ + struct bind_auth_state *state = + talloc_get_type(c->private_data, struct bind_auth_state); + struct dcerpc_security *sec = &state->pipe->conn->security_state; + struct composite_context *creq; + BOOL more_processing = False; + + c->status = gensec_update(sec->generic_state, state, + sec->auth_info->credentials, + &state->credentials); + + if (NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + more_processing = True; + c->status = NT_STATUS_OK; + } + + if (!composite_is_ok(c)) return; - status = gensec_start_mech_by_authtype(p->conn->security_state.generic_state, - auth_type, auth_level); - if (!NT_STATUS_IS_OK(status)) goto done; + if (state->credentials.length == 0) { + composite_done(c); + return; } - p->conn->security_state.auth_info = talloc(p, struct dcerpc_auth); - if (!p->conn->security_state.auth_info) { - status = NT_STATUS_NO_MEMORY; - goto done; + sec->auth_info->credentials = state->credentials; + + if (!more_processing) { + /* NO reply expected, so just send it */ + c->status = dcerpc_auth3(state->pipe->conn, state); + if (!composite_is_ok(c)) return; + composite_done(c); + return; } - p->conn->security_state.auth_info->auth_type = auth_type; - p->conn->security_state.auth_info->auth_level = auth_level; - p->conn->security_state.auth_info->auth_pad_length = 0; - p->conn->security_state.auth_info->auth_reserved = 0; - p->conn->security_state.auth_info->auth_context_id = random(); - p->conn->security_state.auth_info->credentials = null_data_blob; - - while (1) { - num_passes++; - status = gensec_update(p->conn->security_state.generic_state, tmp_ctx, - p->conn->security_state.auth_info->credentials, - &credentials); - - /* The status value here, from GENSEC is vital to the security - * of the system. Even if the other end accepts, if GENSEC - * claims 'MORE_PROCESSING_REQUIRED' then you must keep - * feeding it blobs, or else the remote host/attacker might - * avoid mutal authentication requirements. - * - * Likewise, you must not feed GENSEC too much (after the OK), - * it doesn't like that either - */ - - if (!NT_STATUS_IS_OK(status) - && !NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { - DEBUG(1, ("Failed DCERPC client gensec_update with mechanism %s: %s\n", - gensec_get_name_by_authtype(auth_type), nt_errstr(status))); - - break; - } + creq = dcerpc_alter_context_send(state->pipe, state, + &state->pipe->syntax, + &state->pipe->transfer_syntax); + composite_continue(c, creq, bind_auth_recv_alter, c); +} - if (!credentials.length) { - break; - } +static void bind_auth_recv_alter(struct composite_context *creq) +{ + struct composite_context *c = + talloc_get_type(creq->async.private_data, + struct composite_context); - p->conn->security_state.auth_info->credentials = credentials; - - if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { - if (num_passes == 1) { - status = dcerpc_bind_byuuid(p, tmp_ctx, uuid, version); - } else { - /* We are demanding a reply, so use a request that will get us one */ - status = dcerpc_alter_context(p, tmp_ctx, &p->syntax, &p->transfer_syntax); - } - if (!NT_STATUS_IS_OK(status)) { - break; - } - } else if (NT_STATUS_IS_OK(status)) { - /* NO reply expected, so just send it */ - if (num_passes == 1) { - status = dcerpc_bind_byuuid(p, tmp_ctx, uuid, version); - } else { - status = dcerpc_auth3(p->conn, tmp_ctx); - } - break; - } else { - break; - } - }; + c->status = dcerpc_alter_context_recv(creq); + if (!composite_is_ok(c)) return; -done: - talloc_free(tmp_ctx); + bind_auth_next_step(c); +} - if (!NT_STATUS_IS_OK(status)) { - talloc_free(p->conn->security_state.generic_state); - ZERO_STRUCT(p->conn->security_state); - } else { - /* Authenticated connections use the generic session key */ - p->conn->security_state.session_key = dcerpc_generic_session_key; +static void bind_auth_recv_bindreply(struct composite_context *creq) +{ + struct composite_context *c = + talloc_get_type(creq->async.private_data, + struct composite_context); + struct bind_auth_state *state = + talloc_get_type(c->private_data, struct bind_auth_state); + + c->status = dcerpc_bind_recv(creq); + if (!composite_is_ok(c)) return; + + if (!state->more_processing) { + composite_done(c); + return; } - return status; + bind_auth_next_step(c); } -/* - setup GENSEC on a DCE-RPC pipe -*/ -NTSTATUS dcerpc_bind_auth_password(struct dcerpc_pipe *p, - const char *uuid, uint_t version, - struct cli_credentials *credentials, - uint8_t auth_type, - const char *service) +static struct composite_context *dcerpc_bind_auth_send(struct dcerpc_pipe *p, + TALLOC_CTX *mem_ctx, + const char *uuid, uint_t version, + struct cli_credentials *credentials, + uint8_t auth_type, + const char *service) { - NTSTATUS status; + struct composite_context *c, *creq; + struct bind_auth_state *state; + struct dcerpc_security *sec; + + struct dcerpc_syntax_id syntax, transfer_syntax; + + c = talloc_zero(mem_ctx, struct composite_context); + if (c == NULL) return NULL; - if (!(p->conn->flags & (DCERPC_SIGN | DCERPC_SEAL))) { - p->conn->flags |= DCERPC_CONNECT; + state = talloc(c, struct bind_auth_state); + if (state == NULL) { + c->status = NT_STATUS_NO_MEMORY; + goto failed; } - status = gensec_client_start(p, &p->conn->security_state.generic_state, - p->conn->event_ctx); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("Failed to start GENSEC client mode: %s\n", nt_errstr(status))); - return status; + c->state = COMPOSITE_STATE_IN_PROGRESS; + c->private_data = state; + c->event_ctx = p->conn->event_ctx; + + state->pipe = p; + + c->status = dcerpc_init_syntaxes(uuid, version, + &syntax, + &transfer_syntax); + if (!NT_STATUS_IS_OK(c->status)) goto failed; + + sec = &p->conn->security_state; + + c->status = gensec_client_start(p, &sec->generic_state, + p->conn->event_ctx); + if (!NT_STATUS_IS_OK(c->status)) { + DEBUG(1, ("Failed to start GENSEC client mode: %s\n", + nt_errstr(c->status))); + goto failed; } - status = gensec_set_credentials(p->conn->security_state.generic_state, - credentials); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("Failed to start set GENSEC client credentails: %s\n", - nt_errstr(status))); - return status; + c->status = gensec_set_credentials(sec->generic_state, credentials); + if (!NT_STATUS_IS_OK(c->status)) { + DEBUG(1, ("Failed to set GENSEC client credentails: %s\n", + nt_errstr(c->status))); + goto failed; } - status = gensec_set_target_hostname(p->conn->security_state.generic_state, - p->conn->transport.peer_name(p->conn)); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("Failed to start set GENSEC target hostname: %s\n", - nt_errstr(status))); - return status; + c->status = gensec_set_target_hostname( + sec->generic_state, p->conn->transport.peer_name(p->conn)); + if (!NT_STATUS_IS_OK(c->status)) { + DEBUG(1, ("Failed to set GENSEC target hostname: %s\n", + nt_errstr(c->status))); + goto failed; } - if (service) { - status = gensec_set_target_service(p->conn->security_state.generic_state, service); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("Failed to start set GENSEC target service: %s\n", - nt_errstr(status))); - return status; + if (service != NULL) { + c->status = gensec_set_target_service(sec->generic_state, + service); + if (!NT_STATUS_IS_OK(c->status)) { + DEBUG(1, ("Failed to set GENSEC target service: %s\n", + nt_errstr(c->status))); + goto failed; } } - status = gensec_start_mech_by_authtype(p->conn->security_state.generic_state, - auth_type, - dcerpc_auth_level(p->conn)); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("Failed to start set GENSEC client mechanism %s: %s\n", - gensec_get_name_by_authtype(auth_type), nt_errstr(status))); - return status; + c->status = gensec_start_mech_by_authtype(sec->generic_state, + auth_type, + dcerpc_auth_level(p->conn)); + if (!NT_STATUS_IS_OK(c->status)) { + DEBUG(1, ("Failed to start GENSEC client mechanism %s: %s\n", + gensec_get_name_by_authtype(auth_type), + nt_errstr(c->status))); + goto failed; + } + + sec->auth_info = talloc(p, struct dcerpc_auth); + if (sec->auth_info == NULL) { + c->status = NT_STATUS_NO_MEMORY; + goto failed; + } + + sec->auth_info->auth_type = auth_type; + sec->auth_info->auth_level = dcerpc_auth_level(p->conn); + sec->auth_info->auth_pad_length = 0; + sec->auth_info->auth_reserved = 0; + sec->auth_info->auth_context_id = random(); + sec->auth_info->credentials = data_blob(NULL, 0); + + c->status = gensec_update(sec->generic_state, state, + sec->auth_info->credentials, + &state->credentials); + if (!NT_STATUS_IS_OK(c->status) && + !NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + goto failed; + } + + state->more_processing = + NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED); + + if (state->credentials.length == 0) { + composite_trigger_done(c); + return c; } - - status = dcerpc_bind_auth(p, auth_type, - dcerpc_auth_level(p->conn), - uuid, version); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(2, ("Failed to bind to pipe with %s: %s\n", - gensec_get_name_by_authtype(auth_type), nt_errstr(status))); - return status; + + sec->auth_info->credentials = state->credentials; + + creq = dcerpc_bind_send(p, state, &syntax, &transfer_syntax); + if (creq == NULL) { + c->status = NT_STATUS_NO_MEMORY; + goto failed; } - return status; + creq->async.fn = bind_auth_recv_bindreply; + creq->async.private_data = c; + return c; + + failed: + composite_trigger_error(c); + return c; +} + +static NTSTATUS dcerpc_bind_auth_recv(struct composite_context *creq) +{ + NTSTATUS result = composite_wait(creq); + talloc_free(creq); + return result; +} + +/* + setup GENSEC on a DCE-RPC pipe +*/ +NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, + const char *uuid, uint_t version, + struct cli_credentials *credentials, + uint8_t auth_type, + const char *service) +{ + struct composite_context *creq; + creq = dcerpc_bind_auth_send(p, p, uuid, version, credentials, + auth_type, service); + return dcerpc_bind_auth_recv(creq); } -- cgit From a6852523d677f6c39a92e0e2b5d970211b29558b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Nov 2005 17:34:56 +0000 Subject: r11812: Convert winbind to the async bind routines. Also remove tridge's hack for the winbind "bug" :-) Volker (This used to be commit fb9a3c7ef376f289288c71bc47d67f548ddb7194) --- source4/librpc/rpc/dcerpc_auth.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 29ab80da7a..c0d4c55835 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -149,12 +149,12 @@ static void bind_auth_recv_bindreply(struct composite_context *creq) bind_auth_next_step(c); } -static struct composite_context *dcerpc_bind_auth_send(struct dcerpc_pipe *p, - TALLOC_CTX *mem_ctx, - const char *uuid, uint_t version, - struct cli_credentials *credentials, - uint8_t auth_type, - const char *service) +struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, + struct dcerpc_pipe *p, + const char *uuid, uint_t version, + struct cli_credentials *credentials, + uint8_t auth_type, + const char *service) { struct composite_context *c, *creq; struct bind_auth_state *state; @@ -273,7 +273,7 @@ static struct composite_context *dcerpc_bind_auth_send(struct dcerpc_pipe *p, return c; } -static NTSTATUS dcerpc_bind_auth_recv(struct composite_context *creq) +NTSTATUS dcerpc_bind_auth_recv(struct composite_context *creq) { NTSTATUS result = composite_wait(creq); talloc_free(creq); -- cgit From 38d540e9fe8701ab3942f0fcbeba01c53d29798b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 21 Nov 2005 04:09:36 +0000 Subject: r11817: fixed the problem with the RPC join tests. The problem was that revision 11809 had removed the change to the session key function after authentication succeeds. (This used to be commit c04c78d617b0d8c9f8fa724d475fefbe9e478ef7) --- source4/librpc/rpc/dcerpc_auth.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index c0d4c55835..5745a38a8f 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -276,6 +276,16 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, NTSTATUS dcerpc_bind_auth_recv(struct composite_context *creq) { NTSTATUS result = composite_wait(creq); + struct bind_auth_state *state = talloc_get_type(creq->private_data, struct bind_auth_state); + + if (NT_STATUS_IS_OK(result)) { + /* + after a successful authenticated bind the session + key reverts to the generic session key + */ + state->pipe->conn->security_state.session_key = dcerpc_generic_session_key; + } + talloc_free(creq); return result; } -- cgit From 35741ad8b1429c72c8acec34041de54afee1063e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 21 Nov 2005 19:43:06 +0000 Subject: r11835: Restore comments (This used to be commit 94591bdb6542d4a3096074b672e19142c9236211) --- source4/librpc/rpc/dcerpc_auth.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 5745a38a8f..1dbc3b8aef 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -73,7 +73,8 @@ NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, struct bind_auth_state { struct dcerpc_pipe *pipe; DATA_BLOB credentials; - BOOL more_processing; + BOOL more_processing; /* Is there anything more to do after the + * first bind itself received? */ }; static void bind_auth_recv_alter(struct composite_context *creq); @@ -86,6 +87,16 @@ static void bind_auth_next_step(struct composite_context *c) struct composite_context *creq; BOOL more_processing = False; + /* The status value here, from GENSEC is vital to the security + * of the system. Even if the other end accepts, if GENSEC + * claims 'MORE_PROCESSING_REQUIRED' then you must keep + * feeding it blobs, or else the remote host/attacker might + * avoid mutal authentication requirements. + * + * Likewise, you must not feed GENSEC too much (after the OK), + * it doesn't like that either + */ + c->status = gensec_update(sec->generic_state, state, sec->auth_info->credentials, &state->credentials); @@ -112,6 +123,8 @@ static void bind_auth_next_step(struct composite_context *c) return; } + /* We are demanding a reply, so use a request that will get us one */ + creq = dcerpc_alter_context_send(state->pipe, state, &state->pipe->syntax, &state->pipe->transfer_syntax); @@ -142,6 +155,8 @@ static void bind_auth_recv_bindreply(struct composite_context *creq) if (!composite_is_ok(c)) return; if (!state->more_processing) { + /* The first gensec_update has not requested a second run, so + * we're done here. */ composite_done(c); return; } @@ -240,6 +255,16 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, sec->auth_info->auth_context_id = random(); sec->auth_info->credentials = data_blob(NULL, 0); + /* The status value here, from GENSEC is vital to the security + * of the system. Even if the other end accepts, if GENSEC + * claims 'MORE_PROCESSING_REQUIRED' then you must keep + * feeding it blobs, or else the remote host/attacker might + * avoid mutal authentication requirements. + * + * Likewise, you must not feed GENSEC too much (after the OK), + * it doesn't like that either + */ + c->status = gensec_update(sec->generic_state, state, sec->auth_info->credentials, &state->credentials); @@ -258,6 +283,8 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, sec->auth_info->credentials = state->credentials; + /* The first request always is a dcerpc_bind. The subsequent ones + * depend on gensec results */ creq = dcerpc_bind_send(p, state, &syntax, &transfer_syntax); if (creq == NULL) { c->status = NT_STATUS_NO_MEMORY; -- cgit From 111a920fdb92ccef32f89b2f992bdd3051e5ac54 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 8 Dec 2005 01:13:45 +0000 Subject: r12116: got rid of composite_trigger_done() and composite_trigger_error(), and instead make the normal composite_done() and composite_error() functions automatically trigger a delayed callback if the caller has had no opportunity to setup a async callback this removes one of the common mistakes in writing a composite function (This used to be commit f9413ce792ded682e05134b66d433eeec293e6f1) --- source4/librpc/rpc/dcerpc_auth.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 1dbc3b8aef..dcf3334212 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -47,7 +47,7 @@ struct composite_context *dcerpc_bind_auth_none_send(TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(c->status)) { DEBUG(2,("Invalid uuid string in " "dcerpc_bind_auth_none_send\n")); - composite_trigger_error(c); + composite_error(c, c->status); return c; } @@ -277,7 +277,7 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED); if (state->credentials.length == 0) { - composite_trigger_done(c); + composite_done(c); return c; } @@ -296,7 +296,7 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, return c; failed: - composite_trigger_error(c); + composite_error(c, c->status); return c; } -- cgit From acd6a086b341096fcbea1775ce748587fcc8020a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 Dec 2005 14:28:01 +0000 Subject: r12510: Change the DCE/RPC interfaces to take a pointer to a dcerpc_interface_table struct rather then a tuple of interface name, UUID and version. This removes the requirement for having a global list of DCE/RPC interfaces, except for these parts of the code that use that list explicitly (ndrdump and the scanner torture test). This should also allow us to remove the hack that put the authservice parameter in the dcerpc_binding struct as it can now be read directly from dcerpc_interface_table. I will now modify some of these functions to take a dcerpc_syntax_id structure rather then a full dcerpc_interface_table. (This used to be commit 8aae0f168e54c01d0866ad6e0da141dbd828574f) --- source4/librpc/rpc/dcerpc_auth.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index dcf3334212..c66384a3cf 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -31,8 +31,7 @@ struct composite_context *dcerpc_bind_auth_none_send(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, - const char *uuid, - uint_t version) + const struct dcerpc_interface_table *table) { struct dcerpc_syntax_id syntax; struct dcerpc_syntax_id transfer_syntax; @@ -42,7 +41,7 @@ struct composite_context *dcerpc_bind_auth_none_send(TALLOC_CTX *mem_ctx, c = talloc_zero(mem_ctx, struct composite_context); if (c == NULL) return NULL; - c->status = dcerpc_init_syntaxes(uuid, version, + c->status = dcerpc_init_syntaxes(table, &syntax, &transfer_syntax); if (!NT_STATUS_IS_OK(c->status)) { DEBUG(2,("Invalid uuid string in " @@ -63,10 +62,10 @@ NTSTATUS dcerpc_bind_auth_none_recv(struct composite_context *ctx) } NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, - const char *uuid, uint_t version) + const struct dcerpc_interface_table *table) { struct composite_context *ctx; - ctx = dcerpc_bind_auth_none_send(p, p, uuid, version); + ctx = dcerpc_bind_auth_none_send(p, p, table); return dcerpc_bind_auth_none_recv(ctx); } @@ -166,7 +165,7 @@ static void bind_auth_recv_bindreply(struct composite_context *creq) struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, - const char *uuid, uint_t version, + const struct dcerpc_interface_table *table, struct cli_credentials *credentials, uint8_t auth_type, const char *service) @@ -192,7 +191,7 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, state->pipe = p; - c->status = dcerpc_init_syntaxes(uuid, version, + c->status = dcerpc_init_syntaxes(table, &syntax, &transfer_syntax); if (!NT_STATUS_IS_OK(c->status)) goto failed; @@ -321,13 +320,13 @@ NTSTATUS dcerpc_bind_auth_recv(struct composite_context *creq) setup GENSEC on a DCE-RPC pipe */ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, - const char *uuid, uint_t version, + const struct dcerpc_interface_table *table, struct cli_credentials *credentials, uint8_t auth_type, const char *service) { struct composite_context *creq; - creq = dcerpc_bind_auth_send(p, p, uuid, version, credentials, + creq = dcerpc_bind_auth_send(p, p, table, credentials, auth_type, service); return dcerpc_bind_auth_recv(creq); } -- cgit From 2cd5ca7d25f12aa9198bf8c2deb6aea282f573ee Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Dec 2005 15:38:36 +0000 Subject: r12542: Move some more prototypes out to seperate headers (This used to be commit 0aca5fd5130d980d07398f3291d294202aefe3c2) --- source4/librpc/rpc/dcerpc_auth.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index c66384a3cf..bffa994abe 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -24,6 +24,7 @@ #include "includes.h" #include "libcli/composite/composite.h" +#include "auth/gensec/gensec.h" /* do a non-athenticated dcerpc bind -- cgit From a5a79e8b8cbdf24d5c2db45ece4110ed5d85e58f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 12 Jan 2006 09:33:49 +0000 Subject: r12865: Upgrade the librpc and libnet code. In librpc, always try SMB level authentication, even if trying schannel, but allow fallback to anonymous. This should better function with servers that set restrict anonymous. There are too many parts of Samba that get, parse and modify the binding parameters. Avoid the extra work, and add a binding element to the struct dcerpc_pipe The libnet vampire code has been refactored, to reduce extra layers and to better conform with the standard argument pattern. Also, take advantage of the new libnet_Lookup code, so we don't require the silly 'password server' smb.conf parameter. To better support forcing traffic to be sealed for the vampire operation, the dcerpc_bind_auth() function now takes an auth level parameter. Andrew Bartlett (This used to be commit d65b354959842326fdd4bd7eb7fbeea0390f4afa) --- source4/librpc/rpc/dcerpc_auth.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index bffa994abe..f0a7dc8ffe 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -168,7 +168,7 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, const struct dcerpc_interface_table *table, struct cli_credentials *credentials, - uint8_t auth_type, + uint8_t auth_type, uint8_t auth_level, const char *service) { struct composite_context *c, *creq; @@ -233,8 +233,7 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, } c->status = gensec_start_mech_by_authtype(sec->generic_state, - auth_type, - dcerpc_auth_level(p->conn)); + auth_type, auth_level); if (!NT_STATUS_IS_OK(c->status)) { DEBUG(1, ("Failed to start GENSEC client mechanism %s: %s\n", gensec_get_name_by_authtype(auth_type), @@ -249,7 +248,7 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, } sec->auth_info->auth_type = auth_type; - sec->auth_info->auth_level = dcerpc_auth_level(p->conn); + sec->auth_info->auth_level = auth_level, sec->auth_info->auth_pad_length = 0; sec->auth_info->auth_reserved = 0; sec->auth_info->auth_context_id = random(); @@ -323,11 +322,11 @@ NTSTATUS dcerpc_bind_auth_recv(struct composite_context *creq) NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, const struct dcerpc_interface_table *table, struct cli_credentials *credentials, - uint8_t auth_type, + uint8_t auth_type, uint8_t auth_level, const char *service) { struct composite_context *creq; creq = dcerpc_bind_auth_send(p, p, table, credentials, - auth_type, service); + auth_type, auth_level, service); return dcerpc_bind_auth_recv(creq); } -- cgit From f2d76bddd5c9d8b02283f66ba0b1f1584d1734be Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 4 Feb 2006 07:56:30 +0000 Subject: r13334: Add comments describing what these functions do. We still need many more, but it is a start... Andrew Bartlett (This used to be commit b2bda127f681dc1e2003c86159a85fa613373f16) --- source4/librpc/rpc/dcerpc_auth.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index f0a7dc8ffe..4f11667365 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -164,6 +164,18 @@ static void bind_auth_recv_bindreply(struct composite_context *creq) bind_auth_next_step(c); } +/** + Bind to a DCE/RPC pipe, async + @param mem_ctx TALLOC_CTX for the allocation of the composite_context + @param p The dcerpc_pipe to bind (must already be connected) + @param table The interface table to use (the DCE/RPC bind both selects and interface and authenticates) + @param credentials The credentials of the account to connect with + @param auth_type Select the authentication scheme to use + @param auth_level Chooses between unprotected (connect), signed or sealed + @param service The service (used by Kerberos to select the service principal to contact) + @retval A composite context describing the partial state of the bind +*/ + struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, const struct dcerpc_interface_table *table, @@ -316,8 +328,15 @@ NTSTATUS dcerpc_bind_auth_recv(struct composite_context *creq) return result; } -/* - setup GENSEC on a DCE-RPC pipe +/** + Perform a GENSEC authenticated bind to a DCE/RPC pipe, sync + @param p The dcerpc_pipe to bind (must already be connected) + @param table The interface table to use (the DCE/RPC bind both selects and interface and authenticates) + @param credentials The credentials of the account to connect with + @param auth_type Select the authentication scheme to use + @param auth_level Chooses between unprotected (connect), signed or sealed + @param service The service (used by Kerberos to select the service principal to contact) + @retval NTSTATUS status code */ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, const struct dcerpc_interface_table *table, -- cgit From 35349a58df5b69446607fbd742a05f57f3515319 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 18 Mar 2006 15:42:57 +0000 Subject: r14542: Remove librpc, libndr and libnbt from includes.h (This used to be commit 51b4270513752d2eafbe77f9de598de16ef84a1f) --- source4/librpc/rpc/dcerpc_auth.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 4f11667365..88132b15fe 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -25,6 +25,7 @@ #include "includes.h" #include "libcli/composite/composite.h" #include "auth/gensec/gensec.h" +#include "librpc/rpc/dcerpc.h" /* do a non-athenticated dcerpc bind -- cgit From 57589e3b67c4fbe6412478bef9a46cdf5b1df795 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 25 Mar 2006 11:39:09 +0000 Subject: r14714: On DCE/RPC, we need the name of the remote server used on the socket, for Kerberos. It must be the full name contacted, not the 'called name' we might want to use for \\server things, so add another function. Andrew Bartlett (This used to be commit 6d57d1dbb76e7d1ca2fd4f1a6c0bacfa7a189e2b) --- source4/librpc/rpc/dcerpc_auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 88132b15fe..04f3d9b436 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -228,7 +228,7 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, } c->status = gensec_set_target_hostname( - sec->generic_state, p->conn->transport.peer_name(p->conn)); + sec->generic_state, p->conn->transport.target_hostname(p->conn)); if (!NT_STATUS_IS_OK(c->status)) { DEBUG(1, ("Failed to set GENSEC target hostname: %s\n", nt_errstr(c->status))); -- cgit From 0240d4a8753b599b35766a5df0b70ab94e053257 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Mon, 10 Apr 2006 22:03:26 +0000 Subject: r15021: Couple more comments and fixes in spirit of utility functions for composite interface. rafal (This used to be commit 905ca5a3ecd1c4ed5b9f206cdc855d0ddb92a07a) --- source4/librpc/rpc/dcerpc_auth.c | 81 ++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 32 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 04f3d9b436..c6b718e208 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -27,13 +27,13 @@ #include "auth/gensec/gensec.h" #include "librpc/rpc/dcerpc.h" + /* - do a non-athenticated dcerpc bind + Send request to do a non-authenticated dcerpc bind */ - struct composite_context *dcerpc_bind_auth_none_send(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, - const struct dcerpc_interface_table *table) + const struct dcerpc_interface_table *table) { struct dcerpc_syntax_id syntax; struct dcerpc_syntax_id transfer_syntax; @@ -58,19 +58,29 @@ struct composite_context *dcerpc_bind_auth_none_send(TALLOC_CTX *mem_ctx, return dcerpc_bind_send(p, mem_ctx, &syntax, &transfer_syntax); } + +/* + Receive result of a non-authenticated dcerpc bind +*/ NTSTATUS dcerpc_bind_auth_none_recv(struct composite_context *ctx) { return dcerpc_bind_recv(ctx); } + +/* + Perform sync non-authenticated dcerpc bind +*/ NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, const struct dcerpc_interface_table *table) { struct composite_context *ctx; + ctx = dcerpc_bind_auth_none_send(p, p, table); return dcerpc_bind_auth_none_recv(ctx); } + struct bind_auth_state { struct dcerpc_pipe *pipe; DATA_BLOB credentials; @@ -82,12 +92,14 @@ static void bind_auth_recv_alter(struct composite_context *creq); static void bind_auth_next_step(struct composite_context *c) { - struct bind_auth_state *state = - talloc_get_type(c->private_data, struct bind_auth_state); - struct dcerpc_security *sec = &state->pipe->conn->security_state; + struct bind_auth_state *state; + struct dcerpc_security *sec; struct composite_context *creq; BOOL more_processing = False; + state = talloc_get_type(c->private_data, struct bind_auth_state); + sec = &state->pipe->conn->security_state; + /* The status value here, from GENSEC is vital to the security * of the system. Even if the other end accepts, if GENSEC * claims 'MORE_PROCESSING_REQUIRED' then you must keep @@ -120,6 +132,7 @@ static void bind_auth_next_step(struct composite_context *c) /* NO reply expected, so just send it */ c->status = dcerpc_auth3(state->pipe->conn, state); if (!composite_is_ok(c)) return; + composite_done(c); return; } @@ -129,14 +142,16 @@ static void bind_auth_next_step(struct composite_context *c) creq = dcerpc_alter_context_send(state->pipe, state, &state->pipe->syntax, &state->pipe->transfer_syntax); + if (composite_nomem(creq, c)) return; + composite_continue(c, creq, bind_auth_recv_alter, c); } + static void bind_auth_recv_alter(struct composite_context *creq) { - struct composite_context *c = - talloc_get_type(creq->async.private_data, - struct composite_context); + struct composite_context *c = talloc_get_type(creq->async.private_data, + struct composite_context); c->status = dcerpc_alter_context_recv(creq); if (!composite_is_ok(c)) return; @@ -144,13 +159,13 @@ static void bind_auth_recv_alter(struct composite_context *creq) bind_auth_next_step(c); } + static void bind_auth_recv_bindreply(struct composite_context *creq) { - struct composite_context *c = - talloc_get_type(creq->async.private_data, - struct composite_context); - struct bind_auth_state *state = - talloc_get_type(c->private_data, struct bind_auth_state); + struct composite_context *c = talloc_get_type(creq->async.private_data, + struct composite_context); + struct bind_auth_state *state = talloc_get_type(c->private_data, + struct bind_auth_state); c->status = dcerpc_bind_recv(creq); if (!composite_is_ok(c)) return; @@ -165,8 +180,9 @@ static void bind_auth_recv_bindreply(struct composite_context *creq) bind_auth_next_step(c); } + /** - Bind to a DCE/RPC pipe, async + Bind to a DCE/RPC pipe, send async request @param mem_ctx TALLOC_CTX for the allocation of the composite_context @param p The dcerpc_pipe to bind (must already be connected) @param table The interface table to use (the DCE/RPC bind both selects and interface and authenticates) @@ -190,14 +206,12 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, struct dcerpc_syntax_id syntax, transfer_syntax; + /* composite context allocation and setup */ c = talloc_zero(mem_ctx, struct composite_context); if (c == NULL) return NULL; state = talloc(c, struct bind_auth_state); - if (state == NULL) { - c->status = NT_STATUS_NO_MEMORY; - goto failed; - } + if (composite_nomem(state, c)) return c; c->state = COMPOSITE_STATE_IN_PROGRESS; c->private_data = state; @@ -255,10 +269,7 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, } sec->auth_info = talloc(p, struct dcerpc_auth); - if (sec->auth_info == NULL) { - c->status = NT_STATUS_NO_MEMORY; - goto failed; - } + if (composite_nomem(sec->auth_info, c)) return c; sec->auth_info->auth_type = auth_type; sec->auth_info->auth_level = auth_level, @@ -298,24 +309,28 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, /* The first request always is a dcerpc_bind. The subsequent ones * depend on gensec results */ creq = dcerpc_bind_send(p, state, &syntax, &transfer_syntax); - if (creq == NULL) { - c->status = NT_STATUS_NO_MEMORY; - goto failed; - } + if (composite_nomem(creq, c)) return c; - creq->async.fn = bind_auth_recv_bindreply; - creq->async.private_data = c; + composite_continue(c, creq, bind_auth_recv_bindreply, c); return c; - - failed: + +failed: composite_error(c, c->status); return c; } + +/** + Bind to a DCE/RPC pipe, receive result + @param creq A composite context describing state of async call + @retval NTSTATUS code +*/ + NTSTATUS dcerpc_bind_auth_recv(struct composite_context *creq) { NTSTATUS result = composite_wait(creq); - struct bind_auth_state *state = talloc_get_type(creq->private_data, struct bind_auth_state); + struct bind_auth_state *state = talloc_get_type(creq->private_data, + struct bind_auth_state); if (NT_STATUS_IS_OK(result)) { /* @@ -329,6 +344,7 @@ NTSTATUS dcerpc_bind_auth_recv(struct composite_context *creq) return result; } + /** Perform a GENSEC authenticated bind to a DCE/RPC pipe, sync @param p The dcerpc_pipe to bind (must already be connected) @@ -339,6 +355,7 @@ NTSTATUS dcerpc_bind_auth_recv(struct composite_context *creq) @param service The service (used by Kerberos to select the service principal to contact) @retval NTSTATUS status code */ + NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, const struct dcerpc_interface_table *table, struct cli_credentials *credentials, -- cgit From daff55d64ec0f976f0ad34ec7f0a1737a4a06abc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 30 Jul 2006 17:55:09 +0000 Subject: r17324: make better usage of the composite api metze (This used to be commit 0fa97777107f5f65f8b48976b90f1ae52f1fe2a5) --- source4/librpc/rpc/dcerpc_auth.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index c6b718e208..a6afcd5c89 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -40,7 +40,7 @@ struct composite_context *dcerpc_bind_auth_none_send(TALLOC_CTX *mem_ctx, struct composite_context *c; - c = talloc_zero(mem_ctx, struct composite_context); + c = composite_create(mem_ctx, p->conn->event_ctx); if (c == NULL) return NULL; c->status = dcerpc_init_syntaxes(table, @@ -207,22 +207,19 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, struct dcerpc_syntax_id syntax, transfer_syntax; /* composite context allocation and setup */ - c = talloc_zero(mem_ctx, struct composite_context); + c = composite_create(mem_ctx, p->conn->event_ctx); if (c == NULL) return NULL; state = talloc(c, struct bind_auth_state); if (composite_nomem(state, c)) return c; - - c->state = COMPOSITE_STATE_IN_PROGRESS; c->private_data = state; - c->event_ctx = p->conn->event_ctx; state->pipe = p; c->status = dcerpc_init_syntaxes(table, &syntax, &transfer_syntax); - if (!NT_STATUS_IS_OK(c->status)) goto failed; + if (!composite_is_ok(c)) return c; sec = &p->conn->security_state; @@ -231,22 +228,25 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(c->status)) { DEBUG(1, ("Failed to start GENSEC client mode: %s\n", nt_errstr(c->status))); - goto failed; + composite_error(c, c->status); + return c; } c->status = gensec_set_credentials(sec->generic_state, credentials); if (!NT_STATUS_IS_OK(c->status)) { DEBUG(1, ("Failed to set GENSEC client credentails: %s\n", nt_errstr(c->status))); - goto failed; + composite_error(c, c->status); + return c; } - c->status = gensec_set_target_hostname( - sec->generic_state, p->conn->transport.target_hostname(p->conn)); + c->status = gensec_set_target_hostname(sec->generic_state, + p->conn->transport.target_hostname(p->conn)); if (!NT_STATUS_IS_OK(c->status)) { DEBUG(1, ("Failed to set GENSEC target hostname: %s\n", nt_errstr(c->status))); - goto failed; + composite_error(c, c->status); + return c; } if (service != NULL) { @@ -255,7 +255,8 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(c->status)) { DEBUG(1, ("Failed to set GENSEC target service: %s\n", nt_errstr(c->status))); - goto failed; + composite_error(c, c->status); + return c; } } @@ -265,7 +266,8 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, DEBUG(1, ("Failed to start GENSEC client mechanism %s: %s\n", gensec_get_name_by_authtype(auth_type), nt_errstr(c->status))); - goto failed; + composite_error(c, c->status); + return c; } sec->auth_info = talloc(p, struct dcerpc_auth); @@ -293,11 +295,12 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, &state->credentials); if (!NT_STATUS_IS_OK(c->status) && !NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { - goto failed; + composite_error(c, c->status); + return c; } - state->more_processing = - NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED); + state->more_processing = NT_STATUS_EQUAL(c->status, + NT_STATUS_MORE_PROCESSING_REQUIRED); if (state->credentials.length == 0) { composite_done(c); @@ -313,10 +316,6 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, composite_continue(c, creq, bind_auth_recv_bindreply, c); return c; - -failed: - composite_error(c, c->status); - return c; } -- cgit From 2da96ebd7afba8a0543beaac02acaf66ebe4f8c4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 24 Oct 2006 08:08:03 +0000 Subject: r19479: Remove more unused functions. These are handled via authentication abstractions now. Andrew Bartlett (This used to be commit df31237c0cac0213c4f32fc491bcec2ea9f885c3) --- source4/librpc/rpc/dcerpc_auth.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index a6afcd5c89..990288b7e8 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -27,6 +27,21 @@ #include "auth/gensec/gensec.h" #include "librpc/rpc/dcerpc.h" +/* + return the rpc syntax and transfer syntax given the pipe uuid and version +*/ +static NTSTATUS dcerpc_init_syntaxes(const struct dcerpc_interface_table *table, + struct dcerpc_syntax_id *syntax, + struct dcerpc_syntax_id *transfer_syntax) +{ + syntax->uuid = table->syntax_id.uuid; + syntax->if_version = table->syntax_id.if_version; + + *transfer_syntax = ndr_transfer_syntax; + + return NT_STATUS_OK; +} + /* Send request to do a non-authenticated dcerpc bind -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/librpc/rpc/dcerpc_auth.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 990288b7e8..0caf574f86 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -9,7 +9,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -18,8 +18,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From ce84ab9a83441845202e99f8ffd4512839926024 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 18 Aug 2007 06:57:49 +0000 Subject: r24532: rename struct dcerpc_syntax_id into struct ndr_syntax_id and move it into misc.idl The goal is to get rid a all dcerpc specific stuff in the generated ndr layer. metze (This used to be commit 2ed014cfb894cccab1654e3f7d5876393e2b52d7) --- source4/librpc/rpc/dcerpc_auth.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 0caf574f86..8298b1ecbe 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -30,8 +30,8 @@ return the rpc syntax and transfer syntax given the pipe uuid and version */ static NTSTATUS dcerpc_init_syntaxes(const struct dcerpc_interface_table *table, - struct dcerpc_syntax_id *syntax, - struct dcerpc_syntax_id *transfer_syntax) + struct ndr_syntax_id *syntax, + struct ndr_syntax_id *transfer_syntax) { syntax->uuid = table->syntax_id.uuid; syntax->if_version = table->syntax_id.if_version; @@ -49,8 +49,8 @@ struct composite_context *dcerpc_bind_auth_none_send(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, const struct dcerpc_interface_table *table) { - struct dcerpc_syntax_id syntax; - struct dcerpc_syntax_id transfer_syntax; + struct ndr_syntax_id syntax; + struct ndr_syntax_id transfer_syntax; struct composite_context *c; @@ -218,7 +218,7 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, struct bind_auth_state *state; struct dcerpc_security *sec; - struct dcerpc_syntax_id syntax, transfer_syntax; + struct ndr_syntax_id syntax, transfer_syntax; /* composite context allocation and setup */ c = composite_create(mem_ctx, p->conn->event_ctx); -- cgit From b8cdadced4d2a26a63b8bbe397c12df949783ed4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 19 Aug 2007 20:46:45 +0000 Subject: r24551: rename dcerpc_interface_table -> ndr_interface_table rename dcerpc_interface_list -> ndr_interface_list and move them to libndr.h metze (This used to be commit 4adbebef5df2f833d2d4bfcdda72a34179d52f5c) --- source4/librpc/rpc/dcerpc_auth.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 8298b1ecbe..756cb58e3a 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -29,7 +29,7 @@ /* return the rpc syntax and transfer syntax given the pipe uuid and version */ -static NTSTATUS dcerpc_init_syntaxes(const struct dcerpc_interface_table *table, +static NTSTATUS dcerpc_init_syntaxes(const struct ndr_interface_table *table, struct ndr_syntax_id *syntax, struct ndr_syntax_id *transfer_syntax) { @@ -47,7 +47,7 @@ static NTSTATUS dcerpc_init_syntaxes(const struct dcerpc_interface_table *table, */ struct composite_context *dcerpc_bind_auth_none_send(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, - const struct dcerpc_interface_table *table) + const struct ndr_interface_table *table) { struct ndr_syntax_id syntax; struct ndr_syntax_id transfer_syntax; @@ -86,7 +86,7 @@ NTSTATUS dcerpc_bind_auth_none_recv(struct composite_context *ctx) Perform sync non-authenticated dcerpc bind */ NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, - const struct dcerpc_interface_table *table) + const struct ndr_interface_table *table) { struct composite_context *ctx; @@ -209,7 +209,7 @@ static void bind_auth_recv_bindreply(struct composite_context *creq) struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, - const struct dcerpc_interface_table *table, + const struct ndr_interface_table *table, struct cli_credentials *credentials, uint8_t auth_type, uint8_t auth_level, const char *service) @@ -370,7 +370,7 @@ NTSTATUS dcerpc_bind_auth_recv(struct composite_context *creq) */ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, - const struct dcerpc_interface_table *table, + const struct ndr_interface_table *table, struct cli_credentials *credentials, uint8_t auth_type, uint8_t auth_level, const char *service) -- cgit From 7c30312c1734038825ac2e18fa2a32eb775d5c8d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Sep 2007 16:05:08 +0000 Subject: r25316: Remove last few instances of old BOOL type in librpc/. (This used to be commit 80d1dd41d4b224c46ad545f0afd97a847b99860b) --- source4/librpc/rpc/dcerpc_auth.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 756cb58e3a..7db6c1b7cd 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -98,7 +98,7 @@ NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, struct bind_auth_state { struct dcerpc_pipe *pipe; DATA_BLOB credentials; - BOOL more_processing; /* Is there anything more to do after the + bool more_processing; /* Is there anything more to do after the * first bind itself received? */ }; @@ -109,7 +109,7 @@ static void bind_auth_next_step(struct composite_context *c) struct bind_auth_state *state; struct dcerpc_security *sec; struct composite_context *creq; - BOOL more_processing = False; + bool more_processing = false; state = talloc_get_type(c->private_data, struct bind_auth_state); sec = &state->pipe->conn->security_state; @@ -129,7 +129,7 @@ static void bind_auth_next_step(struct composite_context *c) &state->credentials); if (NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { - more_processing = True; + more_processing = true; c->status = NT_STATUS_OK; } -- cgit From fface33dd731a711688b56593bb703c38090e782 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 2 Dec 2007 19:31:14 +0100 Subject: r26231: Spell check: credentails -> credentials. (This used to be commit 4b46888bd0195ab12190f76868719fc018baafd6) --- source4/librpc/rpc/dcerpc_auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 7db6c1b7cd..0fb898c562 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -248,7 +248,7 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, c->status = gensec_set_credentials(sec->generic_state, credentials); if (!NT_STATUS_IS_OK(c->status)) { - DEBUG(1, ("Failed to set GENSEC client credentails: %s\n", + DEBUG(1, ("Failed to set GENSEC client credentials: %s\n", nt_errstr(c->status))); composite_error(c, c->status); return c; -- cgit From ecea5ce24553989103d4a06296b24f4d29f30a36 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Dec 2007 17:41:50 +0100 Subject: r26260: Store loadparm context in gensec context. (This used to be commit b9e3a4862e267be39d603fed8207a237c3d72081) --- source4/librpc/rpc/dcerpc_auth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 0fb898c562..0012b38f2e 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -25,6 +25,7 @@ #include "libcli/composite/composite.h" #include "auth/gensec/gensec.h" #include "librpc/rpc/dcerpc.h" +#include "param/param.h" /* return the rpc syntax and transfer syntax given the pipe uuid and version @@ -238,7 +239,8 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, sec = &p->conn->security_state; c->status = gensec_client_start(p, &sec->generic_state, - p->conn->event_ctx); + p->conn->event_ctx, + global_loadparm); if (!NT_STATUS_IS_OK(c->status)) { DEBUG(1, ("Failed to start GENSEC client mode: %s\n", nt_errstr(c->status))); -- cgit From 4c4323009fa83f00ed319de59a3aad48fcd65994 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Dec 2007 02:37:04 +0100 Subject: r26327: Explicit loadparm_context for RPC client functions. (This used to be commit eeb2251d22b3d6e0379444a73af69d1014692b07) --- source4/librpc/rpc/dcerpc_auth.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 0012b38f2e..f80ef86413 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -212,6 +212,7 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, const struct ndr_interface_table *table, struct cli_credentials *credentials, + struct loadparm_context *lp_ctx, uint8_t auth_type, uint8_t auth_level, const char *service) { @@ -240,7 +241,7 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, c->status = gensec_client_start(p, &sec->generic_state, p->conn->event_ctx, - global_loadparm); + lp_ctx); if (!NT_STATUS_IS_OK(c->status)) { DEBUG(1, ("Failed to start GENSEC client mode: %s\n", nt_errstr(c->status))); @@ -374,11 +375,12 @@ NTSTATUS dcerpc_bind_auth_recv(struct composite_context *creq) NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, const struct ndr_interface_table *table, struct cli_credentials *credentials, + struct loadparm_context *lp_ctx, uint8_t auth_type, uint8_t auth_level, const char *service) { struct composite_context *creq; - creq = dcerpc_bind_auth_send(p, p, table, credentials, + creq = dcerpc_bind_auth_send(p, p, table, credentials, lp_ctx, auth_type, auth_level, service); return dcerpc_bind_auth_recv(creq); } -- cgit From afe3e8172ddaa5e4aa811faceecda4f943d6e2ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 04:53:27 +0200 Subject: Install public header files again and include required prototypes. (This used to be commit 47ffbbf67435904754469544390b67d34c958343) --- source4/librpc/rpc/dcerpc_auth.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index f80ef86413..f990029f1d 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -25,6 +25,7 @@ #include "libcli/composite/composite.h" #include "auth/gensec/gensec.h" #include "librpc/rpc/dcerpc.h" +#include "librpc/rpc/dcerpc_proto.h" #include "param/param.h" /* @@ -86,7 +87,7 @@ NTSTATUS dcerpc_bind_auth_none_recv(struct composite_context *ctx) /* Perform sync non-authenticated dcerpc bind */ -NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, +_PUBLIC_ NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p, const struct ndr_interface_table *table) { struct composite_context *ctx; @@ -372,7 +373,7 @@ NTSTATUS dcerpc_bind_auth_recv(struct composite_context *creq) @retval NTSTATUS status code */ -NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, +_PUBLIC_ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, const struct ndr_interface_table *table, struct cli_credentials *credentials, struct loadparm_context *lp_ctx, -- cgit From b3573ce76eb053bf262b4ddea5a0fedf416d1ede Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 6 Aug 2008 21:34:00 +0200 Subject: librpc/rpc: pass struct dcerpc_pipe to dcerpc_auth3() metze (This used to be commit 60b3523da485d845b1d930d990688d8434d39ef3) --- source4/librpc/rpc/dcerpc_auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index f990029f1d..661cd13c5a 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -146,7 +146,7 @@ static void bind_auth_next_step(struct composite_context *c) if (!more_processing) { /* NO reply expected, so just send it */ - c->status = dcerpc_auth3(state->pipe->conn, state); + c->status = dcerpc_auth3(state->pipe, state); if (!composite_is_ok(c)) return; composite_done(c); -- cgit From 50f82609b5833b2f242bc7d5adddeb56480fa2bb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 6 Aug 2008 21:35:07 +0200 Subject: librpc/rpc: add support DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN You can trigger it like this: ncacn_ip_tcp:172.31.9.234[sign,hdrsign] or ncacn_ip_tcp:172.31.9.234[seal,hdrsign] metze (This used to be commit 54f1fca582b1474693b5ee11b7b847086d27f75f) --- source4/librpc/rpc/dcerpc_auth.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 661cd13c5a..49fc3d9294 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -137,6 +137,10 @@ static void bind_auth_next_step(struct composite_context *c) if (!composite_is_ok(c)) return; + if (state->pipe->conn->flags & DCERPC_HEADER_SIGNING) { + gensec_want_feature(sec->generic_state, GENSEC_FEATURE_SIGN_PKT_HEADER); + } + if (state->credentials.length == 0) { composite_done(c); return; -- cgit From 73ebb58f2da7f3dbc0d61d68d1b28b482069b344 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 13 Sep 2008 18:49:03 +0200 Subject: client free credentials when not needed anymore (This used to be commit d982b69df638f17da6af398e2613986240031064) --- source4/librpc/rpc/dcerpc_auth.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/librpc/rpc/dcerpc_auth.c') diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index 49fc3d9294..2eced55967 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -129,6 +129,7 @@ static void bind_auth_next_step(struct composite_context *c) c->status = gensec_update(sec->generic_state, state, sec->auth_info->credentials, &state->credentials); + data_blob_free(&sec->auth_info->credentials); if (NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { more_processing = true; @@ -151,6 +152,8 @@ static void bind_auth_next_step(struct composite_context *c) if (!more_processing) { /* NO reply expected, so just send it */ c->status = dcerpc_auth3(state->pipe, state); + data_blob_free(&state->credentials); + sec->auth_info->credentials = data_blob(NULL, 0); if (!composite_is_ok(c)) return; composite_done(c); @@ -162,6 +165,8 @@ static void bind_auth_next_step(struct composite_context *c) creq = dcerpc_alter_context_send(state->pipe, state, &state->pipe->syntax, &state->pipe->transfer_syntax); + data_blob_free(&state->credentials); + sec->auth_info->credentials = data_blob(NULL, 0); if (composite_nomem(creq, c)) return; composite_continue(c, creq, bind_auth_recv_alter, c); @@ -334,6 +339,8 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx, /* The first request always is a dcerpc_bind. The subsequent ones * depend on gensec results */ creq = dcerpc_bind_send(p, state, &syntax, &transfer_syntax); + data_blob_free(&state->credentials); + sec->auth_info->credentials = data_blob(NULL, 0); if (composite_nomem(creq, c)) return c; composite_continue(c, creq, bind_auth_recv_bindreply, c); -- cgit