2 Samba Unix/Linux SMB client library
3 Distributed SMB/CIFS Server Management Utility
4 Copyright (C) Gerald (Jerry) Carter 2005
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "utils/net.h"
21 #include "rpc_client/rpc_client.h"
22 #include "../librpc/gen_ndr/ndr_svcctl.h"
23 #include "../librpc/gen_ndr/ndr_svcctl_c.h"
25 struct svc_state_msg {
30 static struct svc_state_msg state_msg_table[] = {
31 { SVCCTL_STOPPED, N_("stopped") },
32 { SVCCTL_START_PENDING, N_("start pending") },
33 { SVCCTL_STOP_PENDING, N_("stop pending") },
34 { SVCCTL_RUNNING, N_("running") },
35 { SVCCTL_CONTINUE_PENDING, N_("resume pending") },
36 { SVCCTL_PAUSE_PENDING, N_("pause pending") },
37 { SVCCTL_PAUSED, N_("paused") },
42 /********************************************************************
43 ********************************************************************/
44 const char *svc_status_string( uint32_t state )
49 fstr_sprintf( msg, _("Unknown State [%d]"), state );
51 for ( i=0; state_msg_table[i].message; i++ ) {
52 if ( state_msg_table[i].flag == state ) {
53 fstrcpy( msg, state_msg_table[i].message );
58 return talloc_strdup(talloc_tos(), msg);
61 /********************************************************************
62 ********************************************************************/
64 static WERROR open_service(struct dcerpc_binding_handle *b,
66 struct policy_handle *hSCM,
69 struct policy_handle *hService)
74 status = dcerpc_svcctl_OpenServiceW(b, mem_ctx,
80 if (!NT_STATUS_IS_OK(status)) {
81 result = ntstatus_to_werror(status);
82 d_fprintf(stderr, _("Failed to open service. [%s]\n"),
86 if (!W_ERROR_IS_OK(result) ) {
87 d_fprintf(stderr, _("Failed to open service. [%s]\n"),
95 /********************************************************************
96 ********************************************************************/
98 static WERROR open_scm(struct dcerpc_binding_handle *b,
100 const char *server_name,
101 uint32_t access_mask,
102 struct policy_handle *hSCM)
107 status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
113 if (!NT_STATUS_IS_OK(status)) {
114 result = ntstatus_to_werror(status);
116 _("Failed to open Service Control Manager. [%s]\n"),
120 if (!W_ERROR_IS_OK(result)) {
122 _("Failed to open Service Control Manager. [%s]\n"),
130 /********************************************************************
131 ********************************************************************/
133 static WERROR query_service_state(struct rpc_pipe_client *pipe_hnd,
135 struct policy_handle *hSCM,
139 struct policy_handle hService;
140 struct SERVICE_STATUS service_status;
141 WERROR result = WERR_GEN_FAILURE;
143 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
145 /* now cycle until the status is actually 'watch_state' */
147 result = open_service(b, mem_ctx, hSCM, service,
148 SC_RIGHT_SVC_QUERY_STATUS,
150 if (!W_ERROR_IS_OK(result) ) {
154 status = dcerpc_svcctl_QueryServiceStatus(b, mem_ctx,
158 if (!NT_STATUS_IS_OK(status)) {
159 result = ntstatus_to_werror(status);
162 if (!W_ERROR_IS_OK(result)) {
166 *state = service_status.state;
169 if (is_valid_policy_hnd(&hService)) {
171 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
177 /********************************************************************
178 ********************************************************************/
180 static WERROR watch_service_state(struct rpc_pipe_client *pipe_hnd,
182 struct policy_handle *hSCM,
184 uint32_t watch_state,
185 uint32_t *final_state )
189 WERROR result = WERR_GEN_FAILURE;
193 while ( (state != watch_state ) && i<30 ) {
196 result = query_service_state(pipe_hnd, mem_ctx, hSCM, service, &state );
197 if ( !W_ERROR_IS_OK(result) ) {
207 *final_state = state;
212 /********************************************************************
213 ********************************************************************/
215 static WERROR control_service(struct rpc_pipe_client *pipe_hnd,
217 struct policy_handle *hSCM,
220 uint32_t watch_state )
222 struct policy_handle hService;
223 WERROR result = WERR_GEN_FAILURE;
225 struct SERVICE_STATUS service_status;
227 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
229 /* Open the Service */
231 result = open_service(b, mem_ctx, hSCM, service,
232 (SC_RIGHT_SVC_STOP|SC_RIGHT_SVC_PAUSE_CONTINUE),
234 if (!W_ERROR_IS_OK(result) ) {
240 status = dcerpc_svcctl_ControlService(b, mem_ctx,
246 if (!NT_STATUS_IS_OK(status)) {
247 result = ntstatus_to_werror(status);
248 d_fprintf(stderr, _("Control service request failed. [%s]\n"),
252 if (!W_ERROR_IS_OK(result) ) {
253 d_fprintf(stderr, _("Control service request failed. [%s]\n"),
258 /* loop -- checking the state until we are where we want to be */
260 result = watch_service_state(pipe_hnd, mem_ctx, hSCM, service, watch_state, &state );
262 d_printf(_("%s service is %s.\n"), service, svc_status_string(state));
265 if (is_valid_policy_hnd(&hService)) {
267 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
273 /********************************************************************
274 ********************************************************************/
276 static NTSTATUS rpc_service_list_internal(struct net_context *c,
277 const struct dom_sid *domain_sid,
278 const char *domain_name,
279 struct cli_state *cli,
280 struct rpc_pipe_client *pipe_hnd,
285 struct policy_handle hSCM;
286 struct ENUM_SERVICE_STATUSW *services = NULL;
287 WERROR result = WERR_GEN_FAILURE;
290 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
293 uint32_t buf_size = 0;
294 uint32_t bytes_needed = 0;
295 uint32_t num_services = 0;
296 uint32_t resume_handle = 0;
299 d_printf("%s net rpc service list\n", _("Usage:"));
303 result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
304 SC_RIGHT_MGR_ENUMERATE_SERVICE,
306 if (!W_ERROR_IS_OK(result)) {
307 return werror_to_ntstatus(result);
310 buffer = talloc_array(mem_ctx, uint8_t, buf_size);
311 if (buffer == NULL) {
312 status = NT_STATUS_NO_MEMORY;
317 status = dcerpc_svcctl_EnumServicesStatusW(b, mem_ctx,
328 if (!NT_STATUS_IS_OK(status)) {
330 _("Failed to enumerate services. [%s]\n"),
335 if (W_ERROR_EQUAL(result, WERR_MORE_DATA) && bytes_needed > 0) {
336 buf_size = bytes_needed;
337 buffer = talloc_realloc(mem_ctx, buffer, uint8_t, bytes_needed);
338 if (buffer == NULL) {
339 status = NT_STATUS_NO_MEMORY;
345 if (!W_ERROR_IS_OK(result)) {
346 status = werror_to_ntstatus(result);
348 _("Failed to enumerate services. [%s]\n"),
353 if ( num_services == 0 ) {
354 d_printf(_("No services returned\n"));
359 enum ndr_err_code ndr_err;
361 struct ndr_pull *ndr;
363 blob.length = buf_size;
364 blob.data = talloc_steal(mem_ctx, buffer);
366 services = talloc_array(mem_ctx, struct ENUM_SERVICE_STATUSW, num_services);
368 status = NT_STATUS_NO_MEMORY;
372 ndr = ndr_pull_init_blob(&blob, mem_ctx);
374 status = NT_STATUS_NO_MEMORY;
378 ndr_err = ndr_pull_ENUM_SERVICE_STATUSW_array(
379 ndr, num_services, services);
380 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
381 status = ndr_map_error2ntstatus(ndr_err);
385 for ( i=0; i<num_services; i++ ) {
386 d_printf("%-20s \"%s\"\n",
387 services[i].service_name,
388 services[i].display_name);
392 } while (W_ERROR_EQUAL(result, WERR_MORE_DATA));
395 if (is_valid_policy_hnd(&hSCM)) {
397 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
403 /********************************************************************
404 ********************************************************************/
406 static NTSTATUS rpc_service_status_internal(struct net_context *c,
407 const struct dom_sid *domain_sid,
408 const char *domain_name,
409 struct cli_state *cli,
410 struct rpc_pipe_client *pipe_hnd,
415 struct policy_handle hSCM, hService;
416 WERROR result = WERR_GEN_FAILURE;
418 struct SERVICE_STATUS service_status;
419 struct QUERY_SERVICE_CONFIG config;
420 uint32_t buf_size = sizeof(config);
421 uint32_t ret_size = 0;
422 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
425 d_printf("%s net rpc service status <service>\n", _("Usage:"));
429 /* Open the Service Control Manager */
430 result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
431 SC_RIGHT_MGR_ENUMERATE_SERVICE,
433 if (!W_ERROR_IS_OK(result)) {
434 return werror_to_ntstatus(result);
437 /* Open the Service */
439 result = open_service(b, mem_ctx, &hSCM, argv[0],
440 (SC_RIGHT_SVC_QUERY_STATUS|SC_RIGHT_SVC_QUERY_CONFIG),
442 if (!W_ERROR_IS_OK(result) ) {
448 status = dcerpc_svcctl_QueryServiceStatus(b, mem_ctx,
452 if (!NT_STATUS_IS_OK(status)) {
453 result = ntstatus_to_werror(status);
454 d_fprintf(stderr, _("Query status request failed. [%s]\n"),
459 if (!W_ERROR_IS_OK(result) ) {
460 d_fprintf(stderr, _("Query status request failed. [%s]\n"),
465 d_printf(_("%s service is %s.\n"), argv[0],
466 svc_status_string(service_status.state));
470 status = dcerpc_svcctl_QueryServiceConfigW(b, mem_ctx,
476 if (!NT_STATUS_IS_OK(status)) {
477 result = ntstatus_to_werror(status);
478 d_fprintf(stderr, _("Query config request failed. [%s]\n"),
483 if (W_ERROR_EQUAL(result, WERR_INSUFFICIENT_BUFFER)) {
485 status = dcerpc_svcctl_QueryServiceConfigW(b, mem_ctx,
491 if (!NT_STATUS_IS_OK(status)) {
492 result = ntstatus_to_werror(status);
493 d_fprintf(stderr, _("Query config request failed. [%s]\n"),
499 if (!W_ERROR_IS_OK(result) ) {
500 d_fprintf(stderr, _("Query config request failed. [%s]\n"),
505 /* print out the configuration information for the service */
507 d_printf(_("Configuration details:\n"));
508 d_printf(_("\tControls Accepted = 0x%x\n"),
509 service_status.controls_accepted);
510 d_printf(_("\tService Type = 0x%x\n"), config.service_type);
511 d_printf(_("\tStart Type = 0x%x\n"), config.start_type);
512 d_printf(_("\tError Control = 0x%x\n"), config.error_control);
513 d_printf(_("\tTag ID = 0x%x\n"), config.tag_id);
515 if (config.executablepath) {
516 d_printf(_("\tExecutable Path = %s\n"),
517 config.executablepath);
520 if (config.loadordergroup) {
521 d_printf(_("\tLoad Order Group = %s\n"),
522 config.loadordergroup);
525 if (config.dependencies) {
526 d_printf(_("\tDependencies = %s\n"),
527 config.dependencies);
530 if (config.startname) {
531 d_printf(_("\tStart Name = %s\n"), config.startname);
534 if (config.displayname) {
535 d_printf(_("\tDisplay Name = %s\n"),
540 if (is_valid_policy_hnd(&hService)) {
542 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
544 if (is_valid_policy_hnd(&hSCM)) {
546 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
549 return werror_to_ntstatus(result);
552 /********************************************************************
553 ********************************************************************/
555 static NTSTATUS rpc_service_stop_internal(struct net_context *c,
556 const struct dom_sid *domain_sid,
557 const char *domain_name,
558 struct cli_state *cli,
559 struct rpc_pipe_client *pipe_hnd,
564 struct policy_handle hSCM;
565 WERROR result = WERR_GEN_FAILURE;
566 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
569 d_printf("%s net rpc service status <service>\n", _("Usage:"));
573 /* Open the Service Control Manager */
574 result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
575 SC_RIGHT_MGR_ENUMERATE_SERVICE,
577 if (!W_ERROR_IS_OK(result)) {
578 return werror_to_ntstatus(result);
581 result = control_service(pipe_hnd, mem_ctx, &hSCM, argv[0],
582 SVCCTL_CONTROL_STOP, SVCCTL_STOPPED );
584 if (is_valid_policy_hnd(&hSCM)) {
586 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
589 return werror_to_ntstatus(result);
592 /********************************************************************
593 ********************************************************************/
595 static NTSTATUS rpc_service_pause_internal(struct net_context *c,
596 const struct dom_sid *domain_sid,
597 const char *domain_name,
598 struct cli_state *cli,
599 struct rpc_pipe_client *pipe_hnd,
604 struct policy_handle hSCM;
605 WERROR result = WERR_GEN_FAILURE;
606 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
609 d_printf("%s net rpc service status <service>\n", _("Usage:"));
613 /* Open the Service Control Manager */
614 result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
615 SC_RIGHT_MGR_ENUMERATE_SERVICE,
617 if (!W_ERROR_IS_OK(result)) {
618 return werror_to_ntstatus(result);
621 result = control_service(pipe_hnd, mem_ctx, &hSCM, argv[0],
622 SVCCTL_CONTROL_PAUSE, SVCCTL_PAUSED );
624 if (is_valid_policy_hnd(&hSCM)) {
626 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
629 return werror_to_ntstatus(result);
632 /********************************************************************
633 ********************************************************************/
635 static NTSTATUS rpc_service_resume_internal(struct net_context *c,
636 const struct dom_sid *domain_sid,
637 const char *domain_name,
638 struct cli_state *cli,
639 struct rpc_pipe_client *pipe_hnd,
644 struct policy_handle hSCM;
645 WERROR result = WERR_GEN_FAILURE;
646 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
649 d_printf("%s net rpc service status <service>\n", _("Usage:"));
653 /* Open the Service Control Manager */
654 result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
655 SC_RIGHT_MGR_ENUMERATE_SERVICE,
657 if (!W_ERROR_IS_OK(result)) {
658 return werror_to_ntstatus(result);
661 result = control_service(pipe_hnd, mem_ctx, &hSCM, argv[0],
662 SVCCTL_CONTROL_CONTINUE, SVCCTL_RUNNING );
664 if (is_valid_policy_hnd(&hSCM)) {
666 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
669 return werror_to_ntstatus(result);
672 /********************************************************************
673 ********************************************************************/
675 static NTSTATUS rpc_service_start_internal(struct net_context *c,
676 const struct dom_sid *domain_sid,
677 const char *domain_name,
678 struct cli_state *cli,
679 struct rpc_pipe_client *pipe_hnd,
684 struct policy_handle hSCM, hService;
685 WERROR result = WERR_GEN_FAILURE;
688 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
691 d_printf("%s net rpc service status <service>\n", _("Usage:"));
695 /* Open the Service Control Manager */
696 result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
697 SC_RIGHT_MGR_ENUMERATE_SERVICE,
699 if (!W_ERROR_IS_OK(result)) {
700 return werror_to_ntstatus(result);
704 /* Open the Service */
706 result = open_service(b, mem_ctx, &hSCM, argv[0],
709 if (!W_ERROR_IS_OK(result) ) {
715 status = dcerpc_svcctl_StartServiceW(b, mem_ctx,
721 if (!NT_STATUS_IS_OK(status)) {
722 result = ntstatus_to_werror(status);
723 d_fprintf(stderr, _("Query status request failed. [%s]\n"),
727 if (!W_ERROR_IS_OK(result) ) {
728 d_fprintf(stderr, _("Query status request failed. [%s]\n"),
733 result = watch_service_state(pipe_hnd, mem_ctx, &hSCM, argv[0], SVCCTL_RUNNING, &state );
735 if ( W_ERROR_IS_OK(result) && (state == SVCCTL_RUNNING) )
736 d_printf(_("Successfully started service: %s\n"),
739 d_fprintf(stderr,_("Failed to start service: %s [%s]\n"),
740 argv[0], win_errstr(result) );
743 if (is_valid_policy_hnd(&hService)) {
745 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
747 if (is_valid_policy_hnd(&hSCM)) {
749 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
752 return werror_to_ntstatus(result);
755 /********************************************************************
756 ********************************************************************/
758 static NTSTATUS rpc_service_delete_internal(struct net_context *c,
759 const struct dom_sid *domain_sid,
760 const char *domain_name,
761 struct cli_state *cli,
762 struct rpc_pipe_client *pipe_hnd,
767 struct policy_handle hSCM, hService;
768 WERROR result = WERR_GEN_FAILURE;
770 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
773 d_printf("%s net rpc service delete <service>\n", _("Usage:"));
778 ZERO_STRUCT(hService);
780 /* Open the Service Control Manager */
781 result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
782 SC_RIGHT_MGR_ENUMERATE_SERVICE,
784 if (!W_ERROR_IS_OK(result)) {
785 return werror_to_ntstatus(result);
788 /* Open the Service */
790 result = open_service(b, mem_ctx, &hSCM, argv[0],
793 if (!W_ERROR_IS_OK(result) ) {
797 /* Delete the Service */
799 status = dcerpc_svcctl_DeleteService(b, mem_ctx,
803 if (!NT_STATUS_IS_OK(status)) {
804 result = ntstatus_to_werror(status);
805 d_fprintf(stderr, _("Delete service request failed. [%s]\n"),
809 if (!W_ERROR_IS_OK(result)) {
810 d_fprintf(stderr, _("Delete service request failed. [%s]\n"),
815 d_printf(_("Successfully deleted Service: %s\n"), argv[0]);
818 if (is_valid_policy_hnd(&hService)) {
820 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
822 if (is_valid_policy_hnd(&hSCM)) {
824 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
827 return werror_to_ntstatus(result);
830 /********************************************************************
831 ********************************************************************/
833 static NTSTATUS rpc_service_create_internal(struct net_context *c,
834 const struct dom_sid *domain_sid,
835 const char *domain_name,
836 struct cli_state *cli,
837 struct rpc_pipe_client *pipe_hnd,
842 struct policy_handle hSCM, hService;
843 WERROR result = WERR_GEN_FAILURE;
845 const char *ServiceName;
846 const char *DisplayName;
847 const char *binary_path;
848 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
851 d_printf("%s net rpc service create <service> "
852 "<displayname> <binarypath>\n", _("Usage:"));
857 ZERO_STRUCT(hService);
859 /* Open the Service Control Manager */
860 result = open_scm(b, mem_ctx, pipe_hnd->srv_name_slash,
861 SC_RIGHT_MGR_CREATE_SERVICE,
863 if (!W_ERROR_IS_OK(result)) {
864 return werror_to_ntstatus(result);
867 /* Create the service */
869 ServiceName = argv[0];
870 DisplayName = argv[1];
871 binary_path = argv[2];
873 status = dcerpc_svcctl_CreateServiceW(b, mem_ctx,
878 SERVICE_TYPE_WIN32_OWN_PROCESS,
880 SVCCTL_SVC_ERROR_NORMAL,
882 NULL, /* LoadOrderGroupKey */
884 NULL, /* dependencies */
885 0, /* dependencies_size */
886 NULL, /* service_start_name */
888 0, /* password_size */
891 if (!NT_STATUS_IS_OK(status)) {
892 result = ntstatus_to_werror(status);
893 d_fprintf(stderr, _("Create service request failed. [%s]\n"),
897 if (!W_ERROR_IS_OK(result)) {
898 d_fprintf(stderr, _("Create service request failed. [%s]\n"),
903 d_printf(_("Successfully created Service: %s\n"), argv[0]);
906 if (is_valid_policy_hnd(&hService)) {
908 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
910 if (is_valid_policy_hnd(&hSCM)) {
912 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
915 return werror_to_ntstatus(result);
918 /********************************************************************
919 ********************************************************************/
921 static int rpc_service_list(struct net_context *c, int argc, const char **argv )
923 if (c->display_usage) {
925 "net rpc service list\n"
928 _("View configured Win32 services"));
932 return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
933 rpc_service_list_internal, argc, argv );
936 /********************************************************************
937 ********************************************************************/
939 static int rpc_service_start(struct net_context *c, int argc, const char **argv )
941 if (c->display_usage) {
943 "net rpc service start <service>\n"
946 _("Start a Win32 service"));
950 return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
951 rpc_service_start_internal, argc, argv );
954 /********************************************************************
955 ********************************************************************/
957 static int rpc_service_stop(struct net_context *c, int argc, const char **argv )
959 if (c->display_usage) {
961 "net rpc service stop <service>\n"
964 _("Stop a Win32 service"));
968 return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
969 rpc_service_stop_internal, argc, argv );
972 /********************************************************************
973 ********************************************************************/
975 static int rpc_service_resume(struct net_context *c, int argc, const char **argv )
977 if (c->display_usage) {
979 "net rpc service resume <service>\n"
982 _("Resume a Win32 service"));
986 return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
987 rpc_service_resume_internal, argc, argv );
990 /********************************************************************
991 ********************************************************************/
993 static int rpc_service_pause(struct net_context *c, int argc, const char **argv )
995 if (c->display_usage) {
997 "net rpc service pause <service>\n"
1000 _("Pause a Win32 service"));
1004 return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
1005 rpc_service_pause_internal, argc, argv );
1008 /********************************************************************
1009 ********************************************************************/
1011 static int rpc_service_status(struct net_context *c, int argc, const char **argv )
1013 if (c->display_usage) {
1015 "net rpc service status <service>\n"
1018 _("Show the current status of a service"));
1022 return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
1023 rpc_service_status_internal, argc, argv );
1026 /********************************************************************
1027 ********************************************************************/
1029 static int rpc_service_delete(struct net_context *c, int argc, const char **argv)
1031 if (c->display_usage) {
1033 "net rpc service delete <service>\n"
1036 _("Delete a Win32 service"));
1040 return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
1041 rpc_service_delete_internal, argc, argv);
1044 /********************************************************************
1045 ********************************************************************/
1047 static int rpc_service_create(struct net_context *c, int argc, const char **argv)
1049 if (c->display_usage) {
1051 "net rpc service create <service>\n"
1054 _("Create a Win32 service"));
1058 return run_rpc_command(c, NULL, &ndr_table_svcctl, 0,
1059 rpc_service_create_internal, argc, argv);
1062 /********************************************************************
1063 ********************************************************************/
1065 int net_rpc_service(struct net_context *c, int argc, const char **argv)
1067 struct functable func[] = {
1072 N_("View configured Win32 services"),
1073 N_("net rpc service list\n"
1074 " View configured Win32 services")
1080 N_("Start a service"),
1081 N_("net rpc service start\n"
1088 N_("Stop a service"),
1089 N_("net rpc service stop\n"
1096 N_("Pause a service"),
1097 N_("net rpc service pause\n"
1104 N_("Resume a paused service"),
1105 N_("net rpc service resume\n"
1106 " Resume a service")
1112 N_("View current status of a service"),
1113 N_("net rpc service status\n"
1114 " View current status of a service")
1120 N_("Delete a service"),
1121 N_("net rpc service delete\n"
1122 " Deletes a service")
1128 N_("Create a service"),
1129 N_("net rpc service create\n"
1130 " Creates a service")
1133 {NULL, NULL, 0, NULL, NULL}
1136 return net_run_function(c, argc, argv, "net rpc service",func);