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)
49 uint32 info_level = 101;
53 bzero(&ctr, sizeof(ctr));
55 fstrcpy(dest_srv, "\\\\");
56 fstrcat(dest_srv, info->dest_host);
59 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
61 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
64 DEBUG(4,("cmd_srv_query_info: server:%s info level: %d\n",
65 dest_srv, (int)info_level));
67 DEBUG(5, ("cmd_srv_query_info: smb_cli->fd:%d\n", smb_cli->fd));
69 /* open LSARPC session. */
70 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False;
72 /* send info level: receive requested info. hopefully. */
73 res = res ? do_srv_net_srv_get_info(smb_cli,
74 dest_srv, info_level, &ctr) : False;
76 /* close the session */
77 cli_nt_session_close(smb_cli);
81 DEBUG(5,("cmd_srv_query_info: query succeeded\n"));
83 display_srv_info_ctr(out_hnd, ACTION_HEADER , &ctr);
84 display_srv_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
85 display_srv_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
89 DEBUG(5,("cmd_srv_query_info: query failed\n"));
93 /****************************************************************************
94 server enum connections
95 ****************************************************************************/
96 void cmd_srv_enum_conn(struct client_info *info)
101 SRV_CONN_INFO_CTR ctr;
103 uint32 info_level = 0;
107 bzero(&ctr, sizeof(ctr));
109 fstrcpy(qual_srv, "\\\\");
110 fstrcat(qual_srv, info->myhostname);
113 fstrcpy(dest_srv, "\\\\");
114 fstrcat(dest_srv, info->dest_host);
117 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
119 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
122 DEBUG(4,("cmd_srv_enum_conn: server:%s info level: %d\n",
123 dest_srv, (int)info_level));
125 DEBUG(5, ("cmd_srv_enum_conn: smb_cli->fd:%d\n", smb_cli->fd));
127 /* open srvsvc session. */
128 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False;
133 /* enumerate connections on server */
134 res = res ? do_srv_net_srv_conn_enum(smb_cli,
136 info_level, &ctr, 0xffffffff, &hnd) : False;
140 display_srv_conn_info_ctr(out_hnd, ACTION_HEADER , &ctr);
141 display_srv_conn_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
142 display_srv_conn_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
145 /* close the session */
146 cli_nt_session_close(smb_cli);
150 DEBUG(5,("cmd_srv_enum_conn: query succeeded\n"));
154 DEBUG(5,("cmd_srv_enum_conn: query failed\n"));
158 /****************************************************************************
160 ****************************************************************************/
161 void cmd_srv_enum_shares(struct client_info *info)
165 SRV_SHARE_INFO_CTR ctr;
167 uint32 info_level = 1;
171 bzero(&ctr, sizeof(ctr));
173 fstrcpy(dest_srv, "\\\\");
174 fstrcat(dest_srv, info->dest_host);
177 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
179 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
182 DEBUG(4,("cmd_srv_enum_shares: server:%s info level: %d\n",
183 dest_srv, (int)info_level));
185 DEBUG(5, ("cmd_srv_enum_shares: smb_cli->fd:%d\n", smb_cli->fd));
187 /* open srvsvc session. */
188 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False;
193 /* enumerate shares_files on server */
194 res = res ? do_srv_net_srv_share_enum(smb_cli,
196 info_level, &ctr, 0xffffffff, &hnd) : False;
200 display_srv_share_info_ctr(out_hnd, ACTION_HEADER , &ctr);
201 display_srv_share_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
202 display_srv_share_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
205 /* close the session */
206 cli_nt_session_close(smb_cli);
210 DEBUG(5,("cmd_srv_enum_shares: query succeeded\n"));
214 DEBUG(5,("cmd_srv_enum_shares: query failed\n"));
218 /****************************************************************************
220 ****************************************************************************/
221 void cmd_srv_enum_sess(struct client_info *info)
225 SRV_SESS_INFO_CTR ctr;
227 uint32 info_level = 0;
231 bzero(&ctr, sizeof(ctr));
233 fstrcpy(dest_srv, "\\\\");
234 fstrcat(dest_srv, info->dest_host);
237 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
239 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
242 DEBUG(4,("cmd_srv_enum_sess: server:%s info level: %d\n",
243 dest_srv, (int)info_level));
245 DEBUG(5, ("cmd_srv_enum_sess: smb_cli->fd:%d\n", smb_cli->fd));
247 /* open srvsvc session. */
248 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False;
253 /* enumerate sessions on server */
254 res = res ? do_srv_net_srv_sess_enum(smb_cli,
255 dest_srv, NULL, info_level, &ctr, 0x1000, &hnd) : False;
257 /* close the session */
258 cli_nt_session_close(smb_cli);
262 DEBUG(5,("cmd_srv_enum_sess: query succeeded\n"));
266 DEBUG(5,("cmd_srv_enum_sess: query failed\n"));
270 /****************************************************************************
272 ****************************************************************************/
273 void cmd_srv_enum_files(struct client_info *info)
277 SRV_FILE_INFO_CTR ctr;
279 uint32 info_level = 3;
283 bzero(&ctr, sizeof(ctr));
285 fstrcpy(dest_srv, "\\\\");
286 fstrcat(dest_srv, info->dest_host);
289 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
291 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
294 DEBUG(4,("cmd_srv_enum_files: server:%s info level: %d\n",
295 dest_srv, (int)info_level));
297 DEBUG(5, ("cmd_srv_enum_files: smb_cli->fd:%d\n", smb_cli->fd));
299 /* open srvsvc session. */
300 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False;
305 /* enumerate files on server */
306 res = res ? do_srv_net_srv_file_enum(smb_cli,
307 dest_srv, NULL, info_level, &ctr, 0x1000, &hnd) : False;
311 display_srv_file_info_ctr(out_hnd, ACTION_HEADER , &ctr);
312 display_srv_file_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
313 display_srv_file_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
316 /* close the session */
317 cli_nt_session_close(smb_cli);
321 DEBUG(5,("cmd_srv_enum_files: query succeeded\n"));
325 DEBUG(5,("cmd_srv_enum_files: query failed\n"));