r6039: add CLI_DO_RPC macro for cookie cutter code; no new functionality to 'net...
[bbaumbach/samba-autobuild/.git] / source3 / utils / net_rpc_service.c
1 /* 
2    Samba Unix/Linux SMB client library 
3    Distributed SMB/CIFS Server Management Utility 
4    Copyright (C) Gerald (Jerry) Carter          2005
5
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.
10    
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.
15    
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.  */
19  
20 #include "includes.h"
21 #include "utils/net.h"
22
23 /********************************************************************
24 ********************************************************************/
25
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 )
29 {
30         POLICY_HND hSCM;
31         WERROR result = WERR_GENERAL_FAILURE;
32         
33         if (argc != 0 ) {
34                 d_printf("Usage: net rpc service list\n");
35                 return NT_STATUS_OK;
36         }
37
38         if ( !W_ERROR_IS_OK(result = cli_svcctl_open_scm( cli, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE  )) ) {
39                 d_printf("Failed to open Service Control Manager.  [%s]\n", dos_errstr(result));
40                 return werror_to_ntstatus(result);
41         }
42         
43         d_printf("Successfully opened Service Control Manager.\n");
44         
45         
46         
47         close_service_handle( cli, mem_ctx, &hSCM  );
48                 
49         return NT_STATUS_OK;
50 }       
51
52
53 /********************************************************************
54 ********************************************************************/
55
56 static int rpc_service_list( int argc, const char **argv )
57 {
58         return run_rpc_command( NULL, PI_SVCCTL, 0, 
59                 rpc_service_list_internal, argc, argv );
60 }
61
62 /********************************************************************
63 ********************************************************************/
64
65 static int rpc_service_start( int argc, const char **argv )
66 {
67         d_printf("not implemented\n");
68         return 0;
69 }
70
71 /********************************************************************
72 ********************************************************************/
73
74 static int rpc_service_stop( int argc, const char **argv )
75 {
76         d_printf("not implemented\n");
77         return 0;
78 }
79
80 /********************************************************************
81 ********************************************************************/
82
83 static int rpc_service_pause( int argc, const char **argv )
84 {
85         d_printf("not implemented\n");
86         return 0;
87 }
88
89 /********************************************************************
90 ********************************************************************/
91
92 static int rpc_service_status( int argc, const char **argv )
93 {
94         d_printf("not implemented\n");
95         return 0;
96 }
97
98 /********************************************************************
99 ********************************************************************/
100
101 static int net_help_service( int argc, const char **argv )
102 {
103         d_printf("net rpc service list               View configured Win32 services\n");
104         d_printf("net rpc service start <service>    Start a service\n");
105         d_printf("net rpc service stop <service>     Stop a service\n");
106         d_printf("net rpc service pause <service>    Pause a service\n");
107         d_printf("net rpc service status <service>   View the current status of a service\n");
108         
109         return -1;
110 }
111
112 /********************************************************************
113 ********************************************************************/
114
115 int net_rpc_service(int argc, const char **argv) 
116 {
117         struct functable func[] = {
118                 {"list", rpc_service_list},
119                 {"start", rpc_service_start},
120                 {"stop", rpc_service_stop},
121                 {"pause", rpc_service_pause},
122                 {"status", rpc_service_status},
123                 {NULL, NULL}
124         };
125         
126         if ( argc )
127                 return net_run_function( argc, argv, func, net_help_service );
128                 
129         return net_help_service( argc, argv );
130 }
131
132