Added netremotetod to try and figure out which srvsvc commands are denied
authorTim Potter <tpot@samba.org>
Wed, 29 May 2002 01:43:44 +0000 (01:43 +0000)
committerTim Potter <tpot@samba.org>
Wed, 29 May 2002 01:43:44 +0000 (01:43 +0000)
when using restrictanonymous.

source/libsmb/cli_srvsvc.c
source/rpc_parse/parse_srv.c
source/rpcclient/cmd_srvsvc.c

index f3d012434e2859e6b0943af2521a92bcc98c4450..9e2f5a3686db5294cf975d28109727e9d75248a3 100644 (file)
@@ -188,3 +188,48 @@ WERROR cli_srvsvc_net_share_enum(struct cli_state *cli, TALLOC_CTX *mem_ctx,
 
        return result;
 }
+
+WERROR cli_srvsvc_net_remote_tod(struct cli_state *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);
+
+       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_remote_tod(&q, cli->srv_name_slash);
+
+       /* Marshall data and send request */
+
+       if (!srv_io_q_net_remote_tod("", &q, &qbuf, 0) ||
+           !rpc_api_pipe_req(cli, SRV_NET_REMOTE_TOD, &qbuf, &rbuf))
+               goto done;
+
+       /* Unmarshall response */
+
+       r.tod = tod;
+
+       if (!srv_io_r_net_remote_tod("", &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 f469b479238a5c52d7839ea143c967d898fa9e00..79cf0d9776aa71070de189df13127b06b4949420 100644 (file)
@@ -2909,3 +2909,14 @@ BOOL srv_io_r_net_file_set_secdesc(char *desc, SRV_R_NET_FILE_SET_SECDESC *r_n,
 
        return True;
 }
+
+/*******************************************************************
+ Inits a structure
+********************************************************************/
+
+void init_srv_q_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_u, char *server)
+{
+       q_u->ptr_srv_name = 1;
+       init_unistr2(&q_u->uni_srv_name, server, strlen(server) + 1);
+}
+
index c02dfd4573a3aefb2aed116c98a2468426bf47d5..88ebdb207dc997a934982b4c6b818112a4b4a237 100644 (file)
@@ -293,6 +293,28 @@ static NTSTATUS cmd_srvsvc_net_share_enum(struct cli_state *cli,
        return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
 }
 
+static NTSTATUS cmd_srvsvc_net_remote_tod(struct cli_state *cli, 
+                                          TALLOC_CTX *mem_ctx,
+                                          int argc, char **argv)
+{
+       TIME_OF_DAY_INFO tod;
+       WERROR result;
+
+       if (argc > 1) {
+               printf("Usage: %s\n", argv[0]);
+               return NT_STATUS_OK;
+       }
+
+       result = cli_srvsvc_net_remote_tod(
+               cli, mem_ctx, cli->srv_name_slash, &tod);
+
+       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[] = {
@@ -301,6 +323,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", "" },
+       { "netremotetod", cmd_srvsvc_net_remote_tod, PIPE_SRVSVC, "Fetch remote time of day", "" },
 
        { NULL }
 };