summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2010-07-19 13:48:31 -0400
committerSimo Sorce <idra@samba.org>2010-07-19 13:48:31 -0400
commitf9f3358348229b14d368316e327cfd2a4cb48c7c (patch)
tree9fb61c2ed61dd1ff93a64fc4498a4ec8d3a0607d /source3
parent7e4de49bfceed18c81abf93703a61d0a22617a24 (diff)
parent630a2eb68af0d523a1bb4451bbaa75d2ba47d252 (diff)
downloadsamba-f9f3358348229b14d368316e327cfd2a4cb48c7c.tar.gz
samba-f9f3358348229b14d368316e327cfd2a4cb48c7c.tar.bz2
samba-f9f3358348229b14d368316e327cfd2a4cb48c7c.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Diffstat (limited to 'source3')
-rw-r--r--source3/auth/auth.c34
-rw-r--r--source3/auth/auth_compat.c2
-rw-r--r--source3/auth/auth_ntlmssp.c67
-rw-r--r--source3/include/auth.h1
-rw-r--r--source3/include/proto.h22
-rw-r--r--source3/libads/sasl.c14
-rw-r--r--source3/librpc/gen_ndr/README4
-rw-r--r--source3/libsmb/cliconnect.c6
-rw-r--r--source3/libsmb/ntlmssp.c17
-rw-r--r--source3/libsmb/smb_seal.c2
-rw-r--r--source3/m4/aclocal.m410
-rw-r--r--source3/rpc_client/cli_pipe.c2
-rw-r--r--source3/rpc_server/srv_netlog_nt.c2
-rw-r--r--source3/rpc_server/srv_pipe.c7
-rw-r--r--source3/rpc_server/srv_pipe_register.c55
-rw-r--r--source3/smbd/negprot.c3
-rw-r--r--source3/smbd/password.c2
-rw-r--r--source3/smbd/seal.c2
-rw-r--r--source3/smbd/server_exit.c3
-rw-r--r--source3/smbd/sesssetup.c11
-rw-r--r--source3/smbd/smb2_sesssetup.c18
-rw-r--r--source3/utils/ntlm_auth.c34
-rw-r--r--source3/winbindd/winbindd.c4
-rw-r--r--source3/winbindd/winbindd_ccache_access.c2
-rw-r--r--source3/wscript20
25 files changed, 191 insertions, 153 deletions
diff --git a/source3/auth/auth.c b/source3/auth/auth.c
index a52dab9f01..5dc1d970d6 100644
--- a/source3/auth/auth.c
+++ b/source3/auth/auth.c
@@ -322,38 +322,40 @@ static NTSTATUS check_ntlm_password(const struct auth_context *auth_context,
Clear out a auth_context, and destroy the attached TALLOC_CTX
***************************************************************************/
-static void free_auth_context(struct auth_context **auth_context)
+static int auth_context_destructor(void *ptr)
{
- auth_methods *auth_method;
+ struct auth_context *ctx = talloc_get_type(ptr, struct auth_context);
+ struct auth_methods *am;
- if (*auth_context) {
- /* Free private data of context's authentication methods */
- for (auth_method = (*auth_context)->auth_method_list; auth_method; auth_method = auth_method->next) {
- TALLOC_FREE(auth_method->private_data);
- }
- talloc_destroy(*auth_context);
- *auth_context = NULL;
+ /* Free private data of context's authentication methods */
+ for (am = ctx->auth_method_list; am; am = am->next) {
+ TALLOC_FREE(am->private_data);
}
+
+ return 0;
}
/***************************************************************************
Make a auth_info struct
***************************************************************************/
-static NTSTATUS make_auth_context(struct auth_context **auth_context)
+static NTSTATUS make_auth_context(struct auth_context **auth_context)
{
- *auth_context = TALLOC_ZERO_P(talloc_autofree_context(),
- struct auth_context);
- if (!*auth_context) {
+ struct auth_context *ctx;
+
+ ctx = talloc_zero(talloc_autofree_context(), struct auth_context);
+ if (!ctx) {
DEBUG(0,("make_auth_context: talloc failed!\n"));
return NT_STATUS_NO_MEMORY;
}
- (*auth_context)->check_ntlm_password = check_ntlm_password;
- (*auth_context)->get_ntlm_challenge = get_ntlm_challenge;
- (*auth_context)->free = free_auth_context;
+ ctx->check_ntlm_password = check_ntlm_password;
+ ctx->get_ntlm_challenge = get_ntlm_challenge;
+
+ talloc_set_destructor((TALLOC_CTX *)ctx, auth_context_destructor);
+ *auth_context = ctx;
return NT_STATUS_OK;
}
diff --git a/source3/auth/auth_compat.c b/source3/auth/auth_compat.c
index e90036f3ff..cdd4096654 100644
--- a/source3/auth/auth_compat.c
+++ b/source3/auth/auth_compat.c
@@ -59,7 +59,7 @@ NTSTATUS check_plaintext_password(const char *smb_name,
nt_status = plaintext_auth_context->check_ntlm_password(plaintext_auth_context,
user_info, server_info);
- (plaintext_auth_context->free)(&plaintext_auth_context);
+ TALLOC_FREE(plaintext_auth_context);
free_user_info(&user_info);
return nt_status;
}
diff --git a/source3/auth/auth_ntlmssp.c b/source3/auth/auth_ntlmssp.c
index ba7efbf48e..bebb86ee17 100644
--- a/source3/auth/auth_ntlmssp.c
+++ b/source3/auth/auth_ntlmssp.c
@@ -24,7 +24,6 @@
#include "../libcli/auth/ntlmssp.h"
struct auth_ntlmssp_state {
- TALLOC_CTX *mem_ctx;
struct auth_context *auth_context;
struct auth_serversupplied_info *server_info;
struct ntlmssp_state *ntlmssp_state;
@@ -241,29 +240,33 @@ static NTSTATUS auth_ntlmssp_check_password(struct ntlmssp_state *ntlmssp_state,
if (auth_ntlmssp_state->server_info->user_session_key.length) {
DEBUG(10, ("Got NT session key of length %u\n",
(unsigned int)auth_ntlmssp_state->server_info->user_session_key.length));
- *user_session_key = data_blob_talloc(auth_ntlmssp_state->mem_ctx,
+ *user_session_key = data_blob_talloc(auth_ntlmssp_state,
auth_ntlmssp_state->server_info->user_session_key.data,
auth_ntlmssp_state->server_info->user_session_key.length);
}
if (auth_ntlmssp_state->server_info->lm_session_key.length) {
DEBUG(10, ("Got LM session key of length %u\n",
(unsigned int)auth_ntlmssp_state->server_info->lm_session_key.length));
- *lm_session_key = data_blob_talloc(auth_ntlmssp_state->mem_ctx,
+ *lm_session_key = data_blob_talloc(auth_ntlmssp_state,
auth_ntlmssp_state->server_info->lm_session_key.data,
auth_ntlmssp_state->server_info->lm_session_key.length);
}
return nt_status;
}
+static int auth_ntlmssp_state_destructor(void *ptr);
+
NTSTATUS auth_ntlmssp_start(struct auth_ntlmssp_state **auth_ntlmssp_state)
{
NTSTATUS nt_status;
- TALLOC_CTX *mem_ctx;
bool is_standalone;
const char *netbios_name;
const char *netbios_domain;
const char *dns_name;
char *dns_domain;
+ struct auth_ntlmssp_state *ans;
+ struct ntlmssp_state *ntlmssp_state;
+ struct auth_context *auth_context;
if ((enum server_types)lp_server_role() == ROLE_STANDALONE) {
is_standalone = true;
@@ -280,63 +283,51 @@ NTSTATUS auth_ntlmssp_start(struct auth_ntlmssp_state **auth_ntlmssp_state)
}
dns_name = get_mydnsfullname();
- mem_ctx = talloc_init("AUTH NTLMSSP context");
-
- *auth_ntlmssp_state = TALLOC_ZERO_P(mem_ctx, struct auth_ntlmssp_state);
- if (!*auth_ntlmssp_state) {
+ ans = talloc_zero(NULL, struct auth_ntlmssp_state);
+ if (!ans) {
DEBUG(0,("auth_ntlmssp_start: talloc failed!\n"));
- talloc_destroy(mem_ctx);
+ TALLOC_FREE(ntlmssp_state);
return NT_STATUS_NO_MEMORY;
}
- ZERO_STRUCTP(*auth_ntlmssp_state);
-
- (*auth_ntlmssp_state)->mem_ctx = mem_ctx;
-
- nt_status = ntlmssp_server_start(NULL,
+ nt_status = ntlmssp_server_start(ans,
is_standalone,
netbios_name,
netbios_domain,
dns_name,
dns_domain,
- &(*auth_ntlmssp_state)->ntlmssp_state);
+ &ans->ntlmssp_state);
if (!NT_STATUS_IS_OK(nt_status)) {
return nt_status;
}
- if (!NT_STATUS_IS_OK(nt_status = make_auth_context_subsystem(&(*auth_ntlmssp_state)->auth_context))) {
+ nt_status = make_auth_context_subsystem(&auth_context);
+ if (!NT_STATUS_IS_OK(nt_status)) {
return nt_status;
}
+ ans->auth_context = talloc_steal(ans, auth_context);
- (*auth_ntlmssp_state)->ntlmssp_state->callback_private = (*auth_ntlmssp_state);
- (*auth_ntlmssp_state)->ntlmssp_state->get_challenge = auth_ntlmssp_get_challenge;
- (*auth_ntlmssp_state)->ntlmssp_state->may_set_challenge = auth_ntlmssp_may_set_challenge;
- (*auth_ntlmssp_state)->ntlmssp_state->set_challenge = auth_ntlmssp_set_challenge;
- (*auth_ntlmssp_state)->ntlmssp_state->check_password = auth_ntlmssp_check_password;
+ ans->ntlmssp_state->callback_private = ans;
+ ans->ntlmssp_state->get_challenge = auth_ntlmssp_get_challenge;
+ ans->ntlmssp_state->may_set_challenge = auth_ntlmssp_may_set_challenge;
+ ans->ntlmssp_state->set_challenge = auth_ntlmssp_set_challenge;
+ ans->ntlmssp_state->check_password = auth_ntlmssp_check_password;
+ talloc_set_destructor((TALLOC_CTX *)ans, auth_ntlmssp_state_destructor);
+
+ *auth_ntlmssp_state = ans;
return NT_STATUS_OK;
}
-void auth_ntlmssp_end(struct auth_ntlmssp_state **auth_ntlmssp_state)
+static int auth_ntlmssp_state_destructor(void *ptr)
{
- TALLOC_CTX *mem_ctx;
+ struct auth_ntlmssp_state *ans;
- if (*auth_ntlmssp_state == NULL) {
- return;
- }
+ ans = talloc_get_type(ptr, struct auth_ntlmssp_state);
- mem_ctx = (*auth_ntlmssp_state)->mem_ctx;
- if ((*auth_ntlmssp_state)->ntlmssp_state) {
- ntlmssp_end(&(*auth_ntlmssp_state)->ntlmssp_state);
- }
- if ((*auth_ntlmssp_state)->auth_context) {
- ((*auth_ntlmssp_state)->auth_context->free)(&(*auth_ntlmssp_state)->auth_context);
- }
- if ((*auth_ntlmssp_state)->server_info) {
- TALLOC_FREE((*auth_ntlmssp_state)->server_info);
- }
- talloc_destroy(mem_ctx);
- *auth_ntlmssp_state = NULL;
+ TALLOC_FREE(ans->server_info);
+ TALLOC_FREE(ans->ntlmssp_state);
+ return 0;
}
NTSTATUS auth_ntlmssp_update(struct auth_ntlmssp_state *auth_ntlmssp_state,
diff --git a/source3/include/auth.h b/source3/include/auth.h
index 17257b3433..b7089b8c0a 100644
--- a/source3/include/auth.h
+++ b/source3/include/auth.h
@@ -115,7 +115,6 @@ struct auth_context {
const struct auth_usersupplied_info *user_info,
struct auth_serversupplied_info **server_info);
NTSTATUS (*nt_status_squash)(NTSTATUS nt_status);
- void (*free)(struct auth_context **auth_context);
};
typedef struct auth_methods
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 9471f63195..d9f9ab96d4 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -66,7 +66,6 @@ bool auth_ntlmssp_negotiated_seal(struct auth_ntlmssp_state *auth_ntlmssp_state)
void auth_ntlmssp_want_sign(struct auth_ntlmssp_state *auth_ntlmssp_state);
void auth_ntlmssp_want_seal(struct auth_ntlmssp_state *auth_ntlmssp_state);
NTSTATUS auth_ntlmssp_start(struct auth_ntlmssp_state **auth_ntlmssp_state);
-void auth_ntlmssp_end(struct auth_ntlmssp_state **auth_ntlmssp_state);
NTSTATUS auth_ntlmssp_update(struct auth_ntlmssp_state *auth_ntlmssp_state,
const DATA_BLOB request, DATA_BLOB *reply) ;
NTSTATUS auth_ntlmssp_sign_packet(struct auth_ntlmssp_state *auth_ntlmssp_state,
@@ -3102,7 +3101,6 @@ void ntlmssp_want_feature_list(struct ntlmssp_state *ntlmssp_state, char *featur
void ntlmssp_want_feature(struct ntlmssp_state *ntlmssp_state, uint32_t feature);
NTSTATUS ntlmssp_update(struct ntlmssp_state *ntlmssp_state,
const DATA_BLOB in, DATA_BLOB *out) ;
-void ntlmssp_end(struct ntlmssp_state **ntlmssp_state);
DATA_BLOB ntlmssp_weaken_keys(struct ntlmssp_state *ntlmssp_state, TALLOC_CTX *mem_ctx);
NTSTATUS ntlmssp_server_start(TALLOC_CTX *mem_ctx,
bool is_standalone,
@@ -5049,6 +5047,22 @@ void *_policy_handle_find(struct pipes_struct *p,
(_access_granted), #_type, __location__, (_pstatus))
+/* The following definitions come from rpc_server/srv_rpc_register.c */
+
+struct rpc_srv_callbacks {
+ bool (*init)(void *private_data);
+ bool (*shutdown)(void *private_data);
+ void *private_data;
+};
+
+NTSTATUS rpc_srv_register(int version, const char *clnt,
+ const char *srv,
+ const struct ndr_interface_table *iface,
+ const struct api_struct *cmds, int size,
+ const struct rpc_srv_callbacks *rpc_srv_cb);
+
+NTSTATUS rpc_srv_unregister(const struct ndr_interface_table *iface);
+
/* The following definitions come from rpc_server/srv_pipe.c */
bool create_next_pdu(pipes_struct *p);
@@ -5058,10 +5072,6 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt,
const char *srv,
const struct ndr_syntax_id *interface,
const struct api_struct *cmds, int size);
-NTSTATUS rpc_srv_register(int version, const char *clnt,
- const char *srv,
- const struct ndr_interface_table *iface,
- const struct api_struct *cmds, int size);
bool is_known_pipename(const char *cli_filename, struct ndr_syntax_id *syntax);
bool api_pipe_bind_req(pipes_struct *p, struct ncacn_packet *pkt);
bool api_pipe_alter_context(pipes_struct *p, struct ncacn_packet *pkt);
diff --git a/source3/libads/sasl.c b/source3/libads/sasl.c
index 04b9a71d76..a37d1e8474 100644
--- a/source3/libads/sasl.c
+++ b/source3/libads/sasl.c
@@ -106,7 +106,7 @@ static void ads_sasl_ntlmssp_disconnect(ADS_STRUCT *ads)
struct ntlmssp_state *ntlmssp_state =
(struct ntlmssp_state *)ads->ldap.wrap_private_data;
- ntlmssp_end(&ntlmssp_state);
+ TALLOC_FREE(ntlmssp_state);
ads->ldap.wrap_ops = NULL;
ads->ldap.wrap_private_data = NULL;
@@ -209,7 +209,7 @@ static ADS_STATUS ads_sasl_spnego_ntlmssp_bind(ADS_STRUCT *ads)
ber_bvfree(scred);
}
- ntlmssp_end(&ntlmssp_state);
+ TALLOC_FREE(ntlmssp_state);
return ADS_ERROR(rc);
}
if (scred) {
@@ -221,7 +221,7 @@ static ADS_STATUS ads_sasl_spnego_ntlmssp_bind(ADS_STRUCT *ads)
} else {
- ntlmssp_end(&ntlmssp_state);
+ TALLOC_FREE(ntlmssp_state);
data_blob_free(&blob_out);
return ADS_ERROR_NT(nt_status);
}
@@ -233,7 +233,7 @@ static ADS_STATUS ads_sasl_spnego_ntlmssp_bind(ADS_STRUCT *ads)
if (!spnego_parse_challenge(blob, &blob_in,
&tmp_blob)) {
- ntlmssp_end(&ntlmssp_state);
+ TALLOC_FREE(ntlmssp_state);
data_blob_free(&blob);
DEBUG(3,("Failed to parse challenges\n"));
return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER);
@@ -243,7 +243,7 @@ static ADS_STATUS ads_sasl_spnego_ntlmssp_bind(ADS_STRUCT *ads)
if (!spnego_parse_auth_response(blob, nt_status, OID_NTLMSSP,
&blob_in)) {
- ntlmssp_end(&ntlmssp_state);
+ TALLOC_FREE(ntlmssp_state);
data_blob_free(&blob);
DEBUG(3,("Failed to parse auth response\n"));
return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER);
@@ -266,11 +266,11 @@ static ADS_STATUS ads_sasl_spnego_ntlmssp_bind(ADS_STRUCT *ads)
if (!ADS_ERR_OK(status)) {
DEBUG(0, ("ads_setup_sasl_wrapping() failed: %s\n",
ads_errstr(status)));
- ntlmssp_end(&ntlmssp_state);
+ TALLOC_FREE(ntlmssp_state);
return status;
}
} else {
- ntlmssp_end(&ntlmssp_state);
+ TALLOC_FREE(ntlmssp_state);
}
return ADS_ERROR(rc);
diff --git a/source3/librpc/gen_ndr/README b/source3/librpc/gen_ndr/README
new file mode 100644
index 0000000000..5ccb89db5d
--- /dev/null
+++ b/source3/librpc/gen_ndr/README
@@ -0,0 +1,4 @@
+This contains the generated files from PIDL for the IDL files in ../idl/*.idl
+
+DO NOT REMOVE THIS FILE. The waf 1.5 build relies on this directory
+existing in the source tree.
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 06a6f7e683..8d4c1901c1 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -969,7 +969,7 @@ static int cli_session_setup_ntlmssp_state_destructor(
struct cli_session_setup_ntlmssp_state *state)
{
if (state->ntlmssp_state != NULL) {
- ntlmssp_end(&state->ntlmssp_state);
+ TALLOC_FREE(state->ntlmssp_state);
}
return 0;
}
@@ -1079,7 +1079,7 @@ static void cli_session_setup_ntlmssp_done(struct tevent_req *subreq)
return;
}
TALLOC_FREE(subreq);
- ntlmssp_end(&state->ntlmssp_state);
+ TALLOC_FREE(state->ntlmssp_state);
tevent_req_done(req);
return;
}
@@ -1122,7 +1122,7 @@ static void cli_session_setup_ntlmssp_done(struct tevent_req *subreq)
if (!NT_STATUS_IS_OK(status)
&& !NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
TALLOC_FREE(subreq);
- ntlmssp_end(&state->ntlmssp_state);
+ TALLOC_FREE(state->ntlmssp_state);
tevent_req_nterror(req, status);
return;
}
diff --git a/source3/libsmb/ntlmssp.c b/source3/libsmb/ntlmssp.c
index 228d19536e..a0dc39be3e 100644
--- a/source3/libsmb/ntlmssp.c
+++ b/source3/libsmb/ntlmssp.c
@@ -275,23 +275,6 @@ NTSTATUS ntlmssp_update(struct ntlmssp_state *ntlmssp_state,
}
/**
- * End an NTLMSSP state machine
- *
- * @param ntlmssp_state NTLMSSP State, free()ed by this function
- */
-
-void ntlmssp_end(struct ntlmssp_state **ntlmssp_state)
-{
- data_blob_free(&(*ntlmssp_state)->chal);
- data_blob_free(&(*ntlmssp_state)->lm_resp);
- data_blob_free(&(*ntlmssp_state)->nt_resp);
- TALLOC_FREE(*ntlmssp_state);
-
- *ntlmssp_state = NULL;
- return;
-}
-
-/**
* Determine correct target name flags for reply, given server role
* and negotiated flags
*
diff --git a/source3/libsmb/smb_seal.c b/source3/libsmb/smb_seal.c
index 92d7fef651..4610850638 100644
--- a/source3/libsmb/smb_seal.c
+++ b/source3/libsmb/smb_seal.c
@@ -371,7 +371,7 @@ void common_free_encryption_state(struct smb_trans_enc_state **pp_es)
if (es->smb_enc_type == SMB_TRANS_ENC_NTLM) {
if (es->s.ntlmssp_state) {
- ntlmssp_end(&es->s.ntlmssp_state);
+ TALLOC_FREE(es->s.ntlmssp_state);
}
}
#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
diff --git a/source3/m4/aclocal.m4 b/source3/m4/aclocal.m4
index f7f3497a23..3ca44bd496 100644
--- a/source3/m4/aclocal.m4
+++ b/source3/m4/aclocal.m4
@@ -30,9 +30,17 @@ AC_DEFUN(SMB_MODULE,
AC_MSG_RESULT([shared])
[$6]
string_shared_modules="$string_shared_modules $1"
+ elif test x"$DEST" = xSTATIC && test x"$4" = xRPC; then
+ [init_static_modules_]translit([$4], [A-Z], [a-z])="$[init_static_modules_]translit([$4], [A-Z], [a-z]) $1_init(NULL);"
+ [decl_static_modules_]translit([$4], [A-Z], [a-z])="$[decl_static_modules_]translit([$4], [A-Z], [a-z]) extern NTSTATUS $1_init(const struct rpc_srv_callbacks *rpc_srv_cb);"
+ string_static_modules="$string_static_modules $1"
+ $4_STATIC="$$4_STATIC $2"
+ AC_SUBST($4_STATIC)
+ [$5]
+ AC_MSG_RESULT([static])
elif test x"$DEST" = xSTATIC; then
[init_static_modules_]translit([$4], [A-Z], [a-z])="$[init_static_modules_]translit([$4], [A-Z], [a-z]) $1_init();"
- [decl_static_modules_]translit([$4], [A-Z], [a-z])="$[decl_static_modules_]translit([$4], [A-Z], [a-z]) extern NTSTATUS $1_init(void);"
+ [decl_static_modules_]translit([$4], [A-Z], [a-z])="$[decl_static_modules_]translit([$4], [A-Z], [a-z]) extern NTSTATUS $1_init(void);"
string_static_modules="$string_static_modules $1"
$4_STATIC="$$4_STATIC $2"
AC_SUBST($4_STATIC)
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index a61200a104..8dd9386eab 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -2704,7 +2704,7 @@ NTSTATUS rpccli_anon_bind_data(TALLOC_CTX *mem_ctx,
static int cli_auth_ntlmssp_data_destructor(struct cli_pipe_auth_data *auth)
{
- ntlmssp_end(&auth->a_u.ntlmssp_state);
+ TALLOC_FREE(auth->a_u.ntlmssp_state);
return 0;
}
diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c
index ebd37241a6..a57836aa75 100644
--- a/source3/rpc_server/srv_netlog_nt.c
+++ b/source3/rpc_server/srv_netlog_nt.c
@@ -1380,7 +1380,7 @@ static NTSTATUS _netr_LogonSamLogon_base(pipes_struct *p,
user_info, &server_info);
}
- (auth_context->free)(&auth_context);
+ TALLOC_FREE(auth_context);
free_user_info(&user_info);
DEBUG(5,("%s: check_password returned status %s\n",
diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c
index a7a5f4d676..a56a6345cc 100644
--- a/source3/rpc_server/srv_pipe.c
+++ b/source3/rpc_server/srv_pipe.c
@@ -85,12 +85,7 @@ static void dump_pdu_region(const char *name, int v,
static void free_pipe_ntlmssp_auth_data(struct pipe_auth_data *auth)
{
- struct auth_ntlmssp_state *a = auth->a_u.auth_ntlmssp_state;
-
- if (a) {
- auth_ntlmssp_end(&a);
- }
- auth->a_u.auth_ntlmssp_state = NULL;
+ TALLOC_FREE(auth->a_u.auth_ntlmssp_state);
}
static DATA_BLOB generic_session_key(void)
diff --git a/source3/rpc_server/srv_pipe_register.c b/source3/rpc_server/srv_pipe_register.c
index 757e4fbe72..3753596a2b 100644
--- a/source3/rpc_server/srv_pipe_register.c
+++ b/source3/rpc_server/srv_pipe_register.c
@@ -31,11 +31,26 @@ struct rpc_table {
struct ndr_syntax_id rpc_interface;
const struct api_struct *cmds;
uint32_t n_cmds;
+ bool (*shutdown_fn)(void *private_data);
+ void *shutdown_data;
};
static struct rpc_table *rpc_lookup;
static uint32_t rpc_lookup_size;
+static struct rpc_table *rpc_srv_get_pipe_by_id(const struct ndr_syntax_id *id)
+{
+ uint32_t i;
+
+ for (i = 0; i < rpc_lookup_size; i++) {
+ if (ndr_syntax_id_equal(&rpc_lookup[i].rpc_interface, id)) {
+ return &rpc_lookup[i];
+ }
+ }
+
+ return NULL;
+}
+
bool rpc_srv_pipe_exists_by_id(const struct ndr_syntax_id *id)
{
uint32_t i;
@@ -150,7 +165,8 @@ bool rpc_srv_get_pipe_interface_by_cli_name(const char *cli_name,
NTSTATUS rpc_srv_register(int version, const char *clnt, const char *srv,
const struct ndr_interface_table *iface,
- const struct api_struct *cmds, int size)
+ const struct api_struct *cmds, int size,
+ const struct rpc_srv_callbacks *rpc_srv_cb)
{
struct rpc_table *rpc_entry;
@@ -166,12 +182,10 @@ NTSTATUS rpc_srv_register(int version, const char *clnt, const char *srv,
return NT_STATUS_OBJECT_TYPE_MISMATCH;
}
- /* TODO:
- *
- * we still need to make sure that don't register the same commands twice!!!
- *
- * --metze
- */
+ /* Don't register the same command twice */
+ if (rpc_srv_pipe_exists_by_id(&iface->syntax_id)) {
+ return NT_STATUS_OK;
+ }
/*
* We use a temporary variable because this call can fail and
@@ -196,5 +210,32 @@ NTSTATUS rpc_srv_register(int version, const char *clnt, const char *srv,
rpc_entry->cmds = cmds;
rpc_entry->n_cmds = size;
+ if (rpc_srv_cb != NULL) {
+ rpc_entry->shutdown_fn = rpc_srv_cb->shutdown;
+ rpc_entry->shutdown_data = rpc_srv_cb->private_data;
+
+ if (rpc_srv_cb->init != NULL &&
+ !rpc_srv_cb->init(rpc_srv_cb->private_data)) {
+ DEBUG(0, ("rpc_srv_register: Failed to call the %s "
+ "init function!\n", srv));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ }
+
+ return NT_STATUS_OK;
+}
+
+NTSTATUS rpc_srv_unregister(const struct ndr_interface_table *iface)
+{
+ struct rpc_table *rpc_entry = rpc_srv_get_pipe_by_id(&iface->syntax_id);
+
+ if (rpc_entry != NULL && rpc_entry->shutdown_fn != NULL) {
+ if (!rpc_entry->shutdown_fn(rpc_entry->shutdown_data)) {
+ DEBUG(0, ("rpc_srv_unregister: Failed to call the %s "
+ "init function!\n", rpc_entry->pipe.srv));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ }
+
return NT_STATUS_OK;
}
diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c
index 755d3d9718..4d73216854 100644
--- a/source3/smbd/negprot.c
+++ b/source3/smbd/negprot.c
@@ -33,8 +33,7 @@ static void get_challenge(struct smbd_server_connection *sconn, uint8 buff[8])
if (sconn->smb1.negprot.auth_context) {
DEBUG(3, ("get challenge: is this a secondary negprot? "
"sconn->negprot.auth_context is non-NULL!\n"));
- sconn->smb1.negprot.auth_context->free(
- &sconn->smb1.negprot.auth_context);
+ TALLOC_FREE(sconn->smb1.negprot.auth_context);
}
DEBUG(10, ("get challenge: creating negprot_global_auth_context\n"));
diff --git a/source3/smbd/password.c b/source3/smbd/password.c
index 2bd333ab30..996417b51e 100644
--- a/source3/smbd/password.c
+++ b/source3/smbd/password.c
@@ -120,7 +120,7 @@ void invalidate_vuid(struct smbd_server_connection *sconn, uint16 vuid)
session_yield(vuser);
if (vuser->auth_ntlmssp_state) {
- auth_ntlmssp_end(&vuser->auth_ntlmssp_state);
+ TALLOC_FREE(vuser->auth_ntlmssp_state);
}
DLIST_REMOVE(sconn->smb1.sessions.validated_users, vuser);
diff --git a/source3/smbd/seal.c b/source3/smbd/seal.c
index 171e809b44..ad785a4588 100644
--- a/source3/smbd/seal.c
+++ b/source3/smbd/seal.c
@@ -101,7 +101,7 @@ static void destroy_auth_ntlmssp(struct smb_srv_trans_enc_ctx *ec)
*/
if (ec->auth_ntlmssp_state) {
- auth_ntlmssp_end(&ec->auth_ntlmssp_state);
+ TALLOC_FREE(ec->auth_ntlmssp_state);
/* The auth_ntlmssp_end killed this already. */
ec->es->s.ntlmssp_state = NULL;
}
diff --git a/source3/smbd/server_exit.c b/source3/smbd/server_exit.c
index 97394aea96..1a330994b8 100644
--- a/source3/smbd/server_exit.c
+++ b/source3/smbd/server_exit.c
@@ -75,8 +75,7 @@ static void exit_server_common(enum server_exit_reason how,
change_to_root_user();
if (sconn && sconn->smb1.negprot.auth_context) {
- struct auth_context *a = sconn->smb1.negprot.auth_context;
- a->free(&sconn->smb1.negprot.auth_context);
+ TALLOC_FREE(sconn->smb1.negprot.auth_context);
}
if (lp_log_writeable_files_on_exit()) {
diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c
index 52fcd282a6..27eb4f6c48 100644
--- a/source3/smbd/sesssetup.c
+++ b/source3/smbd/sesssetup.c
@@ -150,14 +150,14 @@ static NTSTATUS check_guest_password(struct auth_serversupplied_info **server_in
}
if (!make_user_info_guest(&user_info)) {
- (auth_context->free)(&auth_context);
+ TALLOC_FREE(auth_context);
return NT_STATUS_NO_MEMORY;
}
nt_status = auth_context->check_ntlm_password(auth_context,
user_info,
server_info);
- (auth_context->free)(&auth_context);
+ TALLOC_FREE(auth_context);
free_user_info(&user_info);
return nt_status;
}
@@ -708,7 +708,7 @@ static void reply_spnego_ntlmssp(struct smb_request *req,
if (!NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
/* NB. This is *NOT* an error case. JRA */
if (do_invalidate) {
- auth_ntlmssp_end(auth_ntlmssp_state);
+ TALLOC_FREE(*auth_ntlmssp_state);
if (!NT_STATUS_IS_OK(nt_status)) {
/* Kill the intermediate vuid */
invalidate_vuid(sconn, vuid);
@@ -828,7 +828,7 @@ static void reply_spnego_negotiate(struct smb_request *req,
#endif
if (*auth_ntlmssp_state) {
- auth_ntlmssp_end(auth_ntlmssp_state);
+ TALLOC_FREE(*auth_ntlmssp_state);
}
if (kerb_mech) {
@@ -1751,8 +1751,7 @@ void reply_sesssetup_and_X(struct smb_request *req)
user_info,
&server_info);
- (plaintext_auth_context->free)(
- &plaintext_auth_context);
+ TALLOC_FREE(plaintext_auth_context);
}
}
}
diff --git a/source3/smbd/smb2_sesssetup.c b/source3/smbd/smb2_sesssetup.c
index 493e74802d..4d0f03259b 100644
--- a/source3/smbd/smb2_sesssetup.c
+++ b/source3/smbd/smb2_sesssetup.c
@@ -550,7 +550,7 @@ static NTSTATUS smbd_smb2_spnego_negotiate(struct smbd_smb2_session *session,
NTSTATUS status;
/* Ensure we have no old NTLM state around. */
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
status = parse_spnego_mechanisms(in_security_buffer,
&secblob_in, &kerb_mech);
@@ -621,7 +621,7 @@ static NTSTATUS smbd_smb2_spnego_negotiate(struct smbd_smb2_session *session,
if (!NT_STATUS_IS_OK(status) &&
!NT_STATUS_EQUAL(status,
NT_STATUS_MORE_PROCESSING_REQUIRED)) {
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
TALLOC_FREE(session);
}
return status;
@@ -653,7 +653,7 @@ static NTSTATUS smbd_smb2_common_ntlmssp_auth_return(struct smbd_smb2_session *s
session->compat_vuser = talloc_zero(session, user_struct);
if (session->compat_vuser == NULL) {
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
TALLOC_FREE(session);
return NT_STATUS_NO_MEMORY;
}
@@ -682,7 +682,7 @@ static NTSTATUS smbd_smb2_common_ntlmssp_auth_return(struct smbd_smb2_session *s
DEBUG(1, ("smb2: Failed to claim session "
"for vuid=%d\n",
session->compat_vuser->vuid));
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
TALLOC_FREE(session);
return NT_STATUS_LOGON_FAILURE;
}
@@ -793,7 +793,7 @@ static NTSTATUS smbd_smb2_spnego_auth(struct smbd_smb2_session *session,
if (!NT_STATUS_IS_OK(status) &&
!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
data_blob_free(&auth);
TALLOC_FREE(session);
return status;
@@ -808,7 +808,7 @@ static NTSTATUS smbd_smb2_spnego_auth(struct smbd_smb2_session *session,
secblob_out.data,
secblob_out.length);
if (secblob_out.data && out_security_buffer->data == NULL) {
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
TALLOC_FREE(session);
return NT_STATUS_NO_MEMORY;
}
@@ -858,7 +858,7 @@ static NTSTATUS smbd_smb2_raw_ntlmssp_auth(struct smbd_smb2_session *session,
secblob_out.data,
secblob_out.length);
if (secblob_out.data && out_security_buffer->data == NULL) {
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
TALLOC_FREE(session);
return NT_STATUS_NO_MEMORY;
}
@@ -872,7 +872,7 @@ static NTSTATUS smbd_smb2_raw_ntlmssp_auth(struct smbd_smb2_session *session,
status = setup_ntlmssp_server_info(session, status);
if (!NT_STATUS_IS_OK(status)) {
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
TALLOC_FREE(session);
return status;
}
@@ -971,7 +971,7 @@ static NTSTATUS smbd_smb2_session_setup(struct smbd_smb2_request *smb2req,
/* Unknown packet type. */
DEBUG(1,("Unknown packet type %u in smb2 sessionsetup\n",
(unsigned int)in_security_buffer.data[0] ));
- auth_ntlmssp_end(&session->auth_ntlmssp_state);
+ TALLOC_FREE(session->auth_ntlmssp_state);
TALLOC_FREE(session);
return NT_STATUS_LOGON_FAILURE;
}
diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
index e7887cca71..bfdc369b15 100644
--- a/source3/utils/ntlm_auth.c
+++ b/source3/utils/ntlm_auth.c
@@ -656,7 +656,7 @@ static NTSTATUS ntlm_auth_start_ntlmssp_client(struct ntlmssp_state **client_ntl
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Could not start NTLMSSP client: %s\n",
nt_errstr(status)));
- ntlmssp_end(client_ntlmssp_state);
+ TALLOC_FREE(*client_ntlmssp_state);
return status;
}
@@ -665,7 +665,7 @@ static NTSTATUS ntlm_auth_start_ntlmssp_client(struct ntlmssp_state **client_ntl
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Could not set username: %s\n",
nt_errstr(status)));
- ntlmssp_end(client_ntlmssp_state);
+ TALLOC_FREE(*client_ntlmssp_state);
return status;
}
@@ -674,7 +674,7 @@ static NTSTATUS ntlm_auth_start_ntlmssp_client(struct ntlmssp_state **client_ntl
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Could not set domain: %s\n",
nt_errstr(status)));
- ntlmssp_end(client_ntlmssp_state);
+ TALLOC_FREE(*client_ntlmssp_state);
return status;
}
@@ -684,7 +684,7 @@ static NTSTATUS ntlm_auth_start_ntlmssp_client(struct ntlmssp_state **client_ntl
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Could not set password: %s\n",
nt_errstr(status)));
- ntlmssp_end(client_ntlmssp_state);
+ TALLOC_FREE(*client_ntlmssp_state);
return status;
}
}
@@ -854,7 +854,7 @@ static void manage_squid_ntlmssp_request(struct ntlm_auth_state *state,
if (strncmp(buf, "YR", 2) == 0) {
if (state->ntlmssp_state)
- ntlmssp_end(&state->ntlmssp_state);
+ TALLOC_FREE(state->ntlmssp_state);
state->svr_state = SERVER_INITIAL;
} else if (strncmp(buf, "KK", 2) == 0) {
/* No special preprocessing required */
@@ -916,7 +916,7 @@ static void manage_squid_ntlmssp_request(struct ntlm_auth_state *state,
x_fprintf(x_stdout, "BH %s\n", nt_errstr(nt_status));
DEBUG(0, ("NTLMSSP BH: %s\n", nt_errstr(nt_status)));
- ntlmssp_end(&state->ntlmssp_state);
+ TALLOC_FREE(state->ntlmssp_state);
} else if (!NT_STATUS_IS_OK(nt_status)) {
x_fprintf(x_stdout, "NA %s\n", nt_errstr(nt_status));
DEBUG(10, ("NTLMSSP %s\n", nt_errstr(nt_status)));
@@ -1010,7 +1010,7 @@ static void manage_client_ntlmssp_request(struct ntlm_auth_state *state,
if (strncmp(buf, "YR", 2) == 0) {
if (state->ntlmssp_state)
- ntlmssp_end(&state->ntlmssp_state);
+ TALLOC_FREE(state->ntlmssp_state);
state->cli_state = CLIENT_INITIAL;
} else if (strncmp(buf, "TT", 2) == 0) {
/* No special preprocessing required */
@@ -1102,13 +1102,13 @@ static void manage_client_ntlmssp_request(struct ntlm_auth_state *state,
DEBUG(10, ("NTLMSSP OK!\n"));
state->cli_state = CLIENT_FINISHED;
if (state->ntlmssp_state)
- ntlmssp_end(&state->ntlmssp_state);
+ TALLOC_FREE(state->ntlmssp_state);
} else {
x_fprintf(x_stdout, "BH %s\n", nt_errstr(nt_status));
DEBUG(0, ("NTLMSSP BH: %s\n", nt_errstr(nt_status)));
state->cli_state = CLIENT_ERROR;
if (state->ntlmssp_state)
- ntlmssp_end(&state->ntlmssp_state);
+ TALLOC_FREE(state->ntlmssp_state);
}
data_blob_free(&request);
@@ -1223,7 +1223,7 @@ static void manage_gss_spnego_request(struct ntlm_auth_state *state,
if (strncmp(buf, "YR", 2) == 0) {
if (ntlmssp_state)
- ntlmssp_end(&ntlmssp_state);
+ TALLOC_FREE(ntlmssp_state);
} else if (strncmp(buf, "KK", 2) == 0) {
;
} else {
@@ -1288,7 +1288,7 @@ static void manage_gss_spnego_request(struct ntlm_auth_state *state,
x_fprintf(x_stdout, "BH Client wants a new "
"NTLMSSP challenge, but "
"already got one\n");
- ntlmssp_end(&ntlmssp_state);
+ TALLOC_FREE(ntlmssp_state);
return;
}
@@ -1394,7 +1394,7 @@ static void manage_gss_spnego_request(struct ntlm_auth_state *state,
if (NT_STATUS_IS_OK(status)) {
user = SMB_STRDUP(ntlmssp_state->user);
domain = SMB_STRDUP(ntlmssp_state->domain);
- ntlmssp_end(&ntlmssp_state);
+ TALLOC_FREE(ntlmssp_state);
}
}
@@ -1495,7 +1495,7 @@ static bool manage_client_ntlmssp_init(struct spnego_data spnego)
NT_STATUS_IS_OK(status)) ) {
DEBUG(1, ("Expected OK or MORE_PROCESSING_REQUIRED, got: %s\n",
nt_errstr(status)));
- ntlmssp_end(&client_ntlmssp_state);
+ TALLOC_FREE(client_ntlmssp_state);
return False;
}
@@ -1528,13 +1528,13 @@ static void manage_client_ntlmssp_targ(struct spnego_data spnego)
if (spnego.negTokenTarg.negResult == SPNEGO_REJECT) {
x_fprintf(x_stdout, "NA\n");
- ntlmssp_end(&client_ntlmssp_state);
+ TALLOC_FREE(client_ntlmssp_state);
return;
}
if (spnego.negTokenTarg.negResult == SPNEGO_ACCEPT_COMPLETED) {
x_fprintf(x_stdout, "AF\n");
- ntlmssp_end(&client_ntlmssp_state);
+ TALLOC_FREE(client_ntlmssp_state);
return;
}
@@ -1549,7 +1549,7 @@ static void manage_client_ntlmssp_targ(struct spnego_data spnego)
x_fprintf(x_stdout, "BH Expected MORE_PROCESSING_REQUIRED from "
"ntlmssp_client_update\n");
data_blob_free(&request);
- ntlmssp_end(&client_ntlmssp_state);
+ TALLOC_FREE(client_ntlmssp_state);
return;
}
@@ -1798,7 +1798,7 @@ static void manage_gss_spnego_client_request(struct ntlm_auth_state *state,
"negResult\n");
}
- ntlmssp_end(&client_ntlmssp_state);
+ TALLOC_FREE(client_ntlmssp_state);
goto out;
}
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 7e1eb3e714..9efa8ed984 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -1291,8 +1291,8 @@ int main(int argc, char **argv, char **envp)
winbindd_register_handlers();
- rpc_lsarpc_init();
- rpc_samr_init();
+ rpc_lsarpc_init(NULL);
+ rpc_samr_init(NULL);
if (!init_system_info()) {
DEBUG(0,("ERROR: failed to setup system user info.\n"));
diff --git a/source3/winbindd/winbindd_ccache_access.c b/source3/winbindd/winbindd_ccache_access.c
index c5a760af05..6a265ccaf0 100644
--- a/source3/winbindd/winbindd_ccache_access.c
+++ b/source3/winbindd/winbindd_ccache_access.c
@@ -136,7 +136,7 @@ static NTSTATUS do_ntlm_auth_with_hashes(const char *username,
status = NT_STATUS_OK;
done:
- ntlmssp_end(&ntlmssp_state);
+ TALLOC_FREE(ntlmssp_state);
return status;
}
diff --git a/source3/wscript b/source3/wscript
index 0b31563343..66bddcf858 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -321,12 +321,20 @@ utimensat vsyslog _write __write __xstat
conf.env[shared_env] = []
if p in static_list:
decl_list=""
- for entry in static_list[p]:
- decl_list += "extern NTSTATUS %s_init(void); " % entry
- conf.env[static_env].append('%s' % entry.upper())
- decl_list = decl_list.rstrip()
- conf.DEFINE('static_decl_%s' % p, decl_list)
- conf.DEFINE('static_init_%s' % p, '{ %s_init(); }' % '_init(); '.join(static_list[p]))
+ if p == "rpc":
+ for entry in static_list[p]:
+ decl_list += "extern NTSTATUS %s_init(const struct rpc_srv_callbacks *rpc_srv_cb); " % entry
+ conf.env[static_env].append('%s' % entry.upper())
+ decl_list = decl_list.rstrip()
+ conf.DEFINE('static_decl_%s' % p, decl_list)
+ conf.DEFINE('static_init_%s' % p, '{ %s_init(NULL); }' % '_init(NULL); '.join(static_list[p]))
+ else:
+ for entry in static_list[p]:
+ decl_list += "extern NTSTATUS %s_init(void); " % entry
+ conf.env[static_env].append('%s' % entry.upper())
+ decl_list = decl_list.rstrip()
+ conf.DEFINE('static_decl_%s' % p, decl_list)
+ conf.DEFINE('static_init_%s' % p, '{ %s_init(); }' % '_init(); '.join(static_list[p]))
else:
conf.DEFINE('static_decl_%s' % p, '')
conf.DEFINE('static_init_%s' % p, '{}')