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 connections
107 ****************************************************************************/
108 void cmd_srv_enum_conn(struct client_info *info)
114 SRV_CONN_INFO_CTR ctr;
116 uint32 info_level = 0;
120 bzero(&ctr, sizeof(ctr));
122 fstrcpy(qual_srv, "\\\\");
123 fstrcat(qual_srv, info->myhostname);
126 fstrcpy(dest_srv, "\\\\");
127 fstrcat(dest_srv, info->dest_host);
130 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
132 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
135 DEBUG(4,("cmd_srv_enum_conn: server:%s info level: %d\n",
136 dest_srv, (int)info_level));
138 DEBUG(5, ("cmd_srv_enum_conn: smb_cli->fd:%d\n", smb_cli->fd));
140 /* open srvsvc session. */
141 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
146 /* enumerate connections on server */
147 res = res ? do_srv_net_srv_conn_enum(smb_cli, nt_pipe_fnum,
149 info_level, &ctr, 0xffffffff, &hnd) : False;
153 display_srv_conn_info_ctr(out_hnd, ACTION_HEADER , &ctr);
154 display_srv_conn_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
155 display_srv_conn_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
158 /* close the session */
159 cli_nt_session_close(smb_cli, nt_pipe_fnum);
163 DEBUG(5,("cmd_srv_enum_conn: query succeeded\n"));
167 DEBUG(5,("cmd_srv_enum_conn: query failed\n"));
171 /****************************************************************************
173 ****************************************************************************/
174 void cmd_srv_enum_shares(struct client_info *info)
179 SRV_SHARE_INFO_CTR ctr;
181 uint32 info_level = 1;
185 bzero(&ctr, sizeof(ctr));
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_shares: server:%s info level: %d\n",
197 dest_srv, (int)info_level));
199 DEBUG(5, ("cmd_srv_enum_shares: 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 shares_files on server */
208 res = res ? do_srv_net_srv_share_enum(smb_cli, nt_pipe_fnum,
210 info_level, &ctr, 0xffffffff, &hnd) : False;
214 display_srv_share_info_ctr(out_hnd, ACTION_HEADER , &ctr);
215 display_srv_share_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
216 display_srv_share_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_shares: query succeeded\n"));
228 DEBUG(5,("cmd_srv_enum_shares: query failed\n"));
232 /****************************************************************************
234 ****************************************************************************/
235 void cmd_srv_enum_sess(struct client_info *info)
240 SRV_SESS_INFO_CTR ctr;
242 uint32 info_level = 0;
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_sess: server:%s info level: %d\n",
258 dest_srv, (int)info_level));
260 DEBUG(5, ("cmd_srv_enum_sess: 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 sessions on server */
269 res = res ? do_srv_net_srv_sess_enum(smb_cli, nt_pipe_fnum,
270 dest_srv, NULL, NULL, info_level, &ctr, 0x1000, &hnd) : False;
274 display_srv_sess_info_ctr(out_hnd, ACTION_HEADER , &ctr);
275 display_srv_sess_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
276 display_srv_sess_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
279 /* close the session */
280 cli_nt_session_close(smb_cli, nt_pipe_fnum);
284 DEBUG(5,("cmd_srv_enum_sess: query succeeded\n"));
288 DEBUG(5,("cmd_srv_enum_sess: query failed\n"));
292 /****************************************************************************
294 ****************************************************************************/
295 void cmd_srv_enum_files(struct client_info *info)
300 SRV_FILE_INFO_CTR ctr;
302 uint32 info_level = 3;
306 bzero(&ctr, sizeof(ctr));
308 fstrcpy(dest_srv, "\\\\");
309 fstrcat(dest_srv, info->dest_host);
312 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
314 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
317 DEBUG(4,("cmd_srv_enum_files: server:%s info level: %d\n",
318 dest_srv, (int)info_level));
320 DEBUG(5, ("cmd_srv_enum_files: smb_cli->fd:%d\n", smb_cli->fd));
322 /* open srvsvc session. */
323 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
328 /* enumerate files on server */
329 res = res ? do_srv_net_srv_file_enum(smb_cli, nt_pipe_fnum,
330 dest_srv, NULL, 0, info_level, &ctr, 0x1000, &hnd) : False;
334 display_srv_file_info_ctr(out_hnd, ACTION_HEADER , &ctr);
335 display_srv_file_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
336 display_srv_file_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
339 /* close the session */
340 cli_nt_session_close(smb_cli, nt_pipe_fnum);
344 DEBUG(5,("cmd_srv_enum_files: query succeeded\n"));
348 DEBUG(5,("cmd_srv_enum_files: query failed\n"));
352 /****************************************************************************
354 ****************************************************************************/
355 void cmd_time(struct client_info *info)
359 TIME_OF_DAY_INFO tod;
362 fstrcpy(dest_srv, "\\\\");
363 fstrcat(dest_srv, info->dest_host);
366 DEBUG(4,("cmd_time: server:%s\n", dest_srv));
368 /* open srvsvc session. */
369 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
371 /* enumerate files on server */
372 res = res ? do_srv_net_remote_tod(smb_cli, nt_pipe_fnum,
373 dest_srv, &tod) : False;
377 fprintf(out_hnd, "\tRemote Time:\t%s\n\n",
378 http_timestring(tod.elapsedt));
381 /* Close the session */
382 cli_nt_session_close(smb_cli, nt_pipe_fnum);
386 DEBUG(5,("cmd_srv_enum_files: query succeeded\n"));
390 DEBUG(5,("cmd_srv_enum_files: query failed\n"));