summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-09-10 10:34:28 +0200
committerGünther Deschner <gd@samba.org>2008-09-11 14:38:22 +0200
commitcf1e3e557957ab8af907eada89ee0e84bc63ff61 (patch)
tree9b3303e2f4a1250be77755aefdf6c648d1efc861 /source3/utils
parente10a7af3c652ecd4c3213b5251e188538d0d41d3 (diff)
downloadsamba-cf1e3e557957ab8af907eada89ee0e84bc63ff61.tar.gz
samba-cf1e3e557957ab8af907eada89ee0e84bc63ff61.tar.bz2
samba-cf1e3e557957ab8af907eada89ee0e84bc63ff61.zip
net: use netapi for NetFileEnum.
Guenther (This used to be commit f85dcf8112137b7ad07f2b51eeca598e9c4d0ffa)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_rpc.c100
1 files changed, 32 insertions, 68 deletions
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index c584b54e9e..a849ec4c10 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -4740,72 +4740,58 @@ static int rpc_file_close(struct net_context *c, int argc, const char **argv)
/**
* Formatted print of open file info
*
- * @param r struct srvsvc_NetFileInfo3 contents
+ * @param r struct FILE_INFO_3 contents
**/
-static void display_file_info_3(struct srvsvc_NetFileInfo3 *r)
+static void display_file_info_3(struct FILE_INFO_3 *r)
{
d_printf("%-7.1d %-20.20s 0x%-4.2x %-6.1d %s\n",
- r->fid, r->user, r->permissions, r->num_locks, r->path);
+ r->fi3_id, r->fi3_username, r->fi3_permissions,
+ r->fi3_num_locks, r->fi3_pathname);
}
/**
- * List open files on a remote RPC server.
- *
- * All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passed through.
+ * List files for a user on a remote RPC server.
*
- * @param c A net_context structure.
- * @param domain_sid The domain sid acquired from the remote server.
- * @param cli A cli_state connected to the server.
- * @param mem_ctx Talloc context, destroyed on completion of the function.
* @param argc Standard main() style argc.
* @param argv Standard main() style argv. Initial components are already
* stripped.
*
- * @return Normal NTSTATUS return.
+ * @return A shell status integer (0 for success)..
**/
-static NTSTATUS rpc_file_list_internals(struct net_context *c,
- const DOM_SID *domain_sid,
- const char *domain_name,
- struct cli_state *cli,
- struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
- int argc,
- const char **argv)
+static int rpc_file_user(struct net_context *c, int argc, const char **argv)
{
- struct srvsvc_NetFileInfoCtr info_ctr;
- struct srvsvc_NetFileCtr3 ctr3;
- WERROR result;
- NTSTATUS status;
+ NET_API_STATUS status;
uint32 preferred_len = 0xffffffff, i;
const char *username=NULL;
uint32_t total_entries = 0;
+ uint32_t entries_read = 0;
uint32_t resume_handle = 0;
+ struct FILE_INFO_3 *i3 = NULL;
+
+ if (c->display_usage) {
+ return rpc_file_usage(c, argc, argv);
+ }
/* if argc > 0, must be user command */
- if (argc > 0)
+ if (argc > 0) {
username = smb_xstrdup(argv[0]);
+ }
- ZERO_STRUCT(info_ctr);
- ZERO_STRUCT(ctr3);
-
- info_ctr.level = 3;
- info_ctr.ctr.ctr3 = &ctr3;
-
- status = rpccli_srvsvc_NetFileEnum(pipe_hnd, mem_ctx,
- pipe_hnd->desthost,
- NULL,
- username,
- &info_ctr,
- preferred_len,
- &total_entries,
- &resume_handle,
- &result);
+ status = NetFileEnum(c->opt_host,
+ NULL,
+ username,
+ 3,
+ (uint8_t **)&i3,
+ preferred_len,
+ &entries_read,
+ &total_entries,
+ &resume_handle);
- if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result))
+ if (status != 0) {
goto done;
+ }
/* Display results */
@@ -4813,31 +4799,11 @@ static NTSTATUS rpc_file_list_internals(struct net_context *c,
"\nEnumerating open files on remote server:\n\n"
"\nFileId Opened by Perms Locks Path"
"\n------ --------- ----- ----- ---- \n");
- for (i = 0; i < total_entries; i++)
- display_file_info_3(&info_ctr.ctr.ctr3->array[i]);
- done:
- return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
-}
-
-/**
- * List files for a user on a remote RPC server.
- *
- * @param argc Standard main() style argc.
- * @param argv Standard main() style argv. Initial components are already
- * stripped.
- *
- * @return A shell status integer (0 for success)..
- **/
-
-static int rpc_file_user(struct net_context *c, int argc, const char **argv)
-{
- if (argc < 1 || c->display_usage) {
- return rpc_file_usage(c, argc, argv);
+ for (i = 0; i < entries_read; i++) {
+ display_file_info_3(&i3[i]);
}
-
- return run_rpc_command(c, NULL, &ndr_table_srvsvc.syntax_id, 0,
- rpc_file_list_internals,
- argc, argv);
+ done:
+ return status;
}
/**
@@ -4900,9 +4866,7 @@ int net_rpc_file(struct net_context *c, int argc, const char **argv)
return 0;
}
- return run_rpc_command(c, NULL, &ndr_table_srvsvc.syntax_id, 0,
- rpc_file_list_internals,
- argc, argv);
+ return rpc_file_user(c, argc, argv);
}
return net_run_function(c, argc, argv, "net rpc file", func);