From 4b5e252354660501576c8452f48514852f40270e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 16 Aug 2010 11:01:26 +0200 Subject: s3: Add "client_id" to pipes_struct --- source3/include/ntdomain.h | 2 +- source3/include/proto.h | 4 +++- source3/printing/nt_printing_migrate.c | 1 + source3/rpc_server/rpc_ncacn_np_internal.c | 15 ++++++++++++--- source3/rpc_server/srv_netlog_nt.c | 5 +++-- source3/rpc_server/srv_pipe_hnd.c | 17 +++-------------- source3/rpc_server/srv_spoolss_nt.c | 8 ++++---- source3/rpc_server/srv_spoolss_util.c | 1 + source3/smbd/lanman.c | 14 +++++++++++--- source3/smbd/pipes.c | 1 + source3/winbindd/winbindd_samr.c | 2 ++ 11 files changed, 42 insertions(+), 28 deletions(-) diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h index 071e915561..073efe54b9 100644 --- a/source3/include/ntdomain.h +++ b/source3/include/ntdomain.h @@ -131,7 +131,7 @@ struct pipe_auth_data { struct pipes_struct { struct pipes_struct *next, *prev; - char client_address[INET6_ADDRSTRLEN]; + struct client_address *client_id; struct auth_serversupplied_info *server_info; struct messaging_context *msg_ctx; diff --git a/source3/include/proto.h b/source3/include/proto.h index 9d4b82b063..5c664ebe54 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -4535,12 +4535,13 @@ NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path, struct rpc_pipe_client **presult); struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax, - const char *client_address, + struct client_address *client_id, struct auth_serversupplied_info *server_info, struct messaging_context *msg_ctx); NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *abstract_syntax, struct auth_serversupplied_info *serversupplied_info, + struct client_address *client_id, struct messaging_context *msg_ctx, struct rpc_pipe_client **presult); NTSTATUS rpc_connect_spoolss_pipe(connection_struct *conn, @@ -4752,6 +4753,7 @@ struct tsocket_address; 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 *server_info, struct messaging_context *msg_ctx, struct fake_file_handle **phandle); diff --git a/source3/printing/nt_printing_migrate.c b/source3/printing/nt_printing_migrate.c index 7b37926486..362eb90fa5 100644 --- a/source3/printing/nt_printing_migrate.c +++ b/source3/printing/nt_printing_migrate.c @@ -613,6 +613,7 @@ bool nt_printing_tdb_migrate(struct messaging_context *msg_ctx) status = rpc_pipe_open_internal(tmp_ctx, &ndr_table_spoolss.syntax_id, server_info, + NULL, msg_ctx, &spoolss_pipe); if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/rpc_server/rpc_ncacn_np_internal.c b/source3/rpc_server/rpc_ncacn_np_internal.c index 71a14be845..bbb6338260 100644 --- a/source3/rpc_server/rpc_ncacn_np_internal.c +++ b/source3/rpc_server/rpc_ncacn_np_internal.c @@ -114,7 +114,7 @@ static 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, - const char *client_address, + struct client_address *client_id, struct auth_serversupplied_info *server_info, struct messaging_context *msg_ctx) { @@ -157,7 +157,7 @@ struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, DLIST_ADD(InternalPipes, p); - strlcpy(p->client_address, client_address, sizeof(p->client_address)); + p->client_id = client_id; p->endian = RPC_LITTLE_ENDIAN; @@ -469,6 +469,7 @@ static struct dcerpc_binding_handle *rpcint_binding_handle(struct pipes_struct * NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *abstract_syntax, struct auth_serversupplied_info *serversupplied_info, + struct client_address *client_id, struct messaging_context *msg_ctx, struct rpc_pipe_client **presult) { @@ -482,8 +483,16 @@ 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, "", sizeof(unknown.addr)); + unknown.name = ""; + client_id = &unknown; + } + result->pipes_struct = make_internal_rpc_pipe_p( - result, abstract_syntax, "", serversupplied_info, msg_ctx); + result, abstract_syntax, client_id, serversupplied_info, + msg_ctx); if (result->pipes_struct == NULL) { TALLOC_FREE(result); return NT_STATUS_NO_MEMORY; diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 4433a707ad..1b0544ff50 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -406,6 +406,7 @@ NTSTATUS _netr_NetrEnumerateTrustedDomains(struct pipes_struct *p, status = rpc_pipe_open_internal(p->mem_ctx, &ndr_table_lsarpc.syntax_id, p->server_info, + p->client_id, p->msg_ctx, &cli); if (!NT_STATUS_IS_OK(status)) { @@ -631,7 +632,7 @@ static NTSTATUS get_md4pw(struct samr_Password *md4pw, const char *mach_acct, ZERO_STRUCT(user_handle); status = rpc_pipe_open_internal(mem_ctx, &ndr_table_samr.syntax_id, - server_info, msg_ctx, + server_info, NULL, msg_ctx, &cli); if (!NT_STATUS_IS_OK(status)) { goto out; @@ -1035,7 +1036,7 @@ static NTSTATUS netr_set_machine_account_password(TALLOC_CTX *mem_ctx, ZERO_STRUCT(user_handle); status = rpc_pipe_open_internal(mem_ctx, &ndr_table_samr.syntax_id, - server_info, msg_ctx, + server_info, NULL, msg_ctx, &cli); if (!NT_STATUS_IS_OK(status)) { goto out; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 37efe061c3..4c6e65173e 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -537,6 +537,7 @@ static struct np_proxy_state *make_external_rpc_pipe_p(TALLOC_CTX *mem_ctx, 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 *server_info, struct messaging_context *msg_ctx, struct fake_file_handle **phandle) @@ -564,26 +565,13 @@ NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name, } else { struct pipes_struct *p; struct ndr_syntax_id syntax; - const char *client_address; if (!is_known_pipename(name, &syntax)) { TALLOC_FREE(handle); return NT_STATUS_OBJECT_NAME_NOT_FOUND; } - if (tsocket_address_is_inet(remote_address, "ip")) { - client_address = tsocket_address_inet_addr_string( - remote_address, - talloc_tos()); - if (client_address == NULL) { - TALLOC_FREE(handle); - return NT_STATUS_NO_MEMORY; - } - } else { - client_address = ""; - } - - p = make_internal_rpc_pipe_p(handle, &syntax, client_address, + p = make_internal_rpc_pipe_p(handle, &syntax, client_id, server_info, msg_ctx); handle->type = FAKE_FILE_TYPE_NAMED_PIPE; @@ -930,6 +918,7 @@ NTSTATUS rpc_connect_spoolss_pipe(connection_struct *conn, status = rpc_pipe_open_internal(conn, &ndr_table_spoolss.syntax_id, conn->server_info, + &conn->sconn->client_id, conn->sconn->msg_ctx, &conn->spoolss_pipe); if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4854488ba6..cdb03ff897 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2451,9 +2451,9 @@ WERROR _spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct pipes_struct *p, return WERR_BADFID; DEBUG(10,("_spoolss_RemoteFindFirstPrinterChangeNotifyEx: " - "client_address is %s\n", p->client_address)); + "client_address is %s\n", p->client_id->addr)); - if (!interpret_string_addr(&client_ss, p->client_address, + if (!interpret_string_addr(&client_ss, p->client_id->addr, AI_NUMERICHOST)) { return WERR_SERVER_UNAVAILABLE; } @@ -6111,7 +6111,7 @@ static WERROR update_printer(struct pipes_struct *p, { /* add_printer_hook() will call reload_services() */ if (!add_printer_hook(tmp_ctx, p->server_info->ptok, - printer, p->client_address, + printer, p->client_id->addr, p->msg_ctx)) { result = WERR_ACCESS_DENIED; goto done; @@ -7420,7 +7420,7 @@ static WERROR spoolss_addprinterex_level_2(struct pipes_struct *p, if (*lp_addprinter_cmd() ) { if ( !add_printer_hook(p->mem_ctx, p->server_info->ptok, - info2, p->client_address, + info2, p->client_id->addr, p->msg_ctx) ) { return WERR_ACCESS_DENIED; } diff --git a/source3/rpc_server/srv_spoolss_util.c b/source3/rpc_server/srv_spoolss_util.c index 2de45b70a6..5fbdc0b406 100644 --- a/source3/rpc_server/srv_spoolss_util.c +++ b/source3/rpc_server/srv_spoolss_util.c @@ -262,6 +262,7 @@ static WERROR winreg_printer_openkey(TALLOC_CTX *mem_ctx, status = rpc_pipe_open_internal(mem_ctx, &ndr_table_winreg.syntax_id, server_info, + NULL, msg_ctx, &pipe_handle); if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index 2be2a8c4ac..493a8ec3c6 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -2236,6 +2236,7 @@ static bool api_RNetShareAdd(struct smbd_server_connection *sconn, status = rpc_pipe_open_internal(mem_ctx, &ndr_table_srvsvc.syntax_id, conn->server_info, + &conn->sconn->client_id, conn->sconn->msg_ctx, &cli); if (!NT_STATUS_IS_OK(status)) { @@ -2343,7 +2344,8 @@ static bool api_RNetGroupEnum(struct smbd_server_connection *sconn, status = rpc_pipe_open_internal( talloc_tos(), &ndr_table_samr.syntax_id, - conn->server_info, conn->sconn->msg_ctx, &samr_pipe); + conn->server_info, &conn->sconn->client_id, + conn->sconn->msg_ctx, &samr_pipe); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("api_RNetUserEnum: Could not connect to samr: %s\n", nt_errstr(status))); @@ -2525,7 +2527,8 @@ static bool api_NetUserGetGroups(struct smbd_server_connection *sconn, status = rpc_pipe_open_internal( talloc_tos(), &ndr_table_samr.syntax_id, - conn->server_info, conn->sconn->msg_ctx, &samr_pipe); + conn->server_info, &conn->sconn->client_id, + conn->sconn->msg_ctx, &samr_pipe); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("api_RNetUserEnum: Could not connect to samr: %s\n", nt_errstr(status))); @@ -2681,7 +2684,8 @@ static bool api_RNetUserEnum(struct smbd_server_connection *sconn, status = rpc_pipe_open_internal( talloc_tos(), &ndr_table_samr.syntax_id, - conn->server_info, conn->sconn->msg_ctx, &samr_pipe); + conn->server_info, &conn->sconn->client_id, + conn->sconn->msg_ctx, &samr_pipe); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("api_RNetUserEnum: Could not connect to samr: %s\n", nt_errstr(status))); @@ -2924,6 +2928,7 @@ static bool api_SetUserPassword(struct smbd_server_connection *sconn, status = rpc_pipe_open_internal(mem_ctx, &ndr_table_samr.syntax_id, conn->server_info, + &conn->sconn->client_id, conn->sconn->msg_ctx, &cli); if (!NT_STATUS_IS_OK(status)) { @@ -3141,6 +3146,7 @@ static bool api_SamOEMChangePassword(struct smbd_server_connection *sconn, status = rpc_pipe_open_internal(mem_ctx, &ndr_table_samr.syntax_id, conn->server_info, + &conn->sconn->client_id, conn->sconn->msg_ctx, &cli); if (!NT_STATUS_IS_OK(status)) { @@ -3695,6 +3701,7 @@ static bool api_RNetServerGetInfo(struct smbd_server_connection *sconn, status = rpc_pipe_open_internal(mem_ctx, &ndr_table_srvsvc.syntax_id, conn->server_info, + &conn->sconn->client_id, conn->sconn->msg_ctx, &cli); if (!NT_STATUS_IS_OK(status)) { @@ -4118,6 +4125,7 @@ static bool api_RNetUserGetInfo(struct smbd_server_connection *sconn, status = rpc_pipe_open_internal(mem_ctx, &ndr_table_samr.syntax_id, conn->server_info, + &conn->sconn->client_id, conn->sconn->msg_ctx, &cli); if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c index 97f1c709cd..8bdd8b22e3 100644 --- a/source3/smbd/pipes.c +++ b/source3/smbd/pipes.c @@ -69,6 +69,7 @@ NTSTATUS open_np_file(struct smb_request *smb_req, const char *name, status = np_open(fsp, name, conn->sconn->local_address, conn->sconn->remote_address, + &conn->sconn->client_id, conn->server_info, conn->sconn->msg_ctx, &fsp->fake_file_handle); diff --git a/source3/winbindd/winbindd_samr.c b/source3/winbindd/winbindd_samr.c index 05ba7a7260..f4d84fb132 100644 --- a/source3/winbindd/winbindd_samr.c +++ b/source3/winbindd/winbindd_samr.c @@ -61,6 +61,7 @@ static NTSTATUS open_internal_samr_pipe(TALLOC_CTX *mem_ctx, status = rpc_pipe_open_internal(mem_ctx, &ndr_table_samr.syntax_id, server_info, + NULL, winbind_messaging_context(), &cli); if (!NT_STATUS_IS_OK(status)) { @@ -133,6 +134,7 @@ static NTSTATUS open_internal_lsa_pipe(TALLOC_CTX *mem_ctx, status = rpc_pipe_open_internal(mem_ctx, &ndr_table_lsarpc.syntax_id, server_info, + NULL, winbind_messaging_context(), &cli); if (!NT_STATUS_IS_OK(status)) { -- cgit