00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "includes.h"
00027
00028 WERROR rpccli_srvsvc_net_srv_get_info(struct rpc_pipe_client *cli,
00029 TALLOC_CTX *mem_ctx,
00030 uint32 switch_value, SRV_INFO_CTR *ctr)
00031 {
00032 prs_struct qbuf, rbuf;
00033 SRV_Q_NET_SRV_GET_INFO q;
00034 SRV_R_NET_SRV_GET_INFO r;
00035 WERROR result = W_ERROR(ERRgeneral);
00036 fstring server;
00037
00038 ZERO_STRUCT(q);
00039 ZERO_STRUCT(r);
00040
00041
00042
00043 slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
00044 strupper_m(server);
00045
00046 init_srv_q_net_srv_get_info(&q, server, switch_value);
00047 r.ctr = ctr;
00048
00049
00050
00051 CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SRV_GET_INFO,
00052 q, r,
00053 qbuf, rbuf,
00054 srv_io_q_net_srv_get_info,
00055 srv_io_r_net_srv_get_info,
00056 WERR_GENERAL_FAILURE);
00057
00058 result = r.status;
00059 return result;
00060 }
00061
00062 WERROR rpccli_srvsvc_net_share_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00063 uint32 info_level, SRV_SHARE_INFO_CTR *ctr,
00064 int preferred_len, ENUM_HND *hnd)
00065 {
00066 prs_struct qbuf, rbuf;
00067 SRV_Q_NET_SHARE_ENUM q;
00068 SRV_R_NET_SHARE_ENUM r;
00069 WERROR result = W_ERROR(ERRgeneral);
00070 fstring server;
00071 int i;
00072
00073 ZERO_STRUCT(q);
00074 ZERO_STRUCT(r);
00075
00076
00077
00078 slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
00079 strupper_m(server);
00080
00081 init_srv_q_net_share_enum(&q, server, info_level, preferred_len, hnd);
00082
00083
00084
00085 CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_ENUM_ALL,
00086 q, r,
00087 qbuf, rbuf,
00088 srv_io_q_net_share_enum,
00089 srv_io_r_net_share_enum,
00090 WERR_GENERAL_FAILURE);
00091
00092 result = r.status;
00093
00094 if (!W_ERROR_IS_OK(result))
00095 goto done;
00096
00097
00098
00099
00100
00101
00102 ZERO_STRUCTP(ctr);
00103
00104 if (!r.ctr.num_entries)
00105 goto done;
00106
00107 ctr->info_level = info_level;
00108 ctr->num_entries = r.ctr.num_entries;
00109
00110 switch(info_level) {
00111 case 1:
00112 ctr->share.info1 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_1, ctr->num_entries);
00113 if (ctr->share.info1 == NULL) {
00114 return WERR_NOMEM;
00115 }
00116
00117 memset(ctr->share.info1, 0, sizeof(SRV_SHARE_INFO_1));
00118
00119 for (i = 0; i < ctr->num_entries; i++) {
00120 SRV_SHARE_INFO_1 *info1 = &ctr->share.info1[i];
00121 char *s;
00122
00123
00124
00125 memcpy(&info1->info_1, &r.ctr.share.info1[i].info_1,
00126 sizeof(SH_INFO_1));
00127
00128
00129
00130 s = unistr2_tdup(mem_ctx, &r.ctr.share.info1[i].info_1_str.uni_netname);
00131 if (s)
00132 init_unistr2(&info1->info_1_str.uni_netname, s, UNI_STR_TERMINATE);
00133
00134 s = unistr2_tdup(mem_ctx, &r.ctr.share.info1[i].info_1_str.uni_remark);
00135 if (s)
00136 init_unistr2(&info1->info_1_str.uni_remark, s, UNI_STR_TERMINATE);
00137
00138 }
00139
00140 break;
00141 case 2:
00142 ctr->share.info2 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_2, ctr->num_entries);
00143 if (ctr->share.info2 == NULL) {
00144 return WERR_NOMEM;
00145 }
00146
00147 memset(ctr->share.info2, 0, sizeof(SRV_SHARE_INFO_2));
00148
00149 for (i = 0; i < ctr->num_entries; i++) {
00150 SRV_SHARE_INFO_2 *info2 = &ctr->share.info2[i];
00151 char *s;
00152
00153
00154
00155 memcpy(&info2->info_2, &r.ctr.share.info2[i].info_2,
00156 sizeof(SH_INFO_2));
00157
00158
00159
00160 s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_netname);
00161 if (s)
00162 init_unistr2(&info2->info_2_str.uni_netname, s, UNI_STR_TERMINATE);
00163
00164 s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_remark);
00165 if (s)
00166 init_unistr2(&info2->info_2_str.uni_remark, s, UNI_STR_TERMINATE);
00167
00168 s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_path);
00169 if (s)
00170 init_unistr2(&info2->info_2_str.uni_path, s, UNI_STR_TERMINATE);
00171
00172 s = unistr2_tdup(mem_ctx, &r.ctr.share.info2[i].info_2_str.uni_passwd);
00173 if (s)
00174 init_unistr2(&info2->info_2_str.uni_passwd, s, UNI_STR_TERMINATE);
00175 }
00176 break;
00177
00178 case 502:
00179 ctr->share.info502 = TALLOC_ARRAY(mem_ctx, SRV_SHARE_INFO_502, ctr->num_entries);
00180
00181 if (ctr->share.info502 == NULL) {
00182 return WERR_NOMEM;
00183 }
00184
00185 memset(ctr->share.info502, 0, sizeof(SRV_SHARE_INFO_502));
00186
00187 for (i = 0; i < ctr->num_entries; i++) {
00188 SRV_SHARE_INFO_502 *info502 = &ctr->share.info502[i];
00189 char *s;
00190
00191
00192 memcpy(&info502->info_502, &r.ctr.share.info502[i].info_502,
00193 sizeof(SH_INFO_502));
00194
00195
00196
00197 s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_netname);
00198 if (s)
00199 init_unistr2(&info502->info_502_str.uni_netname, s, UNI_STR_TERMINATE);
00200
00201 s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_remark);
00202 if (s)
00203 init_unistr2(&info502->info_502_str.uni_remark, s, UNI_STR_TERMINATE);
00204
00205 s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_path);
00206 if (s)
00207 init_unistr2(&info502->info_502_str.uni_path, s, UNI_STR_TERMINATE);
00208
00209 s = unistr2_tdup(mem_ctx, &r.ctr.share.info502[i].info_502_str.uni_passwd);
00210 if (s)
00211 init_unistr2(&info502->info_502_str.uni_passwd, s, UNI_STR_TERMINATE);
00212
00213 info502->info_502_str.sd = dup_sec_desc(mem_ctx, r.ctr.share.info502[i].info_502_str.sd);
00214 }
00215 break;
00216 }
00217
00218 done:
00219
00220 return result;
00221 }
00222
00223 WERROR rpccli_srvsvc_net_share_get_info(struct rpc_pipe_client *cli,
00224 TALLOC_CTX *mem_ctx,
00225 const char *sharename,
00226 uint32 info_level,
00227 SRV_SHARE_INFO *info)
00228 {
00229 prs_struct qbuf, rbuf;
00230 SRV_Q_NET_SHARE_GET_INFO q;
00231 SRV_R_NET_SHARE_GET_INFO r;
00232 WERROR result = W_ERROR(ERRgeneral);
00233 fstring server;
00234
00235 ZERO_STRUCT(q);
00236 ZERO_STRUCT(r);
00237
00238
00239
00240 slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
00241 strupper_m(server);
00242
00243 init_srv_q_net_share_get_info(&q, server, sharename, info_level);
00244
00245
00246
00247 CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_GET_INFO,
00248 q, r,
00249 qbuf, rbuf,
00250 srv_io_q_net_share_get_info,
00251 srv_io_r_net_share_get_info,
00252 WERR_GENERAL_FAILURE);
00253
00254 result = r.status;
00255
00256 if (!W_ERROR_IS_OK(result))
00257 goto done;
00258
00259 ZERO_STRUCTP(info);
00260
00261 info->switch_value = info_level;
00262
00263 switch(info_level) {
00264 case 1:
00265 {
00266 SRV_SHARE_INFO_1 *info1 = &info->share.info1;
00267 SH_INFO_1_STR *info1_str = &info1->info_1_str;
00268
00269 char *s;
00270
00271 info->share.info1 = r.info.share.info1;
00272
00273
00274
00275 s = unistr2_tdup(mem_ctx, &info1_str->uni_netname);
00276 if (s)
00277 init_unistr2(&info1_str->uni_netname,
00278 s, UNI_STR_TERMINATE);
00279
00280 s = unistr2_tdup(mem_ctx, &info1_str->uni_remark);
00281 if (s)
00282 init_unistr2(&info1_str->uni_remark,
00283 s, UNI_STR_TERMINATE);
00284
00285 break;
00286 }
00287 case 2:
00288 {
00289 SRV_SHARE_INFO_2 *info2 = &info->share.info2;
00290 SH_INFO_2_STR *info2_str = &info2->info_2_str;
00291
00292 char *s;
00293
00294 info->share.info2 = r.info.share.info2;
00295
00296
00297
00298 s = unistr2_tdup(mem_ctx, &info2_str->uni_netname);
00299 if (s)
00300 init_unistr2(&info2_str->uni_netname,
00301 s, UNI_STR_TERMINATE);
00302
00303 s = unistr2_tdup(mem_ctx, &info2_str->uni_remark);
00304 if (s)
00305 init_unistr2(&info2_str->uni_remark,
00306 s, UNI_STR_TERMINATE);
00307
00308 s = unistr2_tdup(mem_ctx, &info2_str->uni_path);
00309 if (s)
00310 init_unistr2(&info2_str->uni_path,
00311 s, UNI_STR_TERMINATE);
00312
00313 s = unistr2_tdup(mem_ctx, &info2_str->uni_passwd);
00314 if (s)
00315 init_unistr2(&info2_str->uni_passwd,
00316 s, UNI_STR_TERMINATE);
00317
00318
00319 break;
00320 }
00321 case 502:
00322 {
00323 SRV_SHARE_INFO_502 *info502 = &info->share.info502;
00324 SH_INFO_502_STR *info502_str = &info502->info_502_str;
00325
00326 char *s;
00327
00328 info->share.info502 = r.info.share.info502;
00329
00330
00331
00332 s = unistr2_tdup(mem_ctx, &info502_str->uni_netname);
00333 if (s)
00334 init_unistr2(&info502_str->uni_netname,
00335 s, UNI_STR_TERMINATE);
00336
00337 s = unistr2_tdup(mem_ctx, &info502_str->uni_remark);
00338 if (s)
00339 init_unistr2(&info502_str->uni_remark,
00340 s, UNI_STR_TERMINATE);
00341
00342 s = unistr2_tdup(mem_ctx, &info502_str->uni_path);
00343 if (s)
00344 init_unistr2(&info502_str->uni_path,
00345 s, UNI_STR_TERMINATE);
00346
00347 s = unistr2_tdup(mem_ctx, &info502_str->uni_passwd);
00348 if (s)
00349 init_unistr2(&info502_str->uni_passwd,
00350 s, UNI_STR_TERMINATE);
00351
00352 info502_str->sd = dup_sec_desc(mem_ctx, info502_str->sd);
00353 break;
00354 }
00355 default:
00356 DEBUG(0,("unimplemented info-level: %d\n", info_level));
00357 break;
00358 }
00359
00360 done:
00361
00362 return result;
00363 }
00364
00365 WERROR rpccli_srvsvc_net_share_set_info(struct rpc_pipe_client *cli,
00366 TALLOC_CTX *mem_ctx,
00367 const char *sharename,
00368 uint32 info_level,
00369 SRV_SHARE_INFO *info)
00370 {
00371 prs_struct qbuf, rbuf;
00372 SRV_Q_NET_SHARE_SET_INFO q;
00373 SRV_R_NET_SHARE_SET_INFO r;
00374 WERROR result = W_ERROR(ERRgeneral);
00375 fstring server;
00376
00377 ZERO_STRUCT(q);
00378 ZERO_STRUCT(r);
00379
00380
00381
00382 slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
00383 strupper_m(server);
00384
00385 init_srv_q_net_share_set_info(&q, server, sharename, info_level, info);
00386
00387
00388
00389 CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_SET_INFO,
00390 q, r,
00391 qbuf, rbuf,
00392 srv_io_q_net_share_set_info,
00393 srv_io_r_net_share_set_info,
00394 WERR_GENERAL_FAILURE);
00395
00396 result = r.status;
00397 return result;
00398 }
00399
00400 WERROR rpccli_srvsvc_net_share_del(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00401 const char *sharename)
00402 {
00403 prs_struct qbuf, rbuf;
00404 SRV_Q_NET_SHARE_DEL q;
00405 SRV_R_NET_SHARE_DEL r;
00406 WERROR result = W_ERROR(ERRgeneral);
00407 fstring server;
00408
00409 ZERO_STRUCT(q);
00410 ZERO_STRUCT(r);
00411
00412
00413
00414 slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
00415 strupper_m(server);
00416
00417 init_srv_q_net_share_del(&q, server, sharename);
00418
00419
00420
00421 CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_DEL,
00422 q, r,
00423 qbuf, rbuf,
00424 srv_io_q_net_share_del,
00425 srv_io_r_net_share_del,
00426 WERR_GENERAL_FAILURE);
00427
00428 result = r.status;
00429 return result;
00430 }
00431
00432 WERROR rpccli_srvsvc_net_share_add(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00433 const char *netname, uint32 type,
00434 const char *remark, uint32 perms,
00435 uint32 max_uses, uint32 num_uses,
00436 const char *path, const char *passwd,
00437 int level, SEC_DESC *sd)
00438 {
00439 prs_struct qbuf, rbuf;
00440 SRV_Q_NET_SHARE_ADD q;
00441 SRV_R_NET_SHARE_ADD r;
00442 WERROR result = W_ERROR(ERRgeneral);
00443 fstring server;
00444
00445 ZERO_STRUCT(q);
00446 ZERO_STRUCT(r);
00447
00448 slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
00449 strupper_m(server);
00450
00451 init_srv_q_net_share_add(&q,server, netname, type, remark,
00452 perms, max_uses, num_uses, path, passwd,
00453 level, sd);
00454
00455
00456
00457 CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_SHARE_ADD,
00458 q, r,
00459 qbuf, rbuf,
00460 srv_io_q_net_share_add,
00461 srv_io_r_net_share_add,
00462 WERR_GENERAL_FAILURE);
00463
00464 result = r.status;
00465 return result;
00466 }
00467
00468 WERROR rpccli_srvsvc_net_remote_tod(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00469 char *server, TIME_OF_DAY_INFO *tod)
00470 {
00471 prs_struct qbuf, rbuf;
00472 SRV_Q_NET_REMOTE_TOD q;
00473 SRV_R_NET_REMOTE_TOD r;
00474 WERROR result = W_ERROR(ERRgeneral);
00475 fstring server_slash;
00476
00477 ZERO_STRUCT(q);
00478 ZERO_STRUCT(r);
00479
00480
00481
00482 slprintf(server_slash, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
00483 strupper_m(server_slash);
00484
00485 init_srv_q_net_remote_tod(&q, server_slash);
00486 r.tod = tod;
00487
00488
00489
00490 CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_REMOTE_TOD,
00491 q, r,
00492 qbuf, rbuf,
00493 srv_io_q_net_remote_tod,
00494 srv_io_r_net_remote_tod,
00495 WERR_GENERAL_FAILURE);
00496
00497 result = r.status;
00498 return result;
00499 }
00500
00501 WERROR rpccli_srvsvc_net_file_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00502 uint32 file_level, const char *user_name,
00503 SRV_FILE_INFO_CTR *ctr, int preferred_len,
00504 ENUM_HND *hnd)
00505 {
00506 prs_struct qbuf, rbuf;
00507 SRV_Q_NET_FILE_ENUM q;
00508 SRV_R_NET_FILE_ENUM r;
00509 WERROR result = W_ERROR(ERRgeneral);
00510 fstring server;
00511 int i;
00512
00513 ZERO_STRUCT(q);
00514 ZERO_STRUCT(r);
00515
00516
00517
00518 slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
00519 strupper_m(server);
00520
00521 init_srv_q_net_file_enum(&q, server, NULL, user_name,
00522 file_level, ctr, preferred_len, hnd);
00523
00524
00525
00526 CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_FILE_ENUM,
00527 q, r,
00528 qbuf, rbuf,
00529 srv_io_q_net_file_enum,
00530 srv_io_r_net_file_enum,
00531 WERR_GENERAL_FAILURE);
00532
00533 result = r.status;
00534
00535 if (!W_ERROR_IS_OK(result))
00536 goto done;
00537
00538
00539
00540 ZERO_STRUCTP(ctr);
00541
00542 ctr->level = file_level;
00543
00544 ctr->num_entries = ctr->num_entries2 = r.ctr.num_entries;
00545
00546 switch(file_level) {
00547 case 3:
00548 if (ctr->num_entries) {
00549 if ( (ctr->file.info3 = TALLOC_ARRAY(mem_ctx, FILE_INFO_3, ctr->num_entries)) == NULL ) {
00550 return WERR_NOMEM;
00551 }
00552
00553 memset(ctr->file.info3, 0, sizeof(FILE_INFO_3) * ctr->num_entries);
00554 } else {
00555 ctr->file.info3 = NULL;
00556 }
00557
00558 for (i = 0; i < r.ctr.num_entries; i++) {
00559 FILE_INFO_3 *info3 = &ctr->file.info3[i];
00560 char *s;
00561
00562
00563
00564 memcpy(info3, &r.ctr.file.info3[i], sizeof(FILE_INFO_3));
00565
00566
00567
00568 if ( (s = unistr2_tdup(mem_ctx, r.ctr.file.info3[i].path)) != NULL ) {
00569 info3->path = TALLOC_P( mem_ctx, UNISTR2 );
00570 init_unistr2(info3->path, s, UNI_STR_TERMINATE);
00571 }
00572
00573 if ( (s = unistr2_tdup(mem_ctx, r.ctr.file.info3[i].user)) != NULL ) {
00574 info3->user = TALLOC_P( mem_ctx, UNISTR2 );
00575 init_unistr2(info3->user, s, UNI_STR_TERMINATE);
00576 }
00577
00578 }
00579
00580 break;
00581 }
00582
00583 done:
00584 return result;
00585 }
00586
00587 WERROR rpccli_srvsvc_net_file_close(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
00588 uint32 file_id)
00589 {
00590 prs_struct qbuf, rbuf;
00591 SRV_Q_NET_FILE_CLOSE q;
00592 SRV_R_NET_FILE_CLOSE r;
00593 WERROR result = W_ERROR(ERRgeneral);
00594 fstring server;
00595
00596 ZERO_STRUCT(q);
00597 ZERO_STRUCT(r);
00598
00599
00600
00601 slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
00602 strupper_m(server);
00603
00604 init_srv_q_net_file_close(&q, server, file_id);
00605
00606
00607
00608 CLI_DO_RPC_WERR(cli, mem_ctx, PI_SRVSVC, SRV_NET_FILE_CLOSE,
00609 q, r,
00610 qbuf, rbuf,
00611 srv_io_q_net_file_close,
00612 srv_io_r_net_file_close,
00613 WERR_GENERAL_FAILURE);
00614
00615 result = r.status;
00616 return result;
00617 }