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, &nt_pipe_fnum) : False;
63 /* send info level: receive requested info. hopefully. */
64 res = res ? do_srv_net_srv_get_info(smb_cli, nt_pipe_fnum,
65 dest_srv, info_level, ctr) : False;
67 /* close the session */
68 cli_nt_session_close(smb_cli, nt_pipe_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 void cmd_srv_enum_tprt(struct client_info *info)
113 SRV_TPRT_INFO_CTR ctr;
115 uint32 info_level = 0;
119 bzero(&ctr, sizeof(ctr));
121 fstrcpy(dest_srv, "\\\\");
122 fstrcat(dest_srv, info->dest_host);
125 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
127 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
130 DEBUG(4,("cmd_srv_enum_tprt: server:%s info level: %d\n",
131 dest_srv, (int)info_level));
133 DEBUG(5, ("cmd_srv_enum_tprt: smb_cli->fd:%d\n", smb_cli->fd));
135 /* open srvsvc session. */
136 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
141 /* enumerate transports on server */
142 res = res ? do_srv_net_srv_tprt_enum(smb_cli, nt_pipe_fnum,
144 info_level, &ctr, 0xffffffff, &hnd) : False;
148 display_srv_tprt_info_ctr(out_hnd, ACTION_HEADER , &ctr);
149 display_srv_tprt_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
150 display_srv_tprt_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
153 /* close the session */
154 cli_nt_session_close(smb_cli, nt_pipe_fnum);
158 DEBUG(5,("cmd_srv_enum_tprt: query succeeded\n"));
162 DEBUG(5,("cmd_srv_enum_tprt: query failed\n"));
166 /****************************************************************************
167 server enum connections
168 ****************************************************************************/
169 void cmd_srv_enum_conn(struct client_info *info)
175 SRV_CONN_INFO_CTR ctr;
177 uint32 info_level = 0;
181 bzero(&ctr, sizeof(ctr));
183 fstrcpy(qual_srv, "\\\\");
184 fstrcat(qual_srv, info->myhostname);
187 fstrcpy(dest_srv, "\\\\");
188 fstrcat(dest_srv, info->dest_host);
191 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
193 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
196 DEBUG(4,("cmd_srv_enum_conn: server:%s info level: %d\n",
197 dest_srv, (int)info_level));
199 DEBUG(5, ("cmd_srv_enum_conn: smb_cli->fd:%d\n", smb_cli->fd));
201 /* open srvsvc session. */
202 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
207 /* enumerate connections on server */
208 res = res ? do_srv_net_srv_conn_enum(smb_cli, nt_pipe_fnum,
210 info_level, &ctr, 0xffffffff, &hnd) : False;
214 display_srv_conn_info_ctr(out_hnd, ACTION_HEADER , &ctr);
215 display_srv_conn_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
216 display_srv_conn_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
219 /* close the session */
220 cli_nt_session_close(smb_cli, nt_pipe_fnum);
224 DEBUG(5,("cmd_srv_enum_conn: query succeeded\n"));
228 DEBUG(5,("cmd_srv_enum_conn: query failed\n"));
232 /****************************************************************************
234 ****************************************************************************/
235 void cmd_srv_enum_shares(struct client_info *info)
240 SRV_SHARE_INFO_CTR ctr;
242 uint32 info_level = 1;
246 bzero(&ctr, sizeof(ctr));
248 fstrcpy(dest_srv, "\\\\");
249 fstrcat(dest_srv, info->dest_host);
252 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
254 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
257 DEBUG(4,("cmd_srv_enum_shares: server:%s info level: %d\n",
258 dest_srv, (int)info_level));
260 DEBUG(5, ("cmd_srv_enum_shares: smb_cli->fd:%d\n", smb_cli->fd));
262 /* open srvsvc session. */
263 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
268 /* enumerate shares_files on server */
269 res = res ? do_srv_net_srv_share_enum(smb_cli, nt_pipe_fnum,
271 info_level, &ctr, 0xffffffff, &hnd) : False;
275 display_srv_share_info_ctr(out_hnd, ACTION_HEADER , &ctr);
276 display_srv_share_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
277 display_srv_share_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
280 /* close the session */
281 cli_nt_session_close(smb_cli, nt_pipe_fnum);
285 DEBUG(5,("cmd_srv_enum_shares: query succeeded\n"));
289 DEBUG(5,("cmd_srv_enum_shares: query failed\n"));
293 /****************************************************************************
295 ****************************************************************************/
296 void cmd_srv_enum_sess(struct client_info *info)
301 SRV_SESS_INFO_CTR ctr;
303 uint32 info_level = 0;
307 bzero(&ctr, sizeof(ctr));
309 fstrcpy(dest_srv, "\\\\");
310 fstrcat(dest_srv, info->dest_host);
313 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
315 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
318 DEBUG(4,("cmd_srv_enum_sess: server:%s info level: %d\n",
319 dest_srv, (int)info_level));
321 DEBUG(5, ("cmd_srv_enum_sess: smb_cli->fd:%d\n", smb_cli->fd));
323 /* open srvsvc session. */
324 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
329 /* enumerate sessions on server */
330 res = res ? do_srv_net_srv_sess_enum(smb_cli, nt_pipe_fnum,
331 dest_srv, NULL, NULL, info_level, &ctr, 0x1000, &hnd) : False;
335 display_srv_sess_info_ctr(out_hnd, ACTION_HEADER , &ctr);
336 display_srv_sess_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
337 display_srv_sess_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
340 /* close the session */
341 cli_nt_session_close(smb_cli, nt_pipe_fnum);
345 DEBUG(5,("cmd_srv_enum_sess: query succeeded\n"));
349 DEBUG(5,("cmd_srv_enum_sess: query failed\n"));
353 /****************************************************************************
355 ****************************************************************************/
356 void cmd_srv_enum_files(struct client_info *info)
361 SRV_FILE_INFO_CTR ctr;
363 uint32 info_level = 3;
367 bzero(&ctr, sizeof(ctr));
369 fstrcpy(dest_srv, "\\\\");
370 fstrcat(dest_srv, info->dest_host);
373 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
375 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
378 DEBUG(4,("cmd_srv_enum_files: server:%s info level: %d\n",
379 dest_srv, (int)info_level));
381 DEBUG(5, ("cmd_srv_enum_files: smb_cli->fd:%d\n", smb_cli->fd));
383 /* open srvsvc session. */
384 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
389 /* enumerate files on server */
390 res = res ? do_srv_net_srv_file_enum(smb_cli, nt_pipe_fnum,
391 dest_srv, NULL, 0, info_level, &ctr, 0x1000, &hnd) : False;
395 display_srv_file_info_ctr(out_hnd, ACTION_HEADER , &ctr);
396 display_srv_file_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
397 display_srv_file_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
400 /* close the session */
401 cli_nt_session_close(smb_cli, nt_pipe_fnum);
405 DEBUG(5,("cmd_srv_enum_files: query succeeded\n"));
409 DEBUG(5,("cmd_srv_enum_files: query failed\n"));
413 /****************************************************************************
415 ****************************************************************************/
416 void cmd_time(struct client_info *info)
420 TIME_OF_DAY_INFO tod;
423 fstrcpy(dest_srv, "\\\\");
424 fstrcat(dest_srv, info->dest_host);
427 DEBUG(4,("cmd_time: server:%s\n", dest_srv));
429 /* open srvsvc session. */
430 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
432 /* enumerate files on server */
433 res = res ? do_srv_net_remote_tod(smb_cli, nt_pipe_fnum,
434 dest_srv, &tod) : False;
438 fprintf(out_hnd, "\tRemote Time:\t%s\n\n",
439 http_timestring(tod.elapsedt));
442 /* Close the session */
443 cli_nt_session_close(smb_cli, nt_pipe_fnum);
447 DEBUG(5,("cmd_srv_enum_files: query succeeded\n"));
451 DEBUG(5,("cmd_srv_enum_files: query failed\n"));