diff options
-rw-r--r-- | source3/include/proto.h | 34 | ||||
-rw-r--r-- | source3/lib/util_hnd.c | 1 | ||||
-rw-r--r-- | source3/rpc_client/cli_svcctl.c | 98 | ||||
-rw-r--r-- | source3/rpc_parse/parse_svc.c | 2 | ||||
-rw-r--r-- | source3/rpc_server/srv_lsa_hnd.c | 1 | ||||
-rw-r--r-- | source3/rpcclient/cmd_svcctl.c | 129 | ||||
-rw-r--r-- | source3/rpcclient/rpcclient.c | 8 |
7 files changed, 141 insertions, 132 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 475c1a2bac..f986cc7c2d 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -481,7 +481,8 @@ int set_maxfiles(int requested_max); void reg_get_subkey(char *full_keyname, char *key_name, char *subkey_name); BOOL reg_split_key(const char *full_keyname, uint32 *reg_type, char *key_name); BOOL become_user_permanently(uid_t uid, gid_t gid); -BOOL resolve_srv_name(const char* srv_name, fstring dest_host, struct in_addr *ip); +BOOL resolve_srv_name(const char* srv_name, fstring dest_host, + struct in_addr *ip); /*The following definitions come from lib/util_array.c */ @@ -2137,35 +2138,28 @@ BOOL do_srv_net_remote_tod(struct cli_state *cli, uint16 fnum, /*The following definitions come from rpc_client/cli_svcctl.c */ -BOOL svc_open_sc_man(struct cli_state *cli, uint16 fnum, - char *srv_name, char *db_name, +BOOL svc_open_sc_man( const char *srv_name, char *db_name, uint32 des_access, POLICY_HND *hnd); -BOOL svc_open_service(struct cli_state *cli, uint16 fnum, - POLICY_HND *scm_hnd, +BOOL svc_open_service( POLICY_HND *scm_hnd, const char *srv_name, uint32 des_access, POLICY_HND *hnd); -BOOL svc_enum_svcs(struct cli_state *cli, uint16 fnum, - POLICY_HND *hnd, +BOOL svc_enum_svcs( POLICY_HND *hnd, uint32 services_type, uint32 services_state, uint32 *buf_size, uint32 *resume_hnd, uint32 *dos_error, ENUM_SRVC_STATUS **svcs, uint32 *num_svcs); -BOOL svc_stop_service(struct cli_state *cli, uint16 fnum, - POLICY_HND *hnd, +BOOL svc_stop_service( POLICY_HND *hnd, uint32 unknown); -BOOL svc_start_service(struct cli_state *cli, uint16 fnum, - POLICY_HND *hnd, +BOOL svc_start_service( POLICY_HND *hnd, uint32 argc, char **argv); -BOOL svc_query_svc_cfg(struct cli_state *cli, uint16 fnum, - POLICY_HND *hnd, +BOOL svc_query_svc_cfg( POLICY_HND *hnd, QUERY_SERVICE_CONFIG *cfg, uint32 *buf_size); -BOOL svc_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd); -BOOL svc_change_svc_cfg(struct cli_state *cli, uint16 fnum, - POLICY_HND *hnd, +BOOL svc_close(POLICY_HND *hnd); +BOOL svc_change_svc_cfg( POLICY_HND *hnd, uint32 service_type, uint32 start_type, uint32 unknown_0, uint32 error_control, @@ -3415,7 +3409,7 @@ BOOL srv_io_r_net_remote_tod(char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct * /*The following definitions come from rpc_parse/parse_svc.c */ BOOL make_svc_q_open_sc_man(SVC_Q_OPEN_SC_MAN *q_u, - char *server, char *database, + const char *server, const char *database, uint32 des_access) ; BOOL svc_io_q_open_sc_man(char *desc, SVC_Q_OPEN_SC_MAN *q_u, prs_struct *ps, int depth); BOOL make_svc_r_open_sc_man(SVC_R_OPEN_SC_MAN *r_u, POLICY_HND *hnd, @@ -3693,12 +3687,11 @@ void cmd_time(struct client_info *info, int argc, char *argv[]); /*The following definitions come from rpcclient/cmd_svcctl.c */ void svc_display_query_svc_cfg(const QUERY_SERVICE_CONFIG *cfg); -BOOL svc_query_service(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol_scm, +BOOL svc_query_service( POLICY_HND *pol_scm, const char *svc_name, SVC_QUERY_FN(svc_query_fn)); void cmd_svc_info(struct client_info *info, int argc, char *argv[]); -BOOL msrpc_svc_enum(struct client_info *info, +BOOL msrpc_svc_enum(const char* srv_name, ENUM_SRVC_STATUS **svcs, uint32 *num_svcs, SVC_INFO_FN(info_fn), @@ -3852,7 +3845,6 @@ void display_job_info_ctr(FILE *out_hnd, enum action_type action, /*The following definitions come from rpcclient/rpcclient.c */ -void rpcclient_init(void); /*The following definitions come from smbd/blocking.c */ diff --git a/source3/lib/util_hnd.c b/source3/lib/util_hnd.c index 8e4620f8dc..b32b3322b3 100644 --- a/source3/lib/util_hnd.c +++ b/source3/lib/util_hnd.c @@ -462,6 +462,7 @@ BOOL close_policy_hnd(POLICY_HND *hnd) p->dev.cli->free(p->dev.cli->cli, p->dev.cli->fnum); } + free(p->dev.cli); break; } } diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index f85e37dcb5..ed470f5758 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -34,8 +34,7 @@ extern int DEBUGLEVEL; /**************************************************************************** do a SVC Open Policy ****************************************************************************/ -BOOL svc_open_sc_man(struct cli_state *cli, uint16 fnum, - char *srv_name, char *db_name, +BOOL svc_open_sc_man( const char *srv_name, char *db_name, uint32 des_access, POLICY_HND *hnd) { @@ -44,6 +43,14 @@ BOOL svc_open_sc_man(struct cli_state *cli, uint16 fnum, SVC_Q_OPEN_SC_MAN q_o; BOOL valid_pol = False; + struct cli_state *cli = NULL; + uint16 fnum = 0xffff; + + if (!cli_state_init(srv_name, PIPE_SVCCTL, &cli, &fnum)) + { + return False; + } + if (hnd == NULL) return False; prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); @@ -81,6 +88,9 @@ BOOL svc_open_sc_man(struct cli_state *cli, uint16 fnum, /* ok, at last: we're happy. return the policy handle */ memcpy(hnd, r_o.pol.data, sizeof(hnd->data)); valid_pol = True; + valid_pol = register_policy_hnd(hnd) && + set_policy_cli_state(hnd, cli, fnum, + cli_state_free); } } @@ -94,8 +104,7 @@ BOOL svc_open_sc_man(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SVC Open Service ****************************************************************************/ -BOOL svc_open_service(struct cli_state *cli, uint16 fnum, - POLICY_HND *scm_hnd, +BOOL svc_open_service( POLICY_HND *scm_hnd, const char *srv_name, uint32 des_access, POLICY_HND *hnd) @@ -105,6 +114,14 @@ BOOL svc_open_service(struct cli_state *cli, uint16 fnum, SVC_Q_OPEN_SERVICE q_o; BOOL valid_pol = False; + struct cli_state *cli = NULL; + uint16 fnum = 0xffff; + + if (!cli_state_get(scm_hnd, &cli, &fnum)) + { + return False; + } + if (hnd == NULL || scm_hnd == NULL) return False; prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); @@ -141,7 +158,9 @@ BOOL svc_open_service(struct cli_state *cli, uint16 fnum, { /* ok, at last: we're happy. return the policy handle */ memcpy(hnd, r_o.pol.data, sizeof(hnd->data)); - valid_pol = True; + valid_pol = register_policy_hnd(hnd) && + set_policy_cli_state(hnd, cli, fnum, + NULL); } } @@ -155,8 +174,7 @@ BOOL svc_open_service(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SVC Enumerate Services ****************************************************************************/ -BOOL svc_enum_svcs(struct cli_state *cli, uint16 fnum, - POLICY_HND *hnd, +BOOL svc_enum_svcs( POLICY_HND *hnd, uint32 services_type, uint32 services_state, uint32 *buf_size, uint32 *resume_hnd, uint32 *dos_error, @@ -167,6 +185,14 @@ BOOL svc_enum_svcs(struct cli_state *cli, uint16 fnum, SVC_Q_ENUM_SVCS_STATUS q_o; BOOL valid_pol = False; + struct cli_state *cli = NULL; + uint16 fnum = 0xffff; + + if (!cli_state_get(hnd, &cli, &fnum)) + { + return False; + } + if (hnd == NULL || buf_size == NULL || dos_error == NULL || num_svcs == NULL) { return False; @@ -232,8 +258,7 @@ BOOL svc_enum_svcs(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SVC Stop Service ****************************************************************************/ -BOOL svc_stop_service(struct cli_state *cli, uint16 fnum, - POLICY_HND *hnd, +BOOL svc_stop_service( POLICY_HND *hnd, uint32 unknown) { prs_struct rbuf; @@ -241,6 +266,14 @@ BOOL svc_stop_service(struct cli_state *cli, uint16 fnum, SVC_Q_STOP_SERVICE q_c; BOOL valid_cfg = False; + struct cli_state *cli = NULL; + uint16 fnum = 0xffff; + + if (!cli_state_get(hnd, &cli, &fnum)) + { + return False; + } + if (hnd == NULL) return False; /* create and send a MSRPC command with api SVC_STOP_SERVICE */ @@ -290,8 +323,7 @@ BOOL svc_stop_service(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SVC Start Service ****************************************************************************/ -BOOL svc_start_service(struct cli_state *cli, uint16 fnum, - POLICY_HND *hnd, +BOOL svc_start_service( POLICY_HND *hnd, uint32 argc, char **argv) { @@ -300,6 +332,14 @@ BOOL svc_start_service(struct cli_state *cli, uint16 fnum, SVC_Q_START_SERVICE q_c; BOOL valid_cfg = False; + struct cli_state *cli = NULL; + uint16 fnum = 0xffff; + + if (!cli_state_get(hnd, &cli, &fnum)) + { + return False; + } + if (hnd == NULL) return False; /* create and send a MSRPC command with api SVC_START_SERVICE */ @@ -349,8 +389,7 @@ BOOL svc_start_service(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SVC Query Service Config ****************************************************************************/ -BOOL svc_query_svc_cfg(struct cli_state *cli, uint16 fnum, - POLICY_HND *hnd, +BOOL svc_query_svc_cfg( POLICY_HND *hnd, QUERY_SERVICE_CONFIG *cfg, uint32 *buf_size) { @@ -359,6 +398,14 @@ BOOL svc_query_svc_cfg(struct cli_state *cli, uint16 fnum, SVC_Q_QUERY_SVC_CONFIG q_c; BOOL valid_cfg = False; + struct cli_state *cli = NULL; + uint16 fnum = 0xffff; + + if (!cli_state_get(hnd, &cli, &fnum)) + { + return False; + } + if (hnd == NULL || buf_size == NULL) return False; /* create and send a MSRPC command with api SVC_QUERY_SVC_CONFIG */ @@ -411,13 +458,21 @@ BOOL svc_query_svc_cfg(struct cli_state *cli, uint16 fnum, /**************************************************************************** do a SVC Close ****************************************************************************/ -BOOL svc_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd) +BOOL svc_close(POLICY_HND *hnd) { prs_struct rbuf; prs_struct buf; SVC_Q_CLOSE q_c; BOOL valid_close = False; + struct cli_state *cli = NULL; + uint16 fnum = 0xffff; + + if (!cli_state_get(hnd, &cli, &fnum)) + { + return False; + } + if (hnd == NULL) return False; /* create and send a MSRPC command with api SVC_CLOSE */ @@ -472,6 +527,8 @@ BOOL svc_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd) } } + close_policy_hnd(hnd); + prs_mem_free(&rbuf); prs_mem_free(&buf ); @@ -481,8 +538,7 @@ BOOL svc_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd) /**************************************************************************** do a SVC Change Service Config ****************************************************************************/ -BOOL svc_change_svc_cfg(struct cli_state *cli, uint16 fnum, - POLICY_HND *hnd, +BOOL svc_change_svc_cfg( POLICY_HND *hnd, uint32 service_type, uint32 start_type, uint32 unknown_0, uint32 error_control, @@ -497,6 +553,14 @@ BOOL svc_change_svc_cfg(struct cli_state *cli, uint16 fnum, SVC_Q_CHANGE_SVC_CONFIG q_c; BOOL valid_cfg = False; + struct cli_state *cli = NULL; + uint16 fnum = 0xffff; + + if (!cli_state_get(hnd, &cli, &fnum)) + { + return False; + } + if (hnd == NULL) return False; /* create and send a MSRPC command with api SVC_CHANGE_SVC_CONFIG */ @@ -547,5 +611,3 @@ BOOL svc_change_svc_cfg(struct cli_state *cli, uint16 fnum, return valid_cfg; } - - diff --git a/source3/rpc_parse/parse_svc.c b/source3/rpc_parse/parse_svc.c index 93ad0dcced..08fed7d47c 100644 --- a/source3/rpc_parse/parse_svc.c +++ b/source3/rpc_parse/parse_svc.c @@ -31,7 +31,7 @@ extern int DEBUGLEVEL; make_svc_q_open_sc_man ********************************************************************/ BOOL make_svc_q_open_sc_man(SVC_Q_OPEN_SC_MAN *q_u, - char *server, char *database, + const char *server, const char *database, uint32 des_access) { DEBUG(5,("make_svc_q_open_sc_man\n")); diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 8e4620f8dc..b32b3322b3 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -462,6 +462,7 @@ BOOL close_policy_hnd(POLICY_HND *hnd) p->dev.cli->free(p->dev.cli->cli, p->dev.cli->fnum); } + free(p->dev.cli); break; } } diff --git a/source3/rpcclient/cmd_svcctl.c b/source3/rpcclient/cmd_svcctl.c index 708dd49de1..7f3f8532a5 100644 --- a/source3/rpcclient/cmd_svcctl.c +++ b/source3/rpcclient/cmd_svcctl.c @@ -31,9 +31,6 @@ extern int DEBUGLEVEL; -extern struct cli_state *smb_cli; -extern int smb_tidx; - extern FILE* out_hnd; void svc_display_query_svc_cfg(const QUERY_SERVICE_CONFIG *cfg) @@ -43,8 +40,7 @@ void svc_display_query_svc_cfg(const QUERY_SERVICE_CONFIG *cfg) display_query_svc_cfg(out_hnd, ACTION_FOOTER , cfg); } -BOOL svc_query_service(struct cli_state *cli, uint16 fnum, - POLICY_HND *pol_scm, +BOOL svc_query_service( POLICY_HND *pol_scm, const char *svc_name, SVC_QUERY_FN(svc_query_fn)) { @@ -54,12 +50,10 @@ BOOL svc_query_service(struct cli_state *cli, uint16 fnum, QUERY_SERVICE_CONFIG cfg; uint32 svc_buf_size = 0x8000; - res2 = res2 ? svc_open_service(cli, fnum, - pol_scm, + res2 = res2 ? svc_open_service( pol_scm, svc_name, 0x80000001, &pol_svc) : False; - res3 = res2 ? svc_query_svc_cfg(cli, fnum, - &pol_svc, &cfg, + res3 = res2 ? svc_query_svc_cfg( &pol_svc, &cfg, &svc_buf_size) : False; if (res3 && svc_query_fn != NULL) @@ -67,7 +61,7 @@ BOOL svc_query_service(struct cli_state *cli, uint16 fnum, svc_query_fn(&cfg); } - res2 = res2 ? svc_close(cli, fnum, &pol_svc) : False; + res2 = res2 ? svc_close(&pol_svc) : False; return res3; } @@ -77,7 +71,6 @@ nt service info ****************************************************************************/ void cmd_svc_info(struct client_info *info, int argc, char *argv[]) { - uint16 fnum; BOOL res = True; BOOL res1 = True; char *svc_name; @@ -87,7 +80,7 @@ void cmd_svc_info(struct client_info *info, int argc, char *argv[]) fstring srv_name; fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->myhostname); + fstrcat(srv_name, info->dest_host); strupper(srv_name); DEBUG(4,("cmd_svc_info: server:%s\n", srv_name)); @@ -100,21 +93,14 @@ void cmd_svc_info(struct client_info *info, int argc, char *argv[]) svc_name = argv[1]; - /* 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, 0x80000004, + res = res ? svc_open_sc_man( srv_name, NULL, 0x80000004, &pol_scm) : False; - res1 = svc_query_service(smb_cli, fnum, &pol_scm, svc_name, + res1 = svc_query_service(&pol_scm, svc_name, svc_display_query_svc_cfg); - res = res ? svc_close(smb_cli, fnum, &pol_scm) : False; - - /* close the session */ - cli_nt_session_close(smb_cli, fnum); + res = res ? svc_close(&pol_scm) : False; if (res && res1) { @@ -136,13 +122,12 @@ static void svc_display_svc_info(const ENUM_SRVC_STATUS *svc) /**************************************************************************** nt service enum ****************************************************************************/ -BOOL msrpc_svc_enum(struct client_info *info, +BOOL msrpc_svc_enum(const char* srv_name, ENUM_SRVC_STATUS **svcs, uint32 *num_svcs, SVC_INFO_FN(info_fn), SVC_QUERY_FN(query_fn)) { - uint16 fnum; BOOL res = True; BOOL res1 = False; int i; @@ -152,21 +137,11 @@ BOOL msrpc_svc_enum(struct client_info *info, POLICY_HND pol_scm; - fstring srv_name; - (*svcs) = NULL; (*num_svcs) = 0; - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->myhostname); - strupper(srv_name); - - /* 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, 0x80000004, + res = res ? svc_open_sc_man( srv_name, NULL, 0x80000004, &pol_scm) : False; do @@ -181,8 +156,7 @@ BOOL msrpc_svc_enum(struct client_info *info, buf_size += 0x800; /* enumerate services */ - res1 = res ? svc_enum_svcs(smb_cli, fnum, - &pol_scm, + res1 = res ? svc_enum_svcs( &pol_scm, 0x00000030, 0x00000003, &buf_size, &resume_hnd, &dos_error, svcs, num_svcs) : False; @@ -198,7 +172,7 @@ BOOL msrpc_svc_enum(struct client_info *info, if (query_fn != NULL) { - res1 = svc_query_service(smb_cli, fnum, &pol_scm, + res1 = svc_query_service(&pol_scm, svc_name, query_fn); } else if (info_fn != NULL) @@ -207,10 +181,7 @@ BOOL msrpc_svc_enum(struct client_info *info, } } - res = res ? svc_close(smb_cli, fnum, &pol_scm) : False; - - /* close the session */ - cli_nt_session_close(smb_cli, fnum); + res = res ? svc_close(&pol_scm) : False; return res1; } @@ -224,6 +195,11 @@ void cmd_svc_enum(struct client_info *info, int argc, char *argv[]) uint32 num_svcs = 0; BOOL request_info = False; int opt; + fstring srv_name; + + fstrcpy(srv_name, "\\\\"); + fstrcat(srv_name, info->dest_host); + strupper(srv_name); argc--; argv++; @@ -243,7 +219,7 @@ void cmd_svc_enum(struct client_info *info, int argc, char *argv[]) report(out_hnd,"Services\n"); report(out_hnd,"--------\n"); - msrpc_svc_enum(info, &svcs, &num_svcs, + msrpc_svc_enum(srv_name, &svcs, &num_svcs, request_info ? NULL : svc_display_svc_info, request_info ? svc_display_query_svc_cfg : NULL); @@ -258,7 +234,6 @@ nt stop service ****************************************************************************/ void cmd_svc_stop(struct client_info *info, int argc, char *argv[]) { - uint16 fnum; BOOL res = True; BOOL res1 = True; char *svc_name; @@ -269,7 +244,7 @@ void cmd_svc_stop(struct client_info *info, int argc, char *argv[]) fstring srv_name; fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->myhostname); + fstrcat(srv_name, info->dest_host); strupper(srv_name); DEBUG(4,("cmd_svc_stop: server:%s\n", srv_name)); @@ -282,25 +257,17 @@ void cmd_svc_stop(struct client_info *info, int argc, char *argv[]) svc_name = argv[1]; - /* 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, + res = res ? svc_open_sc_man( srv_name, NULL, 0x80000000, &pol_scm) : False; - res1 = res ? svc_open_service(smb_cli, fnum, - &pol_scm, + res1 = res ? svc_open_service( &pol_scm, svc_name, 0x00000020, &pol_svc) : False; - res2 = res1 ? svc_stop_service(smb_cli, fnum, &pol_svc, 0x1) : False; + res2 = res1 ? svc_stop_service(&pol_svc, 0x1) : 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); + res1 = res1 ? svc_close(&pol_svc) : False; + res = res ? svc_close(&pol_scm) : False; if (res2) { @@ -319,7 +286,6 @@ nt start service ****************************************************************************/ void cmd_svc_start(struct client_info *info, int argc, char *argv[]) { - uint16 fnum; BOOL res = True; BOOL res1 = True; char *svc_name; @@ -330,7 +296,7 @@ void cmd_svc_start(struct client_info *info, int argc, char *argv[]) fstring srv_name; fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->myhostname); + fstrcat(srv_name, info->dest_host); strupper(srv_name); DEBUG(4,("cmd_svc_start: server:%s\n", srv_name)); @@ -349,26 +315,17 @@ void cmd_svc_start(struct client_info *info, int argc, char *argv[]) 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, + res = res ? svc_open_sc_man( srv_name, NULL, 0x80000000, &pol_scm) : False; - res1 = res ? svc_open_service(smb_cli, fnum, - &pol_scm, + res1 = res ? svc_open_service( &pol_scm, svc_name, 0x80000010, &pol_svc) : False; - res2 = res1 ? svc_start_service(smb_cli, fnum, - &pol_svc, argc, argv) : False; - - res1 = res1 ? svc_close(smb_cli, fnum, &pol_svc) : False; - res = res ? svc_close(smb_cli, fnum, &pol_scm) : False; + res2 = res1 ? svc_start_service( &pol_svc, argc, argv) : False; - /* close the session */ - cli_nt_session_close(smb_cli, fnum); + res1 = res1 ? svc_close(&pol_svc) : False; + res = res ? svc_close(&pol_scm) : False; if (res2) { @@ -387,7 +344,6 @@ nt service set ****************************************************************************/ void cmd_svc_set(struct client_info *info, int argc, char *argv[]) { - uint16 fnum; BOOL res = True; BOOL res2 = True; BOOL res3; @@ -402,7 +358,7 @@ void cmd_svc_set(struct client_info *info, int argc, char *argv[]) fstring srv_name; fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->myhostname); + fstrcat(srv_name, info->dest_host); strupper(srv_name); DEBUG(4,("cmd_svc_set: server:%s\n", srv_name)); @@ -415,25 +371,19 @@ void cmd_svc_set(struct client_info *info, int argc, char *argv[]) svc_name = argv[1]; - /* 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, 0x80000004, + res = res ? svc_open_sc_man( srv_name, NULL, 0x80000004, &pol_scm) : False; - res2 = res ? svc_open_service(smb_cli, fnum, - &pol_scm, + res2 = res ? svc_open_service( &pol_scm, svc_name, 0x80000001, &pol_svc) : False; - res3 = res2 ? svc_query_svc_cfg(smb_cli, fnum, - &pol_svc, &cfg, + res3 = res2 ? svc_query_svc_cfg( &pol_svc, &cfg, &svc_buf_size) : False; if (res3) { - res3 = svc_change_svc_cfg(smb_cli, fnum, &pol_svc, + res3 = svc_change_svc_cfg(&pol_svc, cfg.service_type, cfg.start_type, 0xffffffff, @@ -444,12 +394,9 @@ void cmd_svc_set(struct client_info *info, int argc, char *argv[]) } - res2 = res2 ? svc_close(smb_cli, fnum, &pol_svc) : False; - - res = res ? svc_close(smb_cli, fnum, &pol_scm) : False; + res2 = res2 ? svc_close(&pol_svc) : False; - /* close the session */ - cli_nt_session_close(smb_cli, fnum); + res = res ? svc_close(&pol_scm) : False; if (res3) { diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 5fa103a57f..6891d4435b 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -1112,6 +1112,12 @@ static char *complete_svcenum(char *text, int state) static uint32 i = 0; static uint32 num_svcs = 0; static ENUM_SRVC_STATUS *svc = NULL; + fstring srv_name; + + fstrcpy(srv_name, "\\\\"); + fstrcat(srv_name, cli_info.dest_host); + strupper(srv_name); + if (state == 0) { @@ -1120,7 +1126,7 @@ static char *complete_svcenum(char *text, int state) num_svcs = 0; /* Iterate all users */ - if (msrpc_svc_enum(&cli_info, &svc, &num_svcs, + if (msrpc_svc_enum(srv_name, &svc, &num_svcs, NULL, NULL) == 0) { return NULL; |