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.
31 extern int DEBUGLEVEL;
35 extern struct cli_state *smb_cli;
40 /****************************************************************************
42 ****************************************************************************/
43 void cmd_srv_query_info(struct client_info *info)
48 uint32 info_level = 101;
52 memset((char *)&ctr, '\0', sizeof(ctr));
54 fstrcpy(dest_srv, "\\\\");
55 fstrcat(dest_srv, info->dest_host);
58 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
60 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
63 DEBUG(4,("cmd_srv_query_info: server:%s info level: %d\n",
64 dest_srv, (int)info_level));
66 DEBUG(5, ("cmd_srv_query_info: smb_cli->fd:%d\n", smb_cli->fd));
68 /* open LSARPC session. */
69 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False;
71 /* send info level: receive requested info. hopefully. */
72 res = res ? do_srv_net_srv_get_info(smb_cli,
73 dest_srv, info_level, &ctr) : False;
75 /* close the session */
76 cli_nt_session_close(smb_cli);
80 DEBUG(5,("cmd_srv_query_info: query succeeded\n"));
82 display_srv_info_ctr(out_hnd, ACTION_HEADER , &ctr);
83 display_srv_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
84 display_srv_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
88 DEBUG(5,("cmd_srv_query_info: query failed\n"));
92 /****************************************************************************
93 server enum connections
94 ****************************************************************************/
95 void cmd_srv_enum_conn(struct client_info *info)
100 SRV_CONN_INFO_CTR ctr;
102 uint32 info_level = 0;
106 memset((char *)&ctr, '\0', sizeof(ctr));
108 fstrcpy(qual_srv, "\\\\");
109 fstrcat(qual_srv, info->myhostname);
112 fstrcpy(dest_srv, "\\\\");
113 fstrcat(dest_srv, info->dest_host);
116 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
118 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
121 DEBUG(4,("cmd_srv_enum_conn: server:%s info level: %d\n",
122 dest_srv, (int)info_level));
124 DEBUG(5, ("cmd_srv_enum_conn: smb_cli->fd:%d\n", smb_cli->fd));
126 /* open srvsvc session. */
127 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False;
132 /* enumerate connections on server */
133 res = res ? do_srv_net_srv_conn_enum(smb_cli,
135 info_level, &ctr, 0xffffffff, &hnd) : False;
139 display_srv_conn_info_ctr(out_hnd, ACTION_HEADER , &ctr);
140 display_srv_conn_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
141 display_srv_conn_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
144 /* close the session */
145 cli_nt_session_close(smb_cli);
149 DEBUG(5,("cmd_srv_enum_conn: query succeeded\n"));
153 DEBUG(5,("cmd_srv_enum_conn: query failed\n"));
157 /****************************************************************************
159 ****************************************************************************/
160 void cmd_srv_enum_shares(struct client_info *info)
164 SRV_R_NET_SHARE_ENUM r_o;
166 uint32 info_level = 1;
170 fstrcpy(dest_srv, "\\\\");
171 fstrcat(dest_srv, info->dest_host);
174 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
176 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
179 DEBUG(4,("cmd_srv_enum_shares: server:%s info level: %d\n",
180 dest_srv, (int)info_level));
182 DEBUG(5, ("cmd_srv_enum_shares: smb_cli->fd:%d\n", smb_cli->fd));
184 /* open srvsvc session. */
185 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False;
190 /* enumerate shares_files on server */
191 res = res ? do_srv_net_srv_share_enum(smb_cli,
193 info_level, &r_o, 0xffffffff, &hnd) : False;
197 display_srv_share_info_ctr(out_hnd, ACTION_HEADER , &r_o.ctr);
198 display_srv_share_info_ctr(out_hnd, ACTION_ENUMERATE, &r_o.ctr);
199 display_srv_share_info_ctr(out_hnd, ACTION_FOOTER , &r_o.ctr);
200 free_srv_r_net_share_enum(&r_o);
203 /* close the session */
204 cli_nt_session_close(smb_cli);
208 DEBUG(5,("cmd_srv_enum_shares: query succeeded\n"));
212 DEBUG(5,("cmd_srv_enum_shares: query failed\n"));
216 /****************************************************************************
218 ****************************************************************************/
219 void cmd_srv_enum_sess(struct client_info *info)
223 SRV_SESS_INFO_CTR ctr;
225 uint32 info_level = 0;
229 memset((char *)&ctr, '\0', sizeof(ctr));
231 fstrcpy(dest_srv, "\\\\");
232 fstrcat(dest_srv, info->dest_host);
235 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
237 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
240 DEBUG(4,("cmd_srv_enum_sess: server:%s info level: %d\n",
241 dest_srv, (int)info_level));
243 DEBUG(5, ("cmd_srv_enum_sess: smb_cli->fd:%d\n", smb_cli->fd));
245 /* open srvsvc session. */
246 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False;
251 /* enumerate sessions on server */
252 res = res ? do_srv_net_srv_sess_enum(smb_cli,
253 dest_srv, NULL, info_level, &ctr, 0x1000, &hnd) : False;
255 /* close the session */
256 cli_nt_session_close(smb_cli);
260 DEBUG(5,("cmd_srv_enum_sess: query succeeded\n"));
264 DEBUG(5,("cmd_srv_enum_sess: query failed\n"));
268 /****************************************************************************
270 ****************************************************************************/
271 void cmd_srv_enum_files(struct client_info *info)
275 SRV_FILE_INFO_CTR ctr;
277 uint32 info_level = 3;
281 memset((char *)&ctr, '\0', sizeof(ctr));
283 fstrcpy(dest_srv, "\\\\");
284 fstrcat(dest_srv, info->dest_host);
287 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
289 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
292 DEBUG(4,("cmd_srv_enum_files: server:%s info level: %d\n",
293 dest_srv, (int)info_level));
295 DEBUG(5, ("cmd_srv_enum_files: smb_cli->fd:%d\n", smb_cli->fd));
297 /* open srvsvc session. */
298 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False;
303 /* enumerate files on server */
304 res = res ? do_srv_net_srv_file_enum(smb_cli,
305 dest_srv, NULL, info_level, &ctr, 0x1000, &hnd) : False;
310 display_srv_file_info_ctr(out_hnd, ACTION_HEADER , &ctr);
311 display_srv_file_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
312 display_srv_file_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
315 /* close the session */
316 cli_nt_session_close(smb_cli);
320 DEBUG(5,("cmd_srv_enum_files: query succeeded\n"));
324 DEBUG(5,("cmd_srv_enum_files: query failed\n"));