Added netfileenum (sorry - no output though (-:) command.
authorTim Potter <tpot@samba.org>
Thu, 30 May 2002 07:12:32 +0000 (07:12 +0000)
committerTim Potter <tpot@samba.org>
Thu, 30 May 2002 07:12:32 +0000 (07:12 +0000)
(This used to be commit 099b750b4ed8f04a1fd8a018508d412691e37df6)

source3/libsmb/cli_srvsvc.c
source3/rpcclient/cmd_srvsvc.c

index 9e2f5a3686db5294cf975d28109727e9d75248a3..bc2058fdbdab251573fd6e85e799eef9dfb0471c 100644 (file)
@@ -233,3 +233,48 @@ WERROR cli_srvsvc_net_remote_tod(struct cli_state *cli, TALLOC_CTX *mem_ctx,
 
        return result;  
 }
+
+WERROR cli_srvsvc_net_file_enum(struct cli_state *cli, TALLOC_CTX *mem_ctx,
+                               uint32 file_level, 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);
+
+       ZERO_STRUCT(q);
+       ZERO_STRUCT(r);
+
+       /* Initialise parse structures */
+
+       prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+       prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
+
+       /* Initialise input parameters */
+
+       init_srv_q_net_file_enum(&q, cli->srv_name_slash, NULL, file_level,
+                                ctr, preferred_len, hnd);
+
+       /* Marshall data and send request */
+
+       if (!srv_io_q_net_file_enum("", &q, &qbuf, 0) ||
+           !rpc_api_pipe_req(cli, SRV_NET_FILE_ENUM, &qbuf, &rbuf))
+               goto done;
+
+       /* Unmarshall response */
+
+       if (!srv_io_r_net_file_enum("", &r, &rbuf, 0))
+               goto done;
+
+       result = r.status;
+
+       if (!W_ERROR_IS_OK(result))
+               goto done;
+
+ done:
+       prs_mem_free(&qbuf);
+       prs_mem_free(&rbuf);
+
+       return result;
+}
index 88ebdb207dc997a934982b4c6b818112a4b4a237..09bb7856655bfcd350b35b3822675b12f48baac4 100644 (file)
@@ -315,6 +315,38 @@ static NTSTATUS cmd_srvsvc_net_remote_tod(struct cli_state *cli,
        return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
 }
 
+static NTSTATUS cmd_srvsvc_net_file_enum(struct cli_state *cli, 
+                                        TALLOC_CTX *mem_ctx,
+                                        int argc, char **argv)
+{
+       uint32 info_level = 3;
+       SRV_FILE_INFO_CTR ctr;
+       WERROR result;
+       ENUM_HND hnd;
+       uint32 preferred_len = 0;
+
+       if (argc > 2) {
+               printf("Usage: %s [infolevel]\n", argv[0]);
+               return NT_STATUS_OK;
+       }
+
+       if (argc == 2)
+               info_level = atoi(argv[1]);
+
+       init_enum_hnd(&hnd, 0);
+
+       ZERO_STRUCT(ctr);
+
+       result = cli_srvsvc_net_file_enum(
+               cli, mem_ctx, 0, &ctr, preferred_len, &hnd);
+
+       if (!W_ERROR_IS_OK(result))
+               goto done;
+
+ done:
+       return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
+}
+
 /* List of commands exported by this module */
 
 struct cmd_set srvsvc_commands[] = {
@@ -323,6 +355,7 @@ struct cmd_set srvsvc_commands[] = {
 
        { "srvinfo",    cmd_srvsvc_srv_query_info,  PIPE_SRVSVC, "Server query info", "" },
        { "netshareenum", cmd_srvsvc_net_share_enum, PIPE_SRVSVC, "Enumerate shares", "" },
+       { "netfileenum", cmd_srvsvc_net_file_enum, PIPE_SRVSVC, "Enumerate open files", "" },
        { "netremotetod", cmd_srvsvc_net_remote_tod, PIPE_SRVSVC, "Fetch remote time of day", "" },
 
        { NULL }