| 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 | NT Domain Authentication SMB / MSRPC client
|
|---|
| 4 | Copyright (C) Andrew Tridgell 1994-2000
|
|---|
| 5 | Copyright (C) Tim Potter 2001
|
|---|
| 6 | Copyright (C) Jim McDonough <[email protected]> 2002
|
|---|
| 7 | Copyright (C) Jeremy Allison 2005.
|
|---|
| 8 | Copyright (C) Gerald (Jerry) Carter 2006.
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 | This program is free software; you can redistribute it and/or modify
|
|---|
| 12 | it under the terms of the GNU General Public License as published by
|
|---|
| 13 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 14 | (at your option) any later version.
|
|---|
| 15 |
|
|---|
| 16 | This program is distributed in the hope that it will be useful,
|
|---|
| 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 19 | GNU General Public License for more details.
|
|---|
| 20 |
|
|---|
| 21 | You should have received a copy of the GNU General Public License
|
|---|
| 22 | along with this program; if not, write to the Free Software
|
|---|
| 23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|---|
| 24 | */
|
|---|
| 25 |
|
|---|
| 26 | #include "includes.h"
|
|---|
| 27 |
|
|---|
| 28 | WERROR rpccli_srvsvc_net_srv_get_info(struct rpc_pipe_client *cli,
|
|---|
| 29 | TALLOC_CTX *mem_ctx,
|
|---|
| 30 | uint32 switch_value, SRV_INFO_CTR *ctr)
|
|---|
| 31 | {
|
|---|
| 32 | prs_struct qbuf, rbuf;
|
|---|
| 33 | SRV_Q_NET_SRV_GET_INFO q;
|
|---|
| 34 | SRV_R_NET_SRV_GET_INFO r;
|
|---|
| 35 | WERROR result = W_ERROR(ERRgeneral);
|
|---|
| 36 | fstring server;
|
|---|
| 37 |
|
|---|
| 38 | ZERO_STRUCT(q);
|
|---|
| 39 | ZERO_STRUCT(r);
|
|---|
| 40 |
|
|---|
| 41 | /* Initialise input parameters */
|
|---|
| 42 |
|
|---|
| 43 | slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
|---|
| 44 | strupper_m(server);
|
|---|
| 45 |
|
|---|
| 46 | init_srv_q_net_srv_get_info(&q, server, switch_value);
|
|---|
| 47 | r.ctr = ctr;
|
|---|
| 48 |
|
|---|
| 49 | /* Marshall data and send request */
|
|---|
| 50 |
|
|---|
| 51 | CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SRV_GET_INFO,
|
|---|
| 52 | q, r,
|
|---|
| 53 | qbuf, rbuf,
|
|---|
| 54 | srv_io_q_net_srv_get_info,
|
|---|
| 55 | srv_io_r_net_srv_get_info,
|
|---|
| 56 | WERR_GENERAL_FAILURE);
|
|---|
| 57 |
|
|---|
| 58 | result = r.status;
|
|---|
| 59 | return result;
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | WERROR rpccli_srvsvc_net_share_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|---|
| 63 | uint32 info_level, SRV_SHARE_INFO_CTR *ctr,
|
|---|
| 64 | int preferred_len, ENUM_HND *hnd)
|
|---|
| 65 | {
|
|---|
| 66 | prs_struct qbuf, rbuf;
|
|---|
| 67 | SRV_Q_NET_SHARE_ENUM q;
|
|---|
| 68 | SRV_R_NET_SHARE_ENUM r;
|
|---|
| 69 | WERROR result = W_ERROR(ERRgeneral);
|
|---|
| 70 | fstring server;
|
|---|
| 71 | int i;
|
|---|
| 72 |
|
|---|
| 73 | ZERO_STRUCT(q);
|
|---|
| 74 | ZERO_STRUCT(r);
|
|---|
| 75 |
|
|---|
| 76 | /* Initialise input parameters */
|
|---|
| 77 |
|
|---|
| 78 | slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
|---|
| 79 | strupper_m(server);
|
|---|
| 80 |
|
|---|
| 81 | init_srv_q_net_share_enum(&q, server, info_level, preferred_len, hnd);
|
|---|
| 82 |
|
|---|
| 83 | /* Marshall data and send request */
|
|---|
| 84 |
|
|---|
| 85 | CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_ENUM_ALL,
|
|---|
| 86 | q, r,
|
|---|
| 87 | qbuf, rbuf,
|
|---|
| 88 | srv_io_q_net_share_enum,
|
|---|
| 89 | srv_io_r_net_share_enum,
|
|---|
| 90 | WERR_GENERAL_FAILURE);
|
|---|
| 91 |
|
|---|
| 92 | result = r.status;
|
|---|
| 93 |
|
|---|
| 94 | if (!W_ERROR_IS_OK(result))
|
|---|
| 95 | goto done;
|
|---|
| 96 |
|
|---|
| 97 | /* Oh yuck yuck yuck - we have to copy all the info out of the
|
|---|
| 98 | SRV_SHARE_INFO_CTR in the SRV_R_NET_SHARE_ENUM as when we do a
|
|---|
| 99 | prs_mem_free() it will all be invalidated. The various share
|
|---|
| 100 | info structures suck badly too. This really is gross. */
|
|---|
| 101 |
|
|---|
| 102 | ZERO_STRUCTP(ctr);
|
|---|
| 103 |
|
|---|
| 104 | if (!r.ctr.num_entries)
|
|---|
| 105 | goto done;
|
|---|
| 106 |
|
|---|
| 107 | ctr->info_level = info_level;
|
|---|
| 108 | ctr->num_entries = r.ctr.num_entries;
|
|---|
| 109 |
|
|---|
| 110 | switch(info_level) {
|
|---|
| 111 | case 1:
|
|---|
| 112 | ctr->share.info1 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_1, ctr->num_entries);
|
|---|
| 113 | if (ctr->share.info1 == NULL) {
|
|---|
| 114 | return WERR_NOMEM;
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | memset(ctr->share.info1, 0, sizeof(SRV_SHARE_INFO_1));
|
|---|
| 118 |
|
|---|
| 119 | for (i = 0; i < ctr->num_entries; i++) {
|
|---|
| 120 | SRV_SHARE_INFO_1 *info1 = &ctr->share.info1[i];
|
|---|
| 121 | char *s;
|
|---|
| 122 |
|
|---|
| 123 | /* Copy pointer crap */
|
|---|
| 124 |
|
|---|
| 125 | memcpy(&info1->info_1, &r.ctr.share.info1[i].info_1,
|
|---|
| 126 | sizeof(SH_INFO_1));
|
|---|
| 127 |
|
|---|
| 128 | /* Duplicate strings */
|
|---|
| 129 |
|
|---|
| 130 | s = unistr2_tdup(mem_ctx, &r.ctr.share.info1[i].info_1_str.uni_netname);
|
|---|
| 131 | if (s)
|
|---|
| 132 | init_unistr2(&info1->info_1_str.uni_netname, s, UNI_STR_TERMINATE);
|
|---|
| 133 |
|
|---|
| 134 | s = unistr2_tdup(mem_ctx, &r.ctr.share.info1[i].info_1_str.uni_remark);
|
|---|
| 135 | if (s)
|
|---|
| 136 | init_unistr2(&info1->info_1_str.uni_remark, s, UNI_STR_TERMINATE);
|
|---|
| 137 |
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | break;
|
|---|
| 141 | case 2:
|
|---|
| 142 | ctr->share.info2 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_2, ctr->num_entries);
|
|---|
| 143 | if (ctr->share.info2 == NULL) {
|
|---|
| 144 | return WERR_NOMEM;
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | memset(ctr->share.info2, 0, sizeof(SRV_SHARE_INFO_2));
|
|---|
| 148 |
|
|---|
| 149 | for (i = 0; i < ctr->num_entries; i++) {
|
|---|
| 150 | SRV_SHARE_INFO_2 *info2 = &ctr->share.info2[i];
|
|---|
| 151 | char *s;
|
|---|
| 152 |
|
|---|
| 153 | /* Copy pointer crap */
|
|---|
| 154 |
|
|---|
| 155 | memcpy(&info2->info_2, &r.ctr.share.info2[i].info_2,
|
|---|
| 156 | sizeof(SH_INFO_2));
|
|---|
| 157 |
|
|---|
| 158 | /* Duplicate strings */
|
|---|
| 159 |
|
|---|
| 160 | s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_netname);
|
|---|
| 161 | if (s)
|
|---|
| 162 | init_unistr2(&info2->info_2_str.uni_netname, s, UNI_STR_TERMINATE);
|
|---|
| 163 |
|
|---|
| 164 | s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_remark);
|
|---|
| 165 | if (s)
|
|---|
| 166 | init_unistr2(&info2->info_2_str.uni_remark, s, UNI_STR_TERMINATE);
|
|---|
| 167 |
|
|---|
| 168 | s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_path);
|
|---|
| 169 | if (s)
|
|---|
| 170 | init_unistr2(&info2->info_2_str.uni_path, s, UNI_STR_TERMINATE);
|
|---|
| 171 |
|
|---|
| 172 | s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_passwd);
|
|---|
| 173 | if (s)
|
|---|
| 174 | init_unistr2(&info2->info_2_str.uni_passwd, s, UNI_STR_TERMINATE);
|
|---|
| 175 | }
|
|---|
| 176 | break;
|
|---|
| 177 | /* adding info-level 502 here */
|
|---|
| 178 | case 502:
|
|---|
| 179 | ctr->share.info502 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_502, ctr->num_entries);
|
|---|
| 180 |
|
|---|
| 181 | if (ctr->share.info502 == NULL) {
|
|---|
| 182 | return WERR_NOMEM;
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | memset(ctr->share.info502, 0, sizeof(SRV_SHARE_INFO_502));
|
|---|
| 186 |
|
|---|
| 187 | for (i = 0; i < ctr->num_entries; i++) {
|
|---|
| 188 | SRV_SHARE_INFO_502 *info502 = &ctr->share.info502[i];
|
|---|
| 189 | char *s;
|
|---|
| 190 |
|
|---|
| 191 | /* Copy pointer crap */
|
|---|
| 192 | memcpy(&info502->info_502, &r.ctr.share.info502[i].info_502,
|
|---|
| 193 | sizeof(SH_INFO_502));
|
|---|
| 194 |
|
|---|
| 195 | /* Duplicate strings */
|
|---|
| 196 |
|
|---|
| 197 | s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_netname);
|
|---|
| 198 | if (s)
|
|---|
| 199 | init_unistr2(&info502->info_502_str.uni_netname, s, UNI_STR_TERMINATE);
|
|---|
| 200 |
|
|---|
| 201 | s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_remark);
|
|---|
| 202 | if (s)
|
|---|
| 203 | init_unistr2(&info502->info_502_str.uni_remark, s, UNI_STR_TERMINATE);
|
|---|
| 204 |
|
|---|
| 205 | s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_path);
|
|---|
| 206 | if (s)
|
|---|
| 207 | init_unistr2(&info502->info_502_str.uni_path, s, UNI_STR_TERMINATE);
|
|---|
| 208 |
|
|---|
| 209 | s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_passwd);
|
|---|
| 210 | if (s)
|
|---|
| 211 | init_unistr2(&info502->info_502_str.uni_passwd, s, UNI_STR_TERMINATE);
|
|---|
| 212 |
|
|---|
| 213 | info502->info_502_str.sd = dup_sec_desc(mem_ctx, r.ctr.share.info502[i].info_502_str.sd);
|
|---|
| 214 | }
|
|---|
| 215 | break;
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | done:
|
|---|
| 219 |
|
|---|
| 220 | return result;
|
|---|
| 221 | }
|
|---|
| 222 |
|
|---|
| 223 | WERROR rpccli_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
|
|---|
| 224 | TALLOC_CTX *mem_ctx,
|
|---|
| 225 | const char *sharename,
|
|---|
| 226 | uint32 info_level,
|
|---|
| 227 | SRV_SHARE_INFO *info)
|
|---|
| 228 | {
|
|---|
| 229 | prs_struct qbuf, rbuf;
|
|---|
| 230 | SRV_Q_NET_SHARE_GET_INFO q;
|
|---|
| 231 | SRV_R_NET_SHARE_GET_INFO r;
|
|---|
| 232 | WERROR result = W_ERROR(ERRgeneral);
|
|---|
| 233 | fstring server;
|
|---|
| 234 |
|
|---|
| 235 | ZERO_STRUCT(q);
|
|---|
| 236 | ZERO_STRUCT(r);
|
|---|
| 237 |
|
|---|
| 238 | /* Initialise input parameters */
|
|---|
| 239 |
|
|---|
| 240 | slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
|---|
| 241 | strupper_m(server);
|
|---|
| 242 |
|
|---|
| 243 | init_srv_q_net_share_get_info(&q, server, sharename, info_level);
|
|---|
| 244 |
|
|---|
| 245 | /* Marshall data and send request */
|
|---|
| 246 |
|
|---|
| 247 | CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_GET_INFO,
|
|---|
| 248 | q, r,
|
|---|
| 249 | qbuf, rbuf,
|
|---|
| 250 | srv_io_q_net_share_get_info,
|
|---|
| 251 | srv_io_r_net_share_get_info,
|
|---|
| 252 | WERR_GENERAL_FAILURE);
|
|---|
| 253 |
|
|---|
| 254 | result = r.status;
|
|---|
| 255 |
|
|---|
| 256 | if (!W_ERROR_IS_OK(result))
|
|---|
| 257 | goto done;
|
|---|
| 258 |
|
|---|
| 259 | ZERO_STRUCTP(info);
|
|---|
| 260 |
|
|---|
| 261 | info->switch_value = info_level;
|
|---|
| 262 |
|
|---|
| 263 | switch(info_level) {
|
|---|
| 264 | case 1:
|
|---|
| 265 | {
|
|---|
| 266 | SRV_SHARE_INFO_1 *info1 = &info->share.info1;
|
|---|
| 267 | SH_INFO_1_STR *info1_str = &info1->info_1_str;
|
|---|
| 268 |
|
|---|
| 269 | char *s;
|
|---|
| 270 |
|
|---|
| 271 | info->share.info1 = r.info.share.info1;
|
|---|
| 272 |
|
|---|
| 273 | /* Duplicate strings */
|
|---|
| 274 |
|
|---|
| 275 | s = unistr2_tdup(mem_ctx, &info1_str->uni_netname);
|
|---|
| 276 | if (s)
|
|---|
| 277 | init_unistr2(&info1_str->uni_netname,
|
|---|
| 278 | s, UNI_STR_TERMINATE);
|
|---|
| 279 |
|
|---|
| 280 | s = unistr2_tdup(mem_ctx, &info1_str->uni_remark);
|
|---|
| 281 | if (s)
|
|---|
| 282 | init_unistr2(&info1_str->uni_remark,
|
|---|
| 283 | s, UNI_STR_TERMINATE);
|
|---|
| 284 |
|
|---|
| 285 | break;
|
|---|
| 286 | }
|
|---|
| 287 | case 2:
|
|---|
| 288 | {
|
|---|
| 289 | SRV_SHARE_INFO_2 *info2 = &info->share.info2;
|
|---|
| 290 | SH_INFO_2_STR *info2_str = &info2->info_2_str;
|
|---|
| 291 |
|
|---|
| 292 | char *s;
|
|---|
| 293 |
|
|---|
| 294 | info->share.info2 = r.info.share.info2;
|
|---|
| 295 |
|
|---|
| 296 | /* Duplicate strings */
|
|---|
| 297 |
|
|---|
| 298 | s = unistr2_tdup(mem_ctx, &info2_str->uni_netname);
|
|---|
| 299 | if (s)
|
|---|
| 300 | init_unistr2(&info2_str->uni_netname,
|
|---|
| 301 | s, UNI_STR_TERMINATE);
|
|---|
| 302 |
|
|---|
| 303 | s = unistr2_tdup(mem_ctx, &info2_str->uni_remark);
|
|---|
| 304 | if (s)
|
|---|
| 305 | init_unistr2(&info2_str->uni_remark,
|
|---|
| 306 | s, UNI_STR_TERMINATE);
|
|---|
| 307 |
|
|---|
| 308 | s = unistr2_tdup(mem_ctx, &info2_str->uni_path);
|
|---|
| 309 | if (s)
|
|---|
| 310 | init_unistr2(&info2_str->uni_path,
|
|---|
| 311 | s, UNI_STR_TERMINATE);
|
|---|
| 312 |
|
|---|
| 313 | s = unistr2_tdup(mem_ctx, &info2_str->uni_passwd);
|
|---|
| 314 | if (s)
|
|---|
| 315 | init_unistr2(&info2_str->uni_passwd,
|
|---|
| 316 | s, UNI_STR_TERMINATE);
|
|---|
| 317 |
|
|---|
| 318 |
|
|---|
| 319 | break;
|
|---|
| 320 | }
|
|---|
| 321 | case 502:
|
|---|
| 322 | {
|
|---|
| 323 | SRV_SHARE_INFO_502 *info502 = &info->share.info502;
|
|---|
| 324 | SH_INFO_502_STR *info502_str = &info502->info_502_str;
|
|---|
| 325 |
|
|---|
| 326 | char *s;
|
|---|
| 327 |
|
|---|
| 328 | info->share.info502 = r.info.share.info502;
|
|---|
| 329 |
|
|---|
| 330 | /* Duplicate strings */
|
|---|
| 331 |
|
|---|
| 332 | s = unistr2_tdup(mem_ctx, &info502_str->uni_netname);
|
|---|
| 333 | if (s)
|
|---|
| 334 | init_unistr2(&info502_str->uni_netname,
|
|---|
| 335 | s, UNI_STR_TERMINATE);
|
|---|
| 336 |
|
|---|
| 337 | s = unistr2_tdup(mem_ctx, &info502_str->uni_remark);
|
|---|
| 338 | if (s)
|
|---|
| 339 | init_unistr2(&info502_str->uni_remark,
|
|---|
| 340 | s, UNI_STR_TERMINATE);
|
|---|
| 341 |
|
|---|
| 342 | s = unistr2_tdup(mem_ctx, &info502_str->uni_path);
|
|---|
| 343 | if (s)
|
|---|
| 344 | init_unistr2(&info502_str->uni_path,
|
|---|
| 345 | s, UNI_STR_TERMINATE);
|
|---|
| 346 |
|
|---|
| 347 | s = unistr2_tdup(mem_ctx, &info502_str->uni_passwd);
|
|---|
| 348 | if (s)
|
|---|
| 349 | init_unistr2(&info502_str->uni_passwd,
|
|---|
| 350 | s, UNI_STR_TERMINATE);
|
|---|
| 351 |
|
|---|
| 352 | info502_str->sd = dup_sec_desc(mem_ctx, info502_str->sd);
|
|---|
| 353 | break;
|
|---|
| 354 | }
|
|---|
| 355 | default:
|
|---|
| 356 | DEBUG(0,("unimplemented info-level: %d\n", info_level));
|
|---|
| 357 | break;
|
|---|
| 358 | }
|
|---|
| 359 |
|
|---|
| 360 | done:
|
|---|
| 361 |
|
|---|
| 362 | return result;
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| 365 | WERROR rpccli_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
|
|---|
| 366 | TALLOC_CTX *mem_ctx,
|
|---|
| 367 | const char *sharename,
|
|---|
| 368 | uint32 info_level,
|
|---|
| 369 | SRV_SHARE_INFO *info)
|
|---|
| 370 | {
|
|---|
| 371 | prs_struct qbuf, rbuf;
|
|---|
| 372 | SRV_Q_NET_SHARE_SET_INFO q;
|
|---|
| 373 | SRV_R_NET_SHARE_SET_INFO r;
|
|---|
| 374 | WERROR result = W_ERROR(ERRgeneral);
|
|---|
| 375 | fstring server;
|
|---|
| 376 |
|
|---|
| 377 | ZERO_STRUCT(q);
|
|---|
| 378 | ZERO_STRUCT(r);
|
|---|
| 379 |
|
|---|
| 380 | /* Initialise input parameters */
|
|---|
| 381 |
|
|---|
| 382 | slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
|---|
| 383 | strupper_m(server);
|
|---|
| 384 |
|
|---|
| 385 | init_srv_q_net_share_set_info(&q, server, sharename, info_level, info);
|
|---|
| 386 |
|
|---|
| 387 | /* Marshall data and send request */
|
|---|
| 388 |
|
|---|
| 389 | CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_SET_INFO,
|
|---|
| 390 | q, r,
|
|---|
| 391 | qbuf, rbuf,
|
|---|
| 392 | srv_io_q_net_share_set_info,
|
|---|
| 393 | srv_io_r_net_share_set_info,
|
|---|
| 394 | WERR_GENERAL_FAILURE);
|
|---|
| 395 |
|
|---|
| 396 | result = r.status;
|
|---|
| 397 | return result;
|
|---|
| 398 | }
|
|---|
| 399 |
|
|---|
| 400 | WERROR rpccli_srvsvc_net_share_del(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|---|
| 401 | const char *sharename)
|
|---|
| 402 | {
|
|---|
| 403 | prs_struct qbuf, rbuf;
|
|---|
| 404 | SRV_Q_NET_SHARE_DEL q;
|
|---|
| 405 | SRV_R_NET_SHARE_DEL r;
|
|---|
| 406 | WERROR result = W_ERROR(ERRgeneral);
|
|---|
| 407 | fstring server;
|
|---|
| 408 |
|
|---|
| 409 | ZERO_STRUCT(q);
|
|---|
| 410 | ZERO_STRUCT(r);
|
|---|
| 411 |
|
|---|
| 412 | /* Initialise input parameters */
|
|---|
| 413 |
|
|---|
| 414 | slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
|---|
| 415 | strupper_m(server);
|
|---|
| 416 |
|
|---|
| 417 | init_srv_q_net_share_del(&q, server, sharename);
|
|---|
| 418 |
|
|---|
| 419 | /* Marshall data and send request */
|
|---|
| 420 |
|
|---|
| 421 | CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_DEL,
|
|---|
| 422 | q, r,
|
|---|
| 423 | qbuf, rbuf,
|
|---|
| 424 | srv_io_q_net_share_del,
|
|---|
| 425 | srv_io_r_net_share_del,
|
|---|
| 426 | WERR_GENERAL_FAILURE);
|
|---|
| 427 |
|
|---|
| 428 | result = r.status;
|
|---|
| 429 | return result;
|
|---|
| 430 | }
|
|---|
| 431 |
|
|---|
| 432 | WERROR rpccli_srvsvc_net_share_add(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|---|
| 433 | const char *netname, uint32 type,
|
|---|
| 434 | const char *remark, uint32 perms,
|
|---|
| 435 | uint32 max_uses, uint32 num_uses,
|
|---|
| 436 | const char *path, const char *passwd,
|
|---|
| 437 | int level, SEC_DESC *sd)
|
|---|
| 438 | {
|
|---|
| 439 | prs_struct qbuf, rbuf;
|
|---|
| 440 | SRV_Q_NET_SHARE_ADD q;
|
|---|
| 441 | SRV_R_NET_SHARE_ADD r;
|
|---|
| 442 | WERROR result = W_ERROR(ERRgeneral);
|
|---|
| 443 | fstring server;
|
|---|
| 444 |
|
|---|
| 445 | ZERO_STRUCT(q);
|
|---|
| 446 | ZERO_STRUCT(r);
|
|---|
| 447 |
|
|---|
| 448 | slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
|---|
| 449 | strupper_m(server);
|
|---|
| 450 |
|
|---|
| 451 | init_srv_q_net_share_add(&q,server, netname, type, remark,
|
|---|
| 452 | perms, max_uses, num_uses, path, passwd,
|
|---|
| 453 | level, sd);
|
|---|
| 454 |
|
|---|
| 455 | /* Marshall data and send request */
|
|---|
| 456 |
|
|---|
| 457 | CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_ADD,
|
|---|
| 458 | q, r,
|
|---|
| 459 | qbuf, rbuf,
|
|---|
| 460 | srv_io_q_net_share_add,
|
|---|
| 461 | srv_io_r_net_share_add,
|
|---|
| 462 | WERR_GENERAL_FAILURE);
|
|---|
| 463 |
|
|---|
| 464 | result = r.status;
|
|---|
| 465 | return result;
|
|---|
| 466 | }
|
|---|
| 467 |
|
|---|
| 468 | WERROR rpccli_srvsvc_net_remote_tod(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|---|
| 469 | char *server, TIME_OF_DAY_INFO *tod)
|
|---|
| 470 | {
|
|---|
| 471 | prs_struct qbuf, rbuf;
|
|---|
| 472 | SRV_Q_NET_REMOTE_TOD q;
|
|---|
| 473 | SRV_R_NET_REMOTE_TOD r;
|
|---|
| 474 | WERROR result = W_ERROR(ERRgeneral);
|
|---|
| 475 | fstring server_slash;
|
|---|
| 476 |
|
|---|
| 477 | ZERO_STRUCT(q);
|
|---|
| 478 | ZERO_STRUCT(r);
|
|---|
| 479 |
|
|---|
| 480 | /* Initialise input parameters */
|
|---|
| 481 |
|
|---|
| 482 | slprintf(server_slash, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
|---|
| 483 | strupper_m(server_slash);
|
|---|
| 484 |
|
|---|
| 485 | init_srv_q_net_remote_tod(&q, server_slash);
|
|---|
| 486 | r.tod = tod;
|
|---|
| 487 |
|
|---|
| 488 | /* Marshall data and send request */
|
|---|
| 489 |
|
|---|
| 490 | CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_REMOTE_TOD,
|
|---|
| 491 | q, r,
|
|---|
| 492 | qbuf, rbuf,
|
|---|
| 493 | srv_io_q_net_remote_tod,
|
|---|
| 494 | srv_io_r_net_remote_tod,
|
|---|
| 495 | WERR_GENERAL_FAILURE);
|
|---|
| 496 |
|
|---|
| 497 | result = r.status;
|
|---|
| 498 | return result;
|
|---|
| 499 | }
|
|---|
| 500 |
|
|---|
| 501 | WERROR rpccli_srvsvc_net_file_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|---|
| 502 | uint32 file_level, const char *user_name,
|
|---|
| 503 | SRV_FILE_INFO_CTR *ctr, int preferred_len,
|
|---|
| 504 | ENUM_HND *hnd)
|
|---|
| 505 | {
|
|---|
| 506 | prs_struct qbuf, rbuf;
|
|---|
| 507 | SRV_Q_NET_FILE_ENUM q;
|
|---|
| 508 | SRV_R_NET_FILE_ENUM r;
|
|---|
| 509 | WERROR result = W_ERROR(ERRgeneral);
|
|---|
| 510 | fstring server;
|
|---|
| 511 | int i;
|
|---|
| 512 |
|
|---|
| 513 | ZERO_STRUCT(q);
|
|---|
| 514 | ZERO_STRUCT(r);
|
|---|
| 515 |
|
|---|
| 516 | /* Initialise input parameters */
|
|---|
| 517 |
|
|---|
| 518 | slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
|---|
| 519 | strupper_m(server);
|
|---|
| 520 |
|
|---|
| 521 | init_srv_q_net_file_enum(&q, server, NULL, user_name,
|
|---|
| 522 | file_level, ctr, preferred_len, hnd);
|
|---|
| 523 |
|
|---|
| 524 | /* Marshall data and send request */
|
|---|
| 525 |
|
|---|
| 526 | CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_FILE_ENUM,
|
|---|
| 527 | q, r,
|
|---|
| 528 | qbuf, rbuf,
|
|---|
| 529 | srv_io_q_net_file_enum,
|
|---|
| 530 | srv_io_r_net_file_enum,
|
|---|
| 531 | WERR_GENERAL_FAILURE);
|
|---|
| 532 |
|
|---|
| 533 | result = r.status;
|
|---|
| 534 |
|
|---|
| 535 | if (!W_ERROR_IS_OK(result))
|
|---|
| 536 | goto done;
|
|---|
| 537 |
|
|---|
| 538 | /* copy the data over to the ctr */
|
|---|
| 539 |
|
|---|
| 540 | ZERO_STRUCTP(ctr);
|
|---|
| 541 |
|
|---|
| 542 | ctr->level = file_level;
|
|---|
| 543 |
|
|---|
| 544 | ctr->num_entries = ctr->num_entries2 = r.ctr.num_entries;
|
|---|
| 545 |
|
|---|
| 546 | switch(file_level) {
|
|---|
| 547 | case 3:
|
|---|
| 548 | if (ctr->num_entries) {
|
|---|
| 549 | if ( (ctr->file.info3 = TALLOC_ARRAY(mem_ctx, FILE_INFO_3, ctr->num_entries)) == NULL ) {
|
|---|
| 550 | return WERR_NOMEM;
|
|---|
| 551 | }
|
|---|
| 552 |
|
|---|
| 553 | memset(ctr->file.info3, 0, sizeof(FILE_INFO_3) * ctr->num_entries);
|
|---|
| 554 | } else {
|
|---|
| 555 | ctr->file.info3 = NULL;
|
|---|
| 556 | }
|
|---|
| 557 |
|
|---|
| 558 | for (i = 0; i < r.ctr.num_entries; i++) {
|
|---|
| 559 | FILE_INFO_3 *info3 = &ctr->file.info3[i];
|
|---|
| 560 | char *s;
|
|---|
| 561 |
|
|---|
| 562 | /* Copy pointer crap */
|
|---|
| 563 |
|
|---|
| 564 | memcpy(info3, &r.ctr.file.info3[i], sizeof(FILE_INFO_3));
|
|---|
| 565 |
|
|---|
| 566 | /* Duplicate strings */
|
|---|
| 567 |
|
|---|
| 568 | if ( (s = unistr2_tdup(mem_ctx, r.ctr.file.info3[i].path)) != NULL ) {
|
|---|
| 569 | info3->path = TALLOC_P( mem_ctx, UNISTR2 );
|
|---|
| 570 | init_unistr2(info3->path, s, UNI_STR_TERMINATE);
|
|---|
| 571 | }
|
|---|
| 572 |
|
|---|
| 573 | if ( (s = unistr2_tdup(mem_ctx, r.ctr.file.info3[i].user)) != NULL ) {
|
|---|
| 574 | info3->user = TALLOC_P( mem_ctx, UNISTR2 );
|
|---|
| 575 | init_unistr2(info3->user, s, UNI_STR_TERMINATE);
|
|---|
| 576 | }
|
|---|
| 577 |
|
|---|
| 578 | }
|
|---|
| 579 |
|
|---|
| 580 | break;
|
|---|
| 581 | }
|
|---|
| 582 |
|
|---|
| 583 | done:
|
|---|
| 584 | return result;
|
|---|
| 585 | }
|
|---|
| 586 |
|
|---|
| 587 | WERROR rpccli_srvsvc_net_file_close(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|---|
| 588 | uint32 file_id)
|
|---|
| 589 | {
|
|---|
| 590 | prs_struct qbuf, rbuf;
|
|---|
| 591 | SRV_Q_NET_FILE_CLOSE q;
|
|---|
| 592 | SRV_R_NET_FILE_CLOSE r;
|
|---|
| 593 | WERROR result = W_ERROR(ERRgeneral);
|
|---|
| 594 | fstring server;
|
|---|
| 595 |
|
|---|
| 596 | ZERO_STRUCT(q);
|
|---|
| 597 | ZERO_STRUCT(r);
|
|---|
| 598 |
|
|---|
| 599 | /* Initialise input parameters */
|
|---|
| 600 |
|
|---|
| 601 | slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
|---|
| 602 | strupper_m(server);
|
|---|
| 603 |
|
|---|
| 604 | init_srv_q_net_file_close(&q, server, file_id);
|
|---|
| 605 |
|
|---|
| 606 | /* Marshall data and send request */
|
|---|
| 607 |
|
|---|
| 608 | CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_FILE_CLOSE,
|
|---|
| 609 | q, r,
|
|---|
| 610 | qbuf, rbuf,
|
|---|
| 611 | srv_io_q_net_file_close,
|
|---|
| 612 | srv_io_r_net_file_close,
|
|---|
| 613 | WERR_GENERAL_FAILURE);
|
|---|
| 614 |
|
|---|
| 615 | result = r.status;
|
|---|
| 616 | return result;
|
|---|
| 617 | }
|
|---|