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 "../librpc/gen_ndr/ndr_svcctl.h"
22 #include "../librpc/gen_ndr/ndr_svcctl_c.h"
24 struct svc_state_msg {
29 static struct svc_state_msg state_msg_table[] = {
30 { SVCCTL_STOPPED, N_("stopped") },
31 { SVCCTL_START_PENDING, N_("start pending") },
32 { SVCCTL_STOP_PENDING, N_("stop pending") },
33 { SVCCTL_RUNNING, N_("running") },
34 { SVCCTL_CONTINUE_PENDING, N_("resume pending") },
35 { SVCCTL_PAUSE_PENDING, N_("pause pending") },
36 { SVCCTL_PAUSED, N_("paused") },
41 /********************************************************************
42 ********************************************************************/
43 const char *svc_status_string( uint32 state )
48 fstr_sprintf( msg, _("Unknown State [%d]"), state );
50 for ( i=0; state_msg_table[i].message; i++ ) {
51 if ( state_msg_table[i].flag == state ) {
52 fstrcpy( msg, state_msg_table[i].message );
57 return talloc_strdup(talloc_tos(), msg);
60 /********************************************************************
61 ********************************************************************/
63 static WERROR open_service(struct dcerpc_binding_handle *b,
65 struct policy_handle *hSCM,
68 struct policy_handle *hService)
73 status = dcerpc_svcctl_OpenServiceW(b, mem_ctx,
79 if (!NT_STATUS_IS_OK(status)) {
80 result = ntstatus_to_werror(status);
81 d_fprintf(stderr, _("Failed to open service. [%s]\n"),
85 if (!W_ERROR_IS_OK(result) ) {
86 d_fprintf(stderr, _("Failed to open service. [%s]\n"),
94 /********************************************************************
95 ********************************************************************/
97 static WERROR query_service_state(struct rpc_pipe_client *pipe_hnd,
99 struct policy_handle *hSCM,
103 struct policy_handle hService;
104 struct SERVICE_STATUS service_status;
105 WERROR result = WERR_GENERAL_FAILURE;
107 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
109 /* now cycle until the status is actually 'watch_state' */
111 result = open_service(b, mem_ctx, hSCM, service,
112 SC_RIGHT_SVC_QUERY_STATUS,
114 if (!W_ERROR_IS_OK(result) ) {
118 status = dcerpc_svcctl_QueryServiceStatus(b, mem_ctx,
122 if (!NT_STATUS_IS_OK(status)) {
123 result = ntstatus_to_werror(status);
126 if (!W_ERROR_IS_OK(result)) {
130 *state = service_status.state;
133 if (is_valid_policy_hnd(&hService)) {
135 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
141 /********************************************************************
142 ********************************************************************/
144 static WERROR watch_service_state(struct rpc_pipe_client *pipe_hnd,
146 struct policy_handle *hSCM,
149 uint32 *final_state )
153 WERROR result = WERR_GENERAL_FAILURE;
157 while ( (state != watch_state ) && i<30 ) {
160 result = query_service_state(pipe_hnd, mem_ctx, hSCM, service, &state );
161 if ( !W_ERROR_IS_OK(result) ) {
171 *final_state = state;
176 /********************************************************************
177 ********************************************************************/
179 static WERROR control_service(struct rpc_pipe_client *pipe_hnd,
181 struct policy_handle *hSCM,
186 struct policy_handle hService;
187 WERROR result = WERR_GENERAL_FAILURE;
189 struct SERVICE_STATUS service_status;
191 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
193 /* Open the Service */
195 result = open_service(b, mem_ctx, hSCM, service,
196 (SC_RIGHT_SVC_STOP|SC_RIGHT_SVC_PAUSE_CONTINUE),
198 if (!W_ERROR_IS_OK(result) ) {
204 status = dcerpc_svcctl_ControlService(b, mem_ctx,
210 if (!NT_STATUS_IS_OK(status)) {
211 result = ntstatus_to_werror(status);
212 d_fprintf(stderr, _("Control service request failed. [%s]\n"),
216 if (!W_ERROR_IS_OK(result) ) {
217 d_fprintf(stderr, _("Control service request failed. [%s]\n"),
222 /* loop -- checking the state until we are where we want to be */
224 result = watch_service_state(pipe_hnd, mem_ctx, hSCM, service, watch_state, &state );
226 d_printf(_("%s service is %s.\n"), service, svc_status_string(state));
229 if (is_valid_policy_hnd(&hService)) {
231 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
237 /********************************************************************
238 ********************************************************************/
240 static NTSTATUS rpc_service_list_internal(struct net_context *c,
241 const struct dom_sid *domain_sid,
242 const char *domain_name,
243 struct cli_state *cli,
244 struct rpc_pipe_client *pipe_hnd,
249 struct policy_handle hSCM;
250 struct ENUM_SERVICE_STATUSW *services = NULL;
251 WERROR result = WERR_GENERAL_FAILURE;
254 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
256 uint8_t *buffer = NULL;
257 uint32_t buf_size = 0;
258 uint32_t bytes_needed = 0;
259 uint32_t num_services = 0;
260 uint32_t resume_handle = 0;
263 d_printf("%s net rpc service list\n", _("Usage:"));
267 status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
268 pipe_hnd->srv_name_slash,
270 SC_RIGHT_MGR_ENUMERATE_SERVICE,
273 if (!NT_STATUS_IS_OK(status)) {
275 _("Failed to open Service Control Manager. [%s]\n"),
279 if (!W_ERROR_IS_OK(result)) {
281 _("Failed to open Service Control Manager. [%s]\n"),
283 return werror_to_ntstatus(result);
287 status = dcerpc_svcctl_EnumServicesStatusW(b, mem_ctx,
298 if (!NT_STATUS_IS_OK(status)) {
300 _("Failed to enumerate services. [%s]\n"),
305 if (W_ERROR_EQUAL(result, WERR_MORE_DATA) && bytes_needed > 0) {
306 buffer = talloc_array(mem_ctx, uint8_t, bytes_needed);
307 buf_size = bytes_needed;
311 if (!W_ERROR_IS_OK(result)) {
312 status = werror_to_ntstatus(result);
314 _("Failed to enumerate services. [%s]\n"),
319 if ( num_services == 0 ) {
320 d_printf(_("No services returned\n"));
325 enum ndr_err_code ndr_err;
327 struct ndr_pull *ndr;
329 blob.length = buf_size;
330 blob.data = talloc_steal(mem_ctx, buffer);
332 services = talloc_array(mem_ctx, struct ENUM_SERVICE_STATUSW, num_services);
334 status = NT_STATUS_NO_MEMORY;
338 ndr = ndr_pull_init_blob(&blob, mem_ctx);
340 status = NT_STATUS_NO_MEMORY;
344 ndr_err = ndr_pull_ENUM_SERVICE_STATUSW_array(
345 ndr, num_services, services);
346 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
347 status = ndr_map_error2ntstatus(ndr_err);
351 for ( i=0; i<num_services; i++ ) {
352 d_printf("%-20s \"%s\"\n",
353 services[i].service_name,
354 services[i].display_name);
358 } while (W_ERROR_EQUAL(result, WERR_MORE_DATA));
360 if (is_valid_policy_hnd(&hSCM)) {
362 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
368 /********************************************************************
369 ********************************************************************/
371 static NTSTATUS rpc_service_status_internal(struct net_context *c,
372 const struct dom_sid *domain_sid,
373 const char *domain_name,
374 struct cli_state *cli,
375 struct rpc_pipe_client *pipe_hnd,
380 struct policy_handle hSCM, hService;
381 WERROR result = WERR_GENERAL_FAILURE;
383 struct SERVICE_STATUS service_status;
384 struct QUERY_SERVICE_CONFIG config;
385 uint32_t buf_size = sizeof(config);
386 uint32_t ret_size = 0;
387 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
390 d_printf("%s net rpc service status <service>\n", _("Usage:"));
394 /* Open the Service Control Manager */
395 status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
396 pipe_hnd->srv_name_slash,
398 SC_RIGHT_MGR_ENUMERATE_SERVICE,
401 if (!NT_STATUS_IS_OK(status)) {
403 _("Failed to open Service Control Manager. [%s]\n"),
407 if (!W_ERROR_IS_OK(result)) {
409 _("Failed to open Service Control Manager. [%s]\n"),
411 return werror_to_ntstatus(result);
414 /* Open the Service */
416 result = open_service(b, mem_ctx, &hSCM, argv[0],
417 (SC_RIGHT_SVC_QUERY_STATUS|SC_RIGHT_SVC_QUERY_CONFIG),
419 if (!W_ERROR_IS_OK(result) ) {
425 status = dcerpc_svcctl_QueryServiceStatus(b, mem_ctx,
429 if (!NT_STATUS_IS_OK(status)) {
430 result = ntstatus_to_werror(status);
431 d_fprintf(stderr, _("Query status request failed. [%s]\n"),
436 if (!W_ERROR_IS_OK(result) ) {
437 d_fprintf(stderr, _("Query status request failed. [%s]\n"),
442 d_printf(_("%s service is %s.\n"), argv[0],
443 svc_status_string(service_status.state));
447 status = dcerpc_svcctl_QueryServiceConfigW(b, mem_ctx,
453 if (!NT_STATUS_IS_OK(status)) {
454 result = ntstatus_to_werror(status);
455 d_fprintf(stderr, _("Query config request failed. [%s]\n"),
460 if (W_ERROR_EQUAL(result, WERR_INSUFFICIENT_BUFFER)) {
462 status = dcerpc_svcctl_QueryServiceConfigW(b, mem_ctx,
468 if (!NT_STATUS_IS_OK(status)) {
469 result = ntstatus_to_werror(status);
470 d_fprintf(stderr, _("Query config request failed. [%s]\n"),
476 if (!W_ERROR_IS_OK(result) ) {
477 d_fprintf(stderr, _("Query config request failed. [%s]\n"),
482 /* print out the configuration information for the service */
484 d_printf(_("Configuration details:\n"));
485 d_printf(_("\tControls Accepted = 0x%x\n"),
486 service_status.controls_accepted);
487 d_printf(_("\tService Type = 0x%x\n"), config.service_type);
488 d_printf(_("\tStart Type = 0x%x\n"), config.start_type);
489 d_printf(_("\tError Control = 0x%x\n"), config.error_control);
490 d_printf(_("\tTag ID = 0x%x\n"), config.tag_id);
492 if (config.executablepath) {
493 d_printf(_("\tExecutable Path = %s\n"),
494 config.executablepath);
497 if (config.loadordergroup) {
498 d_printf(_("\tLoad Order Group = %s\n"),
499 config.loadordergroup);
502 if (config.dependencies) {
503 d_printf(_("\tDependencies = %s\n"),
504 config.dependencies);
507 if (config.startname) {
508 d_printf(_("\tStart Name = %s\n"), config.startname);
511 if (config.displayname) {
512 d_printf(_("\tDisplay Name = %s\n"),
517 if (is_valid_policy_hnd(&hService)) {
519 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
521 if (is_valid_policy_hnd(&hSCM)) {
523 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
526 return werror_to_ntstatus(result);
529 /********************************************************************
530 ********************************************************************/
532 static NTSTATUS rpc_service_stop_internal(struct net_context *c,
533 const struct dom_sid *domain_sid,
534 const char *domain_name,
535 struct cli_state *cli,
536 struct rpc_pipe_client *pipe_hnd,
541 struct policy_handle hSCM;
542 WERROR result = WERR_GENERAL_FAILURE;
545 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
548 d_printf("%s net rpc service status <service>\n", _("Usage:"));
552 fstrcpy( servicename, argv[0] );
554 /* Open the Service Control Manager */
555 status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
556 pipe_hnd->srv_name_slash,
558 SC_RIGHT_MGR_ENUMERATE_SERVICE,
561 if (!NT_STATUS_IS_OK(status)) {
563 _("Failed to open Service Control Manager. [%s]\n"),
567 if (!W_ERROR_IS_OK(result)) {
569 _("Failed to open Service Control Manager. [%s]\n"),
571 return werror_to_ntstatus(result);
574 result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename,
575 SVCCTL_CONTROL_STOP, SVCCTL_STOPPED );
577 if (is_valid_policy_hnd(&hSCM)) {
579 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
582 return werror_to_ntstatus(result);
585 /********************************************************************
586 ********************************************************************/
588 static NTSTATUS rpc_service_pause_internal(struct net_context *c,
589 const struct dom_sid *domain_sid,
590 const char *domain_name,
591 struct cli_state *cli,
592 struct rpc_pipe_client *pipe_hnd,
597 struct policy_handle hSCM;
598 WERROR result = WERR_GENERAL_FAILURE;
601 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
604 d_printf("%s net rpc service status <service>\n", _("Usage:"));
608 fstrcpy( servicename, argv[0] );
610 /* Open the Service Control Manager */
611 status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
612 pipe_hnd->srv_name_slash,
614 SC_RIGHT_MGR_ENUMERATE_SERVICE,
617 if (!NT_STATUS_IS_OK(status)) {
619 _("Failed to open Service Control Manager. [%s]\n"),
623 if (!W_ERROR_IS_OK(result)) {
625 _("Failed to open Service Control Manager. [%s]\n"),
627 return werror_to_ntstatus(result);
630 result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename,
631 SVCCTL_CONTROL_PAUSE, SVCCTL_PAUSED );
633 if (is_valid_policy_hnd(&hSCM)) {
635 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
638 return werror_to_ntstatus(result);
641 /********************************************************************
642 ********************************************************************/
644 static NTSTATUS rpc_service_resume_internal(struct net_context *c,
645 const struct dom_sid *domain_sid,
646 const char *domain_name,
647 struct cli_state *cli,
648 struct rpc_pipe_client *pipe_hnd,
653 struct policy_handle hSCM;
654 WERROR result = WERR_GENERAL_FAILURE;
657 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
660 d_printf("%s net rpc service status <service>\n", _("Usage:"));
664 fstrcpy( servicename, argv[0] );
666 /* Open the Service Control Manager */
667 status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
668 pipe_hnd->srv_name_slash,
670 SC_RIGHT_MGR_ENUMERATE_SERVICE,
673 if (!NT_STATUS_IS_OK(status)) {
675 _("Failed to open Service Control Manager. [%s]\n"),
679 if (!W_ERROR_IS_OK(result)) {
681 _("Failed to open Service Control Manager. [%s]\n"),
683 return werror_to_ntstatus(result);
686 result = control_service(pipe_hnd, mem_ctx, &hSCM, servicename,
687 SVCCTL_CONTROL_CONTINUE, SVCCTL_RUNNING );
689 if (is_valid_policy_hnd(&hSCM)) {
691 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
694 return werror_to_ntstatus(result);
697 /********************************************************************
698 ********************************************************************/
700 static NTSTATUS rpc_service_start_internal(struct net_context *c,
701 const struct dom_sid *domain_sid,
702 const char *domain_name,
703 struct cli_state *cli,
704 struct rpc_pipe_client *pipe_hnd,
709 struct policy_handle hSCM, hService;
710 WERROR result = WERR_GENERAL_FAILURE;
713 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
716 d_printf("%s net rpc service status <service>\n", _("Usage:"));
720 /* Open the Service Control Manager */
721 status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
722 pipe_hnd->srv_name_slash,
724 SC_RIGHT_MGR_ENUMERATE_SERVICE,
727 if (!NT_STATUS_IS_OK(status)) {
729 _("Failed to open Service Control Manager. [%s]\n"),
733 if (!W_ERROR_IS_OK(result)) {
735 _("Failed to open Service Control Manager. [%s]\n"),
737 return werror_to_ntstatus(result);
741 /* Open the Service */
743 result = open_service(b, mem_ctx, &hSCM, argv[0],
746 if (!W_ERROR_IS_OK(result) ) {
752 status = dcerpc_svcctl_StartServiceW(b, mem_ctx,
758 if (!NT_STATUS_IS_OK(status)) {
759 result = ntstatus_to_werror(status);
760 d_fprintf(stderr, _("Query status request failed. [%s]\n"),
764 if (!W_ERROR_IS_OK(result) ) {
765 d_fprintf(stderr, _("Query status request failed. [%s]\n"),
770 result = watch_service_state(pipe_hnd, mem_ctx, &hSCM, argv[0], SVCCTL_RUNNING, &state );
772 if ( W_ERROR_IS_OK(result) && (state == SVCCTL_RUNNING) )
773 d_printf(_("Successfully started service: %s\n"),
776 d_fprintf(stderr,_("Failed to start service: %s [%s]\n"),
777 argv[0], win_errstr(result) );
780 if (is_valid_policy_hnd(&hService)) {
782 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
784 if (is_valid_policy_hnd(&hSCM)) {
786 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
789 return werror_to_ntstatus(result);
792 /********************************************************************
793 ********************************************************************/
795 static NTSTATUS rpc_service_delete_internal(struct net_context *c,
796 const struct dom_sid *domain_sid,
797 const char *domain_name,
798 struct cli_state *cli,
799 struct rpc_pipe_client *pipe_hnd,
804 struct policy_handle hSCM, hService;
805 WERROR result = WERR_GENERAL_FAILURE;
807 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
810 d_printf("%s net rpc service delete <service>\n", _("Usage:"));
815 ZERO_STRUCT(hService);
817 /* Open the Service Control Manager */
818 status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
819 pipe_hnd->srv_name_slash,
821 SC_RIGHT_MGR_ENUMERATE_SERVICE,
824 if (!NT_STATUS_IS_OK(status)) {
826 _("Failed to open Service Control Manager. [%s]\n"),
830 if (!W_ERROR_IS_OK(result)) {
832 _("Failed to open Service Control Manager. [%s]\n"),
834 return werror_to_ntstatus(result);
837 /* Open the Service */
839 result = open_service(b, mem_ctx, &hSCM, argv[0],
842 if (!W_ERROR_IS_OK(result) ) {
846 /* Delete the Service */
848 status = dcerpc_svcctl_DeleteService(b, mem_ctx,
852 if (!NT_STATUS_IS_OK(status)) {
853 result = ntstatus_to_werror(status);
854 d_fprintf(stderr, _("Delete service request failed. [%s]\n"),
858 if (!W_ERROR_IS_OK(result)) {
859 d_fprintf(stderr, _("Delete service request failed. [%s]\n"),
864 d_printf(_("Successfully deleted Service: %s\n"), argv[0]);
867 if (is_valid_policy_hnd(&hService)) {
869 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
871 if (is_valid_policy_hnd(&hSCM)) {
873 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
876 return werror_to_ntstatus(result);
879 /********************************************************************
880 ********************************************************************/
882 static NTSTATUS rpc_service_create_internal(struct net_context *c,
883 const struct dom_sid *domain_sid,
884 const char *domain_name,
885 struct cli_state *cli,
886 struct rpc_pipe_client *pipe_hnd,
891 struct policy_handle hSCM, hService;
892 WERROR result = WERR_GENERAL_FAILURE;
894 const char *ServiceName;
895 const char *DisplayName;
896 const char *binary_path;
897 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
900 d_printf("%s net rpc service create <service> "
901 "<displayname> <binarypath>\n", _("Usage:"));
906 ZERO_STRUCT(hService);
908 /* Open the Service Control Manager */
909 status = dcerpc_svcctl_OpenSCManagerW(b, mem_ctx,
910 pipe_hnd->srv_name_slash,
912 SC_RIGHT_MGR_CREATE_SERVICE,
915 if (!NT_STATUS_IS_OK(status)) {
917 _("Failed to open Service Control Manager. [%s]\n"),
921 if (!W_ERROR_IS_OK(result)) {
923 _("Failed to open Service Control Manager. [%s]\n"),
925 return werror_to_ntstatus(result);
928 /* Create the service */
930 ServiceName = argv[0];
931 DisplayName = argv[1];
932 binary_path = argv[2];
934 status = dcerpc_svcctl_CreateServiceW(b, mem_ctx,
939 SERVICE_TYPE_WIN32_OWN_PROCESS,
941 SVCCTL_SVC_ERROR_NORMAL,
943 NULL, /* LoadOrderGroupKey */
945 NULL, /* dependencies */
946 0, /* dependencies_size */
947 NULL, /* service_start_name */
949 0, /* password_size */
952 if (!NT_STATUS_IS_OK(status)) {
953 result = ntstatus_to_werror(status);
954 d_fprintf(stderr, _("Create service request failed. [%s]\n"),
958 if (!W_ERROR_IS_OK(result)) {
959 d_fprintf(stderr, _("Create service request failed. [%s]\n"),
964 d_printf(_("Successfully created Service: %s\n"), argv[0]);
967 if (is_valid_policy_hnd(&hService)) {
969 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hService, &_result);
971 if (is_valid_policy_hnd(&hSCM)) {
973 dcerpc_svcctl_CloseServiceHandle(b, mem_ctx, &hSCM, &_result);
976 return werror_to_ntstatus(result);
979 /********************************************************************
980 ********************************************************************/
982 static int rpc_service_list(struct net_context *c, int argc, const char **argv )
984 if (c->display_usage) {
986 "net rpc service list\n"
989 _("View configured Win32 services"));
993 return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
994 rpc_service_list_internal, argc, argv );
997 /********************************************************************
998 ********************************************************************/
1000 static int rpc_service_start(struct net_context *c, int argc, const char **argv )
1002 if (c->display_usage) {
1004 "net rpc service start <service>\n"
1007 _("Start a Win32 service"));
1011 return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
1012 rpc_service_start_internal, argc, argv );
1015 /********************************************************************
1016 ********************************************************************/
1018 static int rpc_service_stop(struct net_context *c, int argc, const char **argv )
1020 if (c->display_usage) {
1022 "net rpc service stop <service>\n"
1025 _("Stop a Win32 service"));
1029 return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
1030 rpc_service_stop_internal, argc, argv );
1033 /********************************************************************
1034 ********************************************************************/
1036 static int rpc_service_resume(struct net_context *c, int argc, const char **argv )
1038 if (c->display_usage) {
1040 "net rpc service resume <service>\n"
1043 _("Resume a Win32 service"));
1047 return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
1048 rpc_service_resume_internal, argc, argv );
1051 /********************************************************************
1052 ********************************************************************/
1054 static int rpc_service_pause(struct net_context *c, int argc, const char **argv )
1056 if (c->display_usage) {
1058 "net rpc service pause <service>\n"
1061 _("Pause a Win32 service"));
1065 return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
1066 rpc_service_pause_internal, argc, argv );
1069 /********************************************************************
1070 ********************************************************************/
1072 static int rpc_service_status(struct net_context *c, int argc, const char **argv )
1074 if (c->display_usage) {
1076 "net rpc service status <service>\n"
1079 _("Show the current status of a service"));
1083 return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
1084 rpc_service_status_internal, argc, argv );
1087 /********************************************************************
1088 ********************************************************************/
1090 static int rpc_service_delete(struct net_context *c, int argc, const char **argv)
1092 if (c->display_usage) {
1094 "net rpc service delete <service>\n"
1097 _("Delete a Win32 service"));
1101 return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
1102 rpc_service_delete_internal, argc, argv);
1105 /********************************************************************
1106 ********************************************************************/
1108 static int rpc_service_create(struct net_context *c, int argc, const char **argv)
1110 if (c->display_usage) {
1112 "net rpc service create <service>\n"
1115 _("Create a Win32 service"));
1119 return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
1120 rpc_service_create_internal, argc, argv);
1123 /********************************************************************
1124 ********************************************************************/
1126 int net_rpc_service(struct net_context *c, int argc, const char **argv)
1128 struct functable func[] = {
1133 N_("View configured Win32 services"),
1134 N_("net rpc service list\n"
1135 " View configured Win32 services")
1141 N_("Start a service"),
1142 N_("net rpc service start\n"
1149 N_("Stop a service"),
1150 N_("net rpc service stop\n"
1157 N_("Pause a service"),
1158 N_("net rpc service pause\n"
1165 N_("Resume a paused service"),
1166 N_("net rpc service resume\n"
1167 " Resume a service")
1173 N_("View current status of a service"),
1174 N_("net rpc service status\n"
1175 " View current status of a service")
1181 N_("Delete a service"),
1182 N_("net rpc service delete\n"
1183 " Deletes a service")
1189 N_("Create a service"),
1190 N_("net rpc service create\n"
1191 " Creates a service")
1194 {NULL, NULL, 0, NULL, NULL}
1197 return net_run_function(c, argc, argv, "net rpc service",func);