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 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_GENERAL_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
,
185 uint32
*final_state
)
189 WERROR result
= WERR_GENERAL_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
,
222 struct policy_handle hService
;
223 WERROR result
= WERR_GENERAL_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_GENERAL_FAILURE
;
290 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
292 uint8_t *buffer
= NULL
;
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
);
311 status
= dcerpc_svcctl_EnumServicesStatusW(b
, mem_ctx
,
322 if (!NT_STATUS_IS_OK(status
)) {
324 _("Failed to enumerate services. [%s]\n"),
329 if (W_ERROR_EQUAL(result
, WERR_MORE_DATA
) && bytes_needed
> 0) {
330 buffer
= talloc_array(mem_ctx
, uint8_t, bytes_needed
);
331 buf_size
= bytes_needed
;
335 if (!W_ERROR_IS_OK(result
)) {
336 status
= werror_to_ntstatus(result
);
338 _("Failed to enumerate services. [%s]\n"),
343 if ( num_services
== 0 ) {
344 d_printf(_("No services returned\n"));
349 enum ndr_err_code ndr_err
;
351 struct ndr_pull
*ndr
;
353 blob
.length
= buf_size
;
354 blob
.data
= talloc_steal(mem_ctx
, buffer
);
356 services
= talloc_array(mem_ctx
, struct ENUM_SERVICE_STATUSW
, num_services
);
358 status
= NT_STATUS_NO_MEMORY
;
362 ndr
= ndr_pull_init_blob(&blob
, mem_ctx
);
364 status
= NT_STATUS_NO_MEMORY
;
368 ndr_err
= ndr_pull_ENUM_SERVICE_STATUSW_array(
369 ndr
, num_services
, services
);
370 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
371 status
= ndr_map_error2ntstatus(ndr_err
);
375 for ( i
=0; i
<num_services
; i
++ ) {
376 d_printf("%-20s \"%s\"\n",
377 services
[i
].service_name
,
378 services
[i
].display_name
);
382 } while (W_ERROR_EQUAL(result
, WERR_MORE_DATA
));
384 if (is_valid_policy_hnd(&hSCM
)) {
386 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
392 /********************************************************************
393 ********************************************************************/
395 static NTSTATUS
rpc_service_status_internal(struct net_context
*c
,
396 const struct dom_sid
*domain_sid
,
397 const char *domain_name
,
398 struct cli_state
*cli
,
399 struct rpc_pipe_client
*pipe_hnd
,
404 struct policy_handle hSCM
, hService
;
405 WERROR result
= WERR_GENERAL_FAILURE
;
407 struct SERVICE_STATUS service_status
;
408 struct QUERY_SERVICE_CONFIG config
;
409 uint32_t buf_size
= sizeof(config
);
410 uint32_t ret_size
= 0;
411 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
414 d_printf("%s net rpc service status <service>\n", _("Usage:"));
418 /* Open the Service Control Manager */
419 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
420 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
422 if (!W_ERROR_IS_OK(result
)) {
423 return werror_to_ntstatus(result
);
426 /* Open the Service */
428 result
= open_service(b
, mem_ctx
, &hSCM
, argv
[0],
429 (SC_RIGHT_SVC_QUERY_STATUS
|SC_RIGHT_SVC_QUERY_CONFIG
),
431 if (!W_ERROR_IS_OK(result
) ) {
437 status
= dcerpc_svcctl_QueryServiceStatus(b
, mem_ctx
,
441 if (!NT_STATUS_IS_OK(status
)) {
442 result
= ntstatus_to_werror(status
);
443 d_fprintf(stderr
, _("Query status request failed. [%s]\n"),
448 if (!W_ERROR_IS_OK(result
) ) {
449 d_fprintf(stderr
, _("Query status request failed. [%s]\n"),
454 d_printf(_("%s service is %s.\n"), argv
[0],
455 svc_status_string(service_status
.state
));
459 status
= dcerpc_svcctl_QueryServiceConfigW(b
, mem_ctx
,
465 if (!NT_STATUS_IS_OK(status
)) {
466 result
= ntstatus_to_werror(status
);
467 d_fprintf(stderr
, _("Query config request failed. [%s]\n"),
472 if (W_ERROR_EQUAL(result
, WERR_INSUFFICIENT_BUFFER
)) {
474 status
= dcerpc_svcctl_QueryServiceConfigW(b
, mem_ctx
,
480 if (!NT_STATUS_IS_OK(status
)) {
481 result
= ntstatus_to_werror(status
);
482 d_fprintf(stderr
, _("Query config request failed. [%s]\n"),
488 if (!W_ERROR_IS_OK(result
) ) {
489 d_fprintf(stderr
, _("Query config request failed. [%s]\n"),
494 /* print out the configuration information for the service */
496 d_printf(_("Configuration details:\n"));
497 d_printf(_("\tControls Accepted = 0x%x\n"),
498 service_status
.controls_accepted
);
499 d_printf(_("\tService Type = 0x%x\n"), config
.service_type
);
500 d_printf(_("\tStart Type = 0x%x\n"), config
.start_type
);
501 d_printf(_("\tError Control = 0x%x\n"), config
.error_control
);
502 d_printf(_("\tTag ID = 0x%x\n"), config
.tag_id
);
504 if (config
.executablepath
) {
505 d_printf(_("\tExecutable Path = %s\n"),
506 config
.executablepath
);
509 if (config
.loadordergroup
) {
510 d_printf(_("\tLoad Order Group = %s\n"),
511 config
.loadordergroup
);
514 if (config
.dependencies
) {
515 d_printf(_("\tDependencies = %s\n"),
516 config
.dependencies
);
519 if (config
.startname
) {
520 d_printf(_("\tStart Name = %s\n"), config
.startname
);
523 if (config
.displayname
) {
524 d_printf(_("\tDisplay Name = %s\n"),
529 if (is_valid_policy_hnd(&hService
)) {
531 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
533 if (is_valid_policy_hnd(&hSCM
)) {
535 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
538 return werror_to_ntstatus(result
);
541 /********************************************************************
542 ********************************************************************/
544 static NTSTATUS
rpc_service_stop_internal(struct net_context
*c
,
545 const struct dom_sid
*domain_sid
,
546 const char *domain_name
,
547 struct cli_state
*cli
,
548 struct rpc_pipe_client
*pipe_hnd
,
553 struct policy_handle hSCM
;
554 WERROR result
= WERR_GENERAL_FAILURE
;
555 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
558 d_printf("%s net rpc service status <service>\n", _("Usage:"));
562 /* Open the Service Control Manager */
563 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
564 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
566 if (!W_ERROR_IS_OK(result
)) {
567 return werror_to_ntstatus(result
);
570 result
= control_service(pipe_hnd
, mem_ctx
, &hSCM
, argv
[0],
571 SVCCTL_CONTROL_STOP
, SVCCTL_STOPPED
);
573 if (is_valid_policy_hnd(&hSCM
)) {
575 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
578 return werror_to_ntstatus(result
);
581 /********************************************************************
582 ********************************************************************/
584 static NTSTATUS
rpc_service_pause_internal(struct net_context
*c
,
585 const struct dom_sid
*domain_sid
,
586 const char *domain_name
,
587 struct cli_state
*cli
,
588 struct rpc_pipe_client
*pipe_hnd
,
593 struct policy_handle hSCM
;
594 WERROR result
= WERR_GENERAL_FAILURE
;
595 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
598 d_printf("%s net rpc service status <service>\n", _("Usage:"));
602 /* Open the Service Control Manager */
603 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
604 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
606 if (!W_ERROR_IS_OK(result
)) {
607 return werror_to_ntstatus(result
);
610 result
= control_service(pipe_hnd
, mem_ctx
, &hSCM
, argv
[0],
611 SVCCTL_CONTROL_PAUSE
, SVCCTL_PAUSED
);
613 if (is_valid_policy_hnd(&hSCM
)) {
615 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
618 return werror_to_ntstatus(result
);
621 /********************************************************************
622 ********************************************************************/
624 static NTSTATUS
rpc_service_resume_internal(struct net_context
*c
,
625 const struct dom_sid
*domain_sid
,
626 const char *domain_name
,
627 struct cli_state
*cli
,
628 struct rpc_pipe_client
*pipe_hnd
,
633 struct policy_handle hSCM
;
634 WERROR result
= WERR_GENERAL_FAILURE
;
635 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
638 d_printf("%s net rpc service status <service>\n", _("Usage:"));
642 /* Open the Service Control Manager */
643 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
644 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
646 if (!W_ERROR_IS_OK(result
)) {
647 return werror_to_ntstatus(result
);
650 result
= control_service(pipe_hnd
, mem_ctx
, &hSCM
, argv
[0],
651 SVCCTL_CONTROL_CONTINUE
, SVCCTL_RUNNING
);
653 if (is_valid_policy_hnd(&hSCM
)) {
655 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
658 return werror_to_ntstatus(result
);
661 /********************************************************************
662 ********************************************************************/
664 static NTSTATUS
rpc_service_start_internal(struct net_context
*c
,
665 const struct dom_sid
*domain_sid
,
666 const char *domain_name
,
667 struct cli_state
*cli
,
668 struct rpc_pipe_client
*pipe_hnd
,
673 struct policy_handle hSCM
, hService
;
674 WERROR result
= WERR_GENERAL_FAILURE
;
677 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
680 d_printf("%s net rpc service status <service>\n", _("Usage:"));
684 /* Open the Service Control Manager */
685 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
686 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
688 if (!W_ERROR_IS_OK(result
)) {
689 return werror_to_ntstatus(result
);
693 /* Open the Service */
695 result
= open_service(b
, mem_ctx
, &hSCM
, argv
[0],
698 if (!W_ERROR_IS_OK(result
) ) {
704 status
= dcerpc_svcctl_StartServiceW(b
, mem_ctx
,
710 if (!NT_STATUS_IS_OK(status
)) {
711 result
= ntstatus_to_werror(status
);
712 d_fprintf(stderr
, _("Query status request failed. [%s]\n"),
716 if (!W_ERROR_IS_OK(result
) ) {
717 d_fprintf(stderr
, _("Query status request failed. [%s]\n"),
722 result
= watch_service_state(pipe_hnd
, mem_ctx
, &hSCM
, argv
[0], SVCCTL_RUNNING
, &state
);
724 if ( W_ERROR_IS_OK(result
) && (state
== SVCCTL_RUNNING
) )
725 d_printf(_("Successfully started service: %s\n"),
728 d_fprintf(stderr
,_("Failed to start service: %s [%s]\n"),
729 argv
[0], win_errstr(result
) );
732 if (is_valid_policy_hnd(&hService
)) {
734 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
736 if (is_valid_policy_hnd(&hSCM
)) {
738 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
741 return werror_to_ntstatus(result
);
744 /********************************************************************
745 ********************************************************************/
747 static NTSTATUS
rpc_service_delete_internal(struct net_context
*c
,
748 const struct dom_sid
*domain_sid
,
749 const char *domain_name
,
750 struct cli_state
*cli
,
751 struct rpc_pipe_client
*pipe_hnd
,
756 struct policy_handle hSCM
, hService
;
757 WERROR result
= WERR_GENERAL_FAILURE
;
759 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
762 d_printf("%s net rpc service delete <service>\n", _("Usage:"));
767 ZERO_STRUCT(hService
);
769 /* Open the Service Control Manager */
770 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
771 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
773 if (!W_ERROR_IS_OK(result
)) {
774 return werror_to_ntstatus(result
);
777 /* Open the Service */
779 result
= open_service(b
, mem_ctx
, &hSCM
, argv
[0],
782 if (!W_ERROR_IS_OK(result
) ) {
786 /* Delete the Service */
788 status
= dcerpc_svcctl_DeleteService(b
, mem_ctx
,
792 if (!NT_STATUS_IS_OK(status
)) {
793 result
= ntstatus_to_werror(status
);
794 d_fprintf(stderr
, _("Delete service request failed. [%s]\n"),
798 if (!W_ERROR_IS_OK(result
)) {
799 d_fprintf(stderr
, _("Delete service request failed. [%s]\n"),
804 d_printf(_("Successfully deleted Service: %s\n"), argv
[0]);
807 if (is_valid_policy_hnd(&hService
)) {
809 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
811 if (is_valid_policy_hnd(&hSCM
)) {
813 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
816 return werror_to_ntstatus(result
);
819 /********************************************************************
820 ********************************************************************/
822 static NTSTATUS
rpc_service_create_internal(struct net_context
*c
,
823 const struct dom_sid
*domain_sid
,
824 const char *domain_name
,
825 struct cli_state
*cli
,
826 struct rpc_pipe_client
*pipe_hnd
,
831 struct policy_handle hSCM
, hService
;
832 WERROR result
= WERR_GENERAL_FAILURE
;
834 const char *ServiceName
;
835 const char *DisplayName
;
836 const char *binary_path
;
837 struct dcerpc_binding_handle
*b
= pipe_hnd
->binding_handle
;
840 d_printf("%s net rpc service create <service> "
841 "<displayname> <binarypath>\n", _("Usage:"));
846 ZERO_STRUCT(hService
);
848 /* Open the Service Control Manager */
849 result
= open_scm(b
, mem_ctx
, pipe_hnd
->srv_name_slash
,
850 SC_RIGHT_MGR_CREATE_SERVICE
,
852 if (!W_ERROR_IS_OK(result
)) {
853 return werror_to_ntstatus(result
);
856 /* Create the service */
858 ServiceName
= argv
[0];
859 DisplayName
= argv
[1];
860 binary_path
= argv
[2];
862 status
= dcerpc_svcctl_CreateServiceW(b
, mem_ctx
,
867 SERVICE_TYPE_WIN32_OWN_PROCESS
,
869 SVCCTL_SVC_ERROR_NORMAL
,
871 NULL
, /* LoadOrderGroupKey */
873 NULL
, /* dependencies */
874 0, /* dependencies_size */
875 NULL
, /* service_start_name */
877 0, /* password_size */
880 if (!NT_STATUS_IS_OK(status
)) {
881 result
= ntstatus_to_werror(status
);
882 d_fprintf(stderr
, _("Create service request failed. [%s]\n"),
886 if (!W_ERROR_IS_OK(result
)) {
887 d_fprintf(stderr
, _("Create service request failed. [%s]\n"),
892 d_printf(_("Successfully created Service: %s\n"), argv
[0]);
895 if (is_valid_policy_hnd(&hService
)) {
897 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hService
, &_result
);
899 if (is_valid_policy_hnd(&hSCM
)) {
901 dcerpc_svcctl_CloseServiceHandle(b
, mem_ctx
, &hSCM
, &_result
);
904 return werror_to_ntstatus(result
);
907 /********************************************************************
908 ********************************************************************/
910 static int rpc_service_list(struct net_context
*c
, int argc
, const char **argv
)
912 if (c
->display_usage
) {
914 "net rpc service list\n"
917 _("View configured Win32 services"));
921 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
922 rpc_service_list_internal
, argc
, argv
);
925 /********************************************************************
926 ********************************************************************/
928 static int rpc_service_start(struct net_context
*c
, int argc
, const char **argv
)
930 if (c
->display_usage
) {
932 "net rpc service start <service>\n"
935 _("Start a Win32 service"));
939 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
940 rpc_service_start_internal
, argc
, argv
);
943 /********************************************************************
944 ********************************************************************/
946 static int rpc_service_stop(struct net_context
*c
, int argc
, const char **argv
)
948 if (c
->display_usage
) {
950 "net rpc service stop <service>\n"
953 _("Stop a Win32 service"));
957 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
958 rpc_service_stop_internal
, argc
, argv
);
961 /********************************************************************
962 ********************************************************************/
964 static int rpc_service_resume(struct net_context
*c
, int argc
, const char **argv
)
966 if (c
->display_usage
) {
968 "net rpc service resume <service>\n"
971 _("Resume a Win32 service"));
975 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
976 rpc_service_resume_internal
, argc
, argv
);
979 /********************************************************************
980 ********************************************************************/
982 static int rpc_service_pause(struct net_context
*c
, int argc
, const char **argv
)
984 if (c
->display_usage
) {
986 "net rpc service pause <service>\n"
989 _("Pause a Win32 service"));
993 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
994 rpc_service_pause_internal
, argc
, argv
);
997 /********************************************************************
998 ********************************************************************/
1000 static int rpc_service_status(struct net_context
*c
, int argc
, const char **argv
)
1002 if (c
->display_usage
) {
1004 "net rpc service status <service>\n"
1007 _("Show the current status of a service"));
1011 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
1012 rpc_service_status_internal
, argc
, argv
);
1015 /********************************************************************
1016 ********************************************************************/
1018 static int rpc_service_delete(struct net_context
*c
, int argc
, const char **argv
)
1020 if (c
->display_usage
) {
1022 "net rpc service delete <service>\n"
1025 _("Delete a Win32 service"));
1029 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
1030 rpc_service_delete_internal
, argc
, argv
);
1033 /********************************************************************
1034 ********************************************************************/
1036 static int rpc_service_create(struct net_context
*c
, int argc
, const char **argv
)
1038 if (c
->display_usage
) {
1040 "net rpc service create <service>\n"
1043 _("Create a Win32 service"));
1047 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
1048 rpc_service_create_internal
, argc
, argv
);
1051 /********************************************************************
1052 ********************************************************************/
1054 int net_rpc_service(struct net_context
*c
, int argc
, const char **argv
)
1056 struct functable func
[] = {
1061 N_("View configured Win32 services"),
1062 N_("net rpc service list\n"
1063 " View configured Win32 services")
1069 N_("Start a service"),
1070 N_("net rpc service start\n"
1077 N_("Stop a service"),
1078 N_("net rpc service stop\n"
1085 N_("Pause a service"),
1086 N_("net rpc service pause\n"
1093 N_("Resume a paused service"),
1094 N_("net rpc service resume\n"
1095 " Resume a service")
1101 N_("View current status of a service"),
1102 N_("net rpc service status\n"
1103 " View current status of a service")
1109 N_("Delete a service"),
1110 N_("net rpc service delete\n"
1111 " Deletes a service")
1117 N_("Create a service"),
1118 N_("net rpc service create\n"
1119 " Creates a service")
1122 {NULL
, NULL
, 0, NULL
, NULL
}
1125 return net_run_function(c
, argc
, argv
, "net rpc service",func
);