summaryrefslogtreecommitdiff
path: root/source3/rpc_client/cli_pipe.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-01-29 22:54:55 +0100
committerVolker Lendecke <vl@samba.org>2009-01-30 12:48:00 +0100
commit22e3004829fe742efdbf750611749b9aaf585515 (patch)
treed35089002df57ce272d99d6a7c68f6f4ed8da166 /source3/rpc_client/cli_pipe.c
parentb873ede89d3155438f7f9938d9a027cb4e3791e7 (diff)
downloadsamba-22e3004829fe742efdbf750611749b9aaf585515.tar.gz
samba-22e3004829fe742efdbf750611749b9aaf585515.tar.bz2
samba-22e3004829fe742efdbf750611749b9aaf585515.zip
Add the "SMBD" rpc transport
The idea of this is that all client utils like smbpasswd and also for example "net join" do not access our internal databases like passdb and secrets.tdb directly anymore but pass everything throught the well-established RPC interfaces. The way you use this is the following: With rpc_cli_smbd_conn_init() or its async variant you initialize a "struct rpc_cli_smbd_conn". This structure is the link to a freshly forked smbd, ready to be used for RPC services. You should only ever have one such structure in your program. More don't hurt, but are plainly unnecessary. If you want to use the SAMR pipe to change a passwort, you connect to that pipe with rpc_pipe_open_local. Do you normal rpccli_samr calls on that and your locally forked smbd will connect to passdb for you. GD, this might make the distinction between the _l and _r calls in libnetapi mostly unnecessary. At least it is intended to do so... :-)
Diffstat (limited to 'source3/rpc_client/cli_pipe.c')
-rw-r--r--source3/rpc_client/cli_pipe.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index 5a53c0d940..83247df46b 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -3511,6 +3511,61 @@ static NTSTATUS rpc_pipe_open_np(struct cli_state *cli,
return NT_STATUS_OK;
}
+NTSTATUS rpc_pipe_open_local(TALLOC_CTX *mem_ctx,
+ struct rpc_cli_smbd_conn *conn,
+ const struct ndr_syntax_id *syntax,
+ struct rpc_pipe_client **presult)
+{
+ struct rpc_pipe_client *result;
+ struct cli_pipe_auth_data *auth;
+ NTSTATUS status;
+
+ result = talloc(mem_ctx, struct rpc_pipe_client);
+ if (result == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ result->abstract_syntax = *syntax;
+ result->transfer_syntax = ndr_transfer_syntax;
+ result->dispatch = cli_do_rpc_ndr;
+ result->max_xmit_frag = RPC_MAX_PDU_FRAG_LEN;
+ result->max_recv_frag = RPC_MAX_PDU_FRAG_LEN;
+
+ result->desthost = talloc_strdup(result, global_myname());
+ result->srv_name_slash = talloc_asprintf_strupper_m(
+ result, "\\\\%s", global_myname());
+ if ((result->desthost == NULL) || (result->srv_name_slash == NULL)) {
+ TALLOC_FREE(result);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = rpc_transport_smbd_init(result, conn, syntax,
+ &result->transport);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("rpc_transport_smbd_init failed: %s\n",
+ nt_errstr(status)));
+ TALLOC_FREE(result);
+ return status;
+ }
+
+ status = rpccli_anon_bind_data(result, &auth);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("rpccli_anon_bind_data failed: %s\n",
+ nt_errstr(status)));
+ TALLOC_FREE(result);
+ return status;
+ }
+
+ status = rpc_pipe_bind(result, auth);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("rpc_pipe_bind failed: %s\n", nt_errstr(status)));
+ TALLOC_FREE(result);
+ return status;
+ }
+
+ *presult = result;
+ return NT_STATUS_OK;
+}
+
/****************************************************************************
Open a pipe to a remote server.
****************************************************************************/