This commit was manufactured by cvs2svn to create tag
[Samba.git] / source / rpcclient / cmd_srvsvc.c
blob65065a782b1e46c47209243bea0625e8102f7fc0
1 /*
2 Unix SMB/Netbios implementation.
3 Version 1.9.
4 NT Domain Authentication SMB / MSRPC client
5 Copyright (C) Andrew Tridgell 1994-1999
6 Copyright (C) Luke Kenneth Casson Leighton 1996-1999
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #ifdef SYSLOG
26 #undef SYSLOG
27 #endif
29 #include "includes.h"
30 #include "rpc_parse.h"
31 #include "rpcclient.h"
33 extern int DEBUGLEVEL;
35 #define DEBUG_TESTING
37 extern FILE* out_hnd;
40 /****************************************************************************
41 server get info query
42 ****************************************************************************/
43 BOOL net_srv_get_info(struct client_info *info,
44 uint32 info_level,
45 SRV_INFO_CTR *ctr)
47 fstring dest_srv;
49 BOOL res = True;
51 fstrcpy(dest_srv, "\\\\");
52 fstrcat(dest_srv, info->dest_host);
53 strupper(dest_srv);
55 DEBUG(4,("net_srv_get_info: server:%s info level: %d\n",
56 dest_srv, (int)info_level));
58 /* send info level: receive requested info. hopefully. */
59 res = res ? srv_net_srv_get_info(dest_srv, info_level, ctr) : False;
61 return res;
64 /****************************************************************************
65 server get info query
66 ****************************************************************************/
67 void cmd_srv_query_info(struct client_info *info, int argc, char *argv[])
69 uint32 info_level = 101;
70 SRV_INFO_CTR ctr;
72 ZERO_STRUCT(ctr);
74 if (argc > 1)
76 info_level = (uint32)strtol(argv[1], (char**)NULL, 10);
79 if (net_srv_get_info(info, info_level, &ctr))
81 DEBUG(5,("cmd_srv_query_info: query succeeded\n"));
83 display_srv_info_ctr(out_hnd, ACTION_HEADER , &ctr);
84 display_srv_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
85 display_srv_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
87 else
89 DEBUG(5,("cmd_srv_query_info: query failed\n"));
93 /****************************************************************************
94 server enum transports
95 ****************************************************************************/
96 BOOL msrpc_srv_enum_tprt( const char* dest_srv,
97 uint32 info_level,
98 SRV_TPRT_INFO_CTR *ctr,
99 TPRT_INFO_FN(tprt_fn))
101 BOOL res = True;
102 BOOL res1 = True;
104 ENUM_HND hnd;
106 hnd.ptr_hnd = 1;
107 hnd.handle = 0;
109 /* enumerate transports on server */
110 res1 = res ? srv_net_srv_tprt_enum(dest_srv,
111 info_level, ctr, 0xffffffff, &hnd) : False;
113 tprt_fn(ctr);
115 free_srv_tprt_ctr(ctr);
117 return res1;
120 static void srv_display_tprt_ctr(const SRV_TPRT_INFO_CTR *ctr)
122 display_srv_tprt_info_ctr(out_hnd, ACTION_HEADER , ctr);
123 display_srv_tprt_info_ctr(out_hnd, ACTION_ENUMERATE, ctr);
124 display_srv_tprt_info_ctr(out_hnd, ACTION_FOOTER , ctr);
127 /****************************************************************************
128 server enum transports
129 ****************************************************************************/
130 void cmd_srv_enum_tprt(struct client_info *info, int argc, char *argv[])
132 fstring dest_srv;
133 SRV_TPRT_INFO_CTR ctr;
134 uint32 info_level = 0;
136 ZERO_STRUCT(ctr);
138 fstrcpy(dest_srv, "\\\\");
139 fstrcat(dest_srv, info->dest_host);
140 strupper(dest_srv);
142 if (argc > 1)
144 info_level = (uint32)strtol(argv[1], (char**)NULL, 10);
147 DEBUG(4,("cmd_srv_enum_tprt: server:%s info level: %d\n",
148 dest_srv, (int)info_level));
150 /* enumerate transports on server */
151 msrpc_srv_enum_tprt(dest_srv,
152 info_level, &ctr,
153 srv_display_tprt_ctr);
156 /****************************************************************************
157 server enum connections
158 ****************************************************************************/
159 void cmd_srv_enum_conn(struct client_info *info, int argc, char *argv[])
161 fstring dest_srv;
162 fstring qual_srv;
163 SRV_CONN_INFO_CTR ctr;
164 ENUM_HND hnd;
165 uint32 info_level = 0;
167 BOOL res = True;
169 ZERO_STRUCT(ctr);
171 fstrcpy(qual_srv, "\\\\");
172 fstrcat(qual_srv, info->myhostname);
173 strupper(qual_srv);
175 fstrcpy(dest_srv, "\\\\");
176 fstrcat(dest_srv, info->dest_host);
177 strupper(dest_srv);
179 if (argc > 1)
181 info_level = (uint32)strtol(argv[1], (char**)NULL, 10);
184 DEBUG(4,("cmd_srv_enum_conn: server:%s info level: %d\n",
185 dest_srv, (int)info_level));
187 hnd.ptr_hnd = 1;
188 hnd.handle = 0;
190 /* enumerate connections on server */
191 res = res ? srv_net_srv_conn_enum(dest_srv, qual_srv,
192 info_level, &ctr, 0xffffffff, &hnd) : False;
194 if (res)
196 display_srv_conn_info_ctr(out_hnd, ACTION_HEADER , &ctr);
197 display_srv_conn_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
198 display_srv_conn_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
201 if (res)
203 DEBUG(5,("cmd_srv_enum_conn: query succeeded\n"));
205 else
207 DEBUG(5,("cmd_srv_enum_conn: query failed\n"));
211 /****************************************************************************
212 server enum shares
213 ****************************************************************************/
214 void cmd_srv_enum_shares(struct client_info *info, int argc, char *argv[])
216 fstring dest_srv;
217 SRV_SHARE_INFO_CTR ctr;
218 ENUM_HND hnd;
219 uint32 info_level = 1;
221 BOOL res = True;
223 ZERO_STRUCT(ctr);
225 fstrcpy(dest_srv, "\\\\");
226 fstrcat(dest_srv, info->dest_host);
227 strupper(dest_srv);
229 if (argc > 1)
231 info_level = (uint32)strtol(argv[1], (char**)NULL, 10);
234 DEBUG(4,("cmd_srv_enum_shares: server:%s info level: %d\n",
235 dest_srv, (int)info_level));
237 hnd.ptr_hnd = 0;
238 hnd.handle = 0;
240 /* enumerate shares_files on server */
241 res = res ? srv_net_srv_share_enum(dest_srv,
242 info_level, &ctr, 0xffffffff, &hnd) : False;
244 if (res)
246 display_srv_share_info_ctr(out_hnd, ACTION_HEADER , &ctr);
247 display_srv_share_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
248 display_srv_share_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
251 srv_free_srv_share_ctr(&ctr);
253 if (res)
255 DEBUG(5,("cmd_srv_enum_shares: query succeeded\n"));
257 else
259 DEBUG(5,("cmd_srv_enum_shares: query failed\n"));
263 /****************************************************************************
264 server enum sessions
265 ****************************************************************************/
266 void cmd_srv_enum_sess(struct client_info *info, int argc, char *argv[])
268 fstring dest_srv;
269 SRV_SESS_INFO_CTR ctr;
270 ENUM_HND hnd;
271 uint32 info_level = 0;
273 BOOL res = True;
275 ZERO_STRUCT(ctr);
277 fstrcpy(dest_srv, "\\\\");
278 fstrcat(dest_srv, info->dest_host);
279 strupper(dest_srv);
281 if (argc > 1)
283 info_level = (uint32)strtol(argv[1], (char**)NULL, 10);
286 DEBUG(4,("cmd_srv_enum_sess: server:%s info level: %d\n",
287 dest_srv, (int)info_level));
289 hnd.ptr_hnd = 1;
290 hnd.handle = 0;
292 /* enumerate sessions on server */
293 res = res ? srv_net_srv_sess_enum(dest_srv, NULL, NULL,
294 info_level, &ctr, 0x1000, &hnd) : False;
296 if (res)
298 display_srv_sess_info_ctr(out_hnd, ACTION_HEADER , &ctr);
299 display_srv_sess_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
300 display_srv_sess_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
303 if (res)
305 DEBUG(5,("cmd_srv_enum_sess: query succeeded\n"));
307 else
309 DEBUG(5,("cmd_srv_enum_sess: query failed\n"));
313 /****************************************************************************
314 server enum files
315 ****************************************************************************/
316 void cmd_srv_enum_files(struct client_info *info, int argc, char *argv[])
318 fstring dest_srv;
319 SRV_FILE_INFO_CTR ctr;
320 ENUM_HND hnd;
321 uint32 info_level = 3;
323 BOOL res = True;
325 ZERO_STRUCT(ctr);
327 fstrcpy(dest_srv, "\\\\");
328 fstrcat(dest_srv, info->dest_host);
329 strupper(dest_srv);
331 if (argc > 1)
333 info_level = (uint32)strtol(argv[1], (char**)NULL, 10);
336 DEBUG(4,("cmd_srv_enum_files: server:%s info level: %d\n",
337 dest_srv, (int)info_level));
339 hnd.ptr_hnd = 1;
340 hnd.handle = 0;
342 /* enumerate files on server */
343 res = res ? srv_net_srv_file_enum(dest_srv, NULL, 0,
344 info_level, &ctr, 0x1000, &hnd) : False;
346 if (res)
348 display_srv_file_info_ctr(out_hnd, ACTION_HEADER , &ctr);
349 display_srv_file_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
350 display_srv_file_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
353 srv_free_srv_file_ctr(&ctr);
355 if (res)
357 DEBUG(5,("cmd_srv_enum_files: query succeeded\n"));
359 else
361 DEBUG(5,("cmd_srv_enum_files: query failed\n"));
365 /****************************************************************************
366 display remote time
367 ****************************************************************************/
368 void cmd_time(struct client_info *info, int argc, char *argv[])
370 fstring dest_srv;
371 TIME_OF_DAY_INFO tod;
372 BOOL res = True;
374 fstrcpy(dest_srv, "\\\\");
375 fstrcat(dest_srv, info->dest_host);
376 strupper(dest_srv);
378 DEBUG(4,("cmd_time: server:%s\n", dest_srv));
380 /* enumerate files on server */
381 res = res ? srv_net_remote_tod(dest_srv, &tod) : False;
383 if (res)
385 fprintf(out_hnd, "\tRemote Time:\t%s\n\n",
386 http_timestring(tod.elapsedt));
389 if (res)
391 DEBUG(5,("cmd_srv_enum_files: query succeeded\n"));
393 else
395 DEBUG(5,("cmd_srv_enum_files: query failed\n"));