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 2 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, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 #include "utils/net.h"
23 /********************************************************************
24 ********************************************************************/
26 static NTSTATUS
rpc_service_list_internal( const DOM_SID
*domain_sid
, const char *domain_name
,
27 struct cli_state
*cli
, TALLOC_CTX
*mem_ctx
,
28 int argc
, const char **argv
)
31 ENUM_SERVICES_STATUS
*services
;
32 WERROR result
= WERR_GENERAL_FAILURE
;
35 uint32 num_services
= 0;
39 d_printf("Usage: net rpc service list\n");
43 result
= cli_svcctl_open_scm( cli
, mem_ctx
, &hSCM
, SC_RIGHT_MGR_ENUMERATE_SERVICE
);
44 if ( !W_ERROR_IS_OK(result
) ) {
45 d_printf("Failed to open Service Control Manager. [%s]\n", dos_errstr(result
));
46 return werror_to_ntstatus(result
);
49 result
= cli_svcctl_enumerate_services( cli
, mem_ctx
, &hSCM
, SVCCTL_TYPE_WIN32
,
50 SVCCTL_STATE_ALL
, &num_services
, &services
);
52 if ( !W_ERROR_IS_OK(result
) ) {
53 d_printf("Failed to enumerate services. [%s]\n", dos_errstr(result
));
57 if ( num_services
== 0 )
58 d_printf("No services returned\n");
60 for ( i
=0; i
<num_services
; i
++ ) {
61 rpcstr_pull( servicename
, services
[i
].servicename
.buffer
, sizeof(servicename
), -1, STR_TERMINATE
);
62 rpcstr_pull( displayname
, services
[i
].displayname
.buffer
, sizeof(displayname
), -1, STR_TERMINATE
);
64 d_printf("%-20s \"%s\"\n", servicename
, displayname
);
68 close_service_handle( cli
, mem_ctx
, &hSCM
);
70 return werror_to_ntstatus(result
);
74 /********************************************************************
75 ********************************************************************/
77 static int rpc_service_list( int argc
, const char **argv
)
79 return run_rpc_command( NULL
, PI_SVCCTL
, 0,
80 rpc_service_list_internal
, argc
, argv
);
83 /********************************************************************
84 ********************************************************************/
86 static int rpc_service_start( int argc
, const char **argv
)
88 d_printf("not implemented\n");
92 /********************************************************************
93 ********************************************************************/
95 static int rpc_service_stop( int argc
, const char **argv
)
97 d_printf("not implemented\n");
101 /********************************************************************
102 ********************************************************************/
104 static int rpc_service_pause( int argc
, const char **argv
)
106 d_printf("not implemented\n");
110 /********************************************************************
111 ********************************************************************/
113 static int rpc_service_status( int argc
, const char **argv
)
115 d_printf("not implemented\n");
119 /********************************************************************
120 ********************************************************************/
122 static int net_help_service( int argc
, const char **argv
)
124 d_printf("net rpc service list View configured Win32 services\n");
125 d_printf("net rpc service start <service> Start a service\n");
126 d_printf("net rpc service stop <service> Stop a service\n");
127 d_printf("net rpc service pause <service> Pause a service\n");
128 d_printf("net rpc service status <service> View the current status of a service\n");
133 /********************************************************************
134 ********************************************************************/
136 int net_rpc_service(int argc
, const char **argv
)
138 struct functable func
[] = {
139 {"list", rpc_service_list
},
140 {"start", rpc_service_start
},
141 {"stop", rpc_service_stop
},
142 {"pause", rpc_service_pause
},
143 {"status", rpc_service_status
},
148 return net_run_function( argc
, argv
, func
, net_help_service
);
150 return net_help_service( argc
, argv
);