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"
23 struct svc_state_msg
{
28 static struct svc_state_msg state_msg_table
[] = {
29 { SVCCTL_STOPPED
, N_("stopped") },
30 { SVCCTL_START_PENDING
, N_("start pending") },
31 { SVCCTL_STOP_PENDING
, N_("stop pending") },
32 { SVCCTL_RUNNING
, N_("running") },
33 { SVCCTL_CONTINUE_PENDING
, N_("resume pending") },
34 { SVCCTL_PAUSE_PENDING
, N_("pause pending") },
35 { SVCCTL_PAUSED
, N_("paused") },
40 /********************************************************************
41 ********************************************************************/
42 const char *svc_status_string( uint32 state
)
47 fstr_sprintf( msg
, _("Unknown State [%d]"), state
);
49 for ( i
=0; state_msg_table
[i
].message
; i
++ ) {
50 if ( state_msg_table
[i
].flag
== state
) {
51 fstrcpy( msg
, state_msg_table
[i
].message
);
56 return talloc_strdup(talloc_tos(), msg
);
59 /********************************************************************
60 ********************************************************************/
62 static WERROR
query_service_state(struct rpc_pipe_client
*pipe_hnd
,
64 struct policy_handle
*hSCM
,
68 struct policy_handle hService
;
69 struct SERVICE_STATUS service_status
;
70 WERROR result
= WERR_GENERAL_FAILURE
;
73 /* now cycle until the status is actually 'watch_state' */
75 status
= rpccli_svcctl_OpenServiceW(pipe_hnd
, mem_ctx
,
78 SC_RIGHT_SVC_QUERY_STATUS
,
81 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
) ) {
82 d_fprintf(stderr
, _("Failed to open service. [%s]\n"),
87 status
= rpccli_svcctl_QueryServiceStatus(pipe_hnd
, mem_ctx
,
92 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
) ) {
93 *state
= service_status
.state
;
96 rpccli_svcctl_CloseServiceHandle(pipe_hnd
, mem_ctx
, &hService
, NULL
);
101 /********************************************************************
102 ********************************************************************/
104 static WERROR
watch_service_state(struct rpc_pipe_client
*pipe_hnd
,
106 struct policy_handle
*hSCM
,
109 uint32
*final_state
)
113 WERROR result
= WERR_GENERAL_FAILURE
;
117 while ( (state
!= watch_state
) && i
<30 ) {
120 result
= query_service_state(pipe_hnd
, mem_ctx
, hSCM
, service
, &state
);
121 if ( !W_ERROR_IS_OK(result
) ) {
131 *final_state
= state
;
136 /********************************************************************
137 ********************************************************************/
139 static WERROR
control_service(struct rpc_pipe_client
*pipe_hnd
,
141 struct policy_handle
*hSCM
,
146 struct policy_handle hService
;
147 WERROR result
= WERR_GENERAL_FAILURE
;
149 struct SERVICE_STATUS service_status
;
152 /* Open the Service */
154 status
= rpccli_svcctl_OpenServiceW(pipe_hnd
, mem_ctx
,
157 (SC_RIGHT_SVC_STOP
|SC_RIGHT_SVC_PAUSE_CONTINUE
),
161 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
) ) {
162 d_fprintf(stderr
, _("Failed to open service. [%s]\n"),
169 status
= rpccli_svcctl_ControlService(pipe_hnd
, mem_ctx
,
175 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
) ) {
176 d_fprintf(stderr
, _("Control service request failed. [%s]\n"),
181 /* loop -- checking the state until we are where we want to be */
183 result
= watch_service_state(pipe_hnd
, mem_ctx
, hSCM
, service
, watch_state
, &state
);
185 d_printf(_("%s service is %s.\n"), service
, svc_status_string(state
));
188 rpccli_svcctl_CloseServiceHandle(pipe_hnd
, mem_ctx
, &hService
, NULL
);
193 /********************************************************************
194 ********************************************************************/
196 static NTSTATUS
rpc_service_list_internal(struct net_context
*c
,
197 const DOM_SID
*domain_sid
,
198 const char *domain_name
,
199 struct cli_state
*cli
,
200 struct rpc_pipe_client
*pipe_hnd
,
205 struct policy_handle hSCM
;
206 struct ENUM_SERVICE_STATUSW
*services
= NULL
;
207 WERROR result
= WERR_GENERAL_FAILURE
;
211 uint8_t *buffer
= NULL
;
212 uint32_t buf_size
= 0;
213 uint32_t bytes_needed
= 0;
214 uint32_t num_services
= 0;
215 uint32_t resume_handle
= 0;
218 d_printf(_("Usage: net rpc service list\n"));
222 status
= rpccli_svcctl_OpenSCManagerW(pipe_hnd
, mem_ctx
,
223 pipe_hnd
->srv_name_slash
,
225 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
228 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
)) {
230 _("Failed to open Service Control Manager. [%s]\n"),
232 return werror_to_ntstatus(result
);
236 status
= rpccli_svcctl_EnumServicesStatusW(pipe_hnd
, mem_ctx
,
247 if (NT_STATUS_IS_ERR(status
)) {
249 _("Failed to enumerate services. [%s]\n"),
254 if (W_ERROR_EQUAL(result
, WERR_MORE_DATA
) && bytes_needed
> 0) {
255 buffer
= talloc_array(mem_ctx
, uint8_t, bytes_needed
);
256 buf_size
= bytes_needed
;
260 if ( num_services
== 0 ) {
261 d_printf(_("No services returned\n"));
266 enum ndr_err_code ndr_err
;
268 struct ndr_pull
*ndr
;
270 blob
.length
= buf_size
;
271 blob
.data
= talloc_steal(mem_ctx
, buffer
);
273 services
= talloc_array(mem_ctx
, struct ENUM_SERVICE_STATUSW
, num_services
);
275 status
= NT_STATUS_NO_MEMORY
;
279 ndr
= ndr_pull_init_blob(&blob
, mem_ctx
, NULL
);
281 status
= NT_STATUS_NO_MEMORY
;
285 ndr_err
= ndr_pull_ENUM_SERVICE_STATUSW_array(
286 ndr
, num_services
, services
);
287 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
288 status
= ndr_map_error2ntstatus(ndr_err
);
292 for ( i
=0; i
<num_services
; i
++ ) {
293 d_printf("%-20s \"%s\"\n",
294 services
[i
].service_name
,
295 services
[i
].display_name
);
299 } while (W_ERROR_EQUAL(result
, WERR_MORE_DATA
));
301 rpccli_svcctl_CloseServiceHandle(pipe_hnd
, mem_ctx
, &hSCM
, NULL
);
306 /********************************************************************
307 ********************************************************************/
309 static NTSTATUS
rpc_service_status_internal(struct net_context
*c
,
310 const DOM_SID
*domain_sid
,
311 const char *domain_name
,
312 struct cli_state
*cli
,
313 struct rpc_pipe_client
*pipe_hnd
,
318 struct policy_handle hSCM
, hService
;
319 WERROR result
= WERR_GENERAL_FAILURE
;
321 struct SERVICE_STATUS service_status
;
322 struct QUERY_SERVICE_CONFIG config
;
323 uint32_t buf_size
= sizeof(config
);
324 uint32_t ret_size
= 0;
327 d_printf(_("Usage: net rpc service status <service>\n"));
331 /* Open the Service Control Manager */
332 status
= rpccli_svcctl_OpenSCManagerW(pipe_hnd
, mem_ctx
,
333 pipe_hnd
->srv_name_slash
,
335 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
338 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
)) {
340 _("Failed to open Service Control Manager. [%s]\n"),
342 return werror_to_ntstatus(result
);
345 /* Open the Service */
347 status
= rpccli_svcctl_OpenServiceW(pipe_hnd
, mem_ctx
,
350 (SC_RIGHT_SVC_QUERY_STATUS
|SC_RIGHT_SVC_QUERY_CONFIG
),
354 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
) ) {
355 d_fprintf(stderr
, _("Failed to open service. [%s]\n"),
362 status
= rpccli_svcctl_QueryServiceStatus(pipe_hnd
, mem_ctx
,
367 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
) ) {
368 d_fprintf(stderr
, _("Query status request failed. [%s]\n"),
373 d_printf(_("%s service is %s.\n"), argv
[0],
374 svc_status_string(service_status
.state
));
378 status
= rpccli_svcctl_QueryServiceConfigW(pipe_hnd
, mem_ctx
,
384 if (W_ERROR_EQUAL(result
, WERR_INSUFFICIENT_BUFFER
)) {
386 status
= rpccli_svcctl_QueryServiceConfigW(pipe_hnd
, mem_ctx
,
394 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
) ) {
395 d_fprintf(stderr
, _("Query config request failed. [%s]\n"),
400 /* print out the configuration information for the service */
402 d_printf(_("Configuration details:\n"));
403 d_printf(_("\tControls Accepted = 0x%x\n"),
404 service_status
.controls_accepted
);
405 d_printf(_("\tService Type = 0x%x\n"), config
.service_type
);
406 d_printf(_("\tStart Type = 0x%x\n"), config
.start_type
);
407 d_printf(_("\tError Control = 0x%x\n"), config
.error_control
);
408 d_printf(_("\tTag ID = 0x%x\n"), config
.tag_id
);
410 if (config
.executablepath
) {
411 d_printf(_("\tExecutable Path = %s\n"),
412 config
.executablepath
);
415 if (config
.loadordergroup
) {
416 d_printf(_("\tLoad Order Group = %s\n"),
417 config
.loadordergroup
);
420 if (config
.dependencies
) {
421 d_printf(_("\tDependencies = %s\n"),
422 config
.dependencies
);
425 if (config
.startname
) {
426 d_printf(_("\tStart Name = %s\n"), config
.startname
);
429 if (config
.displayname
) {
430 d_printf(_("\tDisplay Name = %s\n"),
435 rpccli_svcctl_CloseServiceHandle(pipe_hnd
, mem_ctx
, &hService
, NULL
);
436 rpccli_svcctl_CloseServiceHandle(pipe_hnd
, mem_ctx
, &hSCM
, NULL
);
438 return werror_to_ntstatus(result
);
441 /********************************************************************
442 ********************************************************************/
444 static NTSTATUS
rpc_service_stop_internal(struct net_context
*c
,
445 const DOM_SID
*domain_sid
,
446 const char *domain_name
,
447 struct cli_state
*cli
,
448 struct rpc_pipe_client
*pipe_hnd
,
453 struct policy_handle hSCM
;
454 WERROR result
= WERR_GENERAL_FAILURE
;
459 d_printf(_("Usage: net rpc service status <service>\n"));
463 fstrcpy( servicename
, argv
[0] );
465 /* Open the Service Control Manager */
466 status
= rpccli_svcctl_OpenSCManagerW(pipe_hnd
, mem_ctx
,
467 pipe_hnd
->srv_name_slash
,
469 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
472 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
)) {
474 _("Failed to open Service Control Manager. [%s]\n"),
476 return werror_to_ntstatus(result
);
479 result
= control_service(pipe_hnd
, mem_ctx
, &hSCM
, servicename
,
480 SVCCTL_CONTROL_STOP
, SVCCTL_STOPPED
);
482 rpccli_svcctl_CloseServiceHandle(pipe_hnd
, mem_ctx
, &hSCM
, NULL
);
484 return werror_to_ntstatus(result
);
487 /********************************************************************
488 ********************************************************************/
490 static NTSTATUS
rpc_service_pause_internal(struct net_context
*c
,
491 const DOM_SID
*domain_sid
,
492 const char *domain_name
,
493 struct cli_state
*cli
,
494 struct rpc_pipe_client
*pipe_hnd
,
499 struct policy_handle hSCM
;
500 WERROR result
= WERR_GENERAL_FAILURE
;
505 d_printf(_("Usage: net rpc service status <service>\n"));
509 fstrcpy( servicename
, argv
[0] );
511 /* Open the Service Control Manager */
512 status
= rpccli_svcctl_OpenSCManagerW(pipe_hnd
, mem_ctx
,
513 pipe_hnd
->srv_name_slash
,
515 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
518 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
)) {
520 _("Failed to open Service Control Manager. [%s]\n"),
522 return werror_to_ntstatus(result
);
525 result
= control_service(pipe_hnd
, mem_ctx
, &hSCM
, servicename
,
526 SVCCTL_CONTROL_PAUSE
, SVCCTL_PAUSED
);
528 rpccli_svcctl_CloseServiceHandle(pipe_hnd
, mem_ctx
, &hSCM
, NULL
);
530 return werror_to_ntstatus(result
);
533 /********************************************************************
534 ********************************************************************/
536 static NTSTATUS
rpc_service_resume_internal(struct net_context
*c
,
537 const DOM_SID
*domain_sid
,
538 const char *domain_name
,
539 struct cli_state
*cli
,
540 struct rpc_pipe_client
*pipe_hnd
,
545 struct policy_handle hSCM
;
546 WERROR result
= WERR_GENERAL_FAILURE
;
551 d_printf(_("Usage: net rpc service status <service>\n"));
555 fstrcpy( servicename
, argv
[0] );
557 /* Open the Service Control Manager */
558 status
= rpccli_svcctl_OpenSCManagerW(pipe_hnd
, mem_ctx
,
559 pipe_hnd
->srv_name_slash
,
561 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
564 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
)) {
566 _("Failed to open Service Control Manager. [%s]\n"),
568 return werror_to_ntstatus(result
);
571 result
= control_service(pipe_hnd
, mem_ctx
, &hSCM
, servicename
,
572 SVCCTL_CONTROL_CONTINUE
, SVCCTL_RUNNING
);
574 rpccli_svcctl_CloseServiceHandle(pipe_hnd
, mem_ctx
, &hSCM
, NULL
);
576 return werror_to_ntstatus(result
);
579 /********************************************************************
580 ********************************************************************/
582 static NTSTATUS
rpc_service_start_internal(struct net_context
*c
,
583 const DOM_SID
*domain_sid
,
584 const char *domain_name
,
585 struct cli_state
*cli
,
586 struct rpc_pipe_client
*pipe_hnd
,
591 struct policy_handle hSCM
, hService
;
592 WERROR result
= WERR_GENERAL_FAILURE
;
597 d_printf(_("Usage: net rpc service status <service>\n"));
601 /* Open the Service Control Manager */
602 status
= rpccli_svcctl_OpenSCManagerW(pipe_hnd
, mem_ctx
,
603 pipe_hnd
->srv_name_slash
,
605 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
608 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
)) {
610 _("Failed to open Service Control Manager. [%s]\n"),
612 return werror_to_ntstatus(result
);
615 /* Open the Service */
617 status
= rpccli_svcctl_OpenServiceW(pipe_hnd
, mem_ctx
,
624 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
) ) {
625 d_fprintf(stderr
, _("Failed to open service. [%s]\n"),
632 status
= rpccli_svcctl_StartServiceW(pipe_hnd
, mem_ctx
,
638 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
) ) {
639 d_fprintf(stderr
, _("Query status request failed. [%s]\n"),
644 result
= watch_service_state(pipe_hnd
, mem_ctx
, &hSCM
, argv
[0], SVCCTL_RUNNING
, &state
);
646 if ( W_ERROR_IS_OK(result
) && (state
== SVCCTL_RUNNING
) )
647 d_printf(_("Successfully started service: %s\n"),
650 d_fprintf(stderr
,_("Failed to start service: %s [%s]\n"),
651 argv
[0], win_errstr(result
) );
654 rpccli_svcctl_CloseServiceHandle(pipe_hnd
, mem_ctx
, &hService
, NULL
);
655 rpccli_svcctl_CloseServiceHandle(pipe_hnd
, mem_ctx
, &hSCM
, NULL
);
657 return werror_to_ntstatus(result
);
660 /********************************************************************
661 ********************************************************************/
663 static NTSTATUS
rpc_service_delete_internal(struct net_context
*c
,
664 const 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
;
677 d_printf(_("Usage: net rpc service delete <service>\n"));
681 /* Open the Service Control Manager */
682 status
= rpccli_svcctl_OpenSCManagerW(pipe_hnd
, mem_ctx
,
683 pipe_hnd
->srv_name_slash
,
685 SC_RIGHT_MGR_ENUMERATE_SERVICE
,
688 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
)) {
690 _("Failed to open Service Control Manager. [%s]\n"),
692 return werror_to_ntstatus(result
);
695 /* Open the Service */
697 status
= rpccli_svcctl_OpenServiceW(pipe_hnd
, mem_ctx
,
704 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
) ) {
705 d_fprintf(stderr
, _("Failed to open service. [%s]\n"),
710 /* Delete the Service */
712 status
= rpccli_svcctl_DeleteService(pipe_hnd
, mem_ctx
,
716 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
) ) {
717 d_fprintf(stderr
, _("Delete service request failed. [%s]\n"),
722 d_printf(_("Successfully deleted Service: %s\n"), argv
[0]);
725 if (is_valid_policy_hnd(&hService
)) {
726 rpccli_svcctl_CloseServiceHandle(pipe_hnd
, mem_ctx
, &hService
, NULL
);
728 if (is_valid_policy_hnd(&hSCM
)) {
729 rpccli_svcctl_CloseServiceHandle(pipe_hnd
, mem_ctx
, &hSCM
, NULL
);
732 return werror_to_ntstatus(result
);
735 /********************************************************************
736 ********************************************************************/
738 static NTSTATUS
rpc_service_create_internal(struct net_context
*c
,
739 const DOM_SID
*domain_sid
,
740 const char *domain_name
,
741 struct cli_state
*cli
,
742 struct rpc_pipe_client
*pipe_hnd
,
747 struct policy_handle hSCM
, hService
;
748 WERROR result
= WERR_GENERAL_FAILURE
;
750 const char *ServiceName
;
751 const char *DisplayName
;
752 const char *binary_path
;
755 d_printf(_("Usage: net rpc service create <service> "
756 "<displayname> <binarypath>\n"));
760 /* Open the Service Control Manager */
761 status
= rpccli_svcctl_OpenSCManagerW(pipe_hnd
, mem_ctx
,
762 pipe_hnd
->srv_name_slash
,
764 SC_RIGHT_MGR_CREATE_SERVICE
,
767 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
)) {
769 _("Failed to open Service Control Manager. [%s]\n"),
771 return werror_to_ntstatus(result
);
774 /* Create the service */
776 ServiceName
= argv
[0];
777 DisplayName
= argv
[1];
778 binary_path
= argv
[2];
780 status
= rpccli_svcctl_CreateServiceW(pipe_hnd
, mem_ctx
,
785 SERVICE_TYPE_WIN32_OWN_PROCESS
,
787 SVCCTL_SVC_ERROR_NORMAL
,
789 NULL
, /* LoadOrderGroupKey */
791 NULL
, /* dependencies */
792 0, /* dependencies_size */
793 NULL
, /* service_start_name */
795 0, /* password_size */
799 if (!NT_STATUS_IS_OK(status
) || !W_ERROR_IS_OK(result
) ) {
800 d_fprintf(stderr
, _("Create service request failed. [%s]\n"),
805 d_printf(_("Successfully created Service: %s\n"), argv
[0]);
808 if (is_valid_policy_hnd(&hService
)) {
809 rpccli_svcctl_CloseServiceHandle(pipe_hnd
, mem_ctx
, &hService
, NULL
);
811 if (is_valid_policy_hnd(&hSCM
)) {
812 rpccli_svcctl_CloseServiceHandle(pipe_hnd
, mem_ctx
, &hSCM
, NULL
);
815 return werror_to_ntstatus(result
);
818 /********************************************************************
819 ********************************************************************/
821 static int rpc_service_list(struct net_context
*c
, int argc
, const char **argv
)
823 if (c
->display_usage
) {
824 d_printf(_("Usage:\n"
825 "net rpc service list\n"
826 " View configured Win32 services\n"));
830 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
831 rpc_service_list_internal
, argc
, argv
);
834 /********************************************************************
835 ********************************************************************/
837 static int rpc_service_start(struct net_context
*c
, int argc
, const char **argv
)
839 if (c
->display_usage
) {
840 d_printf(_("Usage:\n"
841 "net rpc service start <service>\n"
842 " Start a Win32 service\n"));
846 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
847 rpc_service_start_internal
, argc
, argv
);
850 /********************************************************************
851 ********************************************************************/
853 static int rpc_service_stop(struct net_context
*c
, int argc
, const char **argv
)
855 if (c
->display_usage
) {
856 d_printf(_("Usage:\n"
857 "net rpc service stop <service>\n"
858 " Stop a Win32 service\n"));
862 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
863 rpc_service_stop_internal
, argc
, argv
);
866 /********************************************************************
867 ********************************************************************/
869 static int rpc_service_resume(struct net_context
*c
, int argc
, const char **argv
)
871 if (c
->display_usage
) {
872 d_printf(_("Usage:\n"
873 "net rpc service resume <service>\n"
874 " Resume a Win32 service\n"));
878 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
879 rpc_service_resume_internal
, argc
, argv
);
882 /********************************************************************
883 ********************************************************************/
885 static int rpc_service_pause(struct net_context
*c
, int argc
, const char **argv
)
887 if (c
->display_usage
) {
888 d_printf(_("Usage:\n"
889 "net rpc service pause <service>\n"
890 " Pause a Win32 service\n"));
894 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
895 rpc_service_pause_internal
, argc
, argv
);
898 /********************************************************************
899 ********************************************************************/
901 static int rpc_service_status(struct net_context
*c
, int argc
, const char **argv
)
903 if (c
->display_usage
) {
904 d_printf(_("Usage:\n"
905 "net rpc service status <service>\n"
906 " Show the current status of a service\n"));
910 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
911 rpc_service_status_internal
, argc
, argv
);
914 /********************************************************************
915 ********************************************************************/
917 static int rpc_service_delete(struct net_context
*c
, int argc
, const char **argv
)
919 if (c
->display_usage
) {
920 d_printf(_("Usage:\n"
921 "net rpc service delete <service>\n"
922 " Delete a Win32 service\n"));
926 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
927 rpc_service_delete_internal
, argc
, argv
);
930 /********************************************************************
931 ********************************************************************/
933 static int rpc_service_create(struct net_context
*c
, int argc
, const char **argv
)
935 if (c
->display_usage
) {
936 d_printf(_("Usage:\n"
937 "net rpc service create <service>\n"
938 " Create a Win32 service\n"));
942 return run_rpc_command(c
, NULL
, &ndr_table_svcctl
.syntax_id
, 0,
943 rpc_service_create_internal
, argc
, argv
);
946 /********************************************************************
947 ********************************************************************/
949 int net_rpc_service(struct net_context
*c
, int argc
, const char **argv
)
951 struct functable func
[] = {
956 N_("View configured Win32 services"),
957 N_("net rpc service list\n"
958 " View configured Win32 services")
964 N_("Start a service"),
965 N_("net rpc service start\n"
972 N_("Stop a service"),
973 N_("net rpc service stop\n"
980 N_("Pause a service"),
981 N_("net rpc service pause\n"
988 N_("Resume a paused service"),
989 N_("net rpc service resume\n"
996 N_("View current status of a service"),
997 N_("net rpc service status\n"
998 " View current status of a service")
1004 N_("Delete a service"),
1005 N_("net rpc service delete\n"
1006 " Deletes a service")
1012 N_("Create a service"),
1013 N_("net rpc service create\n"
1014 " Creates a service")
1017 {NULL
, NULL
, 0, NULL
, NULL
}
1020 return net_run_function(c
, argc
, argv
, "net rpc service",func
);