2 Unix SMB/Netbios implementation.
4 NT Domain Authentication SMB / MSRPC client
5 Copyright (C) Andrew Tridgell 1994-1997
6 Copyright (C) Luke Kenneth Casson Leighton 1996-1997
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.
32 extern int DEBUGLEVEL;
36 extern struct cli_state *smb_cli;
41 /****************************************************************************
43 ****************************************************************************/
44 BOOL net_srv_get_info(struct client_info *info,
53 fstrcpy(dest_srv, "\\\\");
54 fstrcat(dest_srv, info->dest_host);
57 DEBUG(4,("net_srv_get_info: server:%s info level: %d\n",
58 dest_srv, (int)info_level));
60 /* open LSARPC session. */
61 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &fnum) : False;
63 /* send info level: receive requested info. hopefully. */
64 res = res ? do_srv_net_srv_get_info(smb_cli, fnum,
65 dest_srv, info_level, ctr) : False;
67 /* close the session */
68 cli_nt_session_close(smb_cli, fnum);
73 /****************************************************************************
75 ****************************************************************************/
76 void cmd_srv_query_info(struct client_info *info)
78 uint32 info_level = 101;
82 bzero(&ctr, sizeof(ctr));
84 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
86 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
89 DEBUG(5, ("cmd_srv_query_info: smb_cli->fd:%d\n", smb_cli->fd));
91 if (net_srv_get_info(info, info_level, &ctr))
93 DEBUG(5,("cmd_srv_query_info: query succeeded\n"));
95 display_srv_info_ctr(out_hnd, ACTION_HEADER , &ctr);
96 display_srv_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
97 display_srv_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
101 DEBUG(5,("cmd_srv_query_info: query failed\n"));
105 /****************************************************************************
106 server enum transports
107 ****************************************************************************/
108 BOOL msrpc_srv_enum_tprt(struct cli_state *cli,
109 const char* dest_srv,
111 SRV_TPRT_INFO_CTR *ctr,
120 /* open srvsvc session. */
121 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &fnum) : False;
123 /* enumerate transports on server */
124 res1 = res ? do_srv_net_srv_tprt_enum(smb_cli, fnum,
126 info_level, ctr, pref_sz, hnd) : False;
128 /* close the session */
129 cli_nt_session_close(smb_cli, fnum);
134 /****************************************************************************
135 server enum transports
136 ****************************************************************************/
137 void cmd_srv_enum_tprt(struct client_info *info)
141 SRV_TPRT_INFO_CTR ctr;
143 uint32 info_level = 0;
144 uint32 pref_sz = 0xffffffff;
146 bzero(&ctr, sizeof(ctr));
148 fstrcpy(dest_srv, "\\\\");
149 fstrcat(dest_srv, info->dest_host);
152 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
154 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
157 DEBUG(4,("cmd_srv_enum_tprt: server:%s info level: %d\n",
158 dest_srv, (int)info_level));
160 DEBUG(5, ("cmd_srv_enum_tprt: smb_cli->fd:%d\n", smb_cli->fd));
165 /* enumerate transports on server */
166 if (msrpc_srv_enum_tprt(smb_cli, dest_srv,
167 info_level, &ctr, pref_sz, &hnd))
169 display_srv_tprt_info_ctr(out_hnd, ACTION_HEADER , &ctr);
170 display_srv_tprt_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
171 display_srv_tprt_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
174 free_srv_tprt_ctr(&ctr);
177 /****************************************************************************
178 server enum connections
179 ****************************************************************************/
180 void cmd_srv_enum_conn(struct client_info *info)
186 SRV_CONN_INFO_CTR ctr;
188 uint32 info_level = 0;
192 bzero(&ctr, sizeof(ctr));
194 fstrcpy(qual_srv, "\\\\");
195 fstrcat(qual_srv, info->myhostname);
198 fstrcpy(dest_srv, "\\\\");
199 fstrcat(dest_srv, info->dest_host);
202 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
204 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
207 DEBUG(4,("cmd_srv_enum_conn: server:%s info level: %d\n",
208 dest_srv, (int)info_level));
210 DEBUG(5, ("cmd_srv_enum_conn: smb_cli->fd:%d\n", smb_cli->fd));
212 /* open srvsvc session. */
213 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &fnum) : False;
218 /* enumerate connections on server */
219 res = res ? do_srv_net_srv_conn_enum(smb_cli, fnum,
221 info_level, &ctr, 0xffffffff, &hnd) : False;
225 display_srv_conn_info_ctr(out_hnd, ACTION_HEADER , &ctr);
226 display_srv_conn_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
227 display_srv_conn_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
230 /* close the session */
231 cli_nt_session_close(smb_cli, fnum);
235 DEBUG(5,("cmd_srv_enum_conn: query succeeded\n"));
239 DEBUG(5,("cmd_srv_enum_conn: query failed\n"));
243 /****************************************************************************
245 ****************************************************************************/
246 void cmd_srv_enum_shares(struct client_info *info)
251 SRV_SHARE_INFO_CTR ctr;
253 uint32 info_level = 1;
257 bzero(&ctr, sizeof(ctr));
259 fstrcpy(dest_srv, "\\\\");
260 fstrcat(dest_srv, info->dest_host);
263 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
265 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
268 DEBUG(4,("cmd_srv_enum_shares: server:%s info level: %d\n",
269 dest_srv, (int)info_level));
271 DEBUG(5, ("cmd_srv_enum_shares: smb_cli->fd:%d\n", smb_cli->fd));
273 /* open srvsvc session. */
274 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &fnum) : False;
279 /* enumerate shares_files on server */
280 res = res ? do_srv_net_srv_share_enum(smb_cli, fnum,
282 info_level, &ctr, 0xffffffff, &hnd) : False;
286 display_srv_share_info_ctr(out_hnd, ACTION_HEADER , &ctr);
287 display_srv_share_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
288 display_srv_share_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
291 /* close the session */
292 cli_nt_session_close(smb_cli, fnum);
296 DEBUG(5,("cmd_srv_enum_shares: query succeeded\n"));
300 DEBUG(5,("cmd_srv_enum_shares: query failed\n"));
304 /****************************************************************************
306 ****************************************************************************/
307 void cmd_srv_enum_sess(struct client_info *info)
312 SRV_SESS_INFO_CTR ctr;
314 uint32 info_level = 0;
318 bzero(&ctr, sizeof(ctr));
320 fstrcpy(dest_srv, "\\\\");
321 fstrcat(dest_srv, info->dest_host);
324 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
326 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
329 DEBUG(4,("cmd_srv_enum_sess: server:%s info level: %d\n",
330 dest_srv, (int)info_level));
332 DEBUG(5, ("cmd_srv_enum_sess: smb_cli->fd:%d\n", smb_cli->fd));
334 /* open srvsvc session. */
335 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &fnum) : False;
340 /* enumerate sessions on server */
341 res = res ? do_srv_net_srv_sess_enum(smb_cli, fnum,
342 dest_srv, NULL, NULL, info_level, &ctr, 0x1000, &hnd) : False;
346 display_srv_sess_info_ctr(out_hnd, ACTION_HEADER , &ctr);
347 display_srv_sess_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
348 display_srv_sess_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
351 /* close the session */
352 cli_nt_session_close(smb_cli, fnum);
356 DEBUG(5,("cmd_srv_enum_sess: query succeeded\n"));
360 DEBUG(5,("cmd_srv_enum_sess: query failed\n"));
364 /****************************************************************************
366 ****************************************************************************/
367 void cmd_srv_enum_files(struct client_info *info)
372 SRV_FILE_INFO_CTR ctr;
374 uint32 info_level = 3;
378 bzero(&ctr, sizeof(ctr));
380 fstrcpy(dest_srv, "\\\\");
381 fstrcat(dest_srv, info->dest_host);
384 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
386 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
389 DEBUG(4,("cmd_srv_enum_files: server:%s info level: %d\n",
390 dest_srv, (int)info_level));
392 DEBUG(5, ("cmd_srv_enum_files: smb_cli->fd:%d\n", smb_cli->fd));
394 /* open srvsvc session. */
395 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &fnum) : False;
400 /* enumerate files on server */
401 res = res ? do_srv_net_srv_file_enum(smb_cli, fnum,
402 dest_srv, NULL, 0, info_level, &ctr, 0x1000, &hnd) : False;
406 display_srv_file_info_ctr(out_hnd, ACTION_HEADER , &ctr);
407 display_srv_file_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
408 display_srv_file_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
411 /* close the session */
412 cli_nt_session_close(smb_cli, fnum);
416 DEBUG(5,("cmd_srv_enum_files: query succeeded\n"));
420 DEBUG(5,("cmd_srv_enum_files: query failed\n"));
424 /****************************************************************************
426 ****************************************************************************/
427 void cmd_time(struct client_info *info)
431 TIME_OF_DAY_INFO tod;
434 fstrcpy(dest_srv, "\\\\");
435 fstrcat(dest_srv, info->dest_host);
438 DEBUG(4,("cmd_time: server:%s\n", dest_srv));
440 /* open srvsvc session. */
441 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &fnum) : False;
443 /* enumerate files on server */
444 res = res ? do_srv_net_remote_tod(smb_cli, fnum,
445 dest_srv, &tod) : False;
449 fprintf(out_hnd, "\tRemote Time:\t%s\n\n",
450 http_timestring(tod.elapsedt));
453 /* Close the session */
454 cli_nt_session_close(smb_cli, fnum);
458 DEBUG(5,("cmd_srv_enum_files: query succeeded\n"));
462 DEBUG(5,("cmd_srv_enum_files: query failed\n"));