From 7135fb0a2c869169996206a9c1cf5ac1112b9f0a Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 8 Dec 1998 23:29:37 +0000 Subject: adding "Service Control Manager" commands to rpcclient. (This used to be commit e5ee965f8d8452ab694bc5d88e474c4b91dce5b0) --- source3/rpc_client/cli_svcctl.c | 230 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 source3/rpc_client/cli_svcctl.c (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c new file mode 100644 index 0000000000..90d74188da --- /dev/null +++ b/source3/rpc_client/cli_svcctl.c @@ -0,0 +1,230 @@ + +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1998, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, + * Copyright (C) Paul Ashton 1997-1998. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#ifdef SYSLOG +#undef SYSLOG +#endif + +#include "includes.h" + +extern int DEBUGLEVEL; + +/**************************************************************************** +do a SVC Open Policy +****************************************************************************/ +BOOL do_svc_open_sc_man(struct cli_state *cli, uint16 fnum, + char *srv_name, char *db_name, + uint32 des_access, + POLICY_HND *hnd) +{ + prs_struct rbuf; + prs_struct buf; + SVC_Q_OPEN_SC_MAN q_o; + BOOL valid_pol = False; + + if (hnd == NULL) return False; + + prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); + prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); + + /* create and send a MSRPC command with api SVC_OPEN_SC_MAN */ + + DEBUG(4,("SVC Open SC_MAN\n")); + + make_svc_q_open_sc_man(&q_o, srv_name, db_name, des_access); + + /* turn parameters into data stream */ + svc_io_q_open_sc_man("", &q_o, &buf, 0); + + /* send the data on \PIPE\ */ + if (rpc_api_pipe_req(cli, fnum, SVC_OPEN_SC_MAN, &buf, &rbuf)) + { + SVC_R_OPEN_SC_MAN r_o; + BOOL p; + + ZERO_STRUCT(r_o); + + svc_io_r_open_sc_man("", &r_o, &rbuf, 0); + p = rbuf.offset != 0; + + if (p && r_o.status != 0) + { + /* report error code */ + DEBUG(0,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status))); + p = False; + } + + if (p) + { + /* ok, at last: we're happy. return the policy handle */ + memcpy(hnd, r_o.pol.data, sizeof(hnd->data)); + valid_pol = True; + } + } + + prs_mem_free(&rbuf); + prs_mem_free(&buf ); + + return valid_pol; +} + + +/**************************************************************************** +do a SVC Enumerate Services +****************************************************************************/ +BOOL do_svc_enum_svcs(struct cli_state *cli, uint16 fnum, + POLICY_HND *hnd, + uint32 services_type, uint32 services_state, + uint32 buf_size, uint32 *resume_hnd) +{ + prs_struct rbuf; + prs_struct buf; + SVC_Q_ENUM_SVCS_STATUS q_o; + BOOL valid_pol = False; + + if (hnd == NULL) return False; + + prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); + prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); + + /* create and send a MSRPC command with api SVC_ENUM_SVCS_STATUS */ + + DEBUG(4,("SVC Enum Services Status\n")); + + make_svc_q_enum_svcs_status(&q_o, hnd, + services_type, services_state, + buf_size, *resume_hnd); + + /* turn parameters into data stream */ + svc_io_q_enum_svcs_status("", &q_o, &buf, 0); + + /* send the data on \PIPE\ */ + if (rpc_api_pipe_req(cli, fnum, SVC_ENUM_SVCS_STATUS, &buf, &rbuf)) + { +#if 0 + SVC_R_ENUM_SVCS_STATUS r_o; + BOOL p; + + ZERO_STRUCT(r_o); + + svc_io_r_enum_svcs_status("", &r_o, &rbuf, 0); + p = rbuf.offset != 0; + + if (p && r_o.status != 0) + { + /* report error code */ + DEBUG(0,("SVC_ENUM_SVCS_STATUS: %s\n", get_nt_error_msg(r_o.status))); + p = False; + } + + if (p) + { + /* ok, at last: we're happy. return the policy handle */ + memcpy(hnd, r_o.pol.data, sizeof(hnd->data)); + valid_pol = True; + } +#else + valid_pol = True; +#endif + } + + prs_mem_free(&rbuf); + prs_mem_free(&buf ); + + return valid_pol; +} + + +/**************************************************************************** +do a SVC Close +****************************************************************************/ +BOOL do_svc_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd) +{ + prs_struct rbuf; + prs_struct buf; + SVC_Q_CLOSE q_c; + BOOL valid_close = False; + + if (hnd == NULL) return False; + + /* create and send a MSRPC command with api SVC_CLOSE */ + + prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); + prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); + + DEBUG(4,("SVC Close\n")); + + /* store the parameters */ + make_svc_q_close(&q_c, hnd); + + /* turn parameters into data stream */ + svc_io_q_close("", &q_c, &buf, 0); + + /* send the data on \PIPE\ */ + if (rpc_api_pipe_req(cli, fnum, SVC_CLOSE, &buf, &rbuf)) + { + SVC_R_CLOSE r_c; + BOOL p; + + ZERO_STRUCT(r_c); + + svc_io_r_close("", &r_c, &rbuf, 0); + p = rbuf.offset != 0; + + if (p && r_c.status != 0) + { + /* report error code */ + DEBUG(0,("SVC_CLOSE: %s\n", get_nt_error_msg(r_c.status))); + p = False; + } + + if (p) + { + /* check that the returned policy handle is all zeros */ + int i; + valid_close = True; + + for (i = 0; i < sizeof(r_c.pol.data); i++) + { + if (r_c.pol.data[i] != 0) + { + valid_close = False; + break; + } + } + if (!valid_close) + { + DEBUG(0,("SVC_CLOSE: non-zero handle returned\n")); + } + } + } + + prs_mem_free(&rbuf); + prs_mem_free(&buf ); + + return valid_close; +} + + -- cgit From 74576a48fdf71e4264a892fda58302053f809670 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 9 Dec 1998 16:28:04 +0000 Subject: adding some enumerate services code, client and server. (This used to be commit dacf5b152bf74cc3ee9a816911384a5eb0e77afa) --- source3/rpc_client/cli_svcctl.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 90d74188da..3535c90391 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -97,7 +97,8 @@ do a SVC Enumerate Services BOOL do_svc_enum_svcs(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, uint32 services_type, uint32 services_state, - uint32 buf_size, uint32 *resume_hnd) + uint32 buf_size, uint32 *resume_hnd, + ENUM_SRVC_STATUS **svcs) { prs_struct rbuf; prs_struct buf; @@ -123,7 +124,6 @@ BOOL do_svc_enum_svcs(struct cli_state *cli, uint16 fnum, /* send the data on \PIPE\ */ if (rpc_api_pipe_req(cli, fnum, SVC_ENUM_SVCS_STATUS, &buf, &rbuf)) { -#if 0 SVC_R_ENUM_SVCS_STATUS r_o; BOOL p; @@ -132,22 +132,19 @@ BOOL do_svc_enum_svcs(struct cli_state *cli, uint16 fnum, svc_io_r_enum_svcs_status("", &r_o, &rbuf, 0); p = rbuf.offset != 0; - if (p && r_o.status != 0) + if (p && r_o.dos_status != 0) { /* report error code */ - DEBUG(0,("SVC_ENUM_SVCS_STATUS: %s\n", get_nt_error_msg(r_o.status))); - p = False; + DEBUG(0,("SVC_ENUM_SVCS_STATUS: %s\n", smb_err_msg(ERRDOS, r_o.dos_status))); + p = r_o.dos_status != ERRmoredata; } if (p) { - /* ok, at last: we're happy. return the policy handle */ - memcpy(hnd, r_o.pol.data, sizeof(hnd->data)); + (*svcs) = r_o.svcs; + (*resume_hnd) = get_enum_hnd(&r_o.resume_hnd); valid_pol = True; } -#else - valid_pol = True; -#endif } prs_mem_free(&rbuf); -- cgit From 05040640856b8eb1bebc26afa2a2e210241b4838 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 27 Jan 1999 20:31:58 +0000 Subject: Service Control Manager - service enumeration. (This used to be commit f4dd8f6b566961890b2933b7a413241bf9b93797) --- source3/rpc_client/cli_svcctl.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 3535c90391..f14a699802 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -97,15 +97,19 @@ do a SVC Enumerate Services BOOL do_svc_enum_svcs(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, uint32 services_type, uint32 services_state, - uint32 buf_size, uint32 *resume_hnd, - ENUM_SRVC_STATUS **svcs) + uint32 *buf_size, uint32 *resume_hnd, + uint32 *dos_error, + ENUM_SRVC_STATUS **svcs, uint32 *num_svcs) { prs_struct rbuf; prs_struct buf; SVC_Q_ENUM_SVCS_STATUS q_o; BOOL valid_pol = False; - if (hnd == NULL) return False; + if (hnd == NULL || buf_size == NULL || dos_error == NULL || num_svcs == NULL) + { + return False; + } prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); @@ -116,7 +120,7 @@ BOOL do_svc_enum_svcs(struct cli_state *cli, uint16 fnum, make_svc_q_enum_svcs_status(&q_o, hnd, services_type, services_state, - buf_size, *resume_hnd); + *buf_size, *resume_hnd); /* turn parameters into data stream */ svc_io_q_enum_svcs_status("", &q_o, &buf, 0); @@ -136,13 +140,16 @@ BOOL do_svc_enum_svcs(struct cli_state *cli, uint16 fnum, { /* report error code */ DEBUG(0,("SVC_ENUM_SVCS_STATUS: %s\n", smb_err_msg(ERRDOS, r_o.dos_status))); - p = r_o.dos_status != ERRmoredata; + p = r_o.dos_status == ERRmoredata; } if (p) { (*svcs) = r_o.svcs; + (*num_svcs) = r_o.num_svcs; (*resume_hnd) = get_enum_hnd(&r_o.resume_hnd); + (*buf_size) = r_o.more_buf_size; + (*dos_error) = r_o.dos_status; valid_pol = True; } } -- cgit From 6b7e1ead37b8655cf3cfb52a421461cedb3d0c90 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 28 Jan 1999 21:11:15 +0000 Subject: rpcclient "Service Control Manager" svcenum [-i] command. (This used to be commit a022710f1e3996ecbe6bbe035e1df0bc4c050b34) --- source3/rpc_client/cli_svcctl.c | 129 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 126 insertions(+), 3 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index f14a699802..ebf8c15dc4 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -34,7 +34,7 @@ extern int DEBUGLEVEL; /**************************************************************************** do a SVC Open Policy ****************************************************************************/ -BOOL do_svc_open_sc_man(struct cli_state *cli, uint16 fnum, +BOOL svc_open_sc_man(struct cli_state *cli, uint16 fnum, char *srv_name, char *db_name, uint32 des_access, POLICY_HND *hnd) @@ -91,10 +91,71 @@ BOOL do_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, + char *srv_name, + uint32 des_access, + POLICY_HND *hnd) +{ + prs_struct rbuf; + prs_struct buf; + SVC_Q_OPEN_SERVICE q_o; + BOOL valid_pol = False; + + if (hnd == NULL || scm_hnd == NULL) return False; + + prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); + prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); + + /* create and send a MSRPC command with api SVC_OPEN_SERVICE */ + + DEBUG(4,("SVC Open Service\n")); + + make_svc_q_open_service(&q_o, scm_hnd, srv_name, des_access); + + /* turn parameters into data stream */ + svc_io_q_open_service("", &q_o, &buf, 0); + + /* send the data on \PIPE\ */ + if (rpc_api_pipe_req(cli, fnum, SVC_OPEN_SERVICE, &buf, &rbuf)) + { + SVC_R_OPEN_SERVICE r_o; + BOOL p; + + ZERO_STRUCT(r_o); + + svc_io_r_open_service("", &r_o, &rbuf, 0); + p = rbuf.offset != 0; + + if (p && r_o.status != 0) + { + /* report error code */ + DEBUG(0,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status))); + p = False; + } + + if (p) + { + /* ok, at last: we're happy. return the policy handle */ + memcpy(hnd, r_o.pol.data, sizeof(hnd->data)); + valid_pol = True; + } + } + + prs_mem_free(&rbuf); + prs_mem_free(&buf ); + + return valid_pol; +} + + /**************************************************************************** do a SVC Enumerate Services ****************************************************************************/ -BOOL do_svc_enum_svcs(struct cli_state *cli, uint16 fnum, +BOOL svc_enum_svcs(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, uint32 services_type, uint32 services_state, uint32 *buf_size, uint32 *resume_hnd, @@ -161,10 +222,72 @@ BOOL do_svc_enum_svcs(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, + QUERY_SERVICE_CONFIG *cfg, + uint32 *buf_size) +{ + prs_struct rbuf; + prs_struct buf; + SVC_Q_QUERY_SVC_CONFIG q_c; + BOOL valid_cfg = False; + + if (hnd == NULL || buf_size == NULL) return False; + + /* create and send a MSRPC command with api SVC_QUERY_SVC_CONFIG */ + + prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); + prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); + + DEBUG(4,("SVC Query Service Config\n")); + + /* store the parameters */ + make_svc_q_query_svc_config(&q_c, hnd, *buf_size); + + /* turn parameters into data stream */ + svc_io_q_query_svc_config("", &q_c, &buf, 0); + + /* send the data on \PIPE\ */ + if (rpc_api_pipe_req(cli, fnum, SVC_QUERY_SVC_CONFIG, &buf, &rbuf)) + { + SVC_R_QUERY_SVC_CONFIG r_c; + BOOL p; + + ZERO_STRUCT (r_c); + ZERO_STRUCTP(cfg); + + r_c.cfg = cfg; + + svc_io_r_query_svc_config("", &r_c, &rbuf, 0); + p = rbuf.offset != 0; + + if (p && r_c.status != 0) + { + /* report error code */ + DEBUG(0,("SVC_QUERY_SVC_CONFIG: %s\n", get_nt_error_msg(r_c.status))); + p = False; + } + + if (p) + { + valid_cfg = r_c.buf_size != 0; + } + } + + prs_mem_free(&rbuf); + prs_mem_free(&buf ); + + return valid_cfg; +} + + /**************************************************************************** do a SVC Close ****************************************************************************/ -BOOL do_svc_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd) +BOOL svc_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd) { prs_struct rbuf; prs_struct buf; -- cgit From cae3620b2e8abbe35f0369a82d5461cb596475a3 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 24 Jun 1999 18:58:08 +0000 Subject: safe string error reporting functions (found a potential buffer overflow of a pstrcpy into an fstring). (This used to be commit ac0060443de800fec9042b69b299ff2e9128a31c) --- source3/rpc_client/cli_svcctl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index ebf8c15dc4..5e8a3952a5 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -199,8 +199,11 @@ BOOL svc_enum_svcs(struct cli_state *cli, uint16 fnum, if (p && r_o.dos_status != 0) { + fstring errmsg; + smb_safe_err_msg(ERRDOS, r_o.dos_status, + errmsg, sizeof(errmsg)); /* report error code */ - DEBUG(0,("SVC_ENUM_SVCS_STATUS: %s\n", smb_err_msg(ERRDOS, r_o.dos_status))); + DEBUG(0,("SVC_ENUM_SVCS_STATUS: %s\n", errmsg)); p = r_o.dos_status == ERRmoredata; } -- cgit From 48324fa61b33211bf589f65883373407f81d6f41 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 18 Aug 1999 23:51:02 +0000 Subject: Don't print out a message in svcenum command for the ERRmoredata error. (This used to be commit 92ebd8f12ce4997e77eee22c3bb0c599daa44500) --- source3/rpc_client/cli_svcctl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 5e8a3952a5..ed3ddaf9d3 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -200,10 +200,13 @@ BOOL svc_enum_svcs(struct cli_state *cli, uint16 fnum, if (p && r_o.dos_status != 0) { fstring errmsg; - smb_safe_err_msg(ERRDOS, r_o.dos_status, - errmsg, sizeof(errmsg)); - /* report error code */ - DEBUG(0,("SVC_ENUM_SVCS_STATUS: %s\n", errmsg)); + + if (r_o.dos_status != ERRmoredata) { + smb_safe_err_msg(ERRDOS, r_o.dos_status, + errmsg, sizeof(errmsg)); + /* report error code */ + DEBUG(0,("SVC_ENUM_SVCS_STATUS: %s\n", errmsg)); + } p = r_o.dos_status == ERRmoredata; } -- cgit From 6f9105c853020fde1691a28cd707d6d3f6561b4d Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 21 Oct 1999 16:53:50 +0000 Subject: various. debug levels changed. nmbd doesn't need libsmb/clienttrust.c. samr_lookup_rids() moved to a dynamic memory structure not a static one limited to 32 RIDs. cli_pipe.c reading wasn't checking ERRmoredata when DOS error codes negotiated (this terminates MSRPC code with prejudice). (This used to be commit 8976eca2db43576c32069dcda017e8777048e007) --- source3/rpc_client/cli_svcctl.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index ed3ddaf9d3..e4312c5f33 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -72,7 +72,7 @@ BOOL svc_open_sc_man(struct cli_state *cli, uint16 fnum, if (p && r_o.status != 0) { /* report error code */ - DEBUG(0,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status))); + DEBUG(1,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status))); p = False; } @@ -133,7 +133,7 @@ BOOL svc_open_service(struct cli_state *cli, uint16 fnum, if (p && r_o.status != 0) { /* report error code */ - DEBUG(0,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status))); + DEBUG(1,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status))); p = False; } @@ -201,11 +201,12 @@ BOOL svc_enum_svcs(struct cli_state *cli, uint16 fnum, { fstring errmsg; - if (r_o.dos_status != ERRmoredata) { - smb_safe_err_msg(ERRDOS, r_o.dos_status, - errmsg, sizeof(errmsg)); - /* report error code */ - DEBUG(0,("SVC_ENUM_SVCS_STATUS: %s\n", errmsg)); + if (r_o.dos_status != ERRmoredata) + { + smb_safe_err_msg(ERRDOS, r_o.dos_status, + errmsg, sizeof(errmsg)); + /* report error code */ + DEBUG(1,("SVC_ENUM_SVCS_STATUS: %s\n", errmsg)); } p = r_o.dos_status == ERRmoredata; } @@ -273,7 +274,7 @@ BOOL svc_query_svc_cfg(struct cli_state *cli, uint16 fnum, if (p && r_c.status != 0) { /* report error code */ - DEBUG(0,("SVC_QUERY_SVC_CONFIG: %s\n", get_nt_error_msg(r_c.status))); + DEBUG(1,("SVC_QUERY_SVC_CONFIG: %s\n", get_nt_error_msg(r_c.status))); p = False; } @@ -329,7 +330,7 @@ BOOL svc_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd) if (p && r_c.status != 0) { /* report error code */ - DEBUG(0,("SVC_CLOSE: %s\n", get_nt_error_msg(r_c.status))); + DEBUG(1,("SVC_CLOSE: %s\n", get_nt_error_msg(r_c.status))); p = False; } @@ -349,7 +350,7 @@ BOOL svc_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd) } if (!valid_close) { - DEBUG(0,("SVC_CLOSE: non-zero handle returned\n")); + DEBUG(1,("SVC_CLOSE: non-zero handle returned\n")); } } } -- cgit From 56128244261f8e4c6e1144da66c736fbc2104665 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 25 Oct 1999 19:03:27 +0000 Subject: - typecast malloc / Realloc issues. - signed / unsigned issues. (This used to be commit c8fd555179314baf1672a23db34dc8ad9f2d02bf) --- source3/rpc_client/cli_svcctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index e4312c5f33..292972eae2 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -337,7 +337,7 @@ BOOL svc_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd) if (p) { /* check that the returned policy handle is all zeros */ - int i; + uint32 i; valid_close = True; for (i = 0; i < sizeof(r_c.pol.data); i++) -- cgit From dbda98047df356cb854176982db156971d19466a Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sun, 31 Oct 1999 04:11:17 +0000 Subject: added svcinfo command. (This used to be commit c243231d8596a732aba69179ff8f3882e7118297) --- source3/rpc_client/cli_svcctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 292972eae2..f161e4207f 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -96,7 +96,7 @@ do a SVC Open Service ****************************************************************************/ BOOL svc_open_service(struct cli_state *cli, uint16 fnum, POLICY_HND *scm_hnd, - char *srv_name, + const char *srv_name, uint32 des_access, POLICY_HND *hnd) { -- cgit From e7a9b398c79cb77678de18f3fc448131e1d6eb25 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sun, 31 Oct 1999 05:23:32 +0000 Subject: added yet another rpcclient command: svcstart [arg0] [arg1] ... works with command-line completion on the service name (ohh yesss, this is becoming my favourite bit of functionality-on-the-side hee hee :) had to fix the svc_io_q_start_service() code which was missing the ptr_argv[] array in between the array-size and the UNISTR2-array. i.e it's actually an array of _pointers_ to unicode strings... (This used to be commit 2903f22e7ed9306229035accfa757fd810645820) --- source3/rpc_client/cli_svcctl.c | 59 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index f161e4207f..1e1fe884ff 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -229,6 +229,65 @@ BOOL svc_enum_svcs(struct cli_state *cli, uint16 fnum, } +/**************************************************************************** +do a SVC Start Service +****************************************************************************/ +BOOL svc_start_service(struct cli_state *cli, uint16 fnum, + POLICY_HND *hnd, + uint32 argc, + char **argv) +{ + prs_struct rbuf; + prs_struct buf; + SVC_Q_START_SERVICE q_c; + BOOL valid_cfg = False; + + if (hnd == NULL) return False; + + /* create and send a MSRPC command with api SVC_START_SERVICE */ + + prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); + prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); + + DEBUG(4,("SVC Start Service\n")); + + /* store the parameters */ + make_svc_q_start_service(&q_c, hnd, argc, argv); + + /* turn parameters into data stream */ + svc_io_q_start_service("", &q_c, &buf, 0); + + /* send the data on \PIPE\ */ + if (rpc_api_pipe_req(cli, fnum, SVC_START_SERVICE, &buf, &rbuf)) + { + SVC_R_START_SERVICE r_c; + BOOL p; + + ZERO_STRUCT (r_c); + + svc_io_r_start_service("", &r_c, &rbuf, 0); + p = rbuf.offset != 0; + + if (p && r_c.status != 0) + { + /* report error code */ + DEBUG(1,("SVC_START_SERVICE: %s\n", get_nt_error_msg(r_c.status))); + p = False; + } + + if (p) + { + valid_cfg = True; + } + } + + prs_mem_free(&rbuf); + prs_mem_free(&buf ); + + return valid_cfg; +} + + /**************************************************************************** do a SVC Query Service Config ****************************************************************************/ -- cgit From 92892c014e8b5bf42e36b60b4479dbda6e20b990 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 1 Nov 1999 17:52:11 +0000 Subject: added rpcclient svcstop command. gnu readline command-completion works. (This used to be commit 926fe6273a8cd9550838ecdfca276f915c92031b) --- source3/rpc_client/cli_svcctl.c | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 1e1fe884ff..e09cd4ec12 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -229,6 +229,64 @@ 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, + uint32 unknown) +{ + prs_struct rbuf; + prs_struct buf; + SVC_Q_STOP_SERVICE q_c; + BOOL valid_cfg = False; + + if (hnd == NULL) return False; + + /* create and send a MSRPC command with api SVC_STOP_SERVICE */ + + prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); + prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); + + DEBUG(4,("SVC Stop Service\n")); + + /* store the parameters */ + make_svc_q_stop_service(&q_c, hnd, unknown); + + /* turn parameters into data stream */ + svc_io_q_stop_service("", &q_c, &buf, 0); + + /* send the data on \PIPE\ */ + if (rpc_api_pipe_req(cli, fnum, SVC_STOP_SERVICE, &buf, &rbuf)) + { + SVC_R_STOP_SERVICE r_c; + BOOL p; + + ZERO_STRUCT (r_c); + + svc_io_r_stop_service("", &r_c, &rbuf, 0); + p = rbuf.offset != 0; + + if (p && r_c.status != 0) + { + /* report error code */ + DEBUG(1,("SVC_START_SERVICE: %s\n", get_nt_error_msg(r_c.status))); + p = False; + } + + if (p) + { + valid_cfg = True; + } + } + + prs_mem_free(&rbuf); + prs_mem_free(&buf ); + + return valid_cfg; +} + + /**************************************************************************** do a SVC Start Service ****************************************************************************/ -- cgit From 14713d00b515af95288e9b92d9dfbf8a82eed1f2 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 23 Nov 1999 20:32:52 +0000 Subject: oops!!!! wrong command!!! (This used to be commit cbbfef6d2a5335a6daa4fe09ea2d73197417894f) --- source3/rpc_client/cli_svcctl.c | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'source3/rpc_client/cli_svcctl.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; +} -- cgit From 6b91ecb417ab4dccbd3c0582588f17d24c580e92 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 23 Nov 1999 23:05:47 +0000 Subject: attempted a svcset command. password is encrypted / messed up, therefore command fails. (This used to be commit 9193f0eff56399e9bc09787dbe785b603886eaa3) --- source3/rpc_client/cli_svcctl.c | 74 ++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 31 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index bba6342db8..f85e37dcb5 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -479,61 +479,73 @@ BOOL svc_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd) } /**************************************************************************** -do a SVC Query Lookup RIDS +do a SVC Change Service Config ****************************************************************************/ -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) +BOOL svc_change_svc_cfg(struct cli_state *cli, uint16 fnum, + POLICY_HND *hnd, + uint32 service_type, uint32 start_type, + uint32 unknown_0, + uint32 error_control, + char* bin_path_name, char* load_order_grp, + uint32 tag_id, + char* dependencies, char* service_start_name, + char* password, + char* disp_name) { - prs_struct data; - prs_struct rdata; - - SVC_Q_UNKNOWN_1B q_o; - BOOL valid_query = False; + prs_struct rbuf; + prs_struct buf; + SVC_Q_CHANGE_SVC_CONFIG q_c; + BOOL valid_cfg = False; - if (pol == NULL || num_items == NULL || items == NULL ) return False; + if (hnd == NULL) return False; - /* create and send a MSRPC command with api SVC_UNKNOWN_1B */ + /* create and send a MSRPC command with api SVC_CHANGE_SVC_CONFIG */ - prs_init(&data , 1024, 4, SAFETY_MARGIN, False); - prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True ); + prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); + prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); - DEBUG(4,("SVC Query Unknown 1b.\n")); + DEBUG(4,("SVC Change Service Config\n")); /* store the parameters */ - make_svc_q_unknown_1b(&q_o, pol, switch_value, unknown_1); + make_svc_q_change_svc_config(&q_c, hnd, + service_type, start_type, + unknown_0, error_control, + bin_path_name, load_order_grp, + tag_id, + dependencies, service_start_name, + password, disp_name); /* turn parameters into data stream */ - svc_io_q_unknown_1b("", &q_o, &data, 0); + svc_io_q_change_svc_config("", &q_c, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SVC_UNKNOWN_1B, &data, &rdata)) + if (rpc_api_pipe_req(cli, fnum, SVC_CHANGE_SVC_CONFIG, &buf, &rbuf)) { - SVC_R_UNKNOWN_1B r_o; + SVC_R_CHANGE_SVC_CONFIG r_c; 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) + ZERO_STRUCT (r_c); + + svc_io_r_change_svc_config("", &r_c, &rbuf, 0); + p = rbuf.offset != 0; + + if (p && r_c.status != 0) { /* report error code */ - DEBUG(4,("SVC_R_UNKNOWN_1B: %s\n", get_nt_error_msg(r_o.status))); + DEBUG(1,("SVC_CHANGE_SVC_CONFIG: %s\n", get_nt_error_msg(r_c.status))); p = False; } if (p) { - (*num_items) = r_o.num_items1; - (*items) = r_o.items; + valid_cfg = True; } } - prs_mem_free(&data ); - prs_mem_free(&rdata ); + prs_mem_free(&rbuf); + prs_mem_free(&buf ); - return valid_query; + return valid_cfg; } + + -- cgit From a70a4626df78965e1ad9c7f89f5d1c490e373ee0 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 24 Nov 1999 23:11:03 +0000 Subject: 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) --- source3/rpc_client/cli_svcctl.c | 98 +++++++++++++++++++++++++++++++++-------- 1 file changed, 80 insertions(+), 18 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') 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; } - - -- cgit From 3fc5ec73be6009d50ec1e8e83505572ad16c1943 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sat, 27 Nov 1999 21:50:11 +0000 Subject: further abstraction involving client states. main client-side code is pretty much independent of SMB client states, which will make it easier to add other transports. (This used to be commit a1ff7e8fc3129ba4a04722f977bc2d3725d13624) --- source3/rpc_client/cli_svcctl.c | 63 ++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 36 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index ed470f5758..b284b2661e 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -43,10 +43,9 @@ BOOL svc_open_sc_man( const char *srv_name, char *db_name, SVC_Q_OPEN_SC_MAN q_o; BOOL valid_pol = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; + struct cli_connection *con = NULL; - if (!cli_state_init(srv_name, PIPE_SVCCTL, &cli, &fnum)) + if (!cli_connection_init(srv_name, PIPE_SVCCTL, &con)) { return False; } @@ -66,7 +65,7 @@ BOOL svc_open_sc_man( const char *srv_name, char *db_name, svc_io_q_open_sc_man("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SVC_OPEN_SC_MAN, &buf, &rbuf)) + if (rpc_con_pipe_req(con, SVC_OPEN_SC_MAN, &buf, &rbuf)) { SVC_R_OPEN_SC_MAN r_o; BOOL p; @@ -89,8 +88,8 @@ BOOL svc_open_sc_man( const char *srv_name, char *db_name, 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); + set_policy_con(hnd, con, + cli_connection_unlink); } } @@ -114,10 +113,9 @@ BOOL svc_open_service( POLICY_HND *scm_hnd, SVC_Q_OPEN_SERVICE q_o; BOOL valid_pol = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; + struct cli_connection *con = NULL; - if (!cli_state_get(scm_hnd, &cli, &fnum)) + if (!cli_connection_get(scm_hnd, &con)) { return False; } @@ -137,7 +135,7 @@ BOOL svc_open_service( POLICY_HND *scm_hnd, svc_io_q_open_service("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SVC_OPEN_SERVICE, &buf, &rbuf)) + if (rpc_con_pipe_req(con, SVC_OPEN_SERVICE, &buf, &rbuf)) { SVC_R_OPEN_SERVICE r_o; BOOL p; @@ -159,8 +157,7 @@ BOOL svc_open_service( POLICY_HND *scm_hnd, /* ok, at last: we're happy. return the policy handle */ memcpy(hnd, r_o.pol.data, sizeof(hnd->data)); valid_pol = register_policy_hnd(hnd) && - set_policy_cli_state(hnd, cli, fnum, - NULL); + set_policy_con(hnd, con, NULL); } } @@ -185,10 +182,9 @@ BOOL svc_enum_svcs( POLICY_HND *hnd, SVC_Q_ENUM_SVCS_STATUS q_o; BOOL valid_pol = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; + struct cli_connection *con = NULL; - if (!cli_state_get(hnd, &cli, &fnum)) + if (!cli_connection_get(hnd, &con)) { return False; } @@ -213,7 +209,7 @@ BOOL svc_enum_svcs( POLICY_HND *hnd, svc_io_q_enum_svcs_status("", &q_o, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SVC_ENUM_SVCS_STATUS, &buf, &rbuf)) + if (rpc_con_pipe_req(con, SVC_ENUM_SVCS_STATUS, &buf, &rbuf)) { SVC_R_ENUM_SVCS_STATUS r_o; BOOL p; @@ -266,10 +262,9 @@ BOOL svc_stop_service( POLICY_HND *hnd, SVC_Q_STOP_SERVICE q_c; BOOL valid_cfg = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; + struct cli_connection *con = NULL; - if (!cli_state_get(hnd, &cli, &fnum)) + if (!cli_connection_get(hnd, &con)) { return False; } @@ -290,7 +285,7 @@ BOOL svc_stop_service( POLICY_HND *hnd, svc_io_q_stop_service("", &q_c, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SVC_STOP_SERVICE, &buf, &rbuf)) + if (rpc_con_pipe_req(con, SVC_STOP_SERVICE, &buf, &rbuf)) { SVC_R_STOP_SERVICE r_c; BOOL p; @@ -332,10 +327,9 @@ BOOL svc_start_service( POLICY_HND *hnd, SVC_Q_START_SERVICE q_c; BOOL valid_cfg = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; + struct cli_connection *con = NULL; - if (!cli_state_get(hnd, &cli, &fnum)) + if (!cli_connection_get(hnd, &con)) { return False; } @@ -356,7 +350,7 @@ BOOL svc_start_service( POLICY_HND *hnd, svc_io_q_start_service("", &q_c, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SVC_START_SERVICE, &buf, &rbuf)) + if (rpc_con_pipe_req(con, SVC_START_SERVICE, &buf, &rbuf)) { SVC_R_START_SERVICE r_c; BOOL p; @@ -398,10 +392,9 @@ BOOL svc_query_svc_cfg( POLICY_HND *hnd, SVC_Q_QUERY_SVC_CONFIG q_c; BOOL valid_cfg = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; + struct cli_connection *con = NULL; - if (!cli_state_get(hnd, &cli, &fnum)) + if (!cli_connection_get(hnd, &con)) { return False; } @@ -422,7 +415,7 @@ BOOL svc_query_svc_cfg( POLICY_HND *hnd, svc_io_q_query_svc_config("", &q_c, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SVC_QUERY_SVC_CONFIG, &buf, &rbuf)) + if (rpc_con_pipe_req(con, SVC_QUERY_SVC_CONFIG, &buf, &rbuf)) { SVC_R_QUERY_SVC_CONFIG r_c; BOOL p; @@ -465,10 +458,9 @@ BOOL svc_close(POLICY_HND *hnd) SVC_Q_CLOSE q_c; BOOL valid_close = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; + struct cli_connection *con = NULL; - if (!cli_state_get(hnd, &cli, &fnum)) + if (!cli_connection_get(hnd, &con)) { return False; } @@ -489,7 +481,7 @@ BOOL svc_close(POLICY_HND *hnd) svc_io_q_close("", &q_c, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SVC_CLOSE, &buf, &rbuf)) + if (rpc_con_pipe_req(con, SVC_CLOSE, &buf, &rbuf)) { SVC_R_CLOSE r_c; BOOL p; @@ -553,10 +545,9 @@ BOOL svc_change_svc_cfg( POLICY_HND *hnd, SVC_Q_CHANGE_SVC_CONFIG q_c; BOOL valid_cfg = False; - struct cli_state *cli = NULL; - uint16 fnum = 0xffff; + struct cli_connection *con = NULL; - if (!cli_state_get(hnd, &cli, &fnum)) + if (!cli_connection_get(hnd, &con)) { return False; } @@ -583,7 +574,7 @@ BOOL svc_change_svc_cfg( POLICY_HND *hnd, svc_io_q_change_svc_config("", &q_c, &buf, 0); /* send the data on \PIPE\ */ - if (rpc_api_pipe_req(cli, fnum, SVC_CHANGE_SVC_CONFIG, &buf, &rbuf)) + if (rpc_con_pipe_req(con, SVC_CHANGE_SVC_CONFIG, &buf, &rbuf)) { SVC_R_CHANGE_SVC_CONFIG r_c; BOOL p; -- cgit From 32a965e09ce4befe971855e11e1fb5ceb51a9ed1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 1999 13:35:20 +0000 Subject: 2nd phase of head branch sync with SAMBA_2_0 - this delets all the files that were in the head branch but weren't in SAMBA_2_0 (This used to be commit d7b208786590b5a28618590172b8d523627dda09) --- source3/rpc_client/cli_svcctl.c | 604 ---------------------------------------- 1 file changed, 604 deletions(-) delete mode 100644 source3/rpc_client/cli_svcctl.c (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c deleted file mode 100644 index b284b2661e..0000000000 --- a/source3/rpc_client/cli_svcctl.c +++ /dev/null @@ -1,604 +0,0 @@ - -/* - * Unix SMB/Netbios implementation. - * Version 1.9. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1998, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, - * Copyright (C) Paul Ashton 1997-1998. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -#ifdef SYSLOG -#undef SYSLOG -#endif - -#include "includes.h" - -extern int DEBUGLEVEL; - -/**************************************************************************** -do a SVC Open Policy -****************************************************************************/ -BOOL svc_open_sc_man( const char *srv_name, char *db_name, - uint32 des_access, - POLICY_HND *hnd) -{ - prs_struct rbuf; - prs_struct buf; - SVC_Q_OPEN_SC_MAN q_o; - BOOL valid_pol = False; - - struct cli_connection *con = NULL; - - if (!cli_connection_init(srv_name, PIPE_SVCCTL, &con)) - { - return False; - } - - if (hnd == NULL) return False; - - prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); - prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); - - /* create and send a MSRPC command with api SVC_OPEN_SC_MAN */ - - DEBUG(4,("SVC Open SC_MAN\n")); - - make_svc_q_open_sc_man(&q_o, srv_name, db_name, des_access); - - /* turn parameters into data stream */ - svc_io_q_open_sc_man("", &q_o, &buf, 0); - - /* send the data on \PIPE\ */ - if (rpc_con_pipe_req(con, SVC_OPEN_SC_MAN, &buf, &rbuf)) - { - SVC_R_OPEN_SC_MAN r_o; - BOOL p; - - ZERO_STRUCT(r_o); - - svc_io_r_open_sc_man("", &r_o, &rbuf, 0); - p = rbuf.offset != 0; - - if (p && r_o.status != 0) - { - /* report error code */ - DEBUG(1,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status))); - p = False; - } - - if (p) - { - /* 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_con(hnd, con, - cli_connection_unlink); - } - } - - prs_mem_free(&rbuf); - prs_mem_free(&buf ); - - return valid_pol; -} - - -/**************************************************************************** -do a SVC Open Service -****************************************************************************/ -BOOL svc_open_service( POLICY_HND *scm_hnd, - const char *srv_name, - uint32 des_access, - POLICY_HND *hnd) -{ - prs_struct rbuf; - prs_struct buf; - SVC_Q_OPEN_SERVICE q_o; - BOOL valid_pol = False; - - struct cli_connection *con = NULL; - - if (!cli_connection_get(scm_hnd, &con)) - { - return False; - } - - if (hnd == NULL || scm_hnd == NULL) return False; - - prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); - prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); - - /* create and send a MSRPC command with api SVC_OPEN_SERVICE */ - - DEBUG(4,("SVC Open Service\n")); - - make_svc_q_open_service(&q_o, scm_hnd, srv_name, des_access); - - /* turn parameters into data stream */ - svc_io_q_open_service("", &q_o, &buf, 0); - - /* send the data on \PIPE\ */ - if (rpc_con_pipe_req(con, SVC_OPEN_SERVICE, &buf, &rbuf)) - { - SVC_R_OPEN_SERVICE r_o; - BOOL p; - - ZERO_STRUCT(r_o); - - svc_io_r_open_service("", &r_o, &rbuf, 0); - p = rbuf.offset != 0; - - if (p && r_o.status != 0) - { - /* report error code */ - DEBUG(1,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status))); - p = False; - } - - if (p) - { - /* ok, at last: we're happy. return the policy handle */ - memcpy(hnd, r_o.pol.data, sizeof(hnd->data)); - valid_pol = register_policy_hnd(hnd) && - set_policy_con(hnd, con, NULL); - } - } - - prs_mem_free(&rbuf); - prs_mem_free(&buf ); - - return valid_pol; -} - - -/**************************************************************************** -do a SVC Enumerate Services -****************************************************************************/ -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) -{ - prs_struct rbuf; - prs_struct buf; - SVC_Q_ENUM_SVCS_STATUS q_o; - BOOL valid_pol = False; - - struct cli_connection *con = NULL; - - if (!cli_connection_get(hnd, &con)) - { - return False; - } - - if (hnd == NULL || buf_size == NULL || dos_error == NULL || num_svcs == NULL) - { - return False; - } - - prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); - prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); - - /* create and send a MSRPC command with api SVC_ENUM_SVCS_STATUS */ - - DEBUG(4,("SVC Enum Services Status\n")); - - make_svc_q_enum_svcs_status(&q_o, hnd, - services_type, services_state, - *buf_size, *resume_hnd); - - /* turn parameters into data stream */ - svc_io_q_enum_svcs_status("", &q_o, &buf, 0); - - /* send the data on \PIPE\ */ - if (rpc_con_pipe_req(con, SVC_ENUM_SVCS_STATUS, &buf, &rbuf)) - { - SVC_R_ENUM_SVCS_STATUS r_o; - BOOL p; - - ZERO_STRUCT(r_o); - - svc_io_r_enum_svcs_status("", &r_o, &rbuf, 0); - p = rbuf.offset != 0; - - if (p && r_o.dos_status != 0) - { - fstring errmsg; - - if (r_o.dos_status != ERRmoredata) - { - smb_safe_err_msg(ERRDOS, r_o.dos_status, - errmsg, sizeof(errmsg)); - /* report error code */ - DEBUG(1,("SVC_ENUM_SVCS_STATUS: %s\n", errmsg)); - } - p = r_o.dos_status == ERRmoredata; - } - - if (p) - { - (*svcs) = r_o.svcs; - (*num_svcs) = r_o.num_svcs; - (*resume_hnd) = get_enum_hnd(&r_o.resume_hnd); - (*buf_size) = r_o.more_buf_size; - (*dos_error) = r_o.dos_status; - valid_pol = True; - } - } - - prs_mem_free(&rbuf); - prs_mem_free(&buf ); - - return valid_pol; -} - - -/**************************************************************************** -do a SVC Stop Service -****************************************************************************/ -BOOL svc_stop_service( POLICY_HND *hnd, - uint32 unknown) -{ - prs_struct rbuf; - prs_struct buf; - SVC_Q_STOP_SERVICE q_c; - BOOL valid_cfg = False; - - struct cli_connection *con = NULL; - - if (!cli_connection_get(hnd, &con)) - { - return False; - } - - if (hnd == NULL) return False; - - /* create and send a MSRPC command with api SVC_STOP_SERVICE */ - - prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); - prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); - - DEBUG(4,("SVC Stop Service\n")); - - /* store the parameters */ - make_svc_q_stop_service(&q_c, hnd, unknown); - - /* turn parameters into data stream */ - svc_io_q_stop_service("", &q_c, &buf, 0); - - /* send the data on \PIPE\ */ - if (rpc_con_pipe_req(con, SVC_STOP_SERVICE, &buf, &rbuf)) - { - SVC_R_STOP_SERVICE r_c; - BOOL p; - - ZERO_STRUCT (r_c); - - svc_io_r_stop_service("", &r_c, &rbuf, 0); - p = rbuf.offset != 0; - - if (p && r_c.status != 0) - { - /* report error code */ - DEBUG(1,("SVC_START_SERVICE: %s\n", get_nt_error_msg(r_c.status))); - p = False; - } - - if (p) - { - valid_cfg = True; - } - } - - prs_mem_free(&rbuf); - prs_mem_free(&buf ); - - return valid_cfg; -} - - -/**************************************************************************** -do a SVC Start Service -****************************************************************************/ -BOOL svc_start_service( POLICY_HND *hnd, - uint32 argc, - char **argv) -{ - prs_struct rbuf; - prs_struct buf; - SVC_Q_START_SERVICE q_c; - BOOL valid_cfg = False; - - struct cli_connection *con = NULL; - - if (!cli_connection_get(hnd, &con)) - { - return False; - } - - if (hnd == NULL) return False; - - /* create and send a MSRPC command with api SVC_START_SERVICE */ - - prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); - prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); - - DEBUG(4,("SVC Start Service\n")); - - /* store the parameters */ - make_svc_q_start_service(&q_c, hnd, argc, argv); - - /* turn parameters into data stream */ - svc_io_q_start_service("", &q_c, &buf, 0); - - /* send the data on \PIPE\ */ - if (rpc_con_pipe_req(con, SVC_START_SERVICE, &buf, &rbuf)) - { - SVC_R_START_SERVICE r_c; - BOOL p; - - ZERO_STRUCT (r_c); - - svc_io_r_start_service("", &r_c, &rbuf, 0); - p = rbuf.offset != 0; - - if (p && r_c.status != 0) - { - /* report error code */ - DEBUG(1,("SVC_START_SERVICE: %s\n", get_nt_error_msg(r_c.status))); - p = False; - } - - if (p) - { - valid_cfg = True; - } - } - - prs_mem_free(&rbuf); - prs_mem_free(&buf ); - - return valid_cfg; -} - - -/**************************************************************************** -do a SVC Query Service Config -****************************************************************************/ -BOOL svc_query_svc_cfg( POLICY_HND *hnd, - QUERY_SERVICE_CONFIG *cfg, - uint32 *buf_size) -{ - prs_struct rbuf; - prs_struct buf; - SVC_Q_QUERY_SVC_CONFIG q_c; - BOOL valid_cfg = False; - - struct cli_connection *con = NULL; - - if (!cli_connection_get(hnd, &con)) - { - return False; - } - - if (hnd == NULL || buf_size == NULL) return False; - - /* create and send a MSRPC command with api SVC_QUERY_SVC_CONFIG */ - - prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); - prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); - - DEBUG(4,("SVC Query Service Config\n")); - - /* store the parameters */ - make_svc_q_query_svc_config(&q_c, hnd, *buf_size); - - /* turn parameters into data stream */ - svc_io_q_query_svc_config("", &q_c, &buf, 0); - - /* send the data on \PIPE\ */ - if (rpc_con_pipe_req(con, SVC_QUERY_SVC_CONFIG, &buf, &rbuf)) - { - SVC_R_QUERY_SVC_CONFIG r_c; - BOOL p; - - ZERO_STRUCT (r_c); - ZERO_STRUCTP(cfg); - - r_c.cfg = cfg; - - svc_io_r_query_svc_config("", &r_c, &rbuf, 0); - p = rbuf.offset != 0; - - if (p && r_c.status != 0) - { - /* report error code */ - DEBUG(1,("SVC_QUERY_SVC_CONFIG: %s\n", get_nt_error_msg(r_c.status))); - p = False; - } - - if (p) - { - valid_cfg = r_c.buf_size != 0; - } - } - - prs_mem_free(&rbuf); - prs_mem_free(&buf ); - - return valid_cfg; -} - - -/**************************************************************************** -do a SVC Close -****************************************************************************/ -BOOL svc_close(POLICY_HND *hnd) -{ - prs_struct rbuf; - prs_struct buf; - SVC_Q_CLOSE q_c; - BOOL valid_close = False; - - struct cli_connection *con = NULL; - - if (!cli_connection_get(hnd, &con)) - { - return False; - } - - if (hnd == NULL) return False; - - /* create and send a MSRPC command with api SVC_CLOSE */ - - prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); - prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); - - DEBUG(4,("SVC Close\n")); - - /* store the parameters */ - make_svc_q_close(&q_c, hnd); - - /* turn parameters into data stream */ - svc_io_q_close("", &q_c, &buf, 0); - - /* send the data on \PIPE\ */ - if (rpc_con_pipe_req(con, SVC_CLOSE, &buf, &rbuf)) - { - SVC_R_CLOSE r_c; - BOOL p; - - ZERO_STRUCT(r_c); - - svc_io_r_close("", &r_c, &rbuf, 0); - p = rbuf.offset != 0; - - if (p && r_c.status != 0) - { - /* report error code */ - DEBUG(1,("SVC_CLOSE: %s\n", get_nt_error_msg(r_c.status))); - p = False; - } - - if (p) - { - /* check that the returned policy handle is all zeros */ - uint32 i; - valid_close = True; - - for (i = 0; i < sizeof(r_c.pol.data); i++) - { - if (r_c.pol.data[i] != 0) - { - valid_close = False; - break; - } - } - if (!valid_close) - { - DEBUG(1,("SVC_CLOSE: non-zero handle returned\n")); - } - } - } - - close_policy_hnd(hnd); - - prs_mem_free(&rbuf); - prs_mem_free(&buf ); - - return valid_close; -} - -/**************************************************************************** -do a SVC Change Service Config -****************************************************************************/ -BOOL svc_change_svc_cfg( POLICY_HND *hnd, - uint32 service_type, uint32 start_type, - uint32 unknown_0, - uint32 error_control, - char* bin_path_name, char* load_order_grp, - uint32 tag_id, - char* dependencies, char* service_start_name, - char* password, - char* disp_name) -{ - prs_struct rbuf; - prs_struct buf; - SVC_Q_CHANGE_SVC_CONFIG q_c; - BOOL valid_cfg = False; - - struct cli_connection *con = NULL; - - if (!cli_connection_get(hnd, &con)) - { - return False; - } - - if (hnd == NULL) return False; - - /* create and send a MSRPC command with api SVC_CHANGE_SVC_CONFIG */ - - prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); - prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); - - DEBUG(4,("SVC Change Service Config\n")); - - /* store the parameters */ - make_svc_q_change_svc_config(&q_c, hnd, - service_type, start_type, - unknown_0, error_control, - bin_path_name, load_order_grp, - tag_id, - dependencies, service_start_name, - password, disp_name); - - /* turn parameters into data stream */ - svc_io_q_change_svc_config("", &q_c, &buf, 0); - - /* send the data on \PIPE\ */ - if (rpc_con_pipe_req(con, SVC_CHANGE_SVC_CONFIG, &buf, &rbuf)) - { - SVC_R_CHANGE_SVC_CONFIG r_c; - BOOL p; - - ZERO_STRUCT (r_c); - - svc_io_r_change_svc_config("", &r_c, &rbuf, 0); - p = rbuf.offset != 0; - - if (p && r_c.status != 0) - { - /* report error code */ - DEBUG(1,("SVC_CHANGE_SVC_CONFIG: %s\n", get_nt_error_msg(r_c.status))); - p = False; - } - - if (p) - { - valid_cfg = True; - } - } - - prs_mem_free(&rbuf); - prs_mem_free(&buf ); - - return valid_cfg; -} -- cgit From 2e3ce1d534b544b2eedd9183f9f97c17a8e403fc Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 24 Mar 2005 04:25:49 +0000 Subject: r6029: adding files necessary to support 'net rpc service' functions; will fill in tomorrow (This used to be commit 6bbd61cfd1ca2dbe8d96d894f90f263b8f24571f) --- source3/rpc_client/cli_svcctl.c | 77 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 source3/rpc_client/cli_svcctl.c (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c new file mode 100644 index 0000000000..afef5f4fbb --- /dev/null +++ b/source3/rpc_client/cli_svcctl.c @@ -0,0 +1,77 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Gerald Carter 2005. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include "includes.h" + + +/******************************************************************* +*******************************************************************/ + +NTSTATUS cli_svcctl_enumerate_services(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +{ + return NT_STATUS_OK; +} + +/******************************************************************* +*******************************************************************/ + +NTSTATUS cli_svcctl_start_service(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +{ + + return NT_STATUS_OK; +} + +/******************************************************************* +*******************************************************************/ + +NTSTATUS cli_svcctl_control_service(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +{ + + return NT_STATUS_OK; +} + +/******************************************************************* +*******************************************************************/ + +NTSTATUS cli_svcctl_query_status(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +{ + + return NT_STATUS_OK; +} + +/******************************************************************* +*******************************************************************/ + +NTSTATUS cli_svcctl_query_config(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +{ + + return NT_STATUS_OK; +} + +/******************************************************************* +*******************************************************************/ + +NTSTATUS cli_svcctl_get_dispname(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +{ + + return NT_STATUS_OK; +} + -- cgit From 259d44dbb2c2239339f6888fd5da12632abcbb28 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 24 Mar 2005 16:11:23 +0000 Subject: r6038: adding more flesh to 'net rpc service' open and close the service control manager. Also experimenting with ideas for cli_xxx() interface. (This used to be commit 4da89ef17b8c4644b97b923cebfe8e446b508b4d) --- source3/rpc_client/cli_svcctl.c | 109 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 2 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index afef5f4fbb..7bf7392cd6 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -21,13 +21,118 @@ #include "includes.h" +/******************************************************************* +*******************************************************************/ + +WERROR cli_svcctl_open_scm( struct cli_state *cli, TALLOC_CTX *mem_ctx, + SVCCTL_Q_OPEN_SCMANAGER *in, SVCCTL_R_OPEN_SCMANAGER *out ) +{ + prs_struct qbuf, rbuf; + + /* Initialise parse structures */ + + prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL); + prs_init(&rbuf, 0, mem_ctx, UNMARSHALL); + + out->status = WERR_GENERAL_FAILURE; + + /* Marshall data and send request */ + + if ( svcctl_io_q_open_scmanager("", in, &qbuf, 0) ) { + if ( rpc_api_pipe_req(cli, PI_SVCCTL, SVCCTL_OPEN_SCMANAGER_W, &qbuf, &rbuf) ) { + /* Unmarshall response */ + if (!svcctl_io_r_open_scmanager("", out, &rbuf, 0)) { + out->status = WERR_GENERAL_FAILURE; + } + } + } + + prs_mem_free(&qbuf); + prs_mem_free(&rbuf); + + return out->status; +} /******************************************************************* *******************************************************************/ -NTSTATUS cli_svcctl_enumerate_services(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +WERROR cli_svcctl_close_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, + SVCCTL_Q_CLOSE_SERVICE *in, SVCCTL_R_CLOSE_SERVICE *out ) { - return NT_STATUS_OK; + prs_struct qbuf, rbuf; + + /* Initialise parse structures */ + + prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL); + prs_init(&rbuf, 0, mem_ctx, UNMARSHALL); + + out->status = WERR_GENERAL_FAILURE; + + /* Marshall data and send request */ + + if ( svcctl_io_q_close_service("", in, &qbuf, 0) ) { + if ( rpc_api_pipe_req(cli, PI_SVCCTL, SVCCTL_CLOSE_SERVICE, &qbuf, &rbuf) ) { + /* Unmarshall response */ + if (!svcctl_io_r_close_service("", out, &rbuf, 0)) { + out->status = WERR_GENERAL_FAILURE; + } + } + } + + prs_mem_free(&qbuf); + prs_mem_free(&rbuf); + + return out->status; +} + +/******************************************************************* +*******************************************************************/ + +WERROR cli_svcctl_enumerate_services( struct cli_state *cli, TALLOC_CTX *mem_ctx, + POLICY_HND *hSCM, uint32 type, uint32 state, + uint32 *resume, uint32 buffer_size, RPC_BUFFER *buffer, + uint32 returned ) +{ + prs_struct qbuf, rbuf; + SVCCTL_Q_ENUM_SERVICES_STATUS q; + SVCCTL_R_ENUM_SERVICES_STATUS r; + WERROR result = WERR_GENERAL_FAILURE; + + 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 */ + + + /* Marshall data and send request */ + + if (!svcctl_io_q_enum_services_status("", &q, &qbuf, 0) || + !rpc_api_pipe_req(cli, PI_SVCCTL, SVCCTL_ENUM_SERVICES_STATUS_W, &qbuf, &rbuf)) { + goto done; + } + + /* Unmarshall response */ + + if (!svcctl_io_r_enum_services_status("", &r, &rbuf, 0)) { + goto done; + } + + /* Return output parameters */ + + if (W_ERROR_IS_OK(result = r.status)) { + *buffer = r.buffer; + } + +done: + prs_mem_free(&qbuf); + prs_mem_free(&rbuf); + + return result; } /******************************************************************* -- cgit From eb1adc527bb1b01f28fa86e7caa66c85181df764 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 24 Mar 2005 17:11:51 +0000 Subject: r6039: add CLI_DO_RPC macro for cookie cutter code; no new functionality to 'net rpc service' (This used to be commit 759affb1e1aa59fcb878b4dee781aa362b3e7e1c) --- source3/rpc_client/cli_svcctl.c | 185 ++++++++++++++++++++-------------------- 1 file changed, 91 insertions(+), 94 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 7bf7392cd6..1702112bba 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -20,69 +20,89 @@ #include "includes.h" + +/* macro to expand cookie-cutter code */ + +#define CLI_DO_RPC( cli, mem_ctx, pipe_num, opnum, in, out, qbuf, rbuf, q_io_fn, r_io_fn, default_error) \ +{ out.status = default_error;\ + prs_init( &qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL ); \ + prs_init( &rbuf, 0, mem_ctx, UNMARSHALL );\ + if ( q_io_fn("", &in, &qbuf, 0) ) {\ + if ( rpc_api_pipe_req(cli, pipe_num, opnum, &qbuf, &rbuf) ) {\ + if (!r_io_fn("", &out, &rbuf, 0)) {\ + out.status = default_error;\ + }\ + }\ + }\ + prs_mem_free( &qbuf );\ + prs_mem_free( &rbuf );\ +} -/******************************************************************* -*******************************************************************/ + +/******************************************************************** +********************************************************************/ WERROR cli_svcctl_open_scm( struct cli_state *cli, TALLOC_CTX *mem_ctx, - SVCCTL_Q_OPEN_SCMANAGER *in, SVCCTL_R_OPEN_SCMANAGER *out ) + POLICY_HND *hSCM, uint32 access_desired ) { + SVCCTL_Q_OPEN_SCMANAGER in; + SVCCTL_R_OPEN_SCMANAGER out; prs_struct qbuf, rbuf; - - /* Initialise parse structures */ - - prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL); - prs_init(&rbuf, 0, mem_ctx, UNMARSHALL); + fstring server; + + ZERO_STRUCT(in); + ZERO_STRUCT(out); - out->status = WERR_GENERAL_FAILURE; + /* leave the database name NULL to get the default service db */ - /* Marshall data and send request */ + in.database = NULL; - if ( svcctl_io_q_open_scmanager("", in, &qbuf, 0) ) { - if ( rpc_api_pipe_req(cli, PI_SVCCTL, SVCCTL_OPEN_SCMANAGER_W, &qbuf, &rbuf) ) { - /* Unmarshall response */ - if (!svcctl_io_r_open_scmanager("", out, &rbuf, 0)) { - out->status = WERR_GENERAL_FAILURE; - } - } - } + /* set the server name */ - prs_mem_free(&qbuf); - prs_mem_free(&rbuf); + if ( !(in.servername = TALLOC_P( mem_ctx, UNISTR2 )) ) + return WERR_NOMEM; + fstr_sprintf( server, "\\\\%s", cli->desthost ); + init_unistr2( in.servername, server, UNI_STR_TERMINATE ); - return out->status; + in.access = access_desired; + + CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_OPEN_SCMANAGER_W, + in, out, + qbuf, rbuf, + svcctl_io_q_open_scmanager, + svcctl_io_r_open_scmanager, + WERR_GENERAL_FAILURE ); + + if ( !W_ERROR_IS_OK( out.status ) ) + return out.status; + + memcpy( hSCM, &out.handle, sizeof(POLICY_HND) ); + + return out.status; } -/******************************************************************* -*******************************************************************/ +/******************************************************************** +********************************************************************/ -WERROR cli_svcctl_close_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, - SVCCTL_Q_CLOSE_SERVICE *in, SVCCTL_R_CLOSE_SERVICE *out ) +WERROR close_service_handle( struct cli_state *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService ) { + SVCCTL_Q_CLOSE_SERVICE in; + SVCCTL_R_CLOSE_SERVICE out; prs_struct qbuf, rbuf; - - /* Initialise parse structures */ - - prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL); - prs_init(&rbuf, 0, mem_ctx, UNMARSHALL); - out->status = WERR_GENERAL_FAILURE; - - /* Marshall data and send request */ - - if ( svcctl_io_q_close_service("", in, &qbuf, 0) ) { - if ( rpc_api_pipe_req(cli, PI_SVCCTL, SVCCTL_CLOSE_SERVICE, &qbuf, &rbuf) ) { - /* Unmarshall response */ - if (!svcctl_io_r_close_service("", out, &rbuf, 0)) { - out->status = WERR_GENERAL_FAILURE; - } - } - } - - prs_mem_free(&qbuf); - prs_mem_free(&rbuf); - - return out->status; + ZERO_STRUCT(in); + ZERO_STRUCT(out); + + memcpy( &in.handle, hService, sizeof(POLICY_HND) ); + + CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_CLOSE_SERVICE, + in, out, + qbuf, rbuf, + svcctl_io_q_close_service, + svcctl_io_r_close_service, + WERR_GENERAL_FAILURE ); + + return out.status; } /******************************************************************* @@ -90,93 +110,70 @@ WERROR cli_svcctl_close_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, WERROR cli_svcctl_enumerate_services( struct cli_state *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hSCM, uint32 type, uint32 state, - uint32 *resume, uint32 buffer_size, RPC_BUFFER *buffer, - uint32 returned ) + uint32 *resume, uint32 returned ) { + SVCCTL_Q_ENUM_SERVICES_STATUS in; + SVCCTL_R_ENUM_SERVICES_STATUS out; prs_struct qbuf, rbuf; - SVCCTL_Q_ENUM_SERVICES_STATUS q; - SVCCTL_R_ENUM_SERVICES_STATUS r; - WERROR result = WERR_GENERAL_FAILURE; - - 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 */ - - - /* Marshall data and send request */ - - if (!svcctl_io_q_enum_services_status("", &q, &qbuf, 0) || - !rpc_api_pipe_req(cli, PI_SVCCTL, SVCCTL_ENUM_SERVICES_STATUS_W, &qbuf, &rbuf)) { - goto done; - } - - /* Unmarshall response */ - - if (!svcctl_io_r_enum_services_status("", &r, &rbuf, 0)) { - goto done; - } - /* Return output parameters */ + ZERO_STRUCT(in); + ZERO_STRUCT(out); - if (W_ERROR_IS_OK(result = r.status)) { - *buffer = r.buffer; - } + CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_ENUM_SERVICES_STATUS_W, + in, out, + qbuf, rbuf, + svcctl_io_q_enum_services_status, + svcctl_io_r_enum_services_status, + WERR_GENERAL_FAILURE ); -done: - prs_mem_free(&qbuf); - prs_mem_free(&rbuf); + if ( !W_ERROR_IS_OK(out.status) ) + return out.status; - return result; + return out.status; } /******************************************************************* *******************************************************************/ -NTSTATUS cli_svcctl_start_service(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +WERROR cli_svcctl_start_service(struct cli_state *cli, TALLOC_CTX *mem_ctx ) { - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************* *******************************************************************/ -NTSTATUS cli_svcctl_control_service(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +WERROR cli_svcctl_control_service(struct cli_state *cli, TALLOC_CTX *mem_ctx ) { - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************* *******************************************************************/ -NTSTATUS cli_svcctl_query_status(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +WERROR cli_svcctl_query_status(struct cli_state *cli, TALLOC_CTX *mem_ctx ) { - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************* *******************************************************************/ -NTSTATUS cli_svcctl_query_config(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +WERROR cli_svcctl_query_config(struct cli_state *cli, TALLOC_CTX *mem_ctx ) { - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************* *******************************************************************/ -NTSTATUS cli_svcctl_get_dispname(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +WERROR cli_svcctl_get_dispname(struct cli_state *cli, TALLOC_CTX *mem_ctx ) { - return NT_STATUS_OK; + return WERR_OK; } -- cgit From 9d009834a63e45e8a348419d4f5313757cff8c8d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 24 Mar 2005 18:05:31 +0000 Subject: r6040: finish out 'net rpc service list' (This used to be commit 42588ba50cb1b47a00f3e0bed33ca3431eb8af14) --- source3/rpc_client/cli_svcctl.c | 61 ++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 19 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 1702112bba..74d6483b17 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -20,24 +20,7 @@ #include "includes.h" - -/* macro to expand cookie-cutter code */ - -#define CLI_DO_RPC( cli, mem_ctx, pipe_num, opnum, in, out, qbuf, rbuf, q_io_fn, r_io_fn, default_error) \ -{ out.status = default_error;\ - prs_init( &qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL ); \ - prs_init( &rbuf, 0, mem_ctx, UNMARSHALL );\ - if ( q_io_fn("", &in, &qbuf, 0) ) {\ - if ( rpc_api_pipe_req(cli, pipe_num, opnum, &qbuf, &rbuf) ) {\ - if (!r_io_fn("", &out, &rbuf, 0)) {\ - out.status = default_error;\ - }\ - }\ - }\ - prs_mem_free( &qbuf );\ - prs_mem_free( &rbuf );\ -} - +#include "rpc_client.h" /******************************************************************** ********************************************************************/ @@ -110,14 +93,28 @@ WERROR close_service_handle( struct cli_state *cli, TALLOC_CTX *mem_ctx, POLICY_ WERROR cli_svcctl_enumerate_services( struct cli_state *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hSCM, uint32 type, uint32 state, - uint32 *resume, uint32 returned ) + uint32 *returned, ENUM_SERVICES_STATUS **service_array ) { SVCCTL_Q_ENUM_SERVICES_STATUS in; SVCCTL_R_ENUM_SERVICES_STATUS out; prs_struct qbuf, rbuf; + uint32 resume = 0; + ENUM_SERVICES_STATUS *services; + int i; ZERO_STRUCT(in); ZERO_STRUCT(out); + + /* setup the request */ + + memcpy( &in.handle, hSCM, sizeof(POLICY_HND) ); + + in.type = type; + in.state = state; + in.resume = &resume; + + /* first time is to get the buffer size */ + in.buffer_size = 0; CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_ENUM_SERVICES_STATUS_W, in, out, @@ -126,8 +123,34 @@ WERROR cli_svcctl_enumerate_services( struct cli_state *cli, TALLOC_CTX *mem_ctx svcctl_io_r_enum_services_status, WERR_GENERAL_FAILURE ); + /* second time with correct buffer size...should be ok */ + + if ( !W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) { + in.buffer_size = out.needed; + + CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_ENUM_SERVICES_STATUS_W, + in, out, + qbuf, rbuf, + svcctl_io_q_enum_services_status, + svcctl_io_r_enum_services_status, + WERR_GENERAL_FAILURE ); + } + if ( !W_ERROR_IS_OK(out.status) ) return out.status; + + /* pull out the data */ + if ( !(services = TALLOC_ARRAY( mem_ctx, ENUM_SERVICES_STATUS, out.returned )) ) + return WERR_NOMEM; + + for ( i=0; i Date: Thu, 24 Mar 2005 22:32:31 +0000 Subject: r6046: $ net -S block -U % -W VALE rpc service status spooler spooler service is SVCCTL_RUNNING. Configuration details: Service Type = 0x110 Start Type = 0x2 Error Control = 0x1 Tag ID = 0x0 Executable Path = C:\WINNT\system32\spoolsv.exe Load Order Group = SpoolerGroup Dependencies = RPCSS/ Start Name = LocalSystem Display Name = Print Spooler (This used to be commit b921bf568835042a43bb0bcb2abd9d36c9d2e43f) --- source3/rpc_client/cli_svcctl.c | 192 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 181 insertions(+), 11 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 74d6483b17..c9fdc61379 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -22,6 +22,42 @@ #include "includes.h" #include "rpc_client.h" +struct svc_state_msg { + uint32 flag; + const char *message; +}; + +static struct svc_state_msg state_msg_table[] = { + { SVCCTL_STOPPED, "SVCCTL_STOPPED" }, + { SVCCTL_START_PENDING, "SVCCTL_START_PENDING" }, + { SVCCTL_STOP_PENDING, "SVCCTL_STOP_PENDING" }, + { SVCCTL_RUNNING, "SVCCTL_RUNNING" }, + { SVCCTL_CONTINUE_PENDING, "SVCCTL_CONTINUE_PENDING" }, + { SVCCTL_PAUSE_PENDING, "SVCCTL_PAUSE_PENDING" }, + { SVCCTL_PAUSED, "SVCCTL_PAUSED" }, + { 0, NULL } +}; + + +/******************************************************************** +********************************************************************/ +const char* svc_status_string( uint32 state ) +{ + static fstring msg; + int i; + + fstr_sprintf( msg, "Unknown State [%d]", state ); + + for ( i=0; state_msg_table[i].message; i++ ) { + if ( state_msg_table[i].flag == state ) { + fstrcpy( msg, state_msg_table[i].message ); + break; + } + } + + return msg; +} + /******************************************************************** ********************************************************************/ @@ -67,6 +103,39 @@ WERROR cli_svcctl_open_scm( struct cli_state *cli, TALLOC_CTX *mem_ctx, /******************************************************************** ********************************************************************/ +WERROR cli_svcctl_open_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, + POLICY_HND *hSCM, POLICY_HND *hService, + const char *servicename, uint32 access_desired ) +{ + SVCCTL_Q_OPEN_SERVICE in; + SVCCTL_R_OPEN_SERVICE out; + prs_struct qbuf, rbuf; + + ZERO_STRUCT(in); + ZERO_STRUCT(out); + + memcpy( &in.handle, hSCM, sizeof(POLICY_HND) ); + init_unistr2( &in.servicename, servicename, UNI_STR_TERMINATE ); + in.access = access_desired; + + CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_OPEN_SERVICE_W, + in, out, + qbuf, rbuf, + svcctl_io_q_open_service, + svcctl_io_r_open_service, + WERR_GENERAL_FAILURE ); + + if ( !W_ERROR_IS_OK( out.status ) ) + return out.status; + + memcpy( hService, &out.handle, sizeof(POLICY_HND) ); + + return out.status; +} + +/******************************************************************** +********************************************************************/ + WERROR close_service_handle( struct cli_state *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService ) { SVCCTL_Q_CLOSE_SERVICE in; @@ -125,7 +194,7 @@ WERROR cli_svcctl_enumerate_services( struct cli_state *cli, TALLOC_CTX *mem_ctx /* second time with correct buffer size...should be ok */ - if ( !W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) { + if ( W_ERROR_EQUAL( out.status, WERR_MORE_DATA ) ) { in.buffer_size = out.needed; CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_ENUM_SERVICES_STATUS_W, @@ -150,33 +219,98 @@ WERROR cli_svcctl_enumerate_services( struct cli_state *cli, TALLOC_CTX *mem_ctx *service_array = services; *returned = out.returned; - - return out.status; } /******************************************************************* *******************************************************************/ -WERROR cli_svcctl_start_service(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +WERROR cli_svcctl_query_status( struct cli_state *cli, TALLOC_CTX *mem_ctx, + POLICY_HND *hService, SERVICE_STATUS *status ) { + SVCCTL_Q_QUERY_STATUS in; + SVCCTL_R_QUERY_STATUS out; + prs_struct qbuf, rbuf; + + ZERO_STRUCT(in); + ZERO_STRUCT(out); + + memcpy( &in.handle, hService, sizeof(POLICY_HND) ); + + CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_QUERY_STATUS, + in, out, + qbuf, rbuf, + svcctl_io_q_query_status, + svcctl_io_r_query_status, + WERR_GENERAL_FAILURE ); + + if ( !W_ERROR_IS_OK( out.status ) ) + return out.status; - return WERR_OK; + memcpy( status, &out.svc_status, sizeof(SERVICE_STATUS) ); + + return out.status; } /******************************************************************* *******************************************************************/ -WERROR cli_svcctl_control_service(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +WERROR cli_svcctl_query_config(struct cli_state *cli, TALLOC_CTX *mem_ctx, + POLICY_HND *hService, SERVICE_CONFIG *config ) { + SVCCTL_Q_QUERY_SERVICE_CONFIG in; + SVCCTL_R_QUERY_SERVICE_CONFIG out; + prs_struct qbuf, rbuf; + + ZERO_STRUCT(in); + ZERO_STRUCT(out); + + memcpy( &in.handle, hService, sizeof(POLICY_HND) ); + in.buffer_size = 0; + + + CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_QUERY_SERVICE_CONFIG_W, + in, out, + qbuf, rbuf, + svcctl_io_q_query_service_config, + svcctl_io_r_query_service_config, + WERR_GENERAL_FAILURE ); + + if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) { + in.buffer_size = out.needed; - return WERR_OK; + CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_QUERY_SERVICE_CONFIG_W, + in, out, + qbuf, rbuf, + svcctl_io_q_query_service_config, + svcctl_io_r_query_service_config, + WERR_GENERAL_FAILURE ); + } + + if ( !W_ERROR_IS_OK( out.status ) ) + return out.status; + + memcpy( config, &out.config, sizeof(SERVICE_CONFIG) ); + + config->executablepath = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); + config->loadordergroup = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); + config->dependencies = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); + config->startname = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); + config->displayname = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); + + copy_unistr2( config->executablepath, out.config.executablepath ); + copy_unistr2( config->loadordergroup, out.config.loadordergroup ); + copy_unistr2( config->dependencies, out.config.dependencies ); + copy_unistr2( config->startname, out.config.startname ); + copy_unistr2( config->displayname, out.config.displayname ); + + return out.status; } /******************************************************************* *******************************************************************/ -WERROR cli_svcctl_query_status(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +WERROR cli_svcctl_start_service(struct cli_state *cli, TALLOC_CTX *mem_ctx ) { return WERR_OK; @@ -185,18 +319,54 @@ WERROR cli_svcctl_query_status(struct cli_state *cli, TALLOC_CTX *mem_ctx ) /******************************************************************* *******************************************************************/ -WERROR cli_svcctl_query_config(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +WERROR cli_svcctl_control_service(struct cli_state *cli, TALLOC_CTX *mem_ctx ) { return WERR_OK; } + /******************************************************************* *******************************************************************/ -WERROR cli_svcctl_get_dispname(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +WERROR cli_svcctl_get_dispname( struct cli_state *cli, TALLOC_CTX *mem_ctx, + POLICY_HND *hService, fstring displayname ) { + SVCCTL_Q_GET_DISPLAY_NAME in; + SVCCTL_R_GET_DISPLAY_NAME out; + prs_struct qbuf, rbuf; + + ZERO_STRUCT(in); + ZERO_STRUCT(out); + + memcpy( &in.handle, hService, sizeof(POLICY_HND) ); + in.display_name_len = 0; + + CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_GET_DISPLAY_NAME, + in, out, + qbuf, rbuf, + svcctl_io_q_get_display_name, + svcctl_io_r_get_display_name, + WERR_GENERAL_FAILURE ); + + /* second time with correct buffer size...should be ok */ + + if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) { + in.display_name_len = out.display_name_len; - return WERR_OK; + CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_GET_DISPLAY_NAME, + in, out, + qbuf, rbuf, + svcctl_io_q_get_display_name, + svcctl_io_r_get_display_name, + WERR_GENERAL_FAILURE ); + } + + if ( !W_ERROR_IS_OK( out.status ) ) + return out.status; + + rpcstr_pull( displayname, out.displayname.buffer, sizeof(displayname), -1, STR_TERMINATE ); + + return out.status; } -- cgit From 66e8ed2632f8efb4e749a79609eb34dc488aacdc Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 25 Mar 2005 00:38:30 +0000 Subject: r6051: finish off net rpc service stop net rpc service start net rpc service pause net rpc service resume (This used to be commit a7fb2c50b07a7d9965675272a71f42beba92acfe) --- source3/rpc_client/cli_svcctl.c | 69 +++++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 13 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index c9fdc61379..19bf419983 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -28,13 +28,13 @@ struct svc_state_msg { }; static struct svc_state_msg state_msg_table[] = { - { SVCCTL_STOPPED, "SVCCTL_STOPPED" }, - { SVCCTL_START_PENDING, "SVCCTL_START_PENDING" }, - { SVCCTL_STOP_PENDING, "SVCCTL_STOP_PENDING" }, - { SVCCTL_RUNNING, "SVCCTL_RUNNING" }, - { SVCCTL_CONTINUE_PENDING, "SVCCTL_CONTINUE_PENDING" }, - { SVCCTL_PAUSE_PENDING, "SVCCTL_PAUSE_PENDING" }, - { SVCCTL_PAUSED, "SVCCTL_PAUSED" }, + { SVCCTL_STOPPED, "stopped" }, + { SVCCTL_START_PENDING, "start pending" }, + { SVCCTL_STOP_PENDING, "stop pending" }, + { SVCCTL_RUNNING, "running" }, + { SVCCTL_CONTINUE_PENDING, "resume pending" }, + { SVCCTL_PAUSE_PENDING, "pause pending" }, + { SVCCTL_PAUSED, "paused" }, { 0, NULL } }; @@ -136,7 +136,7 @@ WERROR cli_svcctl_open_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, /******************************************************************** ********************************************************************/ -WERROR close_service_handle( struct cli_state *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService ) +WERROR cli_svcctl_close_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService ) { SVCCTL_Q_CLOSE_SERVICE in; SVCCTL_R_CLOSE_SERVICE out; @@ -310,19 +310,62 @@ WERROR cli_svcctl_query_config(struct cli_state *cli, TALLOC_CTX *mem_ctx, /******************************************************************* *******************************************************************/ -WERROR cli_svcctl_start_service(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +WERROR cli_svcctl_start_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, + POLICY_HND *hService, + const char **parm_array, uint32 parmcount ) { - - return WERR_OK; + SVCCTL_Q_START_SERVICE in; + SVCCTL_R_START_SERVICE out; + prs_struct qbuf, rbuf; + + ZERO_STRUCT(in); + ZERO_STRUCT(out); + + memcpy( &in.handle, hService, sizeof(POLICY_HND) ); + + in.parmcount = 0; + in.parameters.ref_id = 0x0; + + CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_START_SERVICE_W, + in, out, + qbuf, rbuf, + svcctl_io_q_start_service, + svcctl_io_r_start_service, + WERR_GENERAL_FAILURE ); + + return out.status; } /******************************************************************* *******************************************************************/ -WERROR cli_svcctl_control_service(struct cli_state *cli, TALLOC_CTX *mem_ctx ) +WERROR cli_svcctl_control_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, + POLICY_HND *hService, uint32 control, + SERVICE_STATUS *status ) { + SVCCTL_Q_CONTROL_SERVICE in; + SVCCTL_R_CONTROL_SERVICE out; + prs_struct qbuf, rbuf; + + ZERO_STRUCT(in); + ZERO_STRUCT(out); + + memcpy( &in.handle, hService, sizeof(POLICY_HND) ); + in.control = control; + + CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_CONTROL_SERVICE, + in, out, + qbuf, rbuf, + svcctl_io_q_control_service, + svcctl_io_r_control_service, + WERR_GENERAL_FAILURE ); + + if ( !W_ERROR_IS_OK( out.status ) ) + return out.status; - return WERR_OK; + memcpy( status, &out.svc_status, sizeof(SERVICE_STATUS) ); + + return out.status; } -- cgit From 0aa89db9471330fd02db395c2eb387ac2dfef54f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 26 Mar 2005 06:52:56 +0000 Subject: r6071: * clean up UNISTR2_ARRAY ( really just an array of UNISTR4 + count ) * add some backwards compatibility to 'net rpc rights list' * verify privilege name in 'net rpc rights privileges ' in order to give back better error messages. (This used to be commit 0e29dc8aa384dfa6d2495beb8a9ffb5371e60a13) --- source3/rpc_client/cli_svcctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 19bf419983..9f80bb79a3 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -323,8 +323,8 @@ WERROR cli_svcctl_start_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, memcpy( &in.handle, hService, sizeof(POLICY_HND) ); - in.parmcount = 0; - in.parameters.ref_id = 0x0; + in.parmcount = 0; + in.parameters = NULL; CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_START_SERVICE_W, in, out, -- cgit From 54abd2aa66069e6baf7769c496f46d9dba18db39 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Sep 2005 17:13:37 +0000 Subject: r10656: BIG merge from trunk. Features not copied over * \PIPE\unixinfo * winbindd's {group,alias}membership new functions * winbindd's lookupsids() functionality * swat (trunk changes to be reverted as per discussion with Deryck) (This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3) --- source3/rpc_client/cli_svcctl.c | 74 +++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 28 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 9f80bb79a3..2df27c2da5 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -61,7 +61,7 @@ const char* svc_status_string( uint32 state ) /******************************************************************** ********************************************************************/ -WERROR cli_svcctl_open_scm( struct cli_state *cli, TALLOC_CTX *mem_ctx, +WERROR rpccli_svcctl_open_scm(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hSCM, uint32 access_desired ) { SVCCTL_Q_OPEN_SCMANAGER in; @@ -80,12 +80,12 @@ WERROR cli_svcctl_open_scm( struct cli_state *cli, TALLOC_CTX *mem_ctx, if ( !(in.servername = TALLOC_P( mem_ctx, UNISTR2 )) ) return WERR_NOMEM; - fstr_sprintf( server, "\\\\%s", cli->desthost ); + fstr_sprintf( server, "\\\\%s", cli->cli->desthost ); init_unistr2( in.servername, server, UNI_STR_TERMINATE ); in.access = access_desired; - CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_OPEN_SCMANAGER_W, + CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_OPEN_SCMANAGER_W, in, out, qbuf, rbuf, svcctl_io_q_open_scmanager, @@ -103,7 +103,7 @@ WERROR cli_svcctl_open_scm( struct cli_state *cli, TALLOC_CTX *mem_ctx, /******************************************************************** ********************************************************************/ -WERROR cli_svcctl_open_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, +WERROR rpccli_svcctl_open_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hSCM, POLICY_HND *hService, const char *servicename, uint32 access_desired ) { @@ -118,7 +118,7 @@ WERROR cli_svcctl_open_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, init_unistr2( &in.servicename, servicename, UNI_STR_TERMINATE ); in.access = access_desired; - CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_OPEN_SERVICE_W, + CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_OPEN_SERVICE_W, in, out, qbuf, rbuf, svcctl_io_q_open_service, @@ -136,7 +136,7 @@ WERROR cli_svcctl_open_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, /******************************************************************** ********************************************************************/ -WERROR cli_svcctl_close_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService ) +WERROR rpccli_svcctl_close_service(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService ) { SVCCTL_Q_CLOSE_SERVICE in; SVCCTL_R_CLOSE_SERVICE out; @@ -147,7 +147,7 @@ WERROR cli_svcctl_close_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, POL memcpy( &in.handle, hService, sizeof(POLICY_HND) ); - CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_CLOSE_SERVICE, + CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_CLOSE_SERVICE, in, out, qbuf, rbuf, svcctl_io_q_close_service, @@ -160,7 +160,7 @@ WERROR cli_svcctl_close_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, POL /******************************************************************* *******************************************************************/ -WERROR cli_svcctl_enumerate_services( struct cli_state *cli, TALLOC_CTX *mem_ctx, +WERROR rpccli_svcctl_enumerate_services( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hSCM, uint32 type, uint32 state, uint32 *returned, ENUM_SERVICES_STATUS **service_array ) { @@ -185,7 +185,7 @@ WERROR cli_svcctl_enumerate_services( struct cli_state *cli, TALLOC_CTX *mem_ctx /* first time is to get the buffer size */ in.buffer_size = 0; - CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_ENUM_SERVICES_STATUS_W, + CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_ENUM_SERVICES_STATUS_W, in, out, qbuf, rbuf, svcctl_io_q_enum_services_status, @@ -197,7 +197,7 @@ WERROR cli_svcctl_enumerate_services( struct cli_state *cli, TALLOC_CTX *mem_ctx if ( W_ERROR_EQUAL( out.status, WERR_MORE_DATA ) ) { in.buffer_size = out.needed; - CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_ENUM_SERVICES_STATUS_W, + CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_ENUM_SERVICES_STATUS_W, in, out, qbuf, rbuf, svcctl_io_q_enum_services_status, @@ -225,7 +225,7 @@ WERROR cli_svcctl_enumerate_services( struct cli_state *cli, TALLOC_CTX *mem_ctx /******************************************************************* *******************************************************************/ -WERROR cli_svcctl_query_status( struct cli_state *cli, TALLOC_CTX *mem_ctx, +WERROR rpccli_svcctl_query_status( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService, SERVICE_STATUS *status ) { SVCCTL_Q_QUERY_STATUS in; @@ -237,7 +237,7 @@ WERROR cli_svcctl_query_status( struct cli_state *cli, TALLOC_CTX *mem_ctx, memcpy( &in.handle, hService, sizeof(POLICY_HND) ); - CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_QUERY_STATUS, + CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_QUERY_STATUS, in, out, qbuf, rbuf, svcctl_io_q_query_status, @@ -255,7 +255,7 @@ WERROR cli_svcctl_query_status( struct cli_state *cli, TALLOC_CTX *mem_ctx, /******************************************************************* *******************************************************************/ -WERROR cli_svcctl_query_config(struct cli_state *cli, TALLOC_CTX *mem_ctx, +WERROR rpccli_svcctl_query_config(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService, SERVICE_CONFIG *config ) { SVCCTL_Q_QUERY_SERVICE_CONFIG in; @@ -269,7 +269,7 @@ WERROR cli_svcctl_query_config(struct cli_state *cli, TALLOC_CTX *mem_ctx, in.buffer_size = 0; - CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_QUERY_SERVICE_CONFIG_W, + CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_QUERY_SERVICE_CONFIG_W, in, out, qbuf, rbuf, svcctl_io_q_query_service_config, @@ -279,7 +279,7 @@ WERROR cli_svcctl_query_config(struct cli_state *cli, TALLOC_CTX *mem_ctx, if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) { in.buffer_size = out.needed; - CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_QUERY_SERVICE_CONFIG_W, + CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_QUERY_SERVICE_CONFIG_W, in, out, qbuf, rbuf, svcctl_io_q_query_service_config, @@ -298,11 +298,30 @@ WERROR cli_svcctl_query_config(struct cli_state *cli, TALLOC_CTX *mem_ctx, config->startname = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); config->displayname = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); - copy_unistr2( config->executablepath, out.config.executablepath ); - copy_unistr2( config->loadordergroup, out.config.loadordergroup ); - copy_unistr2( config->dependencies, out.config.dependencies ); - copy_unistr2( config->startname, out.config.startname ); - copy_unistr2( config->displayname, out.config.displayname ); + if ( out.config.executablepath ) { + config->executablepath = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); + copy_unistr2( config->executablepath, out.config.executablepath ); + } + + if ( out.config.loadordergroup ) { + config->loadordergroup = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); + copy_unistr2( config->loadordergroup, out.config.loadordergroup ); + } + + if ( out.config.dependencies ) { + config->dependencies = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); + copy_unistr2( config->dependencies, out.config.dependencies ); + } + + if ( out.config.startname ) { + config->startname = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); + copy_unistr2( config->startname, out.config.startname ); + } + + if ( out.config.displayname ) { + config->displayname = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); + copy_unistr2( config->displayname, out.config.displayname ); + } return out.status; } @@ -310,7 +329,7 @@ WERROR cli_svcctl_query_config(struct cli_state *cli, TALLOC_CTX *mem_ctx, /******************************************************************* *******************************************************************/ -WERROR cli_svcctl_start_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, +WERROR rpccli_svcctl_start_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService, const char **parm_array, uint32 parmcount ) { @@ -326,7 +345,7 @@ WERROR cli_svcctl_start_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, in.parmcount = 0; in.parameters = NULL; - CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_START_SERVICE_W, + CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_START_SERVICE_W, in, out, qbuf, rbuf, svcctl_io_q_start_service, @@ -339,7 +358,7 @@ WERROR cli_svcctl_start_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, /******************************************************************* *******************************************************************/ -WERROR cli_svcctl_control_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, +WERROR rpccli_svcctl_control_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService, uint32 control, SERVICE_STATUS *status ) { @@ -353,7 +372,7 @@ WERROR cli_svcctl_control_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, memcpy( &in.handle, hService, sizeof(POLICY_HND) ); in.control = control; - CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_CONTROL_SERVICE, + CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_CONTROL_SERVICE, in, out, qbuf, rbuf, svcctl_io_q_control_service, @@ -372,7 +391,7 @@ WERROR cli_svcctl_control_service( struct cli_state *cli, TALLOC_CTX *mem_ctx, /******************************************************************* *******************************************************************/ -WERROR cli_svcctl_get_dispname( struct cli_state *cli, TALLOC_CTX *mem_ctx, +WERROR rpccli_svcctl_get_dispname( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService, fstring displayname ) { SVCCTL_Q_GET_DISPLAY_NAME in; @@ -385,7 +404,7 @@ WERROR cli_svcctl_get_dispname( struct cli_state *cli, TALLOC_CTX *mem_ctx, memcpy( &in.handle, hService, sizeof(POLICY_HND) ); in.display_name_len = 0; - CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_GET_DISPLAY_NAME, + CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_GET_DISPLAY_NAME, in, out, qbuf, rbuf, svcctl_io_q_get_display_name, @@ -397,7 +416,7 @@ WERROR cli_svcctl_get_dispname( struct cli_state *cli, TALLOC_CTX *mem_ctx, if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) { in.display_name_len = out.display_name_len; - CLI_DO_RPC( cli, mem_ctx, PI_SVCCTL, SVCCTL_GET_DISPLAY_NAME, + CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_GET_DISPLAY_NAME, in, out, qbuf, rbuf, svcctl_io_q_get_display_name, @@ -412,4 +431,3 @@ WERROR cli_svcctl_get_dispname( struct cli_state *cli, TALLOC_CTX *mem_ctx, return out.status; } - -- cgit From f1d8c4da23049cf0115666f8d97dac251395de76 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 May 2007 22:01:26 +0000 Subject: r22675: Simo's patch for 0 size allocation. Still need to examine parse_misc.c fix. Jeremy. (This used to be commit 80d981265cd3bc9d73c5da3c514ec736e2dfa73a) --- source3/rpc_client/cli_svcctl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 2df27c2da5..d183670f5f 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -209,8 +209,12 @@ WERROR rpccli_svcctl_enumerate_services( struct rpc_pipe_client *cli, TALLOC_CTX return out.status; /* pull out the data */ - if ( !(services = TALLOC_ARRAY( mem_ctx, ENUM_SERVICES_STATUS, out.returned )) ) - return WERR_NOMEM; + if (out.returned) { + if ( !(services = TALLOC_ARRAY( mem_ctx, ENUM_SERVICES_STATUS, out.returned )) ) + return WERR_NOMEM; + } else { + services = NULL; + } for ( i=0; i Date: Thu, 31 May 2007 17:24:30 +0000 Subject: r23271: merge service control pidl change for CloseServiceHandle() from SAMBA_3_0_26 (This used to be commit 0b1bc3521fac52f3164b6cc9e053abc3ceabf5e7) --- source3/rpc_client/cli_svcctl.c | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index d183670f5f..021648ba1c 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -133,30 +133,6 @@ WERROR rpccli_svcctl_open_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ return out.status; } -/******************************************************************** -********************************************************************/ - -WERROR rpccli_svcctl_close_service(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService ) -{ - SVCCTL_Q_CLOSE_SERVICE in; - SVCCTL_R_CLOSE_SERVICE out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - memcpy( &in.handle, hService, sizeof(POLICY_HND) ); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_CLOSE_SERVICE, - in, out, - qbuf, rbuf, - svcctl_io_q_close_service, - svcctl_io_r_close_service, - WERR_GENERAL_FAILURE ); - - return out.status; -} - /******************************************************************* *******************************************************************/ -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/rpc_client/cli_svcctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 021648ba1c..87434f482f 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -5,7 +5,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, -- cgit From 153cfb9c83534b09f15cc16205d7adb19b394928 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 05:23:25 +0000 Subject: r23801: The FSF has moved around a lot. This fixes their Mass Ave address. (This used to be commit 87c91e4362c51819032bfbebbb273c52e203b227) --- source3/rpc_client/cli_svcctl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 87434f482f..cb016cbd14 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ -- cgit From ff0947fbed841065fce85c64ff4b2a2e8f24f056 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 4 Sep 2007 10:15:04 +0000 Subject: r24949: Remove some static buffers (This used to be commit df648d47ff3c4e24f439fda839653bda98323100) --- source3/rpc_client/cli_svcctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index cb016cbd14..95673c1565 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -42,7 +42,7 @@ static struct svc_state_msg state_msg_table[] = { ********************************************************************/ const char* svc_status_string( uint32 state ) { - static fstring msg; + fstring msg; int i; fstr_sprintf( msg, "Unknown State [%d]", state ); @@ -54,7 +54,7 @@ const char* svc_status_string( uint32 state ) } } - return msg; + return talloc_strdup(talloc_tos(), msg); } /******************************************************************** -- cgit From 330fe0a62a29ff994e1520dae209eb4980a7259c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 12:12:43 +0100 Subject: Remove unused marshalling for SVCCTL_OPEN_SCMANAGER. Guenther (This used to be commit 1162b8a02d365b79f5a3e86c936bae80092f1869) --- source3/rpc_client/cli_svcctl.c | 42 ----------------------------------------- 1 file changed, 42 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 95673c1565..699db6cd77 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -60,48 +60,6 @@ const char* svc_status_string( uint32 state ) /******************************************************************** ********************************************************************/ -WERROR rpccli_svcctl_open_scm(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hSCM, uint32 access_desired ) -{ - SVCCTL_Q_OPEN_SCMANAGER in; - SVCCTL_R_OPEN_SCMANAGER out; - prs_struct qbuf, rbuf; - fstring server; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - /* leave the database name NULL to get the default service db */ - - in.database = NULL; - - /* set the server name */ - - if ( !(in.servername = TALLOC_P( mem_ctx, UNISTR2 )) ) - return WERR_NOMEM; - fstr_sprintf( server, "\\\\%s", cli->cli->desthost ); - init_unistr2( in.servername, server, UNI_STR_TERMINATE ); - - in.access = access_desired; - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_OPEN_SCMANAGER_W, - in, out, - qbuf, rbuf, - svcctl_io_q_open_scmanager, - svcctl_io_r_open_scmanager, - WERR_GENERAL_FAILURE ); - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - memcpy( hSCM, &out.handle, sizeof(POLICY_HND) ); - - return out.status; -} - -/******************************************************************** -********************************************************************/ - WERROR rpccli_svcctl_open_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hSCM, POLICY_HND *hService, const char *servicename, uint32 access_desired ) -- cgit From 6d95d7d9b9277e3aba6b43869a31fd3226ac697c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 12:48:43 +0100 Subject: Remove unused marshalling for SVCCTL_OPEN_SERVICE. Guenther (This used to be commit e0a8818af0e3e82e9b70ff6c485090986b435fed) --- source3/rpc_client/cli_svcctl.c | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 699db6cd77..0a5cf7674b 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -57,39 +57,6 @@ const char* svc_status_string( uint32 state ) return talloc_strdup(talloc_tos(), msg); } -/******************************************************************** -********************************************************************/ - -WERROR rpccli_svcctl_open_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hSCM, POLICY_HND *hService, - const char *servicename, uint32 access_desired ) -{ - SVCCTL_Q_OPEN_SERVICE in; - SVCCTL_R_OPEN_SERVICE out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - memcpy( &in.handle, hSCM, sizeof(POLICY_HND) ); - init_unistr2( &in.servicename, servicename, UNI_STR_TERMINATE ); - in.access = access_desired; - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_OPEN_SERVICE_W, - in, out, - qbuf, rbuf, - svcctl_io_q_open_service, - svcctl_io_r_open_service, - WERR_GENERAL_FAILURE ); - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - memcpy( hService, &out.handle, sizeof(POLICY_HND) ); - - return out.status; -} - /******************************************************************* *******************************************************************/ -- cgit From 4673706e1d130555231b409baa270d7000267117 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 13:45:36 +0100 Subject: Remove unused marshalling for SVCCTL_GET_DISPLAY_NAME. Guenther (This used to be commit 144f41e7c3c97afede71ed771acd130f9018f0df) --- source3/rpc_client/cli_svcctl.c | 45 ----------------------------------------- 1 file changed, 45 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 0a5cf7674b..cdd1b93aaa 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -290,48 +290,3 @@ WERROR rpccli_svcctl_control_service( struct rpc_pipe_client *cli, TALLOC_CTX *m return out.status; } - - -/******************************************************************* -*******************************************************************/ - -WERROR rpccli_svcctl_get_dispname( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hService, fstring displayname ) -{ - SVCCTL_Q_GET_DISPLAY_NAME in; - SVCCTL_R_GET_DISPLAY_NAME out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - memcpy( &in.handle, hService, sizeof(POLICY_HND) ); - in.display_name_len = 0; - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_GET_DISPLAY_NAME, - in, out, - qbuf, rbuf, - svcctl_io_q_get_display_name, - svcctl_io_r_get_display_name, - WERR_GENERAL_FAILURE ); - - /* second time with correct buffer size...should be ok */ - - if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) { - in.display_name_len = out.display_name_len; - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_GET_DISPLAY_NAME, - in, out, - qbuf, rbuf, - svcctl_io_q_get_display_name, - svcctl_io_r_get_display_name, - WERR_GENERAL_FAILURE ); - } - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - rpcstr_pull( displayname, out.displayname.buffer, sizeof(displayname), -1, STR_TERMINATE ); - - return out.status; -} -- cgit From a750bbf1b8d0d2b48af6be40f8d505b5e0edd899 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:30:53 +0100 Subject: Remove unused marshalling for SVCCTL_START_SERVICE. Guenther (This used to be commit 57e03a7fd56062bbff19c88c3b6928e8a0481794) --- source3/rpc_client/cli_svcctl.c | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index cdd1b93aaa..9889d131f3 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -233,35 +233,6 @@ WERROR rpccli_svcctl_query_config(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c /******************************************************************* *******************************************************************/ -WERROR rpccli_svcctl_start_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hService, - const char **parm_array, uint32 parmcount ) -{ - SVCCTL_Q_START_SERVICE in; - SVCCTL_R_START_SERVICE out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - memcpy( &in.handle, hService, sizeof(POLICY_HND) ); - - in.parmcount = 0; - in.parameters = NULL; - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_START_SERVICE_W, - in, out, - qbuf, rbuf, - svcctl_io_q_start_service, - svcctl_io_r_start_service, - WERR_GENERAL_FAILURE ); - - return out.status; -} - -/******************************************************************* -*******************************************************************/ - WERROR rpccli_svcctl_control_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService, uint32 control, SERVICE_STATUS *status ) -- cgit From 35e48a4b1dfa3d63476fca105766da1ec980b446 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:37:32 +0100 Subject: Remove unused marshalling for SVCCTL_CONTROL_SERVICE. Guenther (This used to be commit 84112a24f5292b8d2e4d446e39462e0402453b4a) --- source3/rpc_client/cli_svcctl.c | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 9889d131f3..c4ff44734a 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -229,35 +229,3 @@ WERROR rpccli_svcctl_query_config(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c return out.status; } - -/******************************************************************* -*******************************************************************/ - -WERROR rpccli_svcctl_control_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hService, uint32 control, - SERVICE_STATUS *status ) -{ - SVCCTL_Q_CONTROL_SERVICE in; - SVCCTL_R_CONTROL_SERVICE out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - memcpy( &in.handle, hService, sizeof(POLICY_HND) ); - in.control = control; - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_CONTROL_SERVICE, - in, out, - qbuf, rbuf, - svcctl_io_q_control_service, - svcctl_io_r_control_service, - WERR_GENERAL_FAILURE ); - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - memcpy( status, &out.svc_status, sizeof(SERVICE_STATUS) ); - - return out.status; -} -- cgit From c147f2fd6b5d8f319b2cf6903da093211f46e575 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:43:56 +0100 Subject: Remove unused marshalling for SVCCTL_QUERY_STATUS. Guenther (This used to be commit 8a621f517fe38ce91f10e12fccc2963af6afc33d) --- source3/rpc_client/cli_svcctl.c | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index c4ff44734a..b21909fd03 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -129,36 +129,6 @@ WERROR rpccli_svcctl_enumerate_services( struct rpc_pipe_client *cli, TALLOC_CTX /******************************************************************* *******************************************************************/ -WERROR rpccli_svcctl_query_status( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hService, SERVICE_STATUS *status ) -{ - SVCCTL_Q_QUERY_STATUS in; - SVCCTL_R_QUERY_STATUS out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - memcpy( &in.handle, hService, sizeof(POLICY_HND) ); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_QUERY_STATUS, - in, out, - qbuf, rbuf, - svcctl_io_q_query_status, - svcctl_io_r_query_status, - WERR_GENERAL_FAILURE ); - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - memcpy( status, &out.svc_status, sizeof(SERVICE_STATUS) ); - - return out.status; -} - -/******************************************************************* -*******************************************************************/ - WERROR rpccli_svcctl_query_config(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hService, SERVICE_CONFIG *config ) { -- cgit From d8acf199876867189f212837059d1d6ac401c6b5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 20 Mar 2008 01:26:37 +0100 Subject: Move svc_status_string() out of rpc_client/cli_svcctl.c Guenther (This used to be commit 2860ae2eb2cb99b4febb352f516b3fa9fbd2abbb) --- source3/rpc_client/cli_svcctl.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index b21909fd03..221dd60a35 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -21,42 +21,6 @@ #include "includes.h" #include "rpc_client.h" -struct svc_state_msg { - uint32 flag; - const char *message; -}; - -static struct svc_state_msg state_msg_table[] = { - { SVCCTL_STOPPED, "stopped" }, - { SVCCTL_START_PENDING, "start pending" }, - { SVCCTL_STOP_PENDING, "stop pending" }, - { SVCCTL_RUNNING, "running" }, - { SVCCTL_CONTINUE_PENDING, "resume pending" }, - { SVCCTL_PAUSE_PENDING, "pause pending" }, - { SVCCTL_PAUSED, "paused" }, - { 0, NULL } -}; - - -/******************************************************************** -********************************************************************/ -const char* svc_status_string( uint32 state ) -{ - fstring msg; - int i; - - fstr_sprintf( msg, "Unknown State [%d]", state ); - - for ( i=0; state_msg_table[i].message; i++ ) { - if ( state_msg_table[i].flag == state ) { - fstrcpy( msg, state_msg_table[i].message ); - break; - } - } - - return talloc_strdup(talloc_tos(), msg); -} - /******************************************************************* *******************************************************************/ -- cgit From 86bb7464066ff3743eb19e874ef7dfe86dd1fcb4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 21 Jul 2008 12:50:32 +0200 Subject: Refactoring: CLI_DO_RPC_* uses interface instead of pipe_idx (This used to be commit 6d2209ba5da0937ce17e71951a1628ff1f5deacb) --- source3/rpc_client/cli_svcctl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source3/rpc_client/cli_svcctl.c') diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 221dd60a35..3c29dcdee8 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -49,7 +49,7 @@ WERROR rpccli_svcctl_enumerate_services( struct rpc_pipe_client *cli, TALLOC_CTX /* first time is to get the buffer size */ in.buffer_size = 0; - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_ENUM_SERVICES_STATUS_W, + CLI_DO_RPC_WERR( cli, mem_ctx, &ndr_table_svcctl.syntax_id, SVCCTL_ENUM_SERVICES_STATUS_W, in, out, qbuf, rbuf, svcctl_io_q_enum_services_status, @@ -61,7 +61,8 @@ WERROR rpccli_svcctl_enumerate_services( struct rpc_pipe_client *cli, TALLOC_CTX if ( W_ERROR_EQUAL( out.status, WERR_MORE_DATA ) ) { in.buffer_size = out.needed; - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_ENUM_SERVICES_STATUS_W, + CLI_DO_RPC_WERR( cli, mem_ctx, &ndr_table_svcctl.syntax_id, + SVCCTL_ENUM_SERVICES_STATUS_W, in, out, qbuf, rbuf, svcctl_io_q_enum_services_status, @@ -107,7 +108,8 @@ WERROR rpccli_svcctl_query_config(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c in.buffer_size = 0; - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_QUERY_SERVICE_CONFIG_W, + CLI_DO_RPC_WERR( cli, mem_ctx, &ndr_table_svcctl.syntax_id, + SVCCTL_QUERY_SERVICE_CONFIG_W, in, out, qbuf, rbuf, svcctl_io_q_query_service_config, @@ -117,7 +119,8 @@ WERROR rpccli_svcctl_query_config(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) { in.buffer_size = out.needed; - CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_QUERY_SERVICE_CONFIG_W, + CLI_DO_RPC_WERR( cli, mem_ctx, &ndr_table_svcctl.syntax_id, + SVCCTL_QUERY_SERVICE_CONFIG_W, in, out, qbuf, rbuf, svcctl_io_q_query_service_config, -- cgit