diff options
Diffstat (limited to 'source3/rpc_server')
-rw-r--r-- | source3/rpc_server/netlogon/srv_netlog_nt.c | 36 | ||||
-rw-r--r-- | source3/rpc_server/rpc_ncacn_np.c | 70 | ||||
-rw-r--r-- | source3/rpc_server/rpc_ncacn_np.h | 6 | ||||
-rw-r--r-- | source3/rpc_server/rpc_server.c | 1 | ||||
-rw-r--r-- | source3/rpc_server/spoolss/srv_spoolss_util.c | 16 | ||||
-rw-r--r-- | source3/rpc_server/srv_pipe_hnd.c | 3 | ||||
-rw-r--r-- | source3/rpc_server/srv_pipe_hnd.h | 1 |
7 files changed, 93 insertions, 40 deletions
diff --git a/source3/rpc_server/netlogon/srv_netlog_nt.c b/source3/rpc_server/netlogon/srv_netlog_nt.c index 03897d77a4..e52dd85352 100644 --- a/source3/rpc_server/netlogon/srv_netlog_nt.c +++ b/source3/rpc_server/netlogon/srv_netlog_nt.c @@ -44,6 +44,7 @@ #include "passdb.h" #include "auth.h" #include "messages.h" +#include "../lib/tsocket/tsocket.h" extern userdom_struct current_user_info; @@ -417,7 +418,7 @@ NTSTATUS _netr_NetrEnumerateTrustedDomains(struct pipes_struct *p, status = rpcint_binding_handle(p->mem_ctx, &ndr_table_lsarpc, - p->client_id, + p->remote_address, p->session_info, p->msg_ctx, &h); @@ -643,13 +644,15 @@ static NTSTATUS get_md4pw(struct samr_Password *md4pw, const char *mach_acct, NTSTATUS result = NT_STATUS_OK; TALLOC_CTX *mem_ctx; struct dcerpc_binding_handle *h = NULL; - static struct client_address client_id; + struct tsocket_address *local; struct policy_handle user_handle; uint32_t user_rid; struct dom_sid *domain_sid; uint32_t acct_ctrl; union samr_UserInfo *info; struct auth_serversupplied_info *session_info; + int rc; + #if 0 /* @@ -682,12 +685,19 @@ static NTSTATUS get_md4pw(struct samr_Password *md4pw, const char *mach_acct, ZERO_STRUCT(user_handle); - strlcpy(client_id.addr, "127.0.0.1", sizeof(client_id.addr)); - client_id.name = "127.0.0.1"; + rc = tsocket_address_inet_from_strings(mem_ctx, + "ip", + "127.0.0.1", + 0, + &local); + if (rc < 0) { + status = NT_STATUS_NO_MEMORY; + goto out; + } status = rpcint_binding_handle(mem_ctx, &ndr_table_samr, - &client_id, + local, session_info, msg_ctx, &h); @@ -1098,21 +1108,29 @@ static NTSTATUS netr_set_machine_account_password(TALLOC_CTX *mem_ctx, NTSTATUS status; NTSTATUS result = NT_STATUS_OK; struct dcerpc_binding_handle *h = NULL; - static struct client_address client_id; + struct tsocket_address *local; struct policy_handle user_handle; uint32_t acct_ctrl; union samr_UserInfo *info; struct samr_UserInfo18 info18; DATA_BLOB in,out; + int rc; ZERO_STRUCT(user_handle); - strlcpy(client_id.addr, "127.0.0.1", sizeof(client_id.addr)); - client_id.name = "127.0.0.1"; + rc = tsocket_address_inet_from_strings(mem_ctx, + "ip", + "127.0.0.1", + 0, + &local); + if (rc < 0) { + status = NT_STATUS_NO_MEMORY; + goto out; + } status = rpcint_binding_handle(mem_ctx, &ndr_table_samr, - &client_id, + local, session_info, msg_ctx, &h); diff --git a/source3/rpc_server/rpc_ncacn_np.c b/source3/rpc_server/rpc_ncacn_np.c index f14aae540d..9bbc5dfddb 100644 --- a/source3/rpc_server/rpc_ncacn_np.c +++ b/source3/rpc_server/rpc_ncacn_np.c @@ -121,7 +121,7 @@ int close_internal_rpc_pipe_hnd(struct pipes_struct *p) struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax, - struct client_address *client_id, + const struct tsocket_address *remote_address, const struct auth_serversupplied_info *session_info, struct messaging_context *msg_ctx) { @@ -165,7 +165,27 @@ struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, DLIST_ADD(InternalPipes, p); - p->client_id = client_id; + p->remote_address = tsocket_address_copy(remote_address, p); + if (p->remote_address == NULL) { + return false; + } + + p->client_id = talloc_zero(p, struct client_address); + if (p->client_id == NULL) { + return false; + } + + if (tsocket_address_is_inet(p->remote_address, "ip")) { + p->client_id->name = tsocket_address_inet_addr_string(p->remote_address, + p->client_id); + } else { + p->client_id->name = talloc_strdup(p->client_id, ""); + } + if (p->client_id->name == NULL) { + return false; + } + strlcpy(p->client_id->addr, + p->client_id->name, sizeof(p->client_id->addr)); p->endian = RPC_LITTLE_ENDIAN; @@ -451,7 +471,7 @@ static const struct dcerpc_binding_handle_ops rpcint_bh_ops = { static NTSTATUS rpcint_binding_handle_ex(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *abstract_syntax, const struct ndr_interface_table *ndr_table, - struct client_address *client_id, + const struct tsocket_address *remote_address, const struct auth_serversupplied_info *session_info, struct messaging_context *msg_ctx, struct dcerpc_binding_handle **binding_handle) @@ -475,7 +495,7 @@ static NTSTATUS rpcint_binding_handle_ex(TALLOC_CTX *mem_ctx, } hs->p = make_internal_rpc_pipe_p(hs, abstract_syntax, - client_id, + remote_address, session_info, msg_ctx); if (hs->p == NULL) { @@ -493,7 +513,7 @@ static NTSTATUS rpcint_binding_handle_ex(TALLOC_CTX *mem_ctx, * * @param[in] ndr_table Normally the ndr_table_<name>. * - * @param[in] client_id The info about the connected client. + * @param[in] remote_address The info about the connected client. * * @param[in] serversupplied_info The server supplied authentication function. * @@ -511,7 +531,7 @@ static NTSTATUS rpcint_binding_handle_ex(TALLOC_CTX *mem_ctx, * * status = rpcint_binding_handle(tmp_ctx, * &ndr_table_winreg, - * p->client_id, + * p->remote_address, * p->session_info, * p->msg_ctx * &winreg_binding); @@ -519,12 +539,12 @@ static NTSTATUS rpcint_binding_handle_ex(TALLOC_CTX *mem_ctx, */ NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx, const struct ndr_interface_table *ndr_table, - struct client_address *client_id, + const struct tsocket_address *remote_address, const struct auth_serversupplied_info *session_info, struct messaging_context *msg_ctx, struct dcerpc_binding_handle **binding_handle) { - return rpcint_binding_handle_ex(mem_ctx, NULL, ndr_table, client_id, + return rpcint_binding_handle_ex(mem_ctx, NULL, ndr_table, remote_address, session_info, msg_ctx, binding_handle); } @@ -544,7 +564,7 @@ NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx, * * @param[in] serversupplied_info The server supplied authentication function. * - * @param[in] client_id The client address information. + * @param[in] remote_address The client address information. * * @param[in] msg_ctx The messaging context to use. * @@ -556,7 +576,7 @@ NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx, static NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *abstract_syntax, const struct auth_serversupplied_info *serversupplied_info, - struct client_address *client_id, + const struct tsocket_address *remote_address, struct messaging_context *msg_ctx, struct rpc_pipe_client **presult) { @@ -571,11 +591,21 @@ static NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx, result->abstract_syntax = *abstract_syntax; result->transfer_syntax = ndr_transfer_syntax; - if (client_id == NULL) { - static struct client_address unknown; - strlcpy(unknown.addr, "<UNKNOWN>", sizeof(unknown.addr)); - unknown.name = "<UNKNOWN>"; - client_id = &unknown; + if (remote_address == NULL) { + struct tsocket_address *local; + int rc; + + rc = tsocket_address_inet_from_strings(mem_ctx, + "ip", + "127.0.0.1", + 0, + &local); + if (rc < 0) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + remote_address = local; } result->max_xmit_frag = -1; @@ -584,7 +614,7 @@ static NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx, status = rpcint_binding_handle_ex(result, abstract_syntax, NULL, - client_id, + remote_address, serversupplied_info, msg_ctx, &result->binding_handle); @@ -849,7 +879,7 @@ done: * * @param[in] serversupplied_info The server supplied authentication function. * - * @param[in] client_id The client address information. + * @param[in] remote_address The client address information. * * @param[in] msg_ctx The messaging context to use. * @@ -865,7 +895,7 @@ done: * status = rpc_pipe_open_interface(tmp_ctx, * &ndr_table_winreg.syntax_id, * p->session_info, - * client_id, + * remote_address, * &winreg_pipe); * @endcode */ @@ -873,7 +903,7 @@ done: NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax, const struct auth_serversupplied_info *session_info, - struct client_address *client_id, + const struct tsocket_address *remote_address, struct messaging_context *msg_ctx, struct rpc_pipe_client **cli_pipe) { @@ -913,7 +943,7 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx, if (strcasecmp_m(server_type, "embedded") == 0) { status = rpc_pipe_open_internal(tmp_ctx, syntax, session_info, - client_id, msg_ctx, + remote_address, msg_ctx, &cli); if (!NT_STATUS_IS_OK(status)) { goto done; diff --git a/source3/rpc_server/rpc_ncacn_np.h b/source3/rpc_server/rpc_ncacn_np.h index 3d9a170cdc..8d3a21e414 100644 --- a/source3/rpc_server/rpc_ncacn_np.h +++ b/source3/rpc_server/rpc_ncacn_np.h @@ -35,7 +35,7 @@ struct np_proxy_state { struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax, - struct client_address *client_id, + const struct tsocket_address *remote_address, const struct auth_serversupplied_info *session_info, struct messaging_context *msg_ctx); struct np_proxy_state *make_external_rpc_pipe_p(TALLOC_CTX *mem_ctx, @@ -45,14 +45,14 @@ struct np_proxy_state *make_external_rpc_pipe_p(TALLOC_CTX *mem_ctx, const struct auth_serversupplied_info *session_info); NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx, const struct ndr_interface_table *ndr_table, - struct client_address *client_id, + const struct tsocket_address *remote_address, const struct auth_serversupplied_info *session_info, struct messaging_context *msg_ctx, struct dcerpc_binding_handle **binding_handle); NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax, const struct auth_serversupplied_info *session_info, - struct client_address *client_id, + const struct tsocket_address *remote_address, struct messaging_context *msg_ctx, struct rpc_pipe_client **cli_pipe); diff --git a/source3/rpc_server/rpc_server.c b/source3/rpc_server/rpc_server.c index 3b86f0092e..6852f2e662 100644 --- a/source3/rpc_server/rpc_server.c +++ b/source3/rpc_server/rpc_server.c @@ -194,7 +194,6 @@ static int make_server_pipes_struct(TALLOC_CTX *mem_ctx, } strlcpy(p->client_id->addr, p->client_id->name, sizeof(p->client_id->addr)); - p->client_id->name = talloc_strdup(p->client_id, p->client_id->name); if (local_address != NULL) { p->local_address = tsocket_address_copy(local_address, p); diff --git a/source3/rpc_server/spoolss/srv_spoolss_util.c b/source3/rpc_server/spoolss/srv_spoolss_util.c index 5201571a37..acf2b40397 100644 --- a/source3/rpc_server/spoolss/srv_spoolss_util.c +++ b/source3/rpc_server/spoolss/srv_spoolss_util.c @@ -30,6 +30,7 @@ #include "../libcli/security/security.h" #include "rpc_client/cli_winreg.h" #include "../libcli/registry/util_reg.h" +#include "../lib/tsocket/tsocket.h" #define TOP_LEVEL_PRINT_KEY "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print" #define TOP_LEVEL_PRINT_PRINTERS_KEY TOP_LEVEL_PRINT_KEY "\\Printers" @@ -255,19 +256,26 @@ static WERROR winreg_printer_openkey(TALLOC_CTX *mem_ctx, struct policy_handle *hive_handle, struct policy_handle *key_handle) { - static struct client_address client_id; + struct tsocket_address *local; struct dcerpc_binding_handle *binding_handle; struct winreg_String wkey, wkeyclass; char *keyname; NTSTATUS status; WERROR result = WERR_OK; + int rc; - strlcpy(client_id.addr, "127.0.0.1", sizeof(client_id.addr)); - client_id.name = "127.0.0.1"; + rc = tsocket_address_inet_from_strings(mem_ctx, + "ip", + "127.0.0.1", + 0, + &local); + if (rc < 0) { + return WERR_NOMEM; + } status = rpcint_binding_handle(mem_ctx, &ndr_table_winreg, - &client_id, + local, session_info, msg_ctx, &binding_handle); diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 501bb1efc7..b6ee6a89dd 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -411,7 +411,6 @@ bool fsp_is_np(struct files_struct *fsp) NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name, const struct tsocket_address *local_address, const struct tsocket_address *remote_address, - struct client_address *client_id, struct auth_serversupplied_info *session_info, struct messaging_context *msg_ctx, struct fake_file_handle **phandle) @@ -461,7 +460,7 @@ NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name, return NT_STATUS_OBJECT_NAME_NOT_FOUND; } - p = make_internal_rpc_pipe_p(handle, &syntax, client_id, + p = make_internal_rpc_pipe_p(handle, &syntax, remote_address, session_info, msg_ctx); handle->type = FAKE_FILE_TYPE_NAMED_PIPE; diff --git a/source3/rpc_server/srv_pipe_hnd.h b/source3/rpc_server/srv_pipe_hnd.h index 680add469b..13c70cf513 100644 --- a/source3/rpc_server/srv_pipe_hnd.h +++ b/source3/rpc_server/srv_pipe_hnd.h @@ -31,7 +31,6 @@ bool fsp_is_np(struct files_struct *fsp); NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name, const struct tsocket_address *local_address, const struct tsocket_address *remote_address, - struct client_address *client_id, struct auth_serversupplied_info *session_info, struct messaging_context *msg_ctx, struct fake_file_handle **phandle); |