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"
24 #include "lib/util/string_wrappers.h"
26 struct svc_state_msg
{
31 static struct svc_state_msg state_msg_table
[] = {
32 { SVCCTL_STOPPED
, N_("stopped") },
33 { SVCCTL_START_PENDING
, N_("start pending") },
34 { SVCCTL_STOP_PENDING
, N_("stop pending") },
35 { SVCCTL_RUNNING
, N_("running") },
36 { SVCCTL_CONTINUE_PENDING
, N_("resume pending") },
37 { SVCCTL_PAUSE_PENDING
, N_("pause pending") },
38 { SVCCTL_PAUSED
, N_("paused") },
43 /********************************************************************
44 ********************************************************************/
45 const char *svc_status_string( uint32_t state
)
50 fstr_sprintf( msg
, _("Unknown State [%d]"), state
);
52 for ( i
=0; state_msg_table
[i
].message
; i
++ ) {
53 if ( state_msg_table
[i
].flag
== state
) {
54 fstrcpy( msg
, state_msg_table
[i
].message
);
59 return talloc_strdup(talloc_tos(), msg
);
62 /********************************************************************
63 ********************************************************************/
65 static WERROR
open_service(struct dcerpc_binding_handle
*b
,
67 struct policy_handle
*hSCM
,
70 struct policy_handle
*hService
)
75 status
= dcerpc_svcctl_OpenServiceW(b
, mem_ctx
,
81 if (!NT_STATUS_IS_OK(status
)) {
82 result
= ntstatus_to_werror(status
);
83 d_fprintf(stderr
, _("Failed to open service. [%s]\n"),
87 if (!W_ERROR_IS_OK(result
) ) {
88 d_fprintf(stderr
, _("Failed to open service. [%s]\n"),
96 /********************************************************************
97 ********************************************************************/
99 static WERROR
open_scm(struct dcerpc_binding_handle
*b
,
101 const char *server_name
,
102 uint32_t access_mask
,
103 struct policy_handle
*hSCM
)
108 status
= dcerpc_svcctl_OpenSCManagerW(b
, mem_ctx
,
114 if (!NT_STATUS_IS_OK(status
)) {
115 result
= ntstatus_to_werror(status
);
117 _("Failed to open Service Control Manager. [%s]\n"),
121 if (!W_ERROR_IS_OK(result
)) {
123 _("Failed to open Service Control Manager. [%s]\n"),
131 /********************************************************************
132 ********************************************************************/
134 static WERROR
query_service_state(struct rpc_pipe_client
*pipe_hnd
,
136 struct policy_handle
*hSCM
,
140 struct policy_handle hService
;
141 struct SERVICE_STATUS service_status
;
142 WERROR result
= WERR_GEN_FAILURE
;
144 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
146 /* now cycle until the status is actually 'watch_state' */
148 result
= open_service(b
, mem_ctx
, hSCM
, service
,
149 SC_RIGHT_SVC_QUERY_STATUS
,
151 if (!W_ERROR_IS_OK(result
) ) {
155 status
= dcerpc_svcctl_QueryServiceStatus(b
, mem_ctx
,
159 if (!NT_STATUS_IS_OK(status
)) {
160 result
= ntstatus_to_werror(status
);
163 if (!W_ERROR_IS_OK(result
)) {
167 *state
= service_status
.state
;
170 if (is_valid_policy_hnd(&hService
)) {
172 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
178 /********************************************************************
179 ********************************************************************/
181 static WERROR
watch_service_state(struct rpc_pipe_client
*pipe_hnd
,
183 struct policy_handle
*hSCM
,
185 uint32_t watch_state
,
186 uint32_t *final_state
)
190 WERROR result
= WERR_GEN_FAILURE
;
194 while ( (state
!= watch_state
) && i
<30 ) {
197 result
= query_service_state(pipe_hnd
, mem_ctx
, hSCM
, service
, &state
);
198 if ( !W_ERROR_IS_OK(result
) ) {
208 *final_state
= state
;
213 /********************************************************************
214 ********************************************************************/
216 static WERROR
control_service(struct rpc_pipe_client
*pipe_hnd
,
218 struct policy_handle
*hSCM
,
221 uint32_t watch_state
)
223 struct policy_handle hService
;
224 WERROR result
= WERR_GEN_FAILURE
;
226 struct SERVICE_STATUS service_status
;
228 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
230 /* Open the Service */
232 result
= open_service(b
, mem_ctx
, hSCM
, service
,
233 (SC_RIGHT_SVC_STOP
|SC_RIGHT_SVC_PAUSE_CONTINUE
),
235 if (!W_ERROR_IS_OK(result
) ) {
241 status
= dcerpc_svcctl_ControlService(b
, mem_ctx
,
247 if (!NT_STATUS_IS_OK(status
)) {
248 result
= ntstatus_to_werror(status
);
249 d_fprintf(stderr
, _("Control service request failed. [%s]\n"),
253 if (!W_ERROR_IS_OK(result
) ) {
254 d_fprintf(stderr
, _("Control service request failed. [%s]\n"),
259 /* loop -- checking the state until we are where we want to be */
261 result
= watch_service_state(pipe_hnd
, mem_ctx
, hSCM
, service
, watch_state
, &state
);
263 d_printf(_("%s service is %s.\n"), service
, svc_status_string(state
));
266 if (is_valid_policy_hnd(&hService
)) {
268 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
274 /********************************************************************
275 ********************************************************************/
277 static NTSTATUS
rpc_service_list_internal(struct net_context
*c
,
278 const struct dom_sid
*domain_sid
,
279 const char *domain_name
,
280 struct cli_state
*cli
,
281 struct rpc_pipe_client
*pipe_hnd
,
286 struct policy_handle hSCM
;
287 struct ENUM_SERVICE_STATUSW
*services
= NULL
;
288 WERROR result
= WERR_GEN_FAILURE
;
291 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
294 uint32_t buf_size
= 0;
295 uint32_t bytes_needed
= 0;
296 uint32_t num_services
= 0;
297 uint32_t resume_handle
= 0;
300 d_printf("%s net rpc service list\n", _("Usage:"));
304 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
305 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
307 if (!W_ERROR_IS_OK(result
)) {
308 return werror_to_ntstatus(result
);
311 buffer
= talloc_array(mem_ctx
, uint8_t, buf_size
);
312 if (buffer
== NULL
) {
313 status
= NT_STATUS_NO_MEMORY
;
318 status
= dcerpc_svcctl_EnumServicesStatusW(b
, mem_ctx
,
329 if (!NT_STATUS_IS_OK(status
)) {
331 _("Failed to enumerate services. [%s]\n"),
336 if (W_ERROR_EQUAL(result
, WERR_MORE_DATA
) && bytes_needed
> 0) {
337 buf_size
= bytes_needed
;
338 buffer
= talloc_realloc(mem_ctx
, buffer
, uint8_t, bytes_needed
);
339 if (buffer
== NULL
) {
340 status
= NT_STATUS_NO_MEMORY
;
346 if (!W_ERROR_IS_OK(result
)) {
347 status
= werror_to_ntstatus(result
);
349 _("Failed to enumerate services. [%s]\n"),
354 if ( num_services
== 0 ) {
355 d_printf(_("No services returned\n"));
360 enum ndr_err_code ndr_err
;
362 struct ndr_pull
*ndr
;
364 blob
.length
= buf_size
;
365 blob
.data
= talloc_steal(mem_ctx
, buffer
);
367 services
= talloc_array(mem_ctx
, struct ENUM_SERVICE_STATUSW
, num_services
);
369 status
= NT_STATUS_NO_MEMORY
;
373 ndr
= ndr_pull_init_blob(&blob
, mem_ctx
);
375 status
= NT_STATUS_NO_MEMORY
;
379 ndr_err
= ndr_pull_ENUM_SERVICE_STATUSW_array(
380 ndr
, num_services
, services
);
381 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
382 status
= ndr_map_error2ntstatus(ndr_err
);
386 for ( i
=0; i
<num_services
; i
++ ) {
387 d_printf("%-20s \"%s\"\n",
388 services
[i
].service_name
,
389 services
[i
].display_name
);
393 } while (W_ERROR_EQUAL(result
, WERR_MORE_DATA
));
396 if (is_valid_policy_hnd(&hSCM
)) {
398 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
404 /********************************************************************
405 ********************************************************************/
407 static NTSTATUS
rpc_service_status_internal(struct net_context
*c
,
408 const struct dom_sid
*domain_sid
,
409 const char *domain_name
,
410 struct cli_state
*cli
,
411 struct rpc_pipe_client
*pipe_hnd
,
416 struct policy_handle hSCM
, hService
;
417 WERROR result
= WERR_GEN_FAILURE
;
419 struct SERVICE_STATUS service_status
;
420 struct QUERY_SERVICE_CONFIG config
;
421 uint32_t buf_size
= sizeof(config
);
422 uint32_t ret_size
= 0;
423 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
426 d_printf("%s net rpc service status <service>\n", _("Usage:"));
430 /* Open the Service Control Manager */
431 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
432 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
434 if (!W_ERROR_IS_OK(result
)) {
435 return werror_to_ntstatus(result
);
438 /* Open the Service */
440 result
= open_service(b
, mem_ctx
, &hSCM
, argv
[0],
441 (SC_RIGHT_SVC_QUERY_STATUS
|SC_RIGHT_SVC_QUERY_CONFIG
),
443 if (!W_ERROR_IS_OK(result
) ) {
449 status
= dcerpc_svcctl_QueryServiceStatus(b
, mem_ctx
,
453 if (!NT_STATUS_IS_OK(status
)) {
454 result
= ntstatus_to_werror(status
);
455 d_fprintf(stderr
, _("Query status request failed. [%s]\n"),
460 if (!W_ERROR_IS_OK(result
) ) {
461 d_fprintf(stderr
, _("Query status request failed. [%s]\n"),
466 d_printf(_("%s service is %s.\n"), argv
[0],
467 svc_status_string(service_status
.state
));
471 status
= dcerpc_svcctl_QueryServiceConfigW(b
, mem_ctx
,
477 if (!NT_STATUS_IS_OK(status
)) {
478 result
= ntstatus_to_werror(status
);
479 d_fprintf(stderr
, _("Query config request failed. [%s]\n"),
484 if (W_ERROR_EQUAL(result
, WERR_INSUFFICIENT_BUFFER
)) {
486 status
= dcerpc_svcctl_QueryServiceConfigW(b
, mem_ctx
,
492 if (!NT_STATUS_IS_OK(status
)) {
493 result
= ntstatus_to_werror(status
);
494 d_fprintf(stderr
, _("Query config request failed. [%s]\n"),
500 if (!W_ERROR_IS_OK(result
) ) {
501 d_fprintf(stderr
, _("Query config request failed. [%s]\n"),
506 /* print out the configuration information for the service */
508 d_printf(_("Configuration details:\n"));
509 d_printf(_("\tControls Accepted = 0x%x\n"),
510 service_status
.controls_accepted
);
511 d_printf(_("\tService Type = 0x%x\n"), config
.service_type
);
512 d_printf(_("\tStart Type = 0x%x\n"), config
.start_type
);
513 d_printf(_("\tError Control = 0x%x\n"), config
.error_control
);
514 d_printf(_("\tTag ID = 0x%x\n"), config
.tag_id
);
516 if (config
.executablepath
) {
517 d_printf(_("\tExecutable Path = %s\n"),
518 config
.executablepath
);
521 if (config
.loadordergroup
) {
522 d_printf(_("\tLoad Order Group = %s\n"),
523 config
.loadordergroup
);
526 if (config
.dependencies
) {
527 d_printf(_("\tDependencies = %s\n"),
528 config
.dependencies
);
531 if (config
.startname
) {
532 d_printf(_("\tStart Name = %s\n"), config
.startname
);
535 if (config
.displayname
) {
536 d_printf(_("\tDisplay Name = %s\n"),
541 if (is_valid_policy_hnd(&hService
)) {
543 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
545 if (is_valid_policy_hnd(&hSCM
)) {
547 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
550 return werror_to_ntstatus(result
);
553 /********************************************************************
554 ********************************************************************/
556 static NTSTATUS
rpc_service_stop_internal(struct net_context
*c
,
557 const struct dom_sid
*domain_sid
,
558 const char *domain_name
,
559 struct cli_state
*cli
,
560 struct rpc_pipe_client
*pipe_hnd
,
565 struct policy_handle hSCM
;
566 WERROR result
= WERR_GEN_FAILURE
;
567 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
570 d_printf("%s net rpc service status <service>\n", _("Usage:"));
574 /* Open the Service Control Manager */
575 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
576 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
578 if (!W_ERROR_IS_OK(result
)) {
579 return werror_to_ntstatus(result
);
582 result
= control_service(pipe_hnd
, mem_ctx
, &hSCM
, argv
[0],
583 SVCCTL_CONTROL_STOP
, SVCCTL_STOPPED
);
585 if (is_valid_policy_hnd(&hSCM
)) {
587 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
590 return werror_to_ntstatus(result
);
593 /********************************************************************
594 ********************************************************************/
596 static NTSTATUS
rpc_service_pause_internal(struct net_context
*c
,
597 const struct dom_sid
*domain_sid
,
598 const char *domain_name
,
599 struct cli_state
*cli
,
600 struct rpc_pipe_client
*pipe_hnd
,
605 struct policy_handle hSCM
;
606 WERROR result
= WERR_GEN_FAILURE
;
607 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
610 d_printf("%s net rpc service status <service>\n", _("Usage:"));
614 /* Open the Service Control Manager */
615 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
616 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
618 if (!W_ERROR_IS_OK(result
)) {
619 return werror_to_ntstatus(result
);
622 result
= control_service(pipe_hnd
, mem_ctx
, &hSCM
, argv
[0],
623 SVCCTL_CONTROL_PAUSE
, SVCCTL_PAUSED
);
625 if (is_valid_policy_hnd(&hSCM
)) {
627 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
630 return werror_to_ntstatus(result
);
633 /********************************************************************
634 ********************************************************************/
636 static NTSTATUS
rpc_service_resume_internal(struct net_context
*c
,
637 const struct dom_sid
*domain_sid
,
638 const char *domain_name
,
639 struct cli_state
*cli
,
640 struct rpc_pipe_client
*pipe_hnd
,
645 struct policy_handle hSCM
;
646 WERROR result
= WERR_GEN_FAILURE
;
647 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
650 d_printf("%s net rpc service status <service>\n", _("Usage:"));
654 /* Open the Service Control Manager */
655 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
656 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
658 if (!W_ERROR_IS_OK(result
)) {
659 return werror_to_ntstatus(result
);
662 result
= control_service(pipe_hnd
, mem_ctx
, &hSCM
, argv
[0],
663 SVCCTL_CONTROL_CONTINUE
, SVCCTL_RUNNING
);
665 if (is_valid_policy_hnd(&hSCM
)) {
667 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
670 return werror_to_ntstatus(result
);
673 /********************************************************************
674 ********************************************************************/
676 static NTSTATUS
rpc_service_start_internal(struct net_context
*c
,
677 const struct dom_sid
*domain_sid
,
678 const char *domain_name
,
679 struct cli_state
*cli
,
680 struct rpc_pipe_client
*pipe_hnd
,
685 struct policy_handle hSCM
, hService
;
686 WERROR result
= WERR_GEN_FAILURE
;
689 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
692 d_printf("%s net rpc service status <service>\n", _("Usage:"));
696 /* Open the Service Control Manager */
697 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
698 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
700 if (!W_ERROR_IS_OK(result
)) {
701 return werror_to_ntstatus(result
);
705 /* Open the Service */
707 result
= open_service(b
, mem_ctx
, &hSCM
, argv
[0],
710 if (!W_ERROR_IS_OK(result
) ) {
716 status
= dcerpc_svcctl_StartServiceW(b
, mem_ctx
,
722 if (!NT_STATUS_IS_OK(status
)) {
723 result
= ntstatus_to_werror(status
);
724 d_fprintf(stderr
, _("Query status request failed. [%s]\n"),
728 if (!W_ERROR_IS_OK(result
) ) {
729 d_fprintf(stderr
, _("Query status request failed. [%s]\n"),
734 result
= watch_service_state(pipe_hnd
, mem_ctx
, &hSCM
, argv
[0], SVCCTL_RUNNING
, &state
);
736 if ( W_ERROR_IS_OK(result
) && (state
== SVCCTL_RUNNING
) )
737 d_printf(_("Successfully started service: %s\n"),
740 d_fprintf(stderr
,_("Failed to start service: %s [%s]\n"),
741 argv
[0], win_errstr(result
) );
744 if (is_valid_policy_hnd(&hService
)) {
746 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
748 if (is_valid_policy_hnd(&hSCM
)) {
750 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
753 return werror_to_ntstatus(result
);
756 /********************************************************************
757 ********************************************************************/
759 static NTSTATUS
rpc_service_delete_internal(struct net_context
*c
,
760 const struct dom_sid
*domain_sid
,
761 const char *domain_name
,
762 struct cli_state
*cli
,
763 struct rpc_pipe_client
*pipe_hnd
,
768 struct policy_handle hSCM
, hService
;
769 WERROR result
= WERR_GEN_FAILURE
;
771 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
774 d_printf("%s net rpc service delete <service>\n", _("Usage:"));
779 ZERO_STRUCT(hService
);
781 /* Open the Service Control Manager */
782 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
783 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
785 if (!W_ERROR_IS_OK(result
)) {
786 return werror_to_ntstatus(result
);
789 /* Open the Service */
791 result
= open_service(b
, mem_ctx
, &hSCM
, argv
[0],
794 if (!W_ERROR_IS_OK(result
) ) {
798 /* Delete the Service */
800 status
= dcerpc_svcctl_DeleteService(b
, mem_ctx
,
804 if (!NT_STATUS_IS_OK(status
)) {
805 result
= ntstatus_to_werror(status
);
806 d_fprintf(stderr
, _("Delete service request failed. [%s]\n"),
810 if (!W_ERROR_IS_OK(result
)) {
811 d_fprintf(stderr
, _("Delete service request failed. [%s]\n"),
816 d_printf(_("Successfully deleted Service: %s\n"), argv
[0]);
819 if (is_valid_policy_hnd(&hService
)) {
821 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
823 if (is_valid_policy_hnd(&hSCM
)) {
825 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
828 return werror_to_ntstatus(result
);
831 /********************************************************************
832 ********************************************************************/
834 static NTSTATUS
rpc_service_create_internal(struct net_context
*c
,
835 const struct dom_sid
*domain_sid
,
836 const char *domain_name
,
837 struct cli_state
*cli
,
838 struct rpc_pipe_client
*pipe_hnd
,
843 struct policy_handle hSCM
, hService
;
844 WERROR result
= WERR_GEN_FAILURE
;
846 const char *ServiceName
;
847 const char *DisplayName
;
848 const char *binary_path
;
849 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
852 d_printf("%s net rpc service create <service> "
853 "<displayname> <binarypath>\n", _("Usage:"));
858 ZERO_STRUCT(hService
);
860 /* Open the Service Control Manager */
861 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
862 SC_RIGHT_MGR_CREATE_SERVICE
,
864 if (!W_ERROR_IS_OK(result
)) {
865 return werror_to_ntstatus(result
);
868 /* Create the service */
870 ServiceName
= argv
[0];
871 DisplayName
= argv
[1];
872 binary_path
= argv
[2];
874 status
= dcerpc_svcctl_CreateServiceW(b
, mem_ctx
,
879 SERVICE_TYPE_WIN32_OWN_PROCESS
,
881 SVCCTL_SVC_ERROR_NORMAL
,
883 NULL
, /* LoadOrderGroupKey */
885 NULL
, /* dependencies */
886 0, /* dependencies_size */
887 NULL
, /* service_start_name */
889 0, /* password_size */
892 if (!NT_STATUS_IS_OK(status
)) {
893 result
= ntstatus_to_werror(status
);
894 d_fprintf(stderr
, _("Create service request failed. [%s]\n"),
898 if (!W_ERROR_IS_OK(result
)) {
899 d_fprintf(stderr
, _("Create service request failed. [%s]\n"),
904 d_printf(_("Successfully created Service: %s\n"), argv
[0]);
907 if (is_valid_policy_hnd(&hService
)) {
909 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
911 if (is_valid_policy_hnd(&hSCM
)) {
913 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
916 return werror_to_ntstatus(result
);
919 /********************************************************************
920 ********************************************************************/
922 static int rpc_service_list(struct net_context
*c
, int argc
, const char **argv
)
924 if (c
->display_usage
) {
926 "net rpc service list\n"
929 _("View configured Win32 services"));
933 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
, 0,
934 rpc_service_list_internal
, argc
, argv
);
937 /********************************************************************
938 ********************************************************************/
940 static int rpc_service_start(struct net_context
*c
, int argc
, const char **argv
)
942 if (c
->display_usage
) {
944 "net rpc service start <service>\n"
947 _("Start a Win32 service"));
951 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
, 0,
952 rpc_service_start_internal
, argc
, argv
);
955 /********************************************************************
956 ********************************************************************/
958 static int rpc_service_stop(struct net_context
*c
, int argc
, const char **argv
)
960 if (c
->display_usage
) {
962 "net rpc service stop <service>\n"
965 _("Stop a Win32 service"));
969 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
, 0,
970 rpc_service_stop_internal
, argc
, argv
);
973 /********************************************************************
974 ********************************************************************/
976 static int rpc_service_resume(struct net_context
*c
, int argc
, const char **argv
)
978 if (c
->display_usage
) {
980 "net rpc service resume <service>\n"
983 _("Resume a Win32 service"));
987 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
, 0,
988 rpc_service_resume_internal
, argc
, argv
);
991 /********************************************************************
992 ********************************************************************/
994 static int rpc_service_pause(struct net_context
*c
, int argc
, const char **argv
)
996 if (c
->display_usage
) {
998 "net rpc service pause <service>\n"
1001 _("Pause a Win32 service"));
1005 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
, 0,
1006 rpc_service_pause_internal
, argc
, argv
);
1009 /********************************************************************
1010 ********************************************************************/
1012 static int rpc_service_status(struct net_context
*c
, int argc
, const char **argv
)
1014 if (c
->display_usage
) {
1016 "net rpc service status <service>\n"
1019 _("Show the current status of a service"));
1023 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
, 0,
1024 rpc_service_status_internal
, argc
, argv
);
1027 /********************************************************************
1028 ********************************************************************/
1030 static int rpc_service_delete(struct net_context
*c
, int argc
, const char **argv
)
1032 if (c
->display_usage
) {
1034 "net rpc service delete <service>\n"
1037 _("Delete a Win32 service"));
1041 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
, 0,
1042 rpc_service_delete_internal
, argc
, argv
);
1045 /********************************************************************
1046 ********************************************************************/
1048 static int rpc_service_create(struct net_context
*c
, int argc
, const char **argv
)
1050 if (c
->display_usage
) {
1052 "net rpc service create <service>\n"
1055 _("Create a Win32 service"));
1059 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
, 0,
1060 rpc_service_create_internal
, argc
, argv
);
1063 /********************************************************************
1064 ********************************************************************/
1066 int net_rpc_service(struct net_context
*c
, int argc
, const char **argv
)
1068 struct functable func
[] = {
1073 N_("View configured Win32 services"),
1074 N_("net rpc service list\n"
1075 " View configured Win32 services")
1081 N_("Start a service"),
1082 N_("net rpc service start\n"
1089 N_("Stop a service"),
1090 N_("net rpc service stop\n"
1097 N_("Pause a service"),
1098 N_("net rpc service pause\n"
1105 N_("Resume a paused service"),
1106 N_("net rpc service resume\n"
1107 " Resume a service")
1113 N_("View current status of a service"),
1114 N_("net rpc service status\n"
1115 " View current status of a service")
1121 N_("Delete a service"),
1122 N_("net rpc service delete\n"
1123 " Deletes a service")
1129 N_("Create a service"),
1130 N_("net rpc service create\n"
1131 " Creates a service")
1134 {NULL
, NULL
, 0, NULL
, NULL
}
1137 return net_run_function(c
, argc
, argv
, "net rpc service",func
);