diff options
author | Luke Leighton <lkcl@samba.org> | 1999-11-24 23:11:03 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1999-11-24 23:11:03 +0000 |
commit | a70a4626df78965e1ad9c7f89f5d1c490e373ee0 (patch) | |
tree | ea252061104d838dd813ceee30d370017db5d5db /source3/rpc_client | |
parent | 2803a72751cf511aa0b5e6745e1b169faa66f68a (diff) | |
download | samba-a70a4626df78965e1ad9c7f89f5d1c490e373ee0.tar.gz samba-a70a4626df78965e1ad9c7f89f5d1c490e373ee0.tar.bz2 samba-a70a4626df78965e1ad9c7f89f5d1c490e373ee0.zip |
service control manager API completed. svcenum -i works, but does not
do so twice. possible memory corruption, revolving around getopt().
(This used to be commit 7cacf8bd026f1ee274f1d352c68cf79cf4f3b499)
Diffstat (limited to 'source3/rpc_client')
-rw-r--r-- | source3/rpc_client/cli_svcctl.c | 98 |
1 files changed, 80 insertions, 18 deletions
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; } - - |