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 void cmd_srv_query_info(struct client_info *info)
50 uint32 info_level = 101;
54 bzero(&ctr, sizeof(ctr));
56 fstrcpy(dest_srv, "\\\\");
57 fstrcat(dest_srv, info->dest_host);
60 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
62 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
65 DEBUG(4,("cmd_srv_query_info: server:%s info level: %d\n",
66 dest_srv, (int)info_level));
68 DEBUG(5, ("cmd_srv_query_info: smb_cli->fd:%d\n", smb_cli->fd));
70 /* open LSARPC session. */
71 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
73 /* send info level: receive requested info. hopefully. */
74 res = res ? do_srv_net_srv_get_info(smb_cli, nt_pipe_fnum,
75 dest_srv, info_level, &ctr) : False;
77 /* close the session */
78 cli_nt_session_close(smb_cli, nt_pipe_fnum);
82 DEBUG(5,("cmd_srv_query_info: query succeeded\n"));
84 display_srv_info_ctr(out_hnd, ACTION_HEADER , &ctr);
85 display_srv_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
86 display_srv_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
90 DEBUG(5,("cmd_srv_query_info: query failed\n"));
94 /****************************************************************************
95 server enum connections
96 ****************************************************************************/
97 void cmd_srv_enum_conn(struct client_info *info)
103 SRV_CONN_INFO_CTR ctr;
105 uint32 info_level = 0;
109 bzero(&ctr, sizeof(ctr));
111 fstrcpy(qual_srv, "\\\\");
112 fstrcat(qual_srv, info->myhostname);
115 fstrcpy(dest_srv, "\\\\");
116 fstrcat(dest_srv, info->dest_host);
119 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
121 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
124 DEBUG(4,("cmd_srv_enum_conn: server:%s info level: %d\n",
125 dest_srv, (int)info_level));
127 DEBUG(5, ("cmd_srv_enum_conn: smb_cli->fd:%d\n", smb_cli->fd));
129 /* open srvsvc session. */
130 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
135 /* enumerate connections on server */
136 res = res ? do_srv_net_srv_conn_enum(smb_cli, nt_pipe_fnum,
138 info_level, &ctr, 0xffffffff, &hnd) : False;
142 display_srv_conn_info_ctr(out_hnd, ACTION_HEADER , &ctr);
143 display_srv_conn_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
144 display_srv_conn_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
147 /* close the session */
148 cli_nt_session_close(smb_cli, nt_pipe_fnum);
152 DEBUG(5,("cmd_srv_enum_conn: query succeeded\n"));
156 DEBUG(5,("cmd_srv_enum_conn: query failed\n"));
160 /****************************************************************************
162 ****************************************************************************/
163 void cmd_srv_enum_shares(struct client_info *info)
168 SRV_SHARE_INFO_CTR ctr;
170 uint32 info_level = 1;
174 bzero(&ctr, sizeof(ctr));
176 fstrcpy(dest_srv, "\\\\");
177 fstrcat(dest_srv, info->dest_host);
180 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
182 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
185 DEBUG(4,("cmd_srv_enum_shares: server:%s info level: %d\n",
186 dest_srv, (int)info_level));
188 DEBUG(5, ("cmd_srv_enum_shares: smb_cli->fd:%d\n", smb_cli->fd));
190 /* open srvsvc session. */
191 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
196 /* enumerate shares_files on server */
197 res = res ? do_srv_net_srv_share_enum(smb_cli, nt_pipe_fnum,
199 info_level, &ctr, 0xffffffff, &hnd) : False;
203 display_srv_share_info_ctr(out_hnd, ACTION_HEADER , &ctr);
204 display_srv_share_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
205 display_srv_share_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
208 /* close the session */
209 cli_nt_session_close(smb_cli, nt_pipe_fnum);
213 DEBUG(5,("cmd_srv_enum_shares: query succeeded\n"));
217 DEBUG(5,("cmd_srv_enum_shares: query failed\n"));
221 /****************************************************************************
223 ****************************************************************************/
224 void cmd_srv_enum_sess(struct client_info *info)
229 SRV_SESS_INFO_CTR ctr;
231 uint32 info_level = 0;
235 bzero(&ctr, sizeof(ctr));
237 fstrcpy(dest_srv, "\\\\");
238 fstrcat(dest_srv, info->dest_host);
241 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
243 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
246 DEBUG(4,("cmd_srv_enum_sess: server:%s info level: %d\n",
247 dest_srv, (int)info_level));
249 DEBUG(5, ("cmd_srv_enum_sess: smb_cli->fd:%d\n", smb_cli->fd));
251 /* open srvsvc session. */
252 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
257 /* enumerate sessions on server */
258 res = res ? do_srv_net_srv_sess_enum(smb_cli, nt_pipe_fnum,
259 dest_srv, NULL, NULL, info_level, &ctr, 0x1000, &hnd) : False;
263 display_srv_sess_info_ctr(out_hnd, ACTION_HEADER , &ctr);
264 display_srv_sess_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
265 display_srv_sess_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
268 /* close the session */
269 cli_nt_session_close(smb_cli, nt_pipe_fnum);
273 DEBUG(5,("cmd_srv_enum_sess: query succeeded\n"));
277 DEBUG(5,("cmd_srv_enum_sess: query failed\n"));
281 /****************************************************************************
283 ****************************************************************************/
284 void cmd_srv_enum_files(struct client_info *info)
289 SRV_FILE_INFO_CTR ctr;
291 uint32 info_level = 3;
295 bzero(&ctr, sizeof(ctr));
297 fstrcpy(dest_srv, "\\\\");
298 fstrcat(dest_srv, info->dest_host);
301 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
303 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
306 DEBUG(4,("cmd_srv_enum_files: server:%s info level: %d\n",
307 dest_srv, (int)info_level));
309 DEBUG(5, ("cmd_srv_enum_files: smb_cli->fd:%d\n", smb_cli->fd));
311 /* open srvsvc session. */
312 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
317 /* enumerate files on server */
318 res = res ? do_srv_net_srv_file_enum(smb_cli, nt_pipe_fnum,
319 dest_srv, NULL, 0, info_level, &ctr, 0x1000, &hnd) : False;
323 display_srv_file_info_ctr(out_hnd, ACTION_HEADER , &ctr);
324 display_srv_file_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
325 display_srv_file_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
328 /* close the session */
329 cli_nt_session_close(smb_cli, nt_pipe_fnum);
333 DEBUG(5,("cmd_srv_enum_files: query succeeded\n"));
337 DEBUG(5,("cmd_srv_enum_files: query failed\n"));
341 /****************************************************************************
343 ****************************************************************************/
344 void cmd_time(struct client_info *info)
348 TIME_OF_DAY_INFO tod;
351 fstrcpy(dest_srv, "\\\\");
352 fstrcat(dest_srv, info->dest_host);
355 DEBUG(4,("cmd_time: server:%s\n", dest_srv));
357 /* open srvsvc session. */
358 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC, &nt_pipe_fnum) : False;
360 /* enumerate files on server */
361 res = res ? do_srv_net_remote_tod(smb_cli, nt_pipe_fnum,
362 dest_srv, &tod) : False;
366 fprintf(out_hnd, "\tRemote Time:\t%s\n\n",
367 http_timestring(tod.elapsedt));
370 /* Close the session */
371 cli_nt_session_close(smb_cli, nt_pipe_fnum);
375 DEBUG(5,("cmd_srv_enum_files: query succeeded\n"));
379 DEBUG(5,("cmd_srv_enum_files: query failed\n"));