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
open_scm(struct dcerpc_binding_handle
*b
,
99 const char *server_name
,
100 uint32_t access_mask
,
101 struct policy_handle
*hSCM
)
106 status
= dcerpc_svcctl_OpenSCManagerW(b
, mem_ctx
,
112 if (!NT_STATUS_IS_OK(status
)) {
113 result
= ntstatus_to_werror(status
);
115 _("Failed to open Service Control Manager. [%s]\n"),
119 if (!W_ERROR_IS_OK(result
)) {
121 _("Failed to open Service Control Manager. [%s]\n"),
129 /********************************************************************
130 ********************************************************************/
132 static WERROR
query_service_state(struct rpc_pipe_client
*pipe_hnd
,
134 struct policy_handle
*hSCM
,
138 struct policy_handle hService
;
139 struct SERVICE_STATUS service_status
;
140 WERROR result
= WERR_GENERAL_FAILURE
;
142 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
144 /* now cycle until the status is actually 'watch_state' */
146 result
= open_service(b
, mem_ctx
, hSCM
, service
,
147 SC_RIGHT_SVC_QUERY_STATUS
,
149 if (!W_ERROR_IS_OK(result
) ) {
153 status
= dcerpc_svcctl_QueryServiceStatus(b
, mem_ctx
,
157 if (!NT_STATUS_IS_OK(status
)) {
158 result
= ntstatus_to_werror(status
);
161 if (!W_ERROR_IS_OK(result
)) {
165 *state
= service_status
.state
;
168 if (is_valid_policy_hnd(&hService
)) {
170 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
176 /********************************************************************
177 ********************************************************************/
179 static WERROR
watch_service_state(struct rpc_pipe_client
*pipe_hnd
,
181 struct policy_handle
*hSCM
,
184 uint32
*final_state
)
188 WERROR result
= WERR_GENERAL_FAILURE
;
192 while ( (state
!= watch_state
) && i
<30 ) {
195 result
= query_service_state(pipe_hnd
, mem_ctx
, hSCM
, service
, &state
);
196 if ( !W_ERROR_IS_OK(result
) ) {
206 *final_state
= state
;
211 /********************************************************************
212 ********************************************************************/
214 static WERROR
control_service(struct rpc_pipe_client
*pipe_hnd
,
216 struct policy_handle
*hSCM
,
221 struct policy_handle hService
;
222 WERROR result
= WERR_GENERAL_FAILURE
;
224 struct SERVICE_STATUS service_status
;
226 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
228 /* Open the Service */
230 result
= open_service(b
, mem_ctx
, hSCM
, service
,
231 (SC_RIGHT_SVC_STOP
|SC_RIGHT_SVC_PAUSE_CONTINUE
),
233 if (!W_ERROR_IS_OK(result
) ) {
239 status
= dcerpc_svcctl_ControlService(b
, mem_ctx
,
245 if (!NT_STATUS_IS_OK(status
)) {
246 result
= ntstatus_to_werror(status
);
247 d_fprintf(stderr
, _("Control service request failed. [%s]\n"),
251 if (!W_ERROR_IS_OK(result
) ) {
252 d_fprintf(stderr
, _("Control service request failed. [%s]\n"),
257 /* loop -- checking the state until we are where we want to be */
259 result
= watch_service_state(pipe_hnd
, mem_ctx
, hSCM
, service
, watch_state
, &state
);
261 d_printf(_("%s service is %s.\n"), service
, svc_status_string(state
));
264 if (is_valid_policy_hnd(&hService
)) {
266 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
272 /********************************************************************
273 ********************************************************************/
275 static NTSTATUS
rpc_service_list_internal(struct net_context
*c
,
276 const struct dom_sid
*domain_sid
,
277 const char *domain_name
,
278 struct cli_state
*cli
,
279 struct rpc_pipe_client
*pipe_hnd
,
284 struct policy_handle hSCM
;
285 struct ENUM_SERVICE_STATUSW
*services
= NULL
;
286 WERROR result
= WERR_GENERAL_FAILURE
;
289 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
291 uint8_t *buffer
= NULL
;
292 uint32_t buf_size
= 0;
293 uint32_t bytes_needed
= 0;
294 uint32_t num_services
= 0;
295 uint32_t resume_handle
= 0;
298 d_printf("%s net rpc service list\n", _("Usage:"));
302 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
303 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
305 if (!W_ERROR_IS_OK(result
)) {
306 return werror_to_ntstatus(result
);
310 status
= dcerpc_svcctl_EnumServicesStatusW(b
, mem_ctx
,
321 if (!NT_STATUS_IS_OK(status
)) {
323 _("Failed to enumerate services. [%s]\n"),
328 if (W_ERROR_EQUAL(result
, WERR_MORE_DATA
) && bytes_needed
> 0) {
329 buffer
= talloc_array(mem_ctx
, uint8_t, bytes_needed
);
330 buf_size
= bytes_needed
;
334 if (!W_ERROR_IS_OK(result
)) {
335 status
= werror_to_ntstatus(result
);
337 _("Failed to enumerate services. [%s]\n"),
342 if ( num_services
== 0 ) {
343 d_printf(_("No services returned\n"));
348 enum ndr_err_code ndr_err
;
350 struct ndr_pull
*ndr
;
352 blob
.length
= buf_size
;
353 blob
.data
= talloc_steal(mem_ctx
, buffer
);
355 services
= talloc_array(mem_ctx
, struct ENUM_SERVICE_STATUSW
, num_services
);
357 status
= NT_STATUS_NO_MEMORY
;
361 ndr
= ndr_pull_init_blob(&blob
, mem_ctx
);
363 status
= NT_STATUS_NO_MEMORY
;
367 ndr_err
= ndr_pull_ENUM_SERVICE_STATUSW_array(
368 ndr
, num_services
, services
);
369 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
370 status
= ndr_map_error2ntstatus(ndr_err
);
374 for ( i
=0; i
<num_services
; i
++ ) {
375 d_printf("%-20s \"%s\"\n",
376 services
[i
].service_name
,
377 services
[i
].display_name
);
381 } while (W_ERROR_EQUAL(result
, WERR_MORE_DATA
));
383 if (is_valid_policy_hnd(&hSCM
)) {
385 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
391 /********************************************************************
392 ********************************************************************/
394 static NTSTATUS
rpc_service_status_internal(struct net_context
*c
,
395 const struct dom_sid
*domain_sid
,
396 const char *domain_name
,
397 struct cli_state
*cli
,
398 struct rpc_pipe_client
*pipe_hnd
,
403 struct policy_handle hSCM
, hService
;
404 WERROR result
= WERR_GENERAL_FAILURE
;
406 struct SERVICE_STATUS service_status
;
407 struct QUERY_SERVICE_CONFIG config
;
408 uint32_t buf_size
= sizeof(config
);
409 uint32_t ret_size
= 0;
410 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
413 d_printf("%s net rpc service status <service>\n", _("Usage:"));
417 /* Open the Service Control Manager */
418 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
419 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
421 if (!W_ERROR_IS_OK(result
)) {
422 return werror_to_ntstatus(result
);
425 /* Open the Service */
427 result
= open_service(b
, mem_ctx
, &hSCM
, argv
[0],
428 (SC_RIGHT_SVC_QUERY_STATUS
|SC_RIGHT_SVC_QUERY_CONFIG
),
430 if (!W_ERROR_IS_OK(result
) ) {
436 status
= dcerpc_svcctl_QueryServiceStatus(b
, mem_ctx
,
440 if (!NT_STATUS_IS_OK(status
)) {
441 result
= ntstatus_to_werror(status
);
442 d_fprintf(stderr
, _("Query status request failed. [%s]\n"),
447 if (!W_ERROR_IS_OK(result
) ) {
448 d_fprintf(stderr
, _("Query status request failed. [%s]\n"),
453 d_printf(_("%s service is %s.\n"), argv
[0],
454 svc_status_string(service_status
.state
));
458 status
= dcerpc_svcctl_QueryServiceConfigW(b
, mem_ctx
,
464 if (!NT_STATUS_IS_OK(status
)) {
465 result
= ntstatus_to_werror(status
);
466 d_fprintf(stderr
, _("Query config request failed. [%s]\n"),
471 if (W_ERROR_EQUAL(result
, WERR_INSUFFICIENT_BUFFER
)) {
473 status
= dcerpc_svcctl_QueryServiceConfigW(b
, mem_ctx
,
479 if (!NT_STATUS_IS_OK(status
)) {
480 result
= ntstatus_to_werror(status
);
481 d_fprintf(stderr
, _("Query config request failed. [%s]\n"),
487 if (!W_ERROR_IS_OK(result
) ) {
488 d_fprintf(stderr
, _("Query config request failed. [%s]\n"),
493 /* print out the configuration information for the service */
495 d_printf(_("Configuration details:\n"));
496 d_printf(_("\tControls Accepted = 0x%x\n"),
497 service_status
.controls_accepted
);
498 d_printf(_("\tService Type = 0x%x\n"), config
.service_type
);
499 d_printf(_("\tStart Type = 0x%x\n"), config
.start_type
);
500 d_printf(_("\tError Control = 0x%x\n"), config
.error_control
);
501 d_printf(_("\tTag ID = 0x%x\n"), config
.tag_id
);
503 if (config
.executablepath
) {
504 d_printf(_("\tExecutable Path = %s\n"),
505 config
.executablepath
);
508 if (config
.loadordergroup
) {
509 d_printf(_("\tLoad Order Group = %s\n"),
510 config
.loadordergroup
);
513 if (config
.dependencies
) {
514 d_printf(_("\tDependencies = %s\n"),
515 config
.dependencies
);
518 if (config
.startname
) {
519 d_printf(_("\tStart Name = %s\n"), config
.startname
);
522 if (config
.displayname
) {
523 d_printf(_("\tDisplay Name = %s\n"),
528 if (is_valid_policy_hnd(&hService
)) {
530 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
532 if (is_valid_policy_hnd(&hSCM
)) {
534 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
537 return werror_to_ntstatus(result
);
540 /********************************************************************
541 ********************************************************************/
543 static NTSTATUS
rpc_service_stop_internal(struct net_context
*c
,
544 const struct dom_sid
*domain_sid
,
545 const char *domain_name
,
546 struct cli_state
*cli
,
547 struct rpc_pipe_client
*pipe_hnd
,
552 struct policy_handle hSCM
;
553 WERROR result
= WERR_GENERAL_FAILURE
;
554 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
557 d_printf("%s net rpc service status <service>\n", _("Usage:"));
561 /* Open the Service Control Manager */
562 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
563 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
565 if (!W_ERROR_IS_OK(result
)) {
566 return werror_to_ntstatus(result
);
569 result
= control_service(pipe_hnd
, mem_ctx
, &hSCM
, argv
[0],
570 SVCCTL_CONTROL_STOP
, SVCCTL_STOPPED
);
572 if (is_valid_policy_hnd(&hSCM
)) {
574 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
577 return werror_to_ntstatus(result
);
580 /********************************************************************
581 ********************************************************************/
583 static NTSTATUS
rpc_service_pause_internal(struct net_context
*c
,
584 const struct dom_sid
*domain_sid
,
585 const char *domain_name
,
586 struct cli_state
*cli
,
587 struct rpc_pipe_client
*pipe_hnd
,
592 struct policy_handle hSCM
;
593 WERROR result
= WERR_GENERAL_FAILURE
;
594 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
597 d_printf("%s net rpc service status <service>\n", _("Usage:"));
601 /* Open the Service Control Manager */
602 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
603 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
605 if (!W_ERROR_IS_OK(result
)) {
606 return werror_to_ntstatus(result
);
609 result
= control_service(pipe_hnd
, mem_ctx
, &hSCM
, argv
[0],
610 SVCCTL_CONTROL_PAUSE
, SVCCTL_PAUSED
);
612 if (is_valid_policy_hnd(&hSCM
)) {
614 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
617 return werror_to_ntstatus(result
);
620 /********************************************************************
621 ********************************************************************/
623 static NTSTATUS
rpc_service_resume_internal(struct net_context
*c
,
624 const struct dom_sid
*domain_sid
,
625 const char *domain_name
,
626 struct cli_state
*cli
,
627 struct rpc_pipe_client
*pipe_hnd
,
632 struct policy_handle hSCM
;
633 WERROR result
= WERR_GENERAL_FAILURE
;
634 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
637 d_printf("%s net rpc service status <service>\n", _("Usage:"));
641 /* Open the Service Control Manager */
642 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
643 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
645 if (!W_ERROR_IS_OK(result
)) {
646 return werror_to_ntstatus(result
);
649 result
= control_service(pipe_hnd
, mem_ctx
, &hSCM
, argv
[0],
650 SVCCTL_CONTROL_CONTINUE
, SVCCTL_RUNNING
);
652 if (is_valid_policy_hnd(&hSCM
)) {
654 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
657 return werror_to_ntstatus(result
);
660 /********************************************************************
661 ********************************************************************/
663 static NTSTATUS
rpc_service_start_internal(struct net_context
*c
,
664 const struct dom_sid
*domain_sid
,
665 const char *domain_name
,
666 struct cli_state
*cli
,
667 struct rpc_pipe_client
*pipe_hnd
,
672 struct policy_handle hSCM
, hService
;
673 WERROR result
= WERR_GENERAL_FAILURE
;
676 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
679 d_printf("%s net rpc service status <service>\n", _("Usage:"));
683 /* Open the Service Control Manager */
684 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
685 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
687 if (!W_ERROR_IS_OK(result
)) {
688 return werror_to_ntstatus(result
);
692 /* Open the Service */
694 result
= open_service(b
, mem_ctx
, &hSCM
, argv
[0],
697 if (!W_ERROR_IS_OK(result
) ) {
703 status
= dcerpc_svcctl_StartServiceW(b
, mem_ctx
,
709 if (!NT_STATUS_IS_OK(status
)) {
710 result
= ntstatus_to_werror(status
);
711 d_fprintf(stderr
, _("Query status request failed. [%s]\n"),
715 if (!W_ERROR_IS_OK(result
) ) {
716 d_fprintf(stderr
, _("Query status request failed. [%s]\n"),
721 result
= watch_service_state(pipe_hnd
, mem_ctx
, &hSCM
, argv
[0], SVCCTL_RUNNING
, &state
);
723 if ( W_ERROR_IS_OK(result
) && (state
== SVCCTL_RUNNING
) )
724 d_printf(_("Successfully started service: %s\n"),
727 d_fprintf(stderr
,_("Failed to start service: %s [%s]\n"),
728 argv
[0], win_errstr(result
) );
731 if (is_valid_policy_hnd(&hService
)) {
733 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
735 if (is_valid_policy_hnd(&hSCM
)) {
737 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
740 return werror_to_ntstatus(result
);
743 /********************************************************************
744 ********************************************************************/
746 static NTSTATUS
rpc_service_delete_internal(struct net_context
*c
,
747 const struct dom_sid
*domain_sid
,
748 const char *domain_name
,
749 struct cli_state
*cli
,
750 struct rpc_pipe_client
*pipe_hnd
,
755 struct policy_handle hSCM
, hService
;
756 WERROR result
= WERR_GENERAL_FAILURE
;
758 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
761 d_printf("%s net rpc service delete <service>\n", _("Usage:"));
766 ZERO_STRUCT(hService
);
768 /* Open the Service Control Manager */
769 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
770 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
772 if (!W_ERROR_IS_OK(result
)) {
773 return werror_to_ntstatus(result
);
776 /* Open the Service */
778 result
= open_service(b
, mem_ctx
, &hSCM
, argv
[0],
781 if (!W_ERROR_IS_OK(result
) ) {
785 /* Delete the Service */
787 status
= dcerpc_svcctl_DeleteService(b
, mem_ctx
,
791 if (!NT_STATUS_IS_OK(status
)) {
792 result
= ntstatus_to_werror(status
);
793 d_fprintf(stderr
, _("Delete service request failed. [%s]\n"),
797 if (!W_ERROR_IS_OK(result
)) {
798 d_fprintf(stderr
, _("Delete service request failed. [%s]\n"),
803 d_printf(_("Successfully deleted Service: %s\n"), argv
[0]);
806 if (is_valid_policy_hnd(&hService
)) {
808 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
810 if (is_valid_policy_hnd(&hSCM
)) {
812 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
815 return werror_to_ntstatus(result
);
818 /********************************************************************
819 ********************************************************************/
821 static NTSTATUS
rpc_service_create_internal(struct net_context
*c
,
822 const struct dom_sid
*domain_sid
,
823 const char *domain_name
,
824 struct cli_state
*cli
,
825 struct rpc_pipe_client
*pipe_hnd
,
830 struct policy_handle hSCM
, hService
;
831 WERROR result
= WERR_GENERAL_FAILURE
;
833 const char *ServiceName
;
834 const char *DisplayName
;
835 const char *binary_path
;
836 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
839 d_printf("%s net rpc service create <service> "
840 "<displayname> <binarypath>\n", _("Usage:"));
845 ZERO_STRUCT(hService
);
847 /* Open the Service Control Manager */
848 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
849 SC_RIGHT_MGR_CREATE_SERVICE
,
851 if (!W_ERROR_IS_OK(result
)) {
852 return werror_to_ntstatus(result
);
855 /* Create the service */
857 ServiceName
= argv
[0];
858 DisplayName
= argv
[1];
859 binary_path
= argv
[2];
861 status
= dcerpc_svcctl_CreateServiceW(b
, mem_ctx
,
866 SERVICE_TYPE_WIN32_OWN_PROCESS
,
868 SVCCTL_SVC_ERROR_NORMAL
,
870 NULL
, /* LoadOrderGroupKey */
872 NULL
, /* dependencies */
873 0, /* dependencies_size */
874 NULL
, /* service_start_name */
876 0, /* password_size */
879 if (!NT_STATUS_IS_OK(status
)) {
880 result
= ntstatus_to_werror(status
);
881 d_fprintf(stderr
, _("Create service request failed. [%s]\n"),
885 if (!W_ERROR_IS_OK(result
)) {
886 d_fprintf(stderr
, _("Create service request failed. [%s]\n"),
891 d_printf(_("Successfully created Service: %s\n"), argv
[0]);
894 if (is_valid_policy_hnd(&hService
)) {
896 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
898 if (is_valid_policy_hnd(&hSCM
)) {
900 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
903 return werror_to_ntstatus(result
);
906 /********************************************************************
907 ********************************************************************/
909 static int rpc_service_list(struct net_context
*c
, int argc
, const char **argv
)
911 if (c
->display_usage
) {
913 "net rpc service list\n"
916 _("View configured Win32 services"));
920 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
921 rpc_service_list_internal
, argc
, argv
);
924 /********************************************************************
925 ********************************************************************/
927 static int rpc_service_start(struct net_context
*c
, int argc
, const char **argv
)
929 if (c
->display_usage
) {
931 "net rpc service start <service>\n"
934 _("Start a Win32 service"));
938 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
939 rpc_service_start_internal
, argc
, argv
);
942 /********************************************************************
943 ********************************************************************/
945 static int rpc_service_stop(struct net_context
*c
, int argc
, const char **argv
)
947 if (c
->display_usage
) {
949 "net rpc service stop <service>\n"
952 _("Stop a Win32 service"));
956 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
957 rpc_service_stop_internal
, argc
, argv
);
960 /********************************************************************
961 ********************************************************************/
963 static int rpc_service_resume(struct net_context
*c
, int argc
, const char **argv
)
965 if (c
->display_usage
) {
967 "net rpc service resume <service>\n"
970 _("Resume a Win32 service"));
974 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
975 rpc_service_resume_internal
, argc
, argv
);
978 /********************************************************************
979 ********************************************************************/
981 static int rpc_service_pause(struct net_context
*c
, int argc
, const char **argv
)
983 if (c
->display_usage
) {
985 "net rpc service pause <service>\n"
988 _("Pause a Win32 service"));
992 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
993 rpc_service_pause_internal
, argc
, argv
);
996 /********************************************************************
997 ********************************************************************/
999 static int rpc_service_status(struct net_context
*c
, int argc
, const char **argv
)
1001 if (c
->display_usage
) {
1003 "net rpc service status <service>\n"
1006 _("Show the current status of a service"));
1010 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
1011 rpc_service_status_internal
, argc
, argv
);
1014 /********************************************************************
1015 ********************************************************************/
1017 static int rpc_service_delete(struct net_context
*c
, int argc
, const char **argv
)
1019 if (c
->display_usage
) {
1021 "net rpc service delete <service>\n"
1024 _("Delete a Win32 service"));
1028 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
1029 rpc_service_delete_internal
, argc
, argv
);
1032 /********************************************************************
1033 ********************************************************************/
1035 static int rpc_service_create(struct net_context
*c
, int argc
, const char **argv
)
1037 if (c
->display_usage
) {
1039 "net rpc service create <service>\n"
1042 _("Create a Win32 service"));
1046 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
1047 rpc_service_create_internal
, argc
, argv
);
1050 /********************************************************************
1051 ********************************************************************/
1053 int net_rpc_service(struct net_context
*c
, int argc
, const char **argv
)
1055 struct functable func
[] = {
1060 N_("View configured Win32 services"),
1061 N_("net rpc service list\n"
1062 " View configured Win32 services")
1068 N_("Start a service"),
1069 N_("net rpc service start\n"
1076 N_("Stop a service"),
1077 N_("net rpc service stop\n"
1084 N_("Pause a service"),
1085 N_("net rpc service pause\n"
1092 N_("Resume a paused service"),
1093 N_("net rpc service resume\n"
1094 " Resume a service")
1100 N_("View current status of a service"),
1101 N_("net rpc service status\n"
1102 " View current status of a service")
1108 N_("Delete a service"),
1109 N_("net rpc service delete\n"
1110 " Deletes a service")
1116 N_("Create a service"),
1117 N_("net rpc service create\n"
1118 " Creates a service")
1121 {NULL
, NULL
, 0, NULL
, NULL
}
1124 return net_run_function(c
, argc
, argv
, "net rpc service",func
);