summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h10
-rw-r--r--source3/rpc_client/cli_svcctl.c58
-rw-r--r--source3/rpcclient/cmd_svcctl.c85
-rw-r--r--source3/rpcclient/rpcclient.c7
4 files changed, 156 insertions, 4 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 204d5e0e0c..df06ac2e9d 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2136,6 +2136,11 @@ BOOL svc_query_svc_cfg(struct cli_state *cli, uint16 fnum,
QUERY_SERVICE_CONFIG *cfg,
uint32 *buf_size);
BOOL svc_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd);
+BOOL svc_query_unknown_1b(struct cli_state *cli, uint16 fnum,
+ const POLICY_HND *pol, uint32 switch_value,
+ uint32 unknown_1,
+ uint32 *num_items,
+ uint32 ***items);
/*The following definitions come from rpc_client/cli_wkssvc.c */
@@ -3398,7 +3403,7 @@ BOOL make_svc_q_start_service(SVC_Q_START_SERVICE *q_c, POLICY_HND *hnd,
BOOL svc_io_q_start_service(char *desc, SVC_Q_START_SERVICE *q_s, prs_struct *ps, int depth);
BOOL svc_io_r_start_service(char *desc, SVC_R_START_SERVICE *r_s, prs_struct *ps, int depth);
BOOL make_svc_query_svc_cfg(QUERY_SERVICE_CONFIG *q_u,
- uint32 service_item, uint32 start_item,
+ uint32 service_type, uint32 start_type,
uint32 error_control,
char* bin_path_name, char* load_order_grp,
uint32 tag_id,
@@ -3406,7 +3411,7 @@ BOOL make_svc_query_svc_cfg(QUERY_SERVICE_CONFIG *q_u,
char* disp_name);
BOOL svc_io_query_svc_cfg(char *desc, QUERY_SERVICE_CONFIG *q_u, prs_struct *ps, int depth);
BOOL make_svc_q_enum_svcs_status(SVC_Q_ENUM_SVCS_STATUS *q_c, POLICY_HND *hnd,
- uint32 service_item, uint32 service_state,
+ uint32 service_type, uint32 service_state,
uint32 buf_size, uint32 resume_hnd );
BOOL svc_io_q_enum_svcs_status(char *desc, SVC_Q_ENUM_SVCS_STATUS *q_u, prs_struct *ps, int depth);
BOOL make_svc_r_enum_svcs_status(SVC_R_ENUM_SVCS_STATUS *r_c,
@@ -3676,6 +3681,7 @@ BOOL msrpc_svc_enum(struct client_info *info,
void cmd_svc_enum(struct client_info *info, int argc, char *argv[]);
void cmd_svc_stop(struct client_info *info, int argc, char *argv[]);
void cmd_svc_start(struct client_info *info, int argc, char *argv[]);
+void cmd_svc_test(struct client_info *info, int argc, char *argv[]);
/*The following definitions come from rpcclient/cmd_wkssvc.c */
diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c
index e09cd4ec12..bba6342db8 100644
--- a/source3/rpc_client/cli_svcctl.c
+++ b/source3/rpc_client/cli_svcctl.c
@@ -478,4 +478,62 @@ BOOL svc_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd)
return valid_close;
}
+/****************************************************************************
+do a SVC Query Lookup RIDS
+****************************************************************************/
+BOOL svc_query_unknown_1b(struct cli_state *cli, uint16 fnum,
+ const POLICY_HND *pol, uint32 switch_value,
+ uint32 unknown_1,
+ uint32 *num_items,
+ uint32 ***items)
+{
+ prs_struct data;
+ prs_struct rdata;
+
+ SVC_Q_UNKNOWN_1B q_o;
+ BOOL valid_query = False;
+
+ if (pol == NULL || num_items == NULL || items == NULL ) return False;
+
+ /* create and send a MSRPC command with api SVC_UNKNOWN_1B */
+
+ prs_init(&data , 1024, 4, SAFETY_MARGIN, False);
+ prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
+
+ DEBUG(4,("SVC Query Unknown 1b.\n"));
+
+ /* store the parameters */
+ make_svc_q_unknown_1b(&q_o, pol, switch_value, unknown_1);
+
+ /* turn parameters into data stream */
+ svc_io_q_unknown_1b("", &q_o, &data, 0);
+
+ /* send the data on \PIPE\ */
+ if (rpc_api_pipe_req(cli, fnum, SVC_UNKNOWN_1B, &data, &rdata))
+ {
+ SVC_R_UNKNOWN_1B r_o;
+ BOOL p;
+ ZERO_STRUCT(r_o);
+
+ svc_io_r_unknown_1b("", &r_o, &rdata, 0);
+ p = rdata.offset != 0;
+
+ if (p && r_o.status != 0)
+ {
+ /* report error code */
+ DEBUG(4,("SVC_R_UNKNOWN_1B: %s\n", get_nt_error_msg(r_o.status)));
+ p = False;
+ }
+ if (p)
+ {
+ (*num_items) = r_o.num_items1;
+ (*items) = r_o.items;
+ }
+ }
+
+ prs_mem_free(&data );
+ prs_mem_free(&rdata );
+
+ return valid_query;
+}
diff --git a/source3/rpcclient/cmd_svcctl.c b/source3/rpcclient/cmd_svcctl.c
index 9e9e3c82bb..6d2311b962 100644
--- a/source3/rpcclient/cmd_svcctl.c
+++ b/source3/rpcclient/cmd_svcctl.c
@@ -341,12 +341,12 @@ void cmd_svc_start(struct client_info *info, int argc, char *argv[])
return;
}
- argc++;
+ argv++;
argc--;
svc_name = argv[0];
- argc++;
+ argv++;
argc--;
/* open SVCCTL session. */
@@ -382,3 +382,84 @@ void cmd_svc_start(struct client_info *info, int argc, char *argv[])
}
}
+/****************************************************************************
+nt test service
+****************************************************************************/
+void cmd_svc_test(struct client_info *info, int argc, char *argv[])
+{
+ uint16 fnum;
+ BOOL res = True;
+ BOOL res1 = True;
+ char *svc_name;
+ BOOL res2 = True;
+ POLICY_HND pol_svc;
+ POLICY_HND pol_scm;
+ uint32 num_items = 0;
+ uint32 **items = NULL;
+
+ fstring srv_name;
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->myhostname);
+ strupper(srv_name);
+
+ DEBUG(4,("cmd_svc_test: server:%s\n", srv_name));
+
+ if (argc < 2)
+ {
+ report(out_hnd,"svctest <service name>]\n");
+ return;
+ }
+
+ argv++;
+ argc--;
+
+ svc_name = argv[0];
+
+ argv++;
+ argc--;
+
+ /* open SVCCTL session. */
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SVCCTL, &fnum) : False;
+
+ /* open service control manager receive a policy handle */
+ res = res ? svc_open_sc_man(smb_cli, fnum,
+ srv_name, NULL, 0x80000000,
+ &pol_scm) : False;
+
+ res1 = res ? svc_open_service(smb_cli, fnum,
+ &pol_scm,
+ svc_name, 0x80000010,
+ &pol_svc) : False;
+ res2 = res1 ? svc_query_unknown_1b(smb_cli, fnum,
+ &pol_svc, 1, 0x227,
+ &num_items, &items) : False;
+
+ res1 = res1 ? svc_close(smb_cli, fnum, &pol_svc) : False;
+ res = res ? svc_close(smb_cli, fnum, &pol_scm) : False;
+
+ /* close the session */
+ cli_nt_session_close(smb_cli, fnum);
+
+ if (res2)
+ {
+ uint32 i;
+ report(out_hnd,"Test 0x1b Service %s\n", svc_name);
+ for (i = 0; i < num_items; i++)
+ {
+ if (items[i] != NULL)
+ {
+ report(out_hnd, "%x\n", *items[i]);
+ }
+ }
+ DEBUG(5,("cmd_svc_test: succeeded\n"));
+ }
+ else
+ report(out_hnd,"Failed Test 0x1b (%s)\n", svc_name);
+ {
+ DEBUG(5,("cmd_svc_test: failed\n"));
+ }
+
+ free_uint32_array(num_items, items);
+}
+
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 33890749ea..de0f72c65d 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -158,6 +158,13 @@ commands[] =
},
{
+ "svctest",
+ cmd_svc_test,
+ "<service> Test Service",
+ {COMPL_SVCLST, COMPL_NONE}
+ },
+
+ {
"svcstop",
cmd_svc_stop,
"<service> Stop Service",