summaryrefslogtreecommitdiff
path: root/source/rpc_client
diff options
context:
space:
mode:
Diffstat (limited to 'source/rpc_client')
-rw-r--r--source/rpc_client/cli_dfs.c632
-rw-r--r--source/rpc_client/cli_echo.c143
-rw-r--r--source/rpc_client/cli_lsarpc.c267
-rw-r--r--source/rpc_client/cli_netlogon.c133
-rw-r--r--source/rpc_client/cli_pipe.c42
-rw-r--r--source/rpc_client/cli_reg.c709
-rw-r--r--source/rpc_client/cli_samr.c297
-rw-r--r--source/rpc_client/cli_shutdown.c119
-rw-r--r--source/rpc_client/cli_srvsvc.c617
-rw-r--r--source/rpc_client/cli_svcctl.c24
10 files changed, 2371 insertions, 612 deletions
diff --git a/source/rpc_client/cli_dfs.c b/source/rpc_client/cli_dfs.c
new file mode 100644
index 00000000000..f93ce29dbfa
--- /dev/null
+++ b/source/rpc_client/cli_dfs.c
@@ -0,0 +1,632 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * client auto-generated by pidl. DO NOT MODIFY!
+ */
+
+#include "includes.h"
+
+NTSTATUS rpccli_dfs_GetManagerVersion(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint32 *exist_flag)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_GETMANAGERVERSION q;
+ NETDFS_R_DFS_GETMANAGERVERSION r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_GetManagerVersion(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_GETMANAGERVERSION,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_GetManagerVersion,
+ netdfs_io_r_dfs_GetManagerVersion,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+ *exist_flag = r.exist_flag;
+
+ /* Return result */
+ return NT_STATUS_OK;
+}
+
+NTSTATUS rpccli_dfs_Add(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *path, const char *server, const char *share, const char *comment, uint32 flags)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_ADD q;
+ NETDFS_R_DFS_ADD r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_Add(&q, path, server, share, comment, flags))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_ADD,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_Add,
+ netdfs_io_r_dfs_Add,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_Remove(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *path, const char *server, const char *share)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_REMOVE q;
+ NETDFS_R_DFS_REMOVE r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_Remove(&q, path, server, share))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_REMOVE,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_Remove,
+ netdfs_io_r_dfs_Remove,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_SetInfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_SETINFO q;
+ NETDFS_R_DFS_SETINFO r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_SetInfo(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_SETINFO,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_SetInfo,
+ netdfs_io_r_dfs_SetInfo,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_GetInfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *path, const char *server, const char *share, uint32 level, NETDFS_DFS_INFO_CTR *info)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_GETINFO q;
+ NETDFS_R_DFS_GETINFO r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_GetInfo(&q, path, server, share, level))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_GETINFO,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_GetInfo,
+ netdfs_io_r_dfs_GetInfo,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+ *info = r.info;
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_Enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint32 level, uint32 bufsize, NETDFS_DFS_ENUMSTRUCT *info, uint32 *total)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_ENUM q;
+ NETDFS_R_DFS_ENUM r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_Enum(&q, level, bufsize, info, total))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_ENUM,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_Enum,
+ netdfs_io_r_dfs_Enum,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+ *info = r.info;
+ *total = r.total;
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_Rename(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_RENAME q;
+ NETDFS_R_DFS_RENAME r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_Rename(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_RENAME,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_Rename,
+ netdfs_io_r_dfs_Rename,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_Move(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_MOVE q;
+ NETDFS_R_DFS_MOVE r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_Move(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_MOVE,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_Move,
+ netdfs_io_r_dfs_Move,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_ManagerGetConfigInfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_MANAGERGETCONFIGINFO q;
+ NETDFS_R_DFS_MANAGERGETCONFIGINFO r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_ManagerGetConfigInfo(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_MANAGERGETCONFIGINFO,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_ManagerGetConfigInfo,
+ netdfs_io_r_dfs_ManagerGetConfigInfo,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_ManagerSendSiteInfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_MANAGERSENDSITEINFO q;
+ NETDFS_R_DFS_MANAGERSENDSITEINFO r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_ManagerSendSiteInfo(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_MANAGERSENDSITEINFO,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_ManagerSendSiteInfo,
+ netdfs_io_r_dfs_ManagerSendSiteInfo,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_AddFtRoot(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_ADDFTROOT q;
+ NETDFS_R_DFS_ADDFTROOT r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_AddFtRoot(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_ADDFTROOT,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_AddFtRoot,
+ netdfs_io_r_dfs_AddFtRoot,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_RemoveFtRoot(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_REMOVEFTROOT q;
+ NETDFS_R_DFS_REMOVEFTROOT r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_RemoveFtRoot(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_REMOVEFTROOT,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_RemoveFtRoot,
+ netdfs_io_r_dfs_RemoveFtRoot,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_AddStdRoot(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_ADDSTDROOT q;
+ NETDFS_R_DFS_ADDSTDROOT r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_AddStdRoot(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_ADDSTDROOT,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_AddStdRoot,
+ netdfs_io_r_dfs_AddStdRoot,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_RemoveStdRoot(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_REMOVESTDROOT q;
+ NETDFS_R_DFS_REMOVESTDROOT r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_RemoveStdRoot(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_REMOVESTDROOT,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_RemoveStdRoot,
+ netdfs_io_r_dfs_RemoveStdRoot,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_ManagerInitialize(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_MANAGERINITIALIZE q;
+ NETDFS_R_DFS_MANAGERINITIALIZE r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_ManagerInitialize(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_MANAGERINITIALIZE,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_ManagerInitialize,
+ netdfs_io_r_dfs_ManagerInitialize,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_AddStdRootForced(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_ADDSTDROOTFORCED q;
+ NETDFS_R_DFS_ADDSTDROOTFORCED r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_AddStdRootForced(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_ADDSTDROOTFORCED,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_AddStdRootForced,
+ netdfs_io_r_dfs_AddStdRootForced,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_GetDcAddress(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_GETDCADDRESS q;
+ NETDFS_R_DFS_GETDCADDRESS r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_GetDcAddress(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_GETDCADDRESS,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_GetDcAddress,
+ netdfs_io_r_dfs_GetDcAddress,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_SetDcAddress(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_SETDCADDRESS q;
+ NETDFS_R_DFS_SETDCADDRESS r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_SetDcAddress(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_SETDCADDRESS,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_SetDcAddress,
+ netdfs_io_r_dfs_SetDcAddress,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_FlushFtTable(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_FLUSHFTTABLE q;
+ NETDFS_R_DFS_FLUSHFTTABLE r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_FlushFtTable(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_FLUSHFTTABLE,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_FlushFtTable,
+ netdfs_io_r_dfs_FlushFtTable,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_Add2(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_ADD2 q;
+ NETDFS_R_DFS_ADD2 r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_Add2(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_ADD2,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_Add2,
+ netdfs_io_r_dfs_Add2,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_Remove2(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_REMOVE2 q;
+ NETDFS_R_DFS_REMOVE2 r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_Remove2(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_REMOVE2,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_Remove2,
+ netdfs_io_r_dfs_Remove2,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_EnumEx(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_ENUMEX q;
+ NETDFS_R_DFS_ENUMEX r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_EnumEx(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_ENUMEX,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_EnumEx,
+ netdfs_io_r_dfs_EnumEx,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
+NTSTATUS rpccli_dfs_SetInfo2(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct qbuf, rbuf;
+ NETDFS_Q_DFS_SETINFO2 q;
+ NETDFS_R_DFS_SETINFO2 r;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ if (!init_netdfs_q_dfs_SetInfo2(&q))
+ return NT_STATUS_INVALID_PARAMETER;
+
+ CLI_DO_RPC(cli, mem_ctx, PI_NETDFS, DFS_SETINFO2,
+ q, r,
+ qbuf, rbuf,
+ netdfs_io_q_dfs_SetInfo2,
+ netdfs_io_r_dfs_SetInfo2,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return variables */
+
+ /* Return result */
+ return werror_to_ntstatus(r.status);
+}
+
diff --git a/source/rpc_client/cli_echo.c b/source/rpc_client/cli_echo.c
new file mode 100644
index 00000000000..9818fad79b5
--- /dev/null
+++ b/source/rpc_client/cli_echo.c
@@ -0,0 +1,143 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ RPC pipe client
+
+ Copyright (C) Tim Potter 2003
+ Copyright (C) Jeremy Allison 2005.
+
+ 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"
+
+NTSTATUS rpccli_echo_add_one(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ uint32 request, uint32 *response)
+{
+ prs_struct qbuf, rbuf;
+ ECHO_Q_ADD_ONE q;
+ ECHO_R_ADD_ONE r;
+ BOOL result = False;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ init_echo_q_add_one(&q, request);
+
+ CLI_DO_RPC( cli, mem_ctx, PI_ECHO, ECHO_ADD_ONE,
+ q, r,
+ qbuf, rbuf,
+ echo_io_q_add_one,
+ echo_io_r_add_one,
+ NT_STATUS_UNSUCCESSFUL);
+
+ if (response)
+ *response = r.response;
+
+ result = True;
+
+ return result ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
+}
+
+NTSTATUS rpccli_echo_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ uint32 size, char *in_data, char **out_data)
+{
+ prs_struct qbuf, rbuf;
+ ECHO_Q_ECHO_DATA q;
+ ECHO_R_ECHO_DATA r;
+ BOOL result = False;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ init_echo_q_echo_data(&q, size, in_data);
+
+ CLI_DO_RPC( cli, mem_ctx, PI_ECHO, ECHO_DATA,
+ q, r,
+ qbuf, rbuf,
+ echo_io_q_echo_data,
+ echo_io_r_echo_data,
+ NT_STATUS_UNSUCCESSFUL);
+
+ result = True;
+
+ if (out_data) {
+ *out_data = TALLOC(mem_ctx, size);
+ if (!*out_data) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ memcpy(*out_data, r.data, size);
+ }
+
+ return result ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
+}
+
+NTSTATUS rpccli_echo_sink_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ uint32 size, char *in_data)
+{
+ prs_struct qbuf, rbuf;
+ ECHO_Q_SINK_DATA q;
+ ECHO_R_SINK_DATA r;
+ BOOL result = False;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ init_echo_q_sink_data(&q, size, in_data);
+
+ CLI_DO_RPC( cli, mem_ctx, PI_ECHO, ECHO_SINK_DATA,
+ q, r,
+ qbuf, rbuf,
+ echo_io_q_sink_data,
+ echo_io_r_sink_data,
+ NT_STATUS_UNSUCCESSFUL);
+
+ result = True;
+
+ return result ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
+}
+
+NTSTATUS rpccli_echo_source_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ uint32 size, char **out_data)
+{
+ prs_struct qbuf, rbuf;
+ ECHO_Q_SOURCE_DATA q;
+ ECHO_R_SOURCE_DATA r;
+ BOOL result = False;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ init_echo_q_source_data(&q, size);
+
+ CLI_DO_RPC( cli, mem_ctx, PI_ECHO, ECHO_SOURCE_DATA,
+ q, r,
+ qbuf, rbuf,
+ echo_io_q_source_data,
+ echo_io_r_source_data,
+ NT_STATUS_UNSUCCESSFUL);
+
+ result = True;
+
+ return result ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
+}
diff --git a/source/rpc_client/cli_lsarpc.c b/source/rpc_client/cli_lsarpc.c
index 00c65d15aaa..4dfce181430 100644
--- a/source/rpc_client/cli_lsarpc.c
+++ b/source/rpc_client/cli_lsarpc.c
@@ -78,6 +78,9 @@ NTSTATUS rpccli_lsa_open_policy(struct rpc_pipe_client *cli,
if (NT_STATUS_IS_OK(result)) {
*pol = r.pol;
+#ifdef __INSURE__
+ pol->marker = MALLOC(1);
+#endif
}
return result;
@@ -122,214 +125,47 @@ NTSTATUS rpccli_lsa_open_policy2(struct rpc_pipe_client *cli,
if (NT_STATUS_IS_OK(result)) {
*pol = r.pol;
+#ifdef __INSURE__
+ pol->marker = (char *)malloc(1);
+#endif
}
return result;
}
-/* Lookup a list of sids
- *
- * internal version withOUT memory allocation of the target arrays.
- * this assumes suffciently sized arrays to store domains, names and types. */
-
-static NTSTATUS rpccli_lsa_lookup_sids_noalloc(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *pol,
- int num_sids,
- const DOM_SID *sids,
- char **domains,
- char **names,
- enum lsa_SidType *types)
+/** Close a LSA policy handle */
+
+NTSTATUS rpccli_lsa_close(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *pol)
{
prs_struct qbuf, rbuf;
- LSA_Q_LOOKUP_SIDS q;
- LSA_R_LOOKUP_SIDS r;
- DOM_R_REF ref;
- NTSTATUS result = NT_STATUS_OK;
- TALLOC_CTX *tmp_ctx = NULL;
- int i;
-
- tmp_ctx = talloc_new(mem_ctx);
- if (!tmp_ctx) {
- DEBUG(0, ("rpccli_lsa_lookup_sids_noalloc: out of memory!\n"));
- result = NT_STATUS_UNSUCCESSFUL;
- goto done;
- }
+ LSA_Q_CLOSE q;
+ LSA_R_CLOSE r;
+ NTSTATUS result;
ZERO_STRUCT(q);
ZERO_STRUCT(r);
- init_q_lookup_sids(tmp_ctx, &q, pol, num_sids, sids, 1);
-
- ZERO_STRUCT(ref);
-
- r.dom_ref = &ref;
+ init_lsa_q_close(&q, pol);
- CLI_DO_RPC( cli, tmp_ctx, PI_LSARPC, LSA_LOOKUPSIDS,
+ CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_CLOSE,
q, r,
qbuf, rbuf,
- lsa_io_q_lookup_sids,
- lsa_io_r_lookup_sids,
+ lsa_io_q_close,
+ lsa_io_r_close,
NT_STATUS_UNSUCCESSFUL );
- if (!NT_STATUS_IS_OK(r.status) &&
- !NT_STATUS_EQUAL(r.status, STATUS_SOME_UNMAPPED))
- {
- /* An actual error occured */
- result = r.status;
- goto done;
- }
-
/* Return output parameters */
- if (r.mapped_count == 0) {
- result = NT_STATUS_NONE_MAPPED;
- goto done;
- }
-
- for (i = 0; i < num_sids; i++) {
- fstring name, dom_name;
- uint32 dom_idx = r.names.name[i].domain_idx;
-
- /* Translate optimised name through domain index array */
-
- if (dom_idx != 0xffffffff) {
-
- rpcstr_pull_unistr2_fstring(
- dom_name, &ref.ref_dom[dom_idx].uni_dom_name);
- rpcstr_pull_unistr2_fstring(
- name, &r.names.uni_name[i]);
-
- (names)[i] = talloc_strdup(mem_ctx, name);
- (domains)[i] = talloc_strdup(mem_ctx, dom_name);
- (types)[i] = (enum lsa_SidType)r.names.name[i].sid_name_use;
-
- if (((names)[i] == NULL) || ((domains)[i] == NULL)) {
- DEBUG(0, ("cli_lsa_lookup_sids_noalloc(): out of memory\n"));
- result = NT_STATUS_UNSUCCESSFUL;
- goto done;
- }
-
- } else {
- (names)[i] = NULL;
- (domains)[i] = NULL;
- (types)[i] = SID_NAME_UNKNOWN;
- }
- }
-
-done:
- TALLOC_FREE(tmp_ctx);
- return result;
-}
-
-/* Lookup a list of sids
- *
- * do it the right way: there is a limit (of 20480 for w2k3) entries
- * returned by this call. when the sids list contains more entries,
- * empty lists are returned. This version of lsa_lookup_sids passes
- * the list of sids in hunks of LOOKUP_SIDS_HUNK_SIZE to the lsa call. */
-
-/* This constant defines the limit of how many sids to look up
- * in one call (maximum). the limit from the server side is
- * at 20480 for win2k3, but we keep it at a save 1000 for now. */
-#define LOOKUP_SIDS_HUNK_SIZE 1000
-
-NTSTATUS rpccli_lsa_lookup_sids_all(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *pol,
- int num_sids,
- const DOM_SID *sids,
- char ***domains,
- char ***names,
- enum lsa_SidType **types)
-{
- NTSTATUS result = NT_STATUS_OK;
- int sids_left = 0;
- int sids_processed = 0;
- const DOM_SID *hunk_sids = sids;
- char **hunk_domains = NULL;
- char **hunk_names = NULL;
- enum lsa_SidType *hunk_types = NULL;
-
- if (num_sids) {
- if (!((*domains) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
- DEBUG(0, ("rpccli_lsa_lookup_sids_all(): out of memory\n"));
- result = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- if (!((*names) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
- DEBUG(0, ("rpccli_lsa_lookup_sids_all(): out of memory\n"));
- result = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- if (!((*types) = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_sids))) {
- DEBUG(0, ("rpccli_lsa_lookup_sids_all(): out of memory\n"));
- result = NT_STATUS_NO_MEMORY;
- goto done;
- }
- } else {
- (*domains) = NULL;
- (*names) = NULL;
- (*types) = NULL;
- }
-
- sids_left = num_sids;
- hunk_domains = *domains;
- hunk_names = *names;
- hunk_types = *types;
-
- while (sids_left > 0) {
- int hunk_num_sids;
- NTSTATUS hunk_result = NT_STATUS_OK;
-
- hunk_num_sids = ((sids_left > LOOKUP_SIDS_HUNK_SIZE)
- ? LOOKUP_SIDS_HUNK_SIZE
- : sids_left);
-
- DEBUG(10, ("rpccli_lsa_lookup_sids_all: processing items "
- "%d -- %d of %d.\n",
- sids_processed,
- sids_processed + hunk_num_sids - 1,
- num_sids));
-
- hunk_result = rpccli_lsa_lookup_sids_noalloc(cli,
- mem_ctx,
- pol,
- hunk_num_sids,
- hunk_sids,
- hunk_domains,
- hunk_names,
- hunk_types);
-
- if (!NT_STATUS_IS_OK(hunk_result) &&
- !NT_STATUS_EQUAL(hunk_result, STATUS_SOME_UNMAPPED) &&
- !NT_STATUS_EQUAL(hunk_result, NT_STATUS_NONE_MAPPED))
- {
- /* An actual error occured */
- goto done;
- }
-
- /* adapt overall result */
- if (( NT_STATUS_IS_OK(result) &&
- !NT_STATUS_IS_OK(hunk_result))
- ||
- ( NT_STATUS_EQUAL(result, NT_STATUS_NONE_MAPPED) &&
- !NT_STATUS_EQUAL(hunk_result, NT_STATUS_NONE_MAPPED)))
- {
- result = STATUS_SOME_UNMAPPED;
- }
+ result = r.status;
- sids_left -= hunk_num_sids;
- sids_processed += hunk_num_sids; /* only used in DEBUG */
- hunk_sids += hunk_num_sids;
- hunk_domains += hunk_num_sids;
- hunk_names += hunk_num_sids;
- hunk_types += hunk_num_sids;
+ if (NT_STATUS_IS_OK(result)) {
+#ifdef __INSURE__
+ SAFE_FREE(pol->marker);
+#endif
+ *pol = r.pol;
}
-done:
return result;
}
@@ -339,9 +175,7 @@ NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
POLICY_HND *pol, int num_sids,
const DOM_SID *sids,
- char ***domains,
- char ***names,
- enum lsa_SidType **types)
+ char ***domains, char ***names, uint32 **types)
{
prs_struct qbuf, rbuf;
LSA_Q_LOOKUP_SIDS q;
@@ -367,7 +201,7 @@ NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
NT_STATUS_UNSUCCESSFUL );
if (!NT_STATUS_IS_OK(r.status) &&
- !NT_STATUS_EQUAL(r.status, STATUS_SOME_UNMAPPED)) {
+ NT_STATUS_V(r.status) != NT_STATUS_V(STATUS_SOME_UNMAPPED)) {
/* An actual error occured */
result = r.status;
@@ -395,7 +229,7 @@ NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
goto done;
}
- if (!((*types) = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_sids))) {
+ if (!((*types) = TALLOC_ARRAY(mem_ctx, uint32, num_sids))) {
DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
result = NT_STATUS_NO_MEMORY;
goto done;
@@ -421,7 +255,7 @@ NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
(*names)[i] = talloc_strdup(mem_ctx, name);
(*domains)[i] = talloc_strdup(mem_ctx, dom_name);
- (*types)[i] = (enum lsa_SidType)r.names.name[i].sid_name_use;
+ (*types)[i] = r.names.name[i].sid_name_use;
if (((*names)[i] == NULL) || ((*domains)[i] == NULL)) {
DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
@@ -448,9 +282,8 @@ NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
POLICY_HND *pol, int num_names,
const char **names,
const char ***dom_names,
- int level,
DOM_SID **sids,
- enum lsa_SidType **types)
+ uint32 **types)
{
prs_struct qbuf, rbuf;
LSA_Q_LOOKUP_NAMES q;
@@ -465,7 +298,7 @@ NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
ZERO_STRUCT(ref);
r.dom_ref = &ref;
- init_q_lookup_names(mem_ctx, &q, pol, num_names, names, level);
+ init_q_lookup_names(mem_ctx, &q, pol, num_names, names);
CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_LOOKUPNAMES,
q, r,
@@ -498,7 +331,7 @@ NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
goto done;
}
- if (!((*types = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_names)))) {
+ if (!((*types = TALLOC_ARRAY(mem_ctx, uint32, num_names)))) {
DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
result = NT_STATUS_NO_MEMORY;
goto done;
@@ -541,7 +374,7 @@ NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
sid_append_rid(sid, dom_rid);
}
- (*types)[i] = (enum lsa_SidType)t_rids[i].type;
+ (*types)[i] = t_rids[i].type;
if (dom_names == NULL) {
continue;
@@ -1466,43 +1299,43 @@ done:
BOOL fetch_domain_sid( char *domain, char *remote_machine, DOM_SID *psid)
{
extern pstring global_myname;
- struct cli_state *cli;
+ struct cli_state cli;
NTSTATUS result;
POLICY_HND lsa_pol;
BOOL ret = False;
ZERO_STRUCT(cli);
- if((cli = cli_initialise()) == NULL) {
+ if(cli_initialise(&cli) == False) {
DEBUG(0,("fetch_domain_sid: unable to initialize client connection.\n"));
return False;
}
- if(!resolve_name( remote_machine, &cli->dest_ip, 0x20)) {
+ if(!resolve_name( remote_machine, &cli.dest_ip, 0x20)) {
DEBUG(0,("fetch_domain_sid: Can't resolve address for %s\n", remote_machine));
goto done;
}
- if (!cli_connect(cli, remote_machine, &cli->dest_ip)) {
+ if (!cli_connect(&cli, remote_machine, &cli.dest_ip)) {
DEBUG(0,("fetch_domain_sid: unable to connect to SMB server on \
-machine %s. Error was : %s.\n", remote_machine, cli_errstr(cli) ));
+machine %s. Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
goto done;
}
- if (!attempt_netbios_session_request(cli, global_myname, remote_machine, &cli->dest_ip)) {
+ if (!attempt_netbios_session_request(&cli, global_myname, remote_machine, &cli.dest_ip)) {
DEBUG(0,("fetch_domain_sid: machine %s rejected the NetBIOS session request.\n",
remote_machine));
goto done;
}
- cli->protocol = PROTOCOL_NT1;
+ cli.protocol = PROTOCOL_NT1;
- if (!cli_negprot(cli)) {
+ if (!cli_negprot(&cli)) {
DEBUG(0,("fetch_domain_sid: machine %s rejected the negotiate protocol. \
-Error was : %s.\n", remote_machine, cli_errstr(cli) ));
+Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
goto done;
}
- if (cli->protocol != PROTOCOL_NT1) {
+ if (cli.protocol != PROTOCOL_NT1) {
DEBUG(0,("fetch_domain_sid: machine %s didn't negotiate NT protocol.\n",
remote_machine));
goto done;
@@ -1512,39 +1345,39 @@ Error was : %s.\n", remote_machine, cli_errstr(cli) ));
* Do an anonymous session setup.
*/
- if (!cli_session_setup(cli, "", "", 0, "", 0, "")) {
+ if (!cli_session_setup(&cli, "", "", 0, "", 0, "")) {
DEBUG(0,("fetch_domain_sid: machine %s rejected the session setup. \
-Error was : %s.\n", remote_machine, cli_errstr(cli) ));
+Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
goto done;
}
- if (!(cli->sec_mode & NEGOTIATE_SECURITY_USER_LEVEL)) {
+ if (!(cli.sec_mode & NEGOTIATE_SECURITY_USER_LEVEL)) {
DEBUG(0,("fetch_domain_sid: machine %s isn't in user level security mode\n",
remote_machine));
goto done;
}
- if (!cli_send_tconX(cli, "IPC$", "IPC", "", 1)) {
+ if (!cli_send_tconX(&cli, "IPC$", "IPC", "", 1)) {
DEBUG(0,("fetch_domain_sid: machine %s rejected the tconX on the IPC$ share. \
-Error was : %s.\n", remote_machine, cli_errstr(cli) ));
+Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
goto done;
}
/* Fetch domain sid */
- if (!cli_nt_session_open(cli, PI_LSARPC)) {
+ if (!cli_nt_session_open(&cli, PI_LSARPC)) {
DEBUG(0, ("fetch_domain_sid: Error connecting to SAM pipe\n"));
goto done;
}
- result = cli_lsa_open_policy(cli, cli->mem_ctx, True, SEC_RIGHTS_QUERY_VALUE, &lsa_pol);
+ result = cli_lsa_open_policy(&cli, cli.mem_ctx, True, SEC_RIGHTS_QUERY_VALUE, &lsa_pol);
if (!NT_STATUS_IS_OK(result)) {
DEBUG(0, ("fetch_domain_sid: Error opening lsa policy handle. %s\n",
nt_errstr(result) ));
goto done;
}
- result = cli_lsa_query_info_policy(cli, cli->mem_ctx, &lsa_pol, 5, domain, psid);
+ result = cli_lsa_query_info_policy(&cli, cli.mem_ctx, &lsa_pol, 5, domain, psid);
if (!NT_STATUS_IS_OK(result)) {
DEBUG(0, ("fetch_domain_sid: Error querying lsa policy handle. %s\n",
nt_errstr(result) ));
@@ -1555,7 +1388,7 @@ Error was : %s.\n", remote_machine, cli_errstr(cli) ));
done:
- cli_shutdown(cli);
+ cli_shutdown(&cli);
return ret;
}
diff --git a/source/rpc_client/cli_netlogon.c b/source/rpc_client/cli_netlogon.c
index e6695f647eb..13a31e81d45 100644
--- a/source/rpc_client/cli_netlogon.c
+++ b/source/rpc_client/cli_netlogon.c
@@ -418,44 +418,6 @@ WERROR rpccli_netlogon_getanydcname(struct rpc_pipe_client *cli,
return result;
}
-/* GetDCName */
-
-WERROR rpccli_netlogon_getdcname(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx, const char *mydcname,
- const char *domainname, fstring newdcname)
-{
- prs_struct qbuf, rbuf;
- NET_Q_GETDCNAME q;
- NET_R_GETDCNAME r;
- WERROR result;
- fstring mydcname_slash;
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Initialise input parameters */
-
- slprintf(mydcname_slash, sizeof(fstring)-1, "\\\\%s", mydcname);
- init_net_q_getdcname(&q, mydcname_slash, domainname);
-
- /* Marshall data and send request */
-
- CLI_DO_RPC_WERR(cli, mem_ctx, PI_NETLOGON, NET_GETDCNAME,
- q, r,
- qbuf, rbuf,
- net_io_q_getdcname,
- net_io_r_getdcname,
- WERR_GENERAL_FAILURE);
-
- result = r.status;
-
- if (W_ERROR_IS_OK(result)) {
- rpcstr_pull_unistr2_fstring(newdcname, &r.uni_dcname);
- }
-
- return result;
-}
-
static WERROR pull_domain_controller_info_from_getdcname_reply(TALLOC_CTX *mem_ctx,
struct DS_DOMAIN_CONTROLLER_INFO **info_out,
NET_R_DSR_GETDCNAME *r)
@@ -501,8 +463,7 @@ static WERROR pull_domain_controller_info_from_getdcname_reply(TALLOC_CTX *mem_c
info->domain_controller_address_type = r->dc_address_type;
- info->domain_guid = (struct GUID *)talloc_memdup(
- mem_ctx, &r->domain_guid, sizeof(struct GUID));
+ info->domain_guid = talloc_memdup(mem_ctx, &r->domain_guid, sizeof(struct GUID));
if (!info->domain_guid) {
return WERR_GENERAL_FAILURE;
}
@@ -1063,98 +1024,6 @@ NTSTATUS rpccli_netlogon_sam_network_logon(struct rpc_pipe_client *cli,
return result;
}
-NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- uint32 logon_parameters,
- const char *server,
- const char *username,
- const char *domain,
- const char *workstation,
- const uint8 chal[8],
- DATA_BLOB lm_response,
- DATA_BLOB nt_response,
- NET_USER_INFO_3 *info3)
-{
- prs_struct qbuf, rbuf;
- NET_Q_SAM_LOGON_EX q;
- NET_R_SAM_LOGON_EX r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- NET_ID_INFO_CTR ctr;
- int validation_level = 3;
- const char *workstation_name_slash;
- const char *server_name_slash;
- static uint8 zeros[16];
- int i;
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- if (server[0] != '\\' && server[1] != '\\') {
- server_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", server);
- } else {
- server_name_slash = server;
- }
-
- if (workstation[0] != '\\' && workstation[1] != '\\') {
- workstation_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", workstation);
- } else {
- workstation_name_slash = workstation;
- }
-
- if (!workstation_name_slash || !server_name_slash) {
- DEBUG(0, ("talloc_asprintf failed!\n"));
- return NT_STATUS_NO_MEMORY;
- }
-
- /* Initialise input parameters */
-
- q.validation_level = validation_level;
-
- ctr.switch_value = NET_LOGON_TYPE;
-
- init_id_info2(&ctr.auth.id2, domain,
- logon_parameters, /* param_ctrl */
- 0xdead, 0xbeef, /* LUID? */
- username, workstation_name_slash, (const uchar*)chal,
- lm_response.data, lm_response.length, nt_response.data,
- nt_response.length);
-
- init_sam_info_ex(&q.sam_id, server_name_slash, global_myname(),
- NET_LOGON_TYPE, &ctr);
-
- r.user = info3;
-
- /* Marshall data and send request */
-
- CLI_DO_RPC(cli, mem_ctx, PI_NETLOGON, NET_SAMLOGON_EX,
- q, r, qbuf, rbuf,
- net_io_q_sam_logon_ex,
- net_io_r_sam_logon_ex,
- NT_STATUS_UNSUCCESSFUL);
-
- if (memcmp(zeros, info3->user_sess_key, 16) != 0) {
- SamOEMhash(info3->user_sess_key, cli->dc->sess_key, 16);
- } else {
- memset(info3->user_sess_key, '\0', 16);
- }
-
- if (memcmp(zeros, info3->lm_sess_key, 8) != 0) {
- SamOEMhash(info3->lm_sess_key, cli->dc->sess_key, 8);
- } else {
- memset(info3->lm_sess_key, '\0', 8);
- }
-
- for (i=0; i < 7; i++) {
- memset(&info3->unknown[i], '\0', 4);
- }
-
- /* Return results */
-
- result = r.status;
-
- return result;
-}
-
/***************************************************************************
LSA Server Password Set.
****************************************************************************/
diff --git a/source/rpc_client/cli_pipe.c b/source/rpc_client/cli_pipe.c
index 5f21caeccfd..61f5ee51bd0 100644
--- a/source/rpc_client/cli_pipe.c
+++ b/source/rpc_client/cli_pipe.c
@@ -915,8 +915,8 @@ static NTSTATUS create_krb5_auth_bind_req( struct rpc_pipe_client *cli,
#ifdef HAVE_KRB5
int ret;
struct kerberos_auth_struct *a = cli->auth.a_u.kerberos_auth;
- DATA_BLOB tkt = data_blob_null;
- DATA_BLOB tkt_wrapped = data_blob_null;
+ DATA_BLOB tkt = data_blob(NULL, 0);
+ DATA_BLOB tkt_wrapped = data_blob(NULL, 0);
/* We may change the pad length before marshalling. */
init_rpc_hdr_auth(pauth_out, RPC_KRB5_AUTH_TYPE, (int)auth_level, 0, 1);
@@ -953,7 +953,7 @@ static NTSTATUS create_krb5_auth_bind_req( struct rpc_pipe_client *cli,
}
DEBUG(5, ("create_krb5_auth_bind_req: Created krb5 GSS blob :\n"));
- dump_data(5, tkt_wrapped.data, tkt_wrapped.length);
+ dump_data(5, (const char *)tkt_wrapped.data, tkt_wrapped.length);
data_blob_free(&tkt_wrapped);
return NT_STATUS_OK;
@@ -972,9 +972,9 @@ static NTSTATUS create_spnego_ntlmssp_auth_rpc_bind_req( struct rpc_pipe_client
prs_struct *auth_data)
{
NTSTATUS nt_status;
- DATA_BLOB null_blob = data_blob_null;
- DATA_BLOB request = data_blob_null;
- DATA_BLOB spnego_msg = data_blob_null;
+ DATA_BLOB null_blob = data_blob(NULL, 0);
+ DATA_BLOB request = data_blob(NULL, 0);
+ DATA_BLOB spnego_msg = data_blob(NULL, 0);
/* We may change the pad length before marshalling. */
init_rpc_hdr_auth(pauth_out, RPC_SPNEGO_AUTH_TYPE, (int)auth_level, 0, 1);
@@ -1003,7 +1003,7 @@ static NTSTATUS create_spnego_ntlmssp_auth_rpc_bind_req( struct rpc_pipe_client
}
DEBUG(5, ("create_spnego_ntlmssp_auth_rpc_bind_req: NTLMSSP Negotiate:\n"));
- dump_data(5, spnego_msg.data, spnego_msg.length);
+ dump_data(5, (const char *)spnego_msg.data, spnego_msg.length);
data_blob_free(&spnego_msg);
return NT_STATUS_OK;
@@ -1019,8 +1019,8 @@ static NTSTATUS create_ntlmssp_auth_rpc_bind_req( struct rpc_pipe_client *cli,
prs_struct *auth_data)
{
NTSTATUS nt_status;
- DATA_BLOB null_blob = data_blob_null;
- DATA_BLOB request = data_blob_null;
+ DATA_BLOB null_blob = data_blob(NULL, 0);
+ DATA_BLOB request = data_blob(NULL, 0);
/* We may change the pad length before marshalling. */
init_rpc_hdr_auth(pauth_out, RPC_NTLMSSP_AUTH_TYPE, (int)auth_level, 0, 1);
@@ -1044,7 +1044,7 @@ static NTSTATUS create_ntlmssp_auth_rpc_bind_req( struct rpc_pipe_client *cli,
}
DEBUG(5, ("create_ntlmssp_auth_rpc_bind_req: NTLMSSP Negotiate:\n"));
- dump_data(5, request.data, request.length);
+ dump_data(5, (const char *)request.data, request.length);
data_blob_free(&request);
return NT_STATUS_OK;
@@ -1250,7 +1250,7 @@ static NTSTATUS add_ntlmssp_auth_footer(struct rpc_pipe_client *cli,
{
RPC_HDR_AUTH auth_info;
NTSTATUS status;
- DATA_BLOB auth_blob = data_blob_null;
+ DATA_BLOB auth_blob = data_blob(NULL, 0);
uint16 data_and_pad_len = prs_offset(outgoing_pdu) - RPC_HEADER_LEN - RPC_HDR_RESP_LEN;
if (!cli->auth.a_u.ntlmssp_state) {
@@ -1645,10 +1645,10 @@ static BOOL valid_pipe_name(const int pipe_idx, RPC_IFACE *abstract, RPC_IFACE *
}
DEBUG(5,("Bind Abstract Syntax: "));
- dump_data(5, (uint8 *)&pipe_names[pipe_idx].abstr_syntax,
+ dump_data(5, (char*)&pipe_names[pipe_idx].abstr_syntax,
sizeof(pipe_names[pipe_idx].abstr_syntax));
DEBUG(5,("Bind Transfer Syntax: "));
- dump_data(5, (uint8 *)&pipe_names[pipe_idx].trans_syntax,
+ dump_data(5, (char*)&pipe_names[pipe_idx].trans_syntax,
sizeof(pipe_names[pipe_idx].trans_syntax));
/* copy the required syntaxes out so we can do the right bind */
@@ -1775,8 +1775,8 @@ static NTSTATUS rpc_finish_auth3_bind(struct rpc_pipe_client *cli,
enum pipe_auth_type auth_type,
enum pipe_auth_level auth_level)
{
- DATA_BLOB server_response = data_blob_null;
- DATA_BLOB client_reply = data_blob_null;
+ DATA_BLOB server_response = data_blob(NULL,0);
+ DATA_BLOB client_reply = data_blob(NULL,0);
RPC_HDR_AUTH hdr_auth;
NTSTATUS nt_status;
prs_struct rpc_out;
@@ -1900,10 +1900,10 @@ static NTSTATUS rpc_finish_spnego_ntlmssp_bind(struct rpc_pipe_client *cli,
enum pipe_auth_type auth_type,
enum pipe_auth_level auth_level)
{
- DATA_BLOB server_spnego_response = data_blob_null;
- DATA_BLOB server_ntlm_response = data_blob_null;
- DATA_BLOB client_reply = data_blob_null;
- DATA_BLOB tmp_blob = data_blob_null;
+ DATA_BLOB server_spnego_response = data_blob(NULL,0);
+ DATA_BLOB server_ntlm_response = data_blob(NULL,0);
+ DATA_BLOB client_reply = data_blob(NULL,0);
+ DATA_BLOB tmp_blob = data_blob(NULL, 0);
RPC_HDR_AUTH hdr_auth;
NTSTATUS nt_status;
prs_struct rpc_out;
@@ -1953,7 +1953,7 @@ static NTSTATUS rpc_finish_spnego_ntlmssp_bind(struct rpc_pipe_client *cli,
tmp_blob = spnego_gen_auth(client_reply);
data_blob_free(&client_reply);
client_reply = tmp_blob;
- tmp_blob = data_blob_null; /* Ensure it's safe to free this just in case. */
+ tmp_blob = data_blob(NULL,0); /* Ensure it's safe to free this just in case. */
/* Now prepare the alter context pdu. */
prs_init(&rpc_out, 0, prs_get_mem_context(rbuf), MARSHALL);
@@ -2002,7 +2002,7 @@ static NTSTATUS rpc_finish_spnego_ntlmssp_bind(struct rpc_pipe_client *cli,
prs_copy_data_out((char *)server_spnego_response.data, rbuf, phdr->auth_len);
/* Check we got a valid auth response. */
- if (!spnego_parse_auth_response(server_spnego_response, NT_STATUS_OK, OID_NTLMSSP, &tmp_blob)) {
+ if (!spnego_parse_auth_response(server_spnego_response, NT_STATUS_OK, &tmp_blob)) {
data_blob_free(&server_spnego_response);
data_blob_free(&tmp_blob);
return NT_STATUS_INVALID_PARAMETER;
diff --git a/source/rpc_client/cli_reg.c b/source/rpc_client/cli_reg.c
index 83ff96b8b3f..e136df753ad 100644
--- a/source/rpc_client/cli_reg.c
+++ b/source/rpc_client/cli_reg.c
@@ -2,7 +2,11 @@
Unix SMB/CIFS implementation.
RPC Pipe client
- Copyright (C) Gerald (Jerry) Carter 2005-2006
+ Copyright (C) Andrew Tridgell 1992-2000,
+ Copyright (C) Jeremy Allison 1999 - 2005
+ Copyright (C) Simo Sorce 2001
+ Copyright (C) Jeremy Cooper 2004
+ Copyright (C) Gerald (Jerry) Carter 2005
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
@@ -22,55 +26,706 @@
#include "includes.h"
#include "rpc_client.h"
+/* Shutdown a server */
+
+/*******************************************************************
+ internal connect to a registry hive root (open a registry policy)
+*******************************************************************/
+
+static WERROR rpccli_reg_open_hive_int(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, uint16 op_code,
+ const char *op_name,
+ uint32 access_mask, POLICY_HND *hnd)
+{
+ REG_Q_OPEN_HIVE in;
+ REG_R_OPEN_HIVE out;
+ prs_struct qbuf, rbuf;
+
+ ZERO_STRUCT(in);
+ ZERO_STRUCT(out);
+
+ init_reg_q_open_hive(&in, access_mask);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, op_code,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_open_hive,
+ reg_io_r_open_hive,
+ WERR_GENERAL_FAILURE );
+
+ if ( !W_ERROR_IS_OK( out.status ) )
+ return out.status;
+
+ memcpy( hnd, &out.pol, sizeof(POLICY_HND) );
+
+ return out.status;
+}
+
/*******************************************************************
connect to a registry hive root (open a registry policy)
*******************************************************************/
-NTSTATUS rpccli_winreg_Connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+WERROR rpccli_reg_connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
uint32 reg_type, uint32 access_mask,
POLICY_HND *reg_hnd)
-{
+{ uint16 op_code;
+ const char *op_name;
+
ZERO_STRUCTP(reg_hnd);
switch (reg_type)
{
case HKEY_CLASSES_ROOT:
- return rpccli_winreg_OpenHKCR( cli, mem_ctx, NULL,
- access_mask, reg_hnd );
-
+ op_code = REG_OPEN_HKCR;
+ op_name = "REG_OPEN_HKCR";
+ break;
case HKEY_LOCAL_MACHINE:
- return rpccli_winreg_OpenHKLM( cli, mem_ctx, NULL,
- access_mask, reg_hnd );
-
+ op_code = REG_OPEN_HKLM;
+ op_name = "REG_OPEN_HKLM";
+ break;
case HKEY_USERS:
- return rpccli_winreg_OpenHKU( cli, mem_ctx, NULL,
- access_mask, reg_hnd );
-
+ op_code = REG_OPEN_HKU;
+ op_name = "REG_OPEN_HKU";
+ break;
case HKEY_PERFORMANCE_DATA:
- return rpccli_winreg_OpenHKPD( cli, mem_ctx, NULL,
- access_mask, reg_hnd );
-
- default:
- /* fall through to end of function */
+ op_code = REG_OPEN_HKPD;
+ op_name = "REG_OPEN_HKPD";
break;
+ default:
+ return WERR_INVALID_PARAM;
}
- return NT_STATUS_INVALID_PARAMETER;
+ return rpccli_reg_open_hive_int(cli, mem_ctx, op_code, op_name,
+ access_mask, reg_hnd);
}
+
/*******************************************************************
- Fill in a REGVAL_BUFFER for the data given a REGISTRY_VALUE
- *******************************************************************/
+*******************************************************************/
+
+WERROR rpccli_reg_shutdown(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ const char *msg, uint32 timeout, BOOL do_reboot,
+ BOOL force)
+{
+ REG_Q_SHUTDOWN in;
+ REG_R_SHUTDOWN out;
+ prs_struct qbuf, rbuf;
+
+ if (msg == NULL)
+ return WERR_INVALID_PARAM;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ /* Marshall data and send request */
+
+ init_reg_q_shutdown(&in, msg, timeout, do_reboot, force);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SHUTDOWN,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_shutdown,
+ reg_io_r_shutdown,
+ WERR_GENERAL_FAILURE );
+
+ return out.status;
+}
+
+/*******************************************************************
+*******************************************************************/
+
+WERROR rpccli_reg_abort_shutdown(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ REG_Q_ABORT_SHUTDOWN in;
+ REG_R_ABORT_SHUTDOWN out;
+ prs_struct qbuf, rbuf;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_ABORT_SHUTDOWN,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_abort_shutdown,
+ reg_io_r_abort_shutdown,
+ WERR_GENERAL_FAILURE );
+
+ return out.status;
+}
+
+
+/****************************************************************************
+do a REG Unknown 0xB command. sent after a create key or create value.
+this might be some sort of "sync" or "refresh" command, sent after
+modification of the registry...
+****************************************************************************/
+
+WERROR rpccli_reg_flush_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd)
+{
+ REG_Q_FLUSH_KEY in;
+ REG_R_FLUSH_KEY out;
+ prs_struct qbuf, rbuf;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ init_reg_q_flush_key(&in, hnd);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_FLUSH_KEY,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_flush_key,
+ reg_io_r_flush_key,
+ WERR_GENERAL_FAILURE );
+
+ return out.status;
+}
+
+/****************************************************************************
+do a REG Query Key
+****************************************************************************/
-uint32 reg_init_regval_buffer( REGVAL_BUFFER *buf2, REGISTRY_VALUE *val )
+WERROR rpccli_reg_query_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd,
+ char *key_class, uint32 *class_len,
+ uint32 *num_subkeys, uint32 *max_subkeylen,
+ uint32 *max_classlen, uint32 *num_values,
+ uint32 *max_valnamelen, uint32 *max_valbufsize,
+ uint32 *sec_desc, NTTIME *mod_time)
{
- uint32 real_size = 0;
+ REG_Q_QUERY_KEY in;
+ REG_R_QUERY_KEY out;
+ prs_struct qbuf, rbuf;
+ uint32 saved_class_len = *class_len;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ init_reg_q_query_key( &in, hnd, key_class );
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_QUERY_KEY,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_query_key,
+ reg_io_r_query_key,
+ WERR_GENERAL_FAILURE );
+
+ if ( W_ERROR_EQUAL( out.status, WERR_MORE_DATA ) ) {
+ ZERO_STRUCT (in);
+
+ *class_len = out.key_class.string->uni_max_len;
+ if ( *class_len > saved_class_len )
+ return out.status;
+
+ /* set a string of spaces and NULL terminate */
+
+ memset( key_class, (int)' ', *class_len );
+ key_class[*class_len] = '\0';
+
+ init_reg_q_query_key( &in, hnd, key_class );
+
+ ZERO_STRUCT (out);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_QUERY_KEY,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_query_key,
+ reg_io_r_query_key,
+ WERR_GENERAL_FAILURE );
+ }
+
+ if ( !W_ERROR_IS_OK( out.status ) )
+ return out.status;
+
+ *class_len = out.key_class.string->uni_max_len;
+ unistr2_to_ascii(key_class, out.key_class.string, saved_class_len-1);
+ *num_subkeys = out.num_subkeys ;
+ *max_subkeylen = out.max_subkeylen ;
+ *num_values = out.num_values ;
+ *max_valnamelen = out.max_valnamelen;
+ *max_valbufsize = out.max_valbufsize;
+ *sec_desc = out.sec_desc ;
+ *mod_time = out.mod_time ;
+ /* Maybe: *max_classlen = out.reserved; */
+
+ return out.status;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+WERROR rpccli_reg_getversion(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd, uint32 *version)
+{
+ REG_Q_GETVERSION in;
+ REG_R_GETVERSION out;
+ prs_struct qbuf, rbuf;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ init_reg_q_getversion(&in, hnd);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_GETVERSION,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_getversion,
+ reg_io_r_getversion,
+ WERR_GENERAL_FAILURE );
+
+
+ if ( !W_ERROR_IS_OK( out.status ) )
+ return out.status;
+
+ *version = out.win_version;
+
+ return out.status;
+}
+
+/****************************************************************************
+do a REG Query Info
+****************************************************************************/
+
+WERROR rpccli_reg_query_value(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd, const char *val_name,
+ uint32 *type, REGVAL_BUFFER *buffer)
+{
+ REG_Q_QUERY_VALUE in;
+ REG_R_QUERY_VALUE out;
+ prs_struct qbuf, rbuf;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ init_reg_q_query_value(&in, hnd, val_name, buffer);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_QUERY_VALUE,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_query_value,
+ reg_io_r_query_value,
+ WERR_GENERAL_FAILURE );
+
+
+ if ( !W_ERROR_IS_OK( out.status ) )
+ return out.status;
+
+ *type = *out.type;
+ *buffer = *out.value;
+
+ return out.status;
+}
+
+/****************************************************************************
+do a REG Set Key Security
+****************************************************************************/
+
+WERROR rpccli_reg_set_key_sec(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd, uint32 sec_info,
+ size_t secdesc_size, SEC_DESC *sec_desc)
+{
+ REG_Q_SET_KEY_SEC in;
+ REG_R_SET_KEY_SEC out;
+ prs_struct qbuf, rbuf;
+ SEC_DESC_BUF *sec_desc_buf;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ /* Flatten the security descriptor */
+
+ if ( !(sec_desc_buf = make_sec_desc_buf(mem_ctx, secdesc_size, sec_desc)) )
+ return WERR_GENERAL_FAILURE;
+
+ init_reg_q_set_key_sec(&in, hnd, sec_info, sec_desc_buf);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SET_KEY_SEC,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_set_key_sec,
+ reg_io_r_set_key_sec,
+ WERR_GENERAL_FAILURE );
+
+
+ return out.status;
+}
+
+
+/****************************************************************************
+do a REG Query Key Security
+****************************************************************************/
+
+WERROR rpccli_reg_get_key_sec(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd, uint32 sec_info,
+ uint32 *sec_buf_size, SEC_DESC_BUF *sec_buf)
+{
+ REG_Q_GET_KEY_SEC in;
+ REG_R_GET_KEY_SEC out;
+ prs_struct qbuf, rbuf;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ init_reg_q_get_key_sec(&in, hnd, sec_info, *sec_buf_size, sec_buf);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_GET_KEY_SEC,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_get_key_sec,
+ reg_io_r_get_key_sec,
+ WERR_GENERAL_FAILURE );
+
+
+ /* this might be able to return WERR_MORE_DATA, I'm not sure */
- if ( !buf2 || !val )
- return 0;
+ if ( !W_ERROR_IS_OK( out.status ) )
+ return out.status;
+
+ sec_buf = out.data;
+ *sec_buf_size = out.data->len;
- real_size = regval_size(val);
- init_regval_buffer( buf2, (unsigned char*)regval_data_p(val), real_size );
+ return out.status;
+}
+
+/****************************************************************************
+do a REG Delete Value
+****************************************************************************/
+
+WERROR rpccli_reg_delete_val(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd, char *val_name)
+{
+ REG_Q_DELETE_VALUE in;
+ REG_R_DELETE_VALUE out;
+ prs_struct qbuf, rbuf;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ init_reg_q_delete_val(&in, hnd, val_name);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_DELETE_VALUE,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_delete_value,
+ reg_io_r_delete_value,
+ WERR_GENERAL_FAILURE );
+
+ return out.status;
+}
+
+/****************************************************************************
+do a REG Delete Key
+****************************************************************************/
+
+WERROR rpccli_reg_delete_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd, char *key_name)
+{
+ REG_Q_DELETE_KEY in;
+ REG_R_DELETE_KEY out;
+ prs_struct qbuf, rbuf;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ init_reg_q_delete_key(&in, hnd, key_name);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_DELETE_KEY,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_delete_key,
+ reg_io_r_delete_key,
+ WERR_GENERAL_FAILURE );
+
+ return out.status;
+}
+
+/****************************************************************************
+do a REG Create Key
+****************************************************************************/
+
+WERROR rpccli_reg_create_key_ex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd, char *key_name, char *key_class,
+ uint32 access_desired, POLICY_HND *key)
+{
+ REG_Q_CREATE_KEY_EX in;
+ REG_R_CREATE_KEY_EX out;
+ prs_struct qbuf, rbuf;
+ SEC_DESC *sec;
+ SEC_DESC_BUF *sec_buf;
+ size_t sec_len;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ if ( !(sec = make_sec_desc(mem_ctx, 1, SEC_DESC_SELF_RELATIVE,
+ NULL, NULL, NULL, NULL, &sec_len)) ) {
+ return WERR_GENERAL_FAILURE;
+ }
+
+ if ( !(sec_buf = make_sec_desc_buf(mem_ctx, sec_len, sec)) )
+ return WERR_GENERAL_FAILURE;
+
+ init_reg_q_create_key_ex(&in, hnd, key_name, key_class, access_desired, sec_buf);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_CREATE_KEY_EX,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_create_key_ex,
+ reg_io_r_create_key_ex,
+ WERR_GENERAL_FAILURE );
+
+
+ if ( !W_ERROR_IS_OK( out.status ) )
+ return out.status;
+
+ memcpy( key, &out.handle, sizeof(POLICY_HND) );
+
+ return out.status;
+}
+
+/****************************************************************************
+do a REG Enum Key
+****************************************************************************/
+
+WERROR rpccli_reg_enum_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd, int key_index, fstring key_name,
+ fstring class_name, time_t *mod_time)
+{
+ REG_Q_ENUM_KEY in;
+ REG_R_ENUM_KEY out;
+ prs_struct qbuf, rbuf;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ init_reg_q_enum_key(&in, hnd, key_index);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_ENUM_KEY,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_enum_key,
+ reg_io_r_enum_key,
+ WERR_GENERAL_FAILURE );
+
+ if ( !W_ERROR_IS_OK(out.status) )
+ return out.status;
+
+ if ( out.keyname.string )
+ rpcstr_pull( key_name, out.keyname.string->buffer, sizeof(fstring), -1, STR_TERMINATE );
+ else
+ fstrcpy( key_name, "(Default)" );
+
+ if ( out.classname && out.classname->string )
+ rpcstr_pull( class_name, out.classname->string->buffer, sizeof(fstring), -1, STR_TERMINATE );
+ else
+ fstrcpy( class_name, "" );
+
+ *mod_time = nt_time_to_unix(*out.time);
+
+ return out.status;
+}
+
+/****************************************************************************
+do a REG Create Value
+****************************************************************************/
+
+WERROR rpccli_reg_set_val(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd, char *val_name, uint32 type,
+ RPC_DATA_BLOB *data)
+{
+ REG_Q_SET_VALUE in;
+ REG_R_SET_VALUE out;
+ prs_struct qbuf, rbuf;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ init_reg_q_set_val(&in, hnd, val_name, type, data);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SET_VALUE,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_set_value,
+ reg_io_r_set_value,
+ WERR_GENERAL_FAILURE );
+
+ return out.status;
+}
+
+/****************************************************************************
+do a REG Enum Value
+****************************************************************************/
+
+WERROR rpccli_reg_enum_val(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd, int idx,
+ fstring val_name, uint32 *type, REGVAL_BUFFER *value)
+{
+ REG_Q_ENUM_VALUE in;
+ REG_R_ENUM_VALUE out;
+ prs_struct qbuf, rbuf;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ init_reg_q_enum_val(&in, hnd, idx, 0x0100, 0x1000);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_ENUM_VALUE,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_enum_val,
+ reg_io_r_enum_val,
+ WERR_GENERAL_FAILURE );
+
+ if ( W_ERROR_EQUAL(out.status, WERR_MORE_DATA) ) {
+
+ ZERO_STRUCT (in);
+
+ init_reg_q_enum_val(&in, hnd, idx, 0x0100, *out.buffer_len1);
+
+ ZERO_STRUCT (out);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_ENUM_VALUE,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_enum_val,
+ reg_io_r_enum_val,
+ WERR_GENERAL_FAILURE );
+ }
+
+ if ( !W_ERROR_IS_OK(out.status) )
+ return out.status;
+
+ unistr2_to_ascii(val_name, out.name.string, sizeof(fstring)-1);
+ *type = *out.type;
+ *value = *out.value;
+
+ return out.status;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+WERROR rpccli_reg_open_entry(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd, char *key_name,
+ uint32 access_desired, POLICY_HND *key_hnd)
+{
+ REG_Q_OPEN_ENTRY in;
+ REG_R_OPEN_ENTRY out;
+ prs_struct qbuf, rbuf;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ init_reg_q_open_entry(&in, hnd, key_name, access_desired);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_OPEN_ENTRY,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_open_entry,
+ reg_io_r_open_entry,
+ WERR_GENERAL_FAILURE );
+
+ if ( !W_ERROR_IS_OK( out.status ) )
+ return out.status;
+
+ memcpy( key_hnd, &out.handle, sizeof(POLICY_HND) );
+
+ return out.status;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+WERROR rpccli_reg_close(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd)
+{
+ REG_Q_CLOSE in;
+ REG_R_CLOSE out;
+ prs_struct qbuf, rbuf;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ init_reg_q_close(&in, hnd);
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_CLOSE,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_close,
+ reg_io_r_close,
+ WERR_GENERAL_FAILURE );
+
+ return out.status;
+}
+
+/****************************************************************************
+do a REG Query Info
+****************************************************************************/
+
+WERROR rpccli_reg_save_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd, const char *filename )
+{
+ REG_Q_SAVE_KEY in;
+ REG_R_SAVE_KEY out;
+ prs_struct qbuf, rbuf;
+
+ ZERO_STRUCT (in);
+ ZERO_STRUCT (out);
+
+ init_q_reg_save_key( &in, hnd, filename );
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SAVE_KEY,
+ in, out,
+ qbuf, rbuf,
+ reg_io_q_save_key,
+ reg_io_r_save_key,
+ WERR_GENERAL_FAILURE );
+
+ return out.status;
+}
+
+
+/*
+ #################################################################
+ Utility functions
+ #################################################################
+ */
+
+/*****************************************************************
+ Splits out the start of the key (HKLM or HKU) and the rest of the key.
+*****************************************************************/
+
+BOOL reg_split_hive(const char *full_keyname, uint32 *reg_type, pstring key_name)
+{
+ pstring tmp;
+
+ if (!next_token(&full_keyname, tmp, "\\", sizeof(tmp)))
+ return False;
+
+ (*reg_type) = 0;
+
+ DEBUG(10, ("reg_split_key: hive %s\n", tmp));
+
+ if (strequal(tmp, "HKLM") || strequal(tmp, "HKEY_LOCAL_MACHINE"))
+ (*reg_type) = HKEY_LOCAL_MACHINE;
+ else if (strequal(tmp, "HKCR") || strequal(tmp, "HKEY_CLASSES_ROOT"))
+ (*reg_type) = HKEY_CLASSES_ROOT;
+ else if (strequal(tmp, "HKU") || strequal(tmp, "HKEY_USERS"))
+ (*reg_type) = HKEY_USERS;
+ else if (strequal(tmp, "HKPD")||strequal(tmp, "HKEY_PERFORMANCE_DATA"))
+ (*reg_type) = HKEY_PERFORMANCE_DATA;
+ else {
+ DEBUG(10,("reg_split_key: unrecognised hive key %s\n", tmp));
+ return False;
+ }
+
+ if (next_token(&full_keyname, tmp, "\n\r", sizeof(tmp)))
+ pstrcpy(key_name, tmp);
+ else
+ key_name[0] = 0;
+
+ DEBUG(10, ("reg_split_key: name %s\n", key_name));
- return real_size;
+ return True;
}
diff --git a/source/rpc_client/cli_samr.c b/source/rpc_client/cli_samr.c
index 462add43819..444011edc5d 100644
--- a/source/rpc_client/cli_samr.c
+++ b/source/rpc_client/cli_samr.c
@@ -52,6 +52,9 @@ NTSTATUS rpccli_samr_connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
if (NT_STATUS_IS_OK(result = r.status)) {
*connect_pol = r.connect_pol;
+#ifdef __INSURE__
+ connect_pol->marker = malloc(1);
+#endif
}
return result;
@@ -85,6 +88,9 @@ NTSTATUS rpccli_samr_connect4(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
if (NT_STATUS_IS_OK(result = r.status)) {
*connect_pol = r.connect_pol;
+#ifdef __INSURE__
+ connect_pol->marker = malloc(1);
+#endif
}
return result;
@@ -119,6 +125,9 @@ NTSTATUS rpccli_samr_close(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
/* Return output parameters */
if (NT_STATUS_IS_OK(result = r.status)) {
+#ifdef __INSURE__
+ SAFE_FREE(connect_pol->marker);
+#endif
*connect_pol = r.pol;
}
@@ -157,6 +166,9 @@ NTSTATUS rpccli_samr_open_domain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ct
if (NT_STATUS_IS_OK(result = r.status)) {
*domain_pol = r.domain_pol;
+#ifdef __INSURE__
+ domain_pol->marker = malloc(1);
+#endif
}
return result;
@@ -192,6 +204,9 @@ NTSTATUS rpccli_samr_open_user(struct rpc_pipe_client *cli,
if (NT_STATUS_IS_OK(result = r.status)) {
*user_pol = r.user_pol;
+#ifdef __INSURE__
+ user_pol->marker = malloc(1);
+#endif
}
return result;
@@ -229,6 +244,9 @@ NTSTATUS rpccli_samr_open_group(struct rpc_pipe_client *cli,
if (NT_STATUS_IS_OK(result = r.status)) {
*group_pol = r.pol;
+#ifdef __INSURE__
+ group_pol->marker = malloc(1);
+#endif
}
return result;
@@ -922,6 +940,9 @@ NTSTATUS rpccli_samr_open_alias(struct rpc_pipe_client *cli,
if (NT_STATUS_IS_OK(result = r.status)) {
*alias_pol = r.pol;
+#ifdef __INSURE__
+ alias_pol->marker = malloc(1);
+#endif
}
return result;
@@ -1197,6 +1218,11 @@ NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
const char *newpassword,
const char *oldpassword )
{
+ prs_struct qbuf, rbuf;
+ SAMR_Q_CHGPASSWD_USER q;
+ SAMR_R_CHGPASSWD_USER r;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+
uchar new_nt_password[516];
uchar new_lm_password[516];
uchar old_nt_hash[16];
@@ -1207,8 +1233,13 @@ NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
uchar new_nt_hash[16];
uchar new_lanman_hash[16];
+ char *srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", cli->cli->desthost);
+
DEBUG(10,("rpccli_samr_chgpasswd_user\n"));
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
/* Calculate the MD4 hash (NT compatible) of the password */
E_md4hash(oldpassword, old_nt_hash);
E_md4hash(newpassword, new_nt_hash);
@@ -1235,35 +1266,50 @@ NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
SamOEMhash( new_nt_password, old_nt_hash, 516);
E_old_pw_hash( new_nt_hash, old_nt_hash, old_nt_hash_enc);
- return rpccli_samr_chng_pswd_auth_crap(cli, mem_ctx, username,
- data_blob_const(new_nt_password,sizeof(new_nt_password)),
- data_blob_const(old_nt_hash_enc,sizeof(old_nt_hash_enc)),
- data_blob_const(new_lm_password,sizeof(new_lm_password)),
- data_blob_const(old_lanman_hash_enc,sizeof(old_lanman_hash_enc)));
+ /* Marshall data and send request */
+
+ init_samr_q_chgpasswd_user(&q, srv_name_slash, username,
+ new_nt_password,
+ old_nt_hash_enc,
+ new_lm_password,
+ old_lanman_hash_enc);
+
+ CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_CHGPASSWD_USER,
+ q, r,
+ qbuf, rbuf,
+ samr_io_q_chgpasswd_user,
+ samr_io_r_chgpasswd_user,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return output parameters */
+
+ if (!NT_STATUS_IS_OK(result = r.status)) {
+ goto done;
+ }
+
+ done:
+
+ return result;
}
-/* User change passwd with auth crap */
+/* User change password given blobs */
NTSTATUS rpccli_samr_chng_pswd_auth_crap(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- const char *username,
- DATA_BLOB new_nt_password,
- DATA_BLOB old_nt_hash_enc,
- DATA_BLOB new_lm_password,
- DATA_BLOB old_lm_hash_enc)
+ TALLOC_CTX *mem_ctx,
+ const char *username,
+ DATA_BLOB new_nt_password,
+ DATA_BLOB old_nt_hash_enc,
+ DATA_BLOB new_lm_password,
+ DATA_BLOB old_lm_hash_enc)
{
prs_struct qbuf, rbuf;
SAMR_Q_CHGPASSWD_USER q;
SAMR_R_CHGPASSWD_USER r;
- char *srv_name_slash;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- if (!(srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s",
- cli->cli->desthost))) {
- return NT_STATUS_NO_MEMORY;
- }
+ char *srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", cli->cli->desthost);
- DEBUG(5,("rpccli_samr_chng_pswd_auth_crap on server: %s\n",
- srv_name_slash));
+ DEBUG(10,("rpccli_samr_chng_pswd_auth_crap\n"));
ZERO_STRUCT(q);
ZERO_STRUCT(r);
@@ -1273,19 +1319,28 @@ NTSTATUS rpccli_samr_chng_pswd_auth_crap(struct rpc_pipe_client *cli,
init_samr_q_chgpasswd_user(&q, srv_name_slash, username,
new_nt_password.data,
old_nt_hash_enc.data,
- new_lm_password.data,
+ new_lm_password.data,
old_lm_hash_enc.data);
CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_CHGPASSWD_USER,
- q, r,
- qbuf, rbuf,
- samr_io_q_chgpasswd_user,
- samr_io_r_chgpasswd_user,
- NT_STATUS_UNSUCCESSFUL);
+ q, r,
+ qbuf, rbuf,
+ samr_io_q_chgpasswd_user,
+ samr_io_r_chgpasswd_user,
+ NT_STATUS_UNSUCCESSFUL);
- return r.status;
+ /* Return output parameters */
+
+ if (!NT_STATUS_IS_OK(result = r.status)) {
+ goto done;
+ }
+
+ done:
+
+ return result;
}
+
/* change password 3 */
NTSTATUS rpccli_samr_chgpasswd3(struct rpc_pipe_client *cli,
@@ -1434,59 +1489,7 @@ NTSTATUS rpccli_samr_query_dispinfo(struct rpc_pipe_client *cli,
/* Return output parameters */
- result = r.status;
-
- if (!NT_STATUS_IS_OK(result) &&
- NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
- goto done;
- }
-
- *num_entries = r.num_entries;
- *start_idx += r.num_entries; /* No next_idx in this structure! */
-
- done:
- return result;
-}
-
-
-/* Query display info2 */
-
-NTSTATUS rpccli_samr_query_dispinfo2(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol, uint32 *start_idx,
- uint16 switch_value, uint32 *num_entries,
- uint32 max_entries, uint32 max_size,
- SAM_DISPINFO_CTR *ctr)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_QUERY_DISPINFO q;
- SAMR_R_QUERY_DISPINFO r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_query_dispinfo2 for start_idx = %u\n", *start_idx));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- *num_entries = 0;
-
- /* Marshall data and send request */
-
- init_samr_q_query_dispinfo(&q, domain_pol, switch_value,
- *start_idx, max_entries, max_size);
-
- r.ctr = ctr;
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_DISPINFO2,
- q, r,
- qbuf, rbuf,
- samr_io_q_query_dispinfo,
- samr_io_r_query_dispinfo,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
+ result = r.status;
if (!NT_STATUS_IS_OK(result) &&
NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
@@ -1500,142 +1503,6 @@ NTSTATUS rpccli_samr_query_dispinfo2(struct rpc_pipe_client *cli,
return result;
}
-/* Query display info */
-
-NTSTATUS rpccli_samr_query_dispinfo3(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol, uint32 *start_idx,
- uint16 switch_value, uint32 *num_entries,
- uint32 max_entries, uint32 max_size,
- SAM_DISPINFO_CTR *ctr)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_QUERY_DISPINFO q;
- SAMR_R_QUERY_DISPINFO r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_query_dispinfo3 for start_idx = %u\n", *start_idx));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- *num_entries = 0;
-
- /* Marshall data and send request */
-
- init_samr_q_query_dispinfo(&q, domain_pol, switch_value,
- *start_idx, max_entries, max_size);
-
- r.ctr = ctr;
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_DISPINFO3,
- q, r,
- qbuf, rbuf,
- samr_io_q_query_dispinfo,
- samr_io_r_query_dispinfo,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
-
- if (!NT_STATUS_IS_OK(result) &&
- NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
- goto done;
- }
-
- *num_entries = r.num_entries;
- *start_idx += r.num_entries; /* No next_idx in this structure! */
-
- done:
- return result;
-}
-
-/* Query display info index */
-
-NTSTATUS rpccli_samr_get_dispenum_index(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol,
- uint16 switch_value,
- const char *name,
- uint32 *idx)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_GET_DISPENUM_INDEX q;
- SAMR_R_GET_DISPENUM_INDEX r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_get_dispenum_index for name = %s\n", name));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_get_dispenum_index(&q, domain_pol, switch_value, name);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_GET_DISPENUM_INDEX,
- q, r,
- qbuf, rbuf,
- samr_io_q_get_dispenum_index,
- samr_io_r_get_dispenum_index,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- *idx = 0;
-
- result = r.status;
-
- if (!NT_STATUS_IS_ERR(result)) {
- *idx = r.idx;
- }
-
- return result;
-}
-
-NTSTATUS rpccli_samr_get_dispenum_index2(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol,
- uint16 switch_value,
- const char *name,
- uint32 *idx)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_GET_DISPENUM_INDEX q;
- SAMR_R_GET_DISPENUM_INDEX r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_get_dispenum_index2 for name = %s\n", name));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_get_dispenum_index(&q, domain_pol, switch_value, name);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_GET_DISPENUM_INDEX2,
- q, r,
- qbuf, rbuf,
- samr_io_q_get_dispenum_index,
- samr_io_r_get_dispenum_index,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- *idx = 0;
-
- result = r.status;
-
- if (!NT_STATUS_IS_ERR(result)) {
- *idx = r.idx;
- }
-
- return result;
-}
-
-
/* Lookup rids. Note that NT4 seems to crash if more than ~1000 rids are
looked up in one packet. */
diff --git a/source/rpc_client/cli_shutdown.c b/source/rpc_client/cli_shutdown.c
new file mode 100644
index 00000000000..c06586e98ab
--- /dev/null
+++ b/source/rpc_client/cli_shutdown.c
@@ -0,0 +1,119 @@
+/*
+ Unix SMB/CIFS implementation.
+ RPC Pipe client
+
+ Copyright (C) Andrew Tridgell 1992-1998,
+ Largely rewritten by Jeremy Allison (C) 2005.
+ Copyright (C) Jim McDonough (jmcd@us.ibm.com) 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"
+
+/* Shutdown a server */
+
+NTSTATUS rpccli_shutdown_init(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ const char *msg, uint32 timeout, BOOL do_reboot,
+ BOOL force)
+{
+ prs_struct qbuf;
+ prs_struct rbuf;
+ SHUTDOWN_Q_INIT q;
+ SHUTDOWN_R_INIT r;
+ WERROR result = WERR_GENERAL_FAILURE;
+
+ if (msg == NULL)
+ return NT_STATUS_INVALID_PARAMETER;
+
+ ZERO_STRUCT (q);
+ ZERO_STRUCT (r);
+
+ /* Marshall data and send request */
+
+ init_shutdown_q_init(&q, msg, timeout, do_reboot, force);
+
+ CLI_DO_RPC(cli, mem_ctx, PI_SHUTDOWN, SHUTDOWN_INIT,
+ q, r,
+ qbuf, rbuf,
+ shutdown_io_q_init,
+ shutdown_io_r_init,
+ NT_STATUS_UNSUCCESSFUL);
+
+ result = r.status;
+ return werror_to_ntstatus(result);
+}
+
+/* Shutdown a server */
+
+NTSTATUS rpccli_shutdown_init_ex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ const char *msg, uint32 timeout, BOOL do_reboot,
+ BOOL force, uint32 reason)
+{
+ prs_struct qbuf;
+ prs_struct rbuf;
+ SHUTDOWN_Q_INIT_EX q;
+ SHUTDOWN_R_INIT_EX r;
+ WERROR result = WERR_GENERAL_FAILURE;
+
+ if (msg == NULL)
+ return NT_STATUS_INVALID_PARAMETER;
+
+ ZERO_STRUCT (q);
+ ZERO_STRUCT (r);
+
+ /* Marshall data and send request */
+
+ init_shutdown_q_init_ex(&q, msg, timeout, do_reboot, force, reason);
+
+ CLI_DO_RPC(cli, mem_ctx, PI_SHUTDOWN, SHUTDOWN_INIT_EX,
+ q, r,
+ qbuf, rbuf,
+ shutdown_io_q_init_ex,
+ shutdown_io_r_init_ex,
+ NT_STATUS_UNSUCCESSFUL);
+
+ result = r.status;
+ return werror_to_ntstatus(result);
+}
+
+
+/* Abort a server shutdown */
+
+NTSTATUS rpccli_shutdown_abort(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
+{
+ prs_struct rbuf;
+ prs_struct qbuf;
+ SHUTDOWN_Q_ABORT q;
+ SHUTDOWN_R_ABORT r;
+ WERROR result = WERR_GENERAL_FAILURE;
+
+ ZERO_STRUCT (q);
+ ZERO_STRUCT (r);
+
+ /* Marshall data and send request */
+
+ init_shutdown_q_abort(&q);
+
+ CLI_DO_RPC(cli, mem_ctx, PI_SHUTDOWN, SHUTDOWN_ABORT,
+ q, r,
+ qbuf, rbuf,
+ shutdown_io_q_abort,
+ shutdown_io_r_abort,
+ NT_STATUS_UNSUCCESSFUL);
+
+ result = r.status;
+ return werror_to_ntstatus(result);
+}
diff --git a/source/rpc_client/cli_srvsvc.c b/source/rpc_client/cli_srvsvc.c
new file mode 100644
index 00000000000..e471de7c3ba
--- /dev/null
+++ b/source/rpc_client/cli_srvsvc.c
@@ -0,0 +1,617 @@
+/*
+ Unix SMB/CIFS implementation.
+ NT Domain Authentication SMB / MSRPC client
+ Copyright (C) Andrew Tridgell 1994-2000
+ Copyright (C) Tim Potter 2001
+ Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002
+ Copyright (C) Jeremy Allison 2005.
+ Copyright (C) Gerald (Jerry) Carter 2006.
+
+
+ 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"
+
+WERROR rpccli_srvsvc_net_srv_get_info(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ uint32 switch_value, SRV_INFO_CTR *ctr)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_SRV_GET_INFO q;
+ SRV_R_NET_SRV_GET_INFO r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise input parameters */
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server);
+
+ init_srv_q_net_srv_get_info(&q, server, switch_value);
+ r.ctr = ctr;
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SRV_GET_INFO,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_srv_get_info,
+ srv_io_r_net_srv_get_info,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+ return result;
+}
+
+WERROR rpccli_srvsvc_net_share_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ uint32 info_level, SRV_SHARE_INFO_CTR *ctr,
+ int preferred_len, ENUM_HND *hnd)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_SHARE_ENUM q;
+ SRV_R_NET_SHARE_ENUM r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server;
+ int i;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise input parameters */
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server);
+
+ init_srv_q_net_share_enum(&q, server, info_level, preferred_len, hnd);
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_ENUM_ALL,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_share_enum,
+ srv_io_r_net_share_enum,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+
+ if (!W_ERROR_IS_OK(result))
+ goto done;
+
+ /* Oh yuck yuck yuck - we have to copy all the info out of the
+ SRV_SHARE_INFO_CTR in the SRV_R_NET_SHARE_ENUM as when we do a
+ prs_mem_free() it will all be invalidated. The various share
+ info structures suck badly too. This really is gross. */
+
+ ZERO_STRUCTP(ctr);
+
+ if (!r.ctr.num_entries)
+ goto done;
+
+ ctr->info_level = info_level;
+ ctr->num_entries = r.ctr.num_entries;
+
+ switch(info_level) {
+ case 1:
+ ctr->share.info1 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_1, ctr->num_entries);
+ if (ctr->share.info1 == NULL) {
+ return WERR_NOMEM;
+ }
+
+ memset(ctr->share.info1, 0, sizeof(SRV_SHARE_INFO_1));
+
+ for (i = 0; i < ctr->num_entries; i++) {
+ SRV_SHARE_INFO_1 *info1 = &ctr->share.info1[i];
+ char *s;
+
+ /* Copy pointer crap */
+
+ memcpy(&info1->info_1, &r.ctr.share.info1[i].info_1,
+ sizeof(SH_INFO_1));
+
+ /* Duplicate strings */
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info1[i].info_1_str.uni_netname);
+ if (s)
+ init_unistr2(&info1->info_1_str.uni_netname, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info1[i].info_1_str.uni_remark);
+ if (s)
+ init_unistr2(&info1->info_1_str.uni_remark, s, UNI_STR_TERMINATE);
+
+ }
+
+ break;
+ case 2:
+ ctr->share.info2 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_2, ctr->num_entries);
+ if (ctr->share.info2 == NULL) {
+ return WERR_NOMEM;
+ }
+
+ memset(ctr->share.info2, 0, sizeof(SRV_SHARE_INFO_2));
+
+ for (i = 0; i < ctr->num_entries; i++) {
+ SRV_SHARE_INFO_2 *info2 = &ctr->share.info2[i];
+ char *s;
+
+ /* Copy pointer crap */
+
+ memcpy(&info2->info_2, &r.ctr.share.info2[i].info_2,
+ sizeof(SH_INFO_2));
+
+ /* Duplicate strings */
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_netname);
+ if (s)
+ init_unistr2(&info2->info_2_str.uni_netname, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_remark);
+ if (s)
+ init_unistr2(&info2->info_2_str.uni_remark, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_path);
+ if (s)
+ init_unistr2(&info2->info_2_str.uni_path, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_passwd);
+ if (s)
+ init_unistr2(&info2->info_2_str.uni_passwd, s, UNI_STR_TERMINATE);
+ }
+ break;
+ /* adding info-level 502 here */
+ case 502:
+ ctr->share.info502 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_502, ctr->num_entries);
+
+ if (ctr->share.info502 == NULL) {
+ return WERR_NOMEM;
+ }
+
+ memset(ctr->share.info502, 0, sizeof(SRV_SHARE_INFO_502));
+
+ for (i = 0; i < ctr->num_entries; i++) {
+ SRV_SHARE_INFO_502 *info502 = &ctr->share.info502[i];
+ char *s;
+
+ /* Copy pointer crap */
+ memcpy(&info502->info_502, &r.ctr.share.info502[i].info_502,
+ sizeof(SH_INFO_502));
+
+ /* Duplicate strings */
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_netname);
+ if (s)
+ init_unistr2(&info502->info_502_str.uni_netname, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_remark);
+ if (s)
+ init_unistr2(&info502->info_502_str.uni_remark, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_path);
+ if (s)
+ init_unistr2(&info502->info_502_str.uni_path, s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_passwd);
+ if (s)
+ init_unistr2(&info502->info_502_str.uni_passwd, s, UNI_STR_TERMINATE);
+
+ info502->info_502_str.sd = dup_sec_desc(mem_ctx, r.ctr.share.info502[i].info_502_str.sd);
+ }
+ break;
+ }
+
+ done:
+
+ return result;
+}
+
+WERROR rpccli_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ const char *sharename,
+ uint32 info_level,
+ SRV_SHARE_INFO *info)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_SHARE_GET_INFO q;
+ SRV_R_NET_SHARE_GET_INFO r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise input parameters */
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server);
+
+ init_srv_q_net_share_get_info(&q, server, sharename, info_level);
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_GET_INFO,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_share_get_info,
+ srv_io_r_net_share_get_info,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+
+ if (!W_ERROR_IS_OK(result))
+ goto done;
+
+ ZERO_STRUCTP(info);
+
+ info->switch_value = info_level;
+
+ switch(info_level) {
+ case 1:
+ {
+ SRV_SHARE_INFO_1 *info1 = &info->share.info1;
+ SH_INFO_1_STR *info1_str = &info1->info_1_str;
+
+ char *s;
+
+ info->share.info1 = r.info.share.info1;
+
+ /* Duplicate strings */
+
+ s = unistr2_tdup(mem_ctx, &info1_str->uni_netname);
+ if (s)
+ init_unistr2(&info1_str->uni_netname,
+ s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info1_str->uni_remark);
+ if (s)
+ init_unistr2(&info1_str->uni_remark,
+ s, UNI_STR_TERMINATE);
+
+ break;
+ }
+ case 2:
+ {
+ SRV_SHARE_INFO_2 *info2 = &info->share.info2;
+ SH_INFO_2_STR *info2_str = &info2->info_2_str;
+
+ char *s;
+
+ info->share.info2 = r.info.share.info2;
+
+ /* Duplicate strings */
+
+ s = unistr2_tdup(mem_ctx, &info2_str->uni_netname);
+ if (s)
+ init_unistr2(&info2_str->uni_netname,
+ s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info2_str->uni_remark);
+ if (s)
+ init_unistr2(&info2_str->uni_remark,
+ s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info2_str->uni_path);
+ if (s)
+ init_unistr2(&info2_str->uni_path,
+ s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info2_str->uni_passwd);
+ if (s)
+ init_unistr2(&info2_str->uni_passwd,
+ s, UNI_STR_TERMINATE);
+
+
+ break;
+ }
+ case 502:
+ {
+ SRV_SHARE_INFO_502 *info502 = &info->share.info502;
+ SH_INFO_502_STR *info502_str = &info502->info_502_str;
+
+ char *s;
+
+ info->share.info502 = r.info.share.info502;
+
+ /* Duplicate strings */
+
+ s = unistr2_tdup(mem_ctx, &info502_str->uni_netname);
+ if (s)
+ init_unistr2(&info502_str->uni_netname,
+ s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info502_str->uni_remark);
+ if (s)
+ init_unistr2(&info502_str->uni_remark,
+ s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info502_str->uni_path);
+ if (s)
+ init_unistr2(&info502_str->uni_path,
+ s, UNI_STR_TERMINATE);
+
+ s = unistr2_tdup(mem_ctx, &info502_str->uni_passwd);
+ if (s)
+ init_unistr2(&info502_str->uni_passwd,
+ s, UNI_STR_TERMINATE);
+
+ info502_str->sd = dup_sec_desc(mem_ctx, info502_str->sd);
+ break;
+ }
+ default:
+ DEBUG(0,("unimplemented info-level: %d\n", info_level));
+ break;
+ }
+
+ done:
+
+ return result;
+}
+
+WERROR rpccli_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ const char *sharename,
+ uint32 info_level,
+ SRV_SHARE_INFO *info)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_SHARE_SET_INFO q;
+ SRV_R_NET_SHARE_SET_INFO r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise input parameters */
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server);
+
+ init_srv_q_net_share_set_info(&q, server, sharename, info_level, info);
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_SET_INFO,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_share_set_info,
+ srv_io_r_net_share_set_info,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+ return result;
+}
+
+WERROR rpccli_srvsvc_net_share_del(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ const char *sharename)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_SHARE_DEL q;
+ SRV_R_NET_SHARE_DEL r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise input parameters */
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server);
+
+ init_srv_q_net_share_del(&q, server, sharename);
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_DEL,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_share_del,
+ srv_io_r_net_share_del,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+ return result;
+}
+
+WERROR rpccli_srvsvc_net_share_add(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ const char *netname, uint32 type,
+ const char *remark, uint32 perms,
+ uint32 max_uses, uint32 num_uses,
+ const char *path, const char *passwd,
+ int level, SEC_DESC *sd)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_SHARE_ADD q;
+ SRV_R_NET_SHARE_ADD r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server);
+
+ init_srv_q_net_share_add(&q,server, netname, type, remark,
+ perms, max_uses, num_uses, path, passwd,
+ level, sd);
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_ADD,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_share_add,
+ srv_io_r_net_share_add,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+ return result;
+}
+
+WERROR rpccli_srvsvc_net_remote_tod(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ char *server, TIME_OF_DAY_INFO *tod)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_REMOTE_TOD q;
+ SRV_R_NET_REMOTE_TOD r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server_slash;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise input parameters */
+
+ slprintf(server_slash, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server_slash);
+
+ init_srv_q_net_remote_tod(&q, server_slash);
+ r.tod = tod;
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_REMOTE_TOD,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_remote_tod,
+ srv_io_r_net_remote_tod,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+ return result;
+}
+
+WERROR rpccli_srvsvc_net_file_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ uint32 file_level, const char *user_name,
+ SRV_FILE_INFO_CTR *ctr, int preferred_len,
+ ENUM_HND *hnd)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_FILE_ENUM q;
+ SRV_R_NET_FILE_ENUM r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server;
+ int i;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise input parameters */
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server);
+
+ init_srv_q_net_file_enum(&q, server, NULL, user_name,
+ file_level, ctr, preferred_len, hnd);
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_FILE_ENUM,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_file_enum,
+ srv_io_r_net_file_enum,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+
+ if (!W_ERROR_IS_OK(result))
+ goto done;
+
+ /* copy the data over to the ctr */
+
+ ZERO_STRUCTP(ctr);
+
+ ctr->level = file_level;
+
+ ctr->num_entries = ctr->num_entries2 = r.ctr.num_entries;
+
+ switch(file_level) {
+ case 3:
+ if (ctr->num_entries) {
+ if ( (ctr->file.info3 = TALLOC_ARRAY(mem_ctx, FILE_INFO_3, ctr->num_entries)) == NULL ) {
+ return WERR_NOMEM;
+ }
+
+ memset(ctr->file.info3, 0, sizeof(FILE_INFO_3) * ctr->num_entries);
+ } else {
+ ctr->file.info3 = NULL;
+ }
+
+ for (i = 0; i < r.ctr.num_entries; i++) {
+ FILE_INFO_3 *info3 = &ctr->file.info3[i];
+ char *s;
+
+ /* Copy pointer crap */
+
+ memcpy(info3, &r.ctr.file.info3[i], sizeof(FILE_INFO_3));
+
+ /* Duplicate strings */
+
+ if ( (s = unistr2_tdup(mem_ctx, r.ctr.file.info3[i].path)) != NULL ) {
+ info3->path = TALLOC_P( mem_ctx, UNISTR2 );
+ init_unistr2(info3->path, s, UNI_STR_TERMINATE);
+ }
+
+ if ( (s = unistr2_tdup(mem_ctx, r.ctr.file.info3[i].user)) != NULL ) {
+ info3->user = TALLOC_P( mem_ctx, UNISTR2 );
+ init_unistr2(info3->user, s, UNI_STR_TERMINATE);
+ }
+
+ }
+
+ break;
+ }
+
+ done:
+ return result;
+}
+
+WERROR rpccli_srvsvc_net_file_close(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ uint32 file_id)
+{
+ prs_struct qbuf, rbuf;
+ SRV_Q_NET_FILE_CLOSE q;
+ SRV_R_NET_FILE_CLOSE r;
+ WERROR result = W_ERROR(ERRgeneral);
+ fstring server;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise input parameters */
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
+ strupper_m(server);
+
+ init_srv_q_net_file_close(&q, server, file_id);
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_FILE_CLOSE,
+ q, r,
+ qbuf, rbuf,
+ srv_io_q_net_file_close,
+ srv_io_r_net_file_close,
+ WERR_GENERAL_FAILURE);
+
+ result = r.status;
+ return result;
+}
diff --git a/source/rpc_client/cli_svcctl.c b/source/rpc_client/cli_svcctl.c
index 021648ba1c5..d183670f5fb 100644
--- a/source/rpc_client/cli_svcctl.c
+++ b/source/rpc_client/cli_svcctl.c
@@ -133,6 +133,30 @@ WERROR rpccli_svcctl_open_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_
return out.status;
}
+/********************************************************************
+********************************************************************/
+
+WERROR rpccli_svcctl_close_service(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService )
+{
+ SVCCTL_Q_CLOSE_SERVICE in;
+ SVCCTL_R_CLOSE_SERVICE out;
+ prs_struct qbuf, rbuf;
+
+ ZERO_STRUCT(in);
+ ZERO_STRUCT(out);
+
+ memcpy( &in.handle, hService, sizeof(POLICY_HND) );
+
+ CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_CLOSE_SERVICE,
+ in, out,
+ qbuf, rbuf,
+ svcctl_io_q_close_service,
+ svcctl_io_r_close_service,
+ WERR_GENERAL_FAILURE );
+
+ return out.status;
+}
+
/*******************************************************************
*******************************************************************/