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 extern struct generic_mapping file_generic_mapping;
00029
00030 #undef DBGC_CLASS
00031 #define DBGC_CLASS DBGC_RPC_SRV
00032
00033
00034
00035 struct file_enum_count {
00036 TALLOC_CTX *ctx;
00037 int count;
00038 FILE_INFO_3 *info;
00039 };
00040
00041 struct sess_file_count {
00042 pid_t pid;
00043 uid_t uid;
00044 int count;
00045 };
00046
00047
00048
00049
00050
00051 static int pipe_enum_fn( TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *p)
00052 {
00053 struct pipe_open_rec prec;
00054 struct file_enum_count *fenum = (struct file_enum_count *)p;
00055
00056 if (dbuf.dsize != sizeof(struct pipe_open_rec))
00057 return 0;
00058
00059 memcpy(&prec, dbuf.dptr, sizeof(struct pipe_open_rec));
00060
00061 if ( process_exists(prec.pid) ) {
00062 FILE_INFO_3 *f;
00063 int i = fenum->count;
00064 pstring fullpath;
00065
00066 snprintf( fullpath, sizeof(fullpath), "\\PIPE\\%s", prec.name );
00067
00068 f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 );
00069 if ( !f ) {
00070 DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
00071 return 1;
00072 }
00073 fenum->info = f;
00074
00075
00076 init_srv_file_info3( &fenum->info[i],
00077 (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum),
00078 (FILE_READ_DATA|FILE_WRITE_DATA),
00079 0,
00080 uidtoname( prec.uid ),
00081 fullpath );
00082
00083 fenum->count++;
00084 }
00085
00086 return 0;
00087 }
00088
00089
00090
00091
00092 static WERROR net_enum_pipes( TALLOC_CTX *ctx, FILE_INFO_3 **info,
00093 uint32 *count, uint32 resume )
00094 {
00095 struct file_enum_count fenum;
00096 TDB_CONTEXT *conn_tdb = conn_tdb_ctx();
00097
00098 if ( !conn_tdb ) {
00099 DEBUG(0,("net_enum_pipes: Failed to retrieve the connections tdb handle!\n"));
00100 return WERR_ACCESS_DENIED;
00101 }
00102
00103 fenum.ctx = ctx;
00104 fenum.count = *count;
00105 fenum.info = *info;
00106
00107 if (tdb_traverse(conn_tdb, pipe_enum_fn, &fenum) == -1) {
00108 DEBUG(0,("net_enum_pipes: traverse of connections.tdb failed with error %s.\n",
00109 tdb_errorstr(conn_tdb) ));
00110 return WERR_NOMEM;
00111 }
00112
00113 *info = fenum.info;
00114 *count = fenum.count;
00115
00116 return WERR_OK;}
00117
00118
00119
00120
00121
00122 static struct file_enum_count f_enum_cnt;
00123
00124 static void enum_file_fn( const struct share_mode_entry *e,
00125 const char *sharepath, const char *fname, void *state )
00126 {
00127 struct file_enum_count *fenum = &f_enum_cnt;
00128
00129
00130
00131 if ( process_exists(e->pid) ) {
00132 FILE_INFO_3 *f;
00133 int i = fenum->count;
00134 files_struct fsp;
00135 struct byte_range_lock *brl;
00136 int num_locks = 0;
00137 pstring fullpath;
00138 uint32 permissions;
00139
00140 f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 );
00141 if ( !f ) {
00142 DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
00143 return;
00144 }
00145 fenum->info = f;
00146
00147
00148
00149 ZERO_STRUCT( fsp );
00150 fsp.dev = e->dev;
00151 fsp.inode = e->inode;
00152
00153 if ( (brl = brl_get_locks(NULL,&fsp)) != NULL ) {
00154 num_locks = brl->num_locks;
00155 TALLOC_FREE( brl );
00156 }
00157
00158 if ( strcmp( fname, "." ) == 0 ) {
00159 pstr_sprintf( fullpath, "C:%s", sharepath );
00160 } else {
00161 pstr_sprintf( fullpath, "C:%s/%s", sharepath, fname );
00162 }
00163 string_replace( fullpath, '/', '\\' );
00164
00165
00166 permissions = e->share_access & (FILE_READ_DATA|FILE_WRITE_DATA);
00167
00168
00169 init_srv_file_info3( &fenum->info[i],
00170 e->share_file_id,
00171 permissions,
00172 num_locks,
00173 uidtoname(e->uid),
00174 fullpath );
00175
00176 fenum->count++;
00177 }
00178
00179 return;
00180
00181 }
00182
00183
00184
00185
00186 static WERROR net_enum_files( TALLOC_CTX *ctx, FILE_INFO_3 **info,
00187 uint32 *count, uint32 resume )
00188 {
00189 f_enum_cnt.ctx = ctx;
00190 f_enum_cnt.count = *count;
00191 f_enum_cnt.info = *info;
00192
00193 share_mode_forall( enum_file_fn, NULL );
00194
00195 *info = f_enum_cnt.info;
00196 *count = f_enum_cnt.count;
00197
00198 return WERR_OK;
00199 }
00200
00201
00202
00203
00204 static uint32 get_share_type(int snum)
00205 {
00206
00207 uint32 type = STYPE_DISKTREE;
00208
00209 if (lp_print_ok(snum))
00210 type = STYPE_PRINTQ;
00211 if (strequal(lp_fstype(snum), "IPC"))
00212 type = STYPE_IPC;
00213 if (lp_administrative_share(snum))
00214 type |= STYPE_HIDDEN;
00215
00216 return type;
00217 }
00218
00219
00220
00221
00222
00223 static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, int snum)
00224 {
00225 pstring net_name;
00226
00227 pstrcpy(net_name, lp_servicename(snum));
00228
00229 init_srv_share_info0(&sh0->info_0, net_name);
00230 init_srv_share_info0_str(&sh0->info_0_str, net_name);
00231 }
00232
00233
00234
00235
00236
00237 static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int snum)
00238 {
00239 pstring remark;
00240
00241 char *net_name = lp_servicename(snum);
00242 pstrcpy(remark, lp_comment(snum));
00243 standard_sub_conn(p->conn, remark,sizeof(remark));
00244
00245 init_srv_share_info1(&sh1->info_1, net_name, get_share_type(snum), remark);
00246 init_srv_share_info1_str(&sh1->info_1_str, net_name, remark);
00247 }
00248
00249
00250
00251
00252
00253 static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int snum)
00254 {
00255 pstring remark;
00256 pstring path;
00257 pstring passwd;
00258 int max_connections = lp_max_connections(snum);
00259 uint32 max_uses = max_connections!=0 ? max_connections : 0xffffffff;
00260 int count = 0;
00261 char *net_name = lp_servicename(snum);
00262
00263 pstrcpy(remark, lp_comment(snum));
00264 standard_sub_conn(p->conn, remark,sizeof(remark));
00265 pstrcpy(path, "C:");
00266 pstrcat(path, lp_pathname(snum));
00267
00268
00269
00270
00271
00272
00273 string_replace(path, '/', '\\');
00274
00275 pstrcpy(passwd, "");
00276
00277 count = count_current_connections( net_name, False );
00278 init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum),
00279 remark, 0, max_uses, count, path, passwd);
00280
00281 init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd);
00282 }
00283
00284
00285
00286
00287
00288 static void map_generic_share_sd_bits(SEC_DESC *psd)
00289 {
00290 int i;
00291 SEC_ACL *ps_dacl = NULL;
00292
00293 if (!psd)
00294 return;
00295
00296 ps_dacl = psd->dacl;
00297 if (!ps_dacl)
00298 return;
00299
00300 for (i = 0; i < ps_dacl->num_aces; i++) {
00301 SEC_ACE *psa = &ps_dacl->aces[i];
00302 uint32 orig_mask = psa->access_mask;
00303
00304 se_map_generic(&psa->access_mask, &file_generic_mapping);
00305 psa->access_mask |= orig_mask;
00306 }
00307 }
00308
00309
00310
00311
00312
00313 static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, int snum)
00314 {
00315 pstring remark;
00316
00317 const char *net_name = lp_servicename(snum);
00318 pstrcpy(remark, lp_comment(snum));
00319 standard_sub_conn(p->conn, remark, sizeof(remark));
00320
00321 init_srv_share_info501(&sh501->info_501, net_name, get_share_type(snum), remark, (lp_csc_policy(snum) << 4));
00322 init_srv_share_info501_str(&sh501->info_501_str, net_name, remark);
00323 }
00324
00325
00326
00327
00328
00329 static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, int snum)
00330 {
00331 pstring net_name;
00332 pstring remark;
00333 pstring path;
00334 pstring passwd;
00335 SEC_DESC *sd;
00336 size_t sd_size;
00337 TALLOC_CTX *ctx = p->mem_ctx;
00338
00339
00340 ZERO_STRUCTP(sh502);
00341
00342 pstrcpy(net_name, lp_servicename(snum));
00343 pstrcpy(remark, lp_comment(snum));
00344 standard_sub_conn(p->conn, remark,sizeof(remark));
00345 pstrcpy(path, "C:");
00346 pstrcat(path, lp_pathname(snum));
00347
00348
00349
00350
00351
00352
00353 string_replace(path, '/', '\\');
00354
00355 pstrcpy(passwd, "");
00356
00357 sd = get_share_security(ctx, lp_servicename(snum), &sd_size);
00358
00359 init_srv_share_info502(&sh502->info_502, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size);
00360 init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, path, passwd, sd, sd_size);
00361 }
00362
00363
00364
00365
00366
00367 static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh1004, int snum)
00368 {
00369 pstring remark;
00370
00371 pstrcpy(remark, lp_comment(snum));
00372 standard_sub_conn(p->conn, remark, sizeof(remark));
00373
00374 ZERO_STRUCTP(sh1004);
00375
00376 init_srv_share_info1004(&sh1004->info_1004, remark);
00377 init_srv_share_info1004_str(&sh1004->info_1004_str, remark);
00378 }
00379
00380
00381
00382
00383
00384 static void init_srv_share_info_1005(pipes_struct *p, SRV_SHARE_INFO_1005* sh1005, int snum)
00385 {
00386 sh1005->share_info_flags = 0;
00387
00388 if(lp_host_msdfs() && lp_msdfs_root(snum))
00389 sh1005->share_info_flags |=
00390 SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT;
00391 sh1005->share_info_flags |=
00392 lp_csc_policy(snum) << SHARE_1005_CSC_POLICY_SHIFT;
00393 }
00394
00395
00396
00397
00398 static void init_srv_share_info_1006(pipes_struct *p, SRV_SHARE_INFO_1006* sh1006, int snum)
00399 {
00400 sh1006->max_uses = -1;
00401 }
00402
00403
00404
00405
00406
00407 static void init_srv_share_info_1007(pipes_struct *p, SRV_SHARE_INFO_1007* sh1007, int snum)
00408 {
00409 pstring alternate_directory_name = "";
00410 uint32 flags = 0;
00411
00412 ZERO_STRUCTP(sh1007);
00413
00414 init_srv_share_info1007(&sh1007->info_1007, flags, alternate_directory_name);
00415 init_srv_share_info1007_str(&sh1007->info_1007_str, alternate_directory_name);
00416 }
00417
00418
00419
00420
00421
00422 static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh1501, int snum)
00423 {
00424 SEC_DESC *sd;
00425 size_t sd_size;
00426 TALLOC_CTX *ctx = p->mem_ctx;
00427
00428 ZERO_STRUCTP(sh1501);
00429
00430 sd = get_share_security(ctx, lp_servicename(snum), &sd_size);
00431
00432 sh1501->sdb = make_sec_desc_buf(p->mem_ctx, sd_size, sd);
00433 }
00434
00435
00436
00437
00438
00439 static BOOL is_hidden_share(int snum)
00440 {
00441 const char *net_name = lp_servicename(snum);
00442
00443 return (net_name[strlen(net_name) - 1] == '$') ? True : False;
00444 }
00445
00446
00447
00448
00449
00450 static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr,
00451 uint32 info_level, uint32 *resume_hnd, uint32 *total_entries, BOOL all_shares)
00452 {
00453 int num_entries = 0;
00454 int num_services = 0;
00455 int snum;
00456 TALLOC_CTX *ctx = p->mem_ctx;
00457
00458 DEBUG(5,("init_srv_share_info_ctr\n"));
00459
00460 ZERO_STRUCTPN(ctr);
00461
00462 ctr->info_level = ctr->switch_value = info_level;
00463 *resume_hnd = 0;
00464
00465
00466 become_root();
00467 num_services = load_usershare_shares();
00468 unbecome_root();
00469
00470
00471 for (snum = 0; snum < num_services; snum++) {
00472 if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) )
00473 num_entries++;
00474 }
00475
00476 *total_entries = num_entries;
00477 ctr->num_entries2 = ctr->num_entries = num_entries;
00478 ctr->ptr_share_info = ctr->ptr_entries = 1;
00479
00480 if (!num_entries)
00481 return True;
00482
00483 switch (info_level) {
00484 case 0:
00485 {
00486 SRV_SHARE_INFO_0 *info0 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_0, num_entries);
00487 int i = 0;
00488
00489 if (!info0) {
00490 return False;
00491 }
00492
00493 for (snum = *resume_hnd; snum < num_services; snum++) {
00494 if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
00495 init_srv_share_info_0(p, &info0[i++], snum);
00496 }
00497 }
00498
00499 ctr->share.info0 = info0;
00500 break;
00501
00502 }
00503
00504 case 1:
00505 {
00506 SRV_SHARE_INFO_1 *info1 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1, num_entries);
00507 int i = 0;
00508
00509 if (!info1) {
00510 return False;
00511 }
00512
00513 for (snum = *resume_hnd; snum < num_services; snum++) {
00514 if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
00515 init_srv_share_info_1(p, &info1[i++], snum);
00516 }
00517 }
00518
00519 ctr->share.info1 = info1;
00520 break;
00521 }
00522
00523 case 2:
00524 {
00525 SRV_SHARE_INFO_2 *info2 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_2, num_entries);
00526 int i = 0;
00527
00528 if (!info2) {
00529 return False;
00530 }
00531
00532 for (snum = *resume_hnd; snum < num_services; snum++) {
00533 if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
00534 init_srv_share_info_2(p, &info2[i++], snum);
00535 }
00536 }
00537
00538 ctr->share.info2 = info2;
00539 break;
00540 }
00541
00542 case 501:
00543 {
00544 SRV_SHARE_INFO_501 *info501 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_501, num_entries);
00545 int i = 0;
00546
00547 if (!info501) {
00548 return False;
00549 }
00550
00551 for (snum = *resume_hnd; snum < num_services; snum++) {
00552 if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
00553 init_srv_share_info_501(p, &info501[i++], snum);
00554 }
00555 }
00556
00557 ctr->share.info501 = info501;
00558 break;
00559 }
00560
00561 case 502:
00562 {
00563 SRV_SHARE_INFO_502 *info502 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_502, num_entries);
00564 int i = 0;
00565
00566 if (!info502) {
00567 return False;
00568 }
00569
00570 for (snum = *resume_hnd; snum < num_services; snum++) {
00571 if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
00572 init_srv_share_info_502(p, &info502[i++], snum);
00573 }
00574 }
00575
00576 ctr->share.info502 = info502;
00577 break;
00578 }
00579
00580
00581
00582 case 1004:
00583 {
00584 SRV_SHARE_INFO_1004 *info1004 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1004, num_entries);
00585 int i = 0;
00586
00587 if (!info1004) {
00588 return False;
00589 }
00590
00591 for (snum = *resume_hnd; snum < num_services; snum++) {
00592 if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
00593 init_srv_share_info_1004(p, &info1004[i++], snum);
00594 }
00595 }
00596
00597 ctr->share.info1004 = info1004;
00598 break;
00599 }
00600
00601 case 1005:
00602 {
00603 SRV_SHARE_INFO_1005 *info1005 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1005, num_entries);
00604 int i = 0;
00605
00606 if (!info1005) {
00607 return False;
00608 }
00609
00610 for (snum = *resume_hnd; snum < num_services; snum++) {
00611 if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
00612 init_srv_share_info_1005(p, &info1005[i++], snum);
00613 }
00614 }
00615
00616 ctr->share.info1005 = info1005;
00617 break;
00618 }
00619
00620 case 1006:
00621 {
00622 SRV_SHARE_INFO_1006 *info1006 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1006, num_entries);
00623 int i = 0;
00624
00625 if (!info1006) {
00626 return False;
00627 }
00628
00629 for (snum = *resume_hnd; snum < num_services; snum++) {
00630 if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
00631 init_srv_share_info_1006(p, &info1006[i++], snum);
00632 }
00633 }
00634
00635 ctr->share.info1006 = info1006;
00636 break;
00637 }
00638
00639 case 1007:
00640 {
00641 SRV_SHARE_INFO_1007 *info1007 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1007, num_entries);
00642 int i = 0;
00643
00644 if (!info1007) {
00645 return False;
00646 }
00647
00648 for (snum = *resume_hnd; snum < num_services; snum++) {
00649 if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
00650 init_srv_share_info_1007(p, &info1007[i++], snum);
00651 }
00652 }
00653
00654 ctr->share.info1007 = info1007;
00655 break;
00656 }
00657
00658 case 1501:
00659 {
00660 SRV_SHARE_INFO_1501 *info1501 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1501, num_entries);
00661 int i = 0;
00662
00663 if (!info1501) {
00664 return False;
00665 }
00666
00667 for (snum = *resume_hnd; snum < num_services; snum++) {
00668 if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
00669 init_srv_share_info_1501(p, &info1501[i++], snum);
00670 }
00671 }
00672
00673 ctr->share.info1501 = info1501;
00674 break;
00675 }
00676 default:
00677 DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", info_level));
00678 return False;
00679 }
00680
00681 return True;
00682 }
00683
00684
00685
00686
00687
00688 static void init_srv_r_net_share_enum(pipes_struct *p, SRV_R_NET_SHARE_ENUM *r_n,
00689 uint32 info_level, uint32 resume_hnd, BOOL all)
00690 {
00691 DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__));
00692
00693 if (init_srv_share_info_ctr(p, &r_n->ctr, info_level,
00694 &resume_hnd, &r_n->total_entries, all)) {
00695 r_n->status = WERR_OK;
00696 } else {
00697 r_n->status = WERR_UNKNOWN_LEVEL;
00698 }
00699
00700 init_enum_hnd(&r_n->enum_hnd, resume_hnd);
00701 }
00702
00703
00704
00705
00706
00707 static void init_srv_r_net_share_get_info(pipes_struct *p, SRV_R_NET_SHARE_GET_INFO *r_n,
00708 char *share_name, uint32 info_level)
00709 {
00710 WERROR status = WERR_OK;
00711 int snum;
00712
00713 DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__));
00714
00715 r_n->info.switch_value = info_level;
00716
00717 snum = find_service(share_name);
00718
00719 if (snum >= 0) {
00720 switch (info_level) {
00721 case 0:
00722 init_srv_share_info_0(p, &r_n->info.share.info0, snum);
00723 break;
00724 case 1:
00725 init_srv_share_info_1(p, &r_n->info.share.info1, snum);
00726 break;
00727 case 2:
00728 init_srv_share_info_2(p, &r_n->info.share.info2, snum);
00729 break;
00730 case 501:
00731 init_srv_share_info_501(p, &r_n->info.share.info501, snum);
00732 break;
00733 case 502:
00734 init_srv_share_info_502(p, &r_n->info.share.info502, snum);
00735 break;
00736
00737
00738 case 1004:
00739 init_srv_share_info_1004(p, &r_n->info.share.info1004, snum);
00740 break;
00741 case 1005:
00742 init_srv_share_info_1005(p, &r_n->info.share.info1005, snum);
00743 break;
00744
00745
00746 case 1006:
00747 init_srv_share_info_1006(p, &r_n->info.share.info1006, snum);
00748 break;
00749 case 1007:
00750 init_srv_share_info_1007(p, &r_n->info.share.info1007, snum);
00751 break;
00752 case 1501:
00753 init_srv_share_info_1501(p, &r_n->info.share.info1501, snum);
00754 break;
00755 default:
00756 DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level));
00757 status = WERR_UNKNOWN_LEVEL;
00758 break;
00759 }
00760 } else {
00761 status = WERR_INVALID_NAME;
00762 }
00763
00764 r_n->info.ptr_share_ctr = W_ERROR_IS_OK(status) ? 1 : 0;
00765 r_n->status = status;
00766 }
00767
00768
00769
00770
00771
00772 static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot)
00773 {
00774 struct sessionid *session_list;
00775 uint32 num_entries = 0;
00776 (*stot) = list_sessions(&session_list);
00777
00778 if (ss0 == NULL) {
00779 if (snum) {
00780 (*snum) = 0;
00781 }
00782 SAFE_FREE(session_list);
00783 return;
00784 }
00785
00786 DEBUG(5,("init_srv_sess_0_ss0\n"));
00787
00788 if (snum) {
00789 for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) {
00790 init_srv_sess_info0( &ss0->info_0[num_entries], session_list[(*snum)].remote_machine);
00791 num_entries++;
00792 }
00793
00794 ss0->num_entries_read = num_entries;
00795 ss0->ptr_sess_info = num_entries > 0 ? 1 : 0;
00796 ss0->num_entries_read2 = num_entries;
00797
00798 if ((*snum) >= (*stot)) {
00799 (*snum) = 0;
00800 }
00801
00802 } else {
00803 ss0->num_entries_read = 0;
00804 ss0->ptr_sess_info = 0;
00805 ss0->num_entries_read2 = 0;
00806 }
00807 SAFE_FREE(session_list);
00808 }
00809
00810
00811
00812
00813
00814 static struct sess_file_count s_file_cnt;
00815
00816 static void sess_file_fn( const struct share_mode_entry *e,
00817 const char *sharepath, const char *fname, void *state )
00818 {
00819 struct sess_file_count *sess = &s_file_cnt;
00820
00821 if ( (procid_to_pid(&e->pid) == sess->pid) && (sess->uid == e->uid) ) {
00822 sess->count++;
00823 }
00824
00825 return;
00826 }
00827
00828
00829
00830
00831 static int net_count_files( uid_t uid, pid_t pid )
00832 {
00833 s_file_cnt.count = 0;
00834 s_file_cnt.uid = uid;
00835 s_file_cnt.pid = pid;
00836
00837 share_mode_forall( sess_file_fn, NULL );
00838
00839 return s_file_cnt.count;
00840 }
00841
00842
00843
00844
00845
00846 static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot)
00847 {
00848 struct sessionid *session_list;
00849 uint32 num_entries = 0;
00850 time_t now = time(NULL);
00851
00852 if ( !snum ) {
00853 ss1->num_entries_read = 0;
00854 ss1->ptr_sess_info = 0;
00855 ss1->num_entries_read2 = 0;
00856
00857 (*stot) = 0;
00858
00859 return;
00860 }
00861
00862 if (ss1 == NULL) {
00863 (*snum) = 0;
00864 return;
00865 }
00866
00867 (*stot) = list_sessions(&session_list);
00868
00869
00870 for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) {
00871 uint32 num_files;
00872 uint32 connect_time;
00873 struct passwd *pw = sys_getpwnam(session_list[*snum].username);
00874 BOOL guest;
00875
00876 if ( !pw ) {
00877 DEBUG(10,("init_srv_sess_info_1: failed to find owner: %s\n",
00878 session_list[*snum].username));
00879 continue;
00880 }
00881
00882 connect_time = (uint32)(now - session_list[*snum].connect_start);
00883 num_files = net_count_files(pw->pw_uid, session_list[*snum].pid);
00884 guest = strequal( session_list[*snum].username, lp_guestaccount() );
00885
00886 init_srv_sess_info1( &ss1->info_1[num_entries],
00887 session_list[*snum].remote_machine,
00888 session_list[*snum].username,
00889 num_files,
00890 connect_time,
00891 0,
00892 guest);
00893 num_entries++;
00894 }
00895
00896 ss1->num_entries_read = num_entries;
00897 ss1->ptr_sess_info = num_entries > 0 ? 1 : 0;
00898 ss1->num_entries_read2 = num_entries;
00899
00900 if ((*snum) >= (*stot)) {
00901 (*snum) = 0;
00902 }
00903
00904 SAFE_FREE(session_list);
00905 }
00906
00907
00908
00909
00910
00911 static WERROR init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr,
00912 int switch_value, uint32 *resume_hnd, uint32 *total_entries)
00913 {
00914 WERROR status = WERR_OK;
00915 DEBUG(5,("init_srv_sess_info_ctr: %d\n", __LINE__));
00916
00917 ctr->switch_value = switch_value;
00918
00919 switch (switch_value) {
00920 case 0:
00921 init_srv_sess_info_0(&(ctr->sess.info0), resume_hnd, total_entries);
00922 ctr->ptr_sess_ctr = 1;
00923 break;
00924 case 1:
00925 init_srv_sess_info_1(&(ctr->sess.info1), resume_hnd, total_entries);
00926 ctr->ptr_sess_ctr = 1;
00927 break;
00928 default:
00929 DEBUG(5,("init_srv_sess_info_ctr: unsupported switch value %d\n", switch_value));
00930 (*resume_hnd) = 0;
00931 (*total_entries) = 0;
00932 ctr->ptr_sess_ctr = 0;
00933 status = WERR_UNKNOWN_LEVEL;
00934 break;
00935 }
00936
00937 return status;
00938 }
00939
00940
00941
00942
00943
00944 static void init_srv_r_net_sess_enum(SRV_R_NET_SESS_ENUM *r_n,
00945 uint32 resume_hnd, int sess_level, int switch_value)
00946 {
00947 DEBUG(5,("init_srv_r_net_sess_enum: %d\n", __LINE__));
00948
00949 r_n->sess_level = sess_level;
00950
00951 if (sess_level == -1)
00952 r_n->status = WERR_UNKNOWN_LEVEL;
00953 else
00954 r_n->status = init_srv_sess_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries);
00955
00956 if (!W_ERROR_IS_OK(r_n->status))
00957 resume_hnd = 0;
00958
00959 init_enum_hnd(&r_n->enum_hnd, resume_hnd);
00960 }
00961
00962
00963
00964
00965
00966 static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *stot)
00967 {
00968 uint32 num_entries = 0;
00969 (*stot) = 1;
00970
00971 if (ss0 == NULL) {
00972 (*snum) = 0;
00973 return;
00974 }
00975
00976 DEBUG(5,("init_srv_conn_0_ss0\n"));
00977
00978 if (snum) {
00979 for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) {
00980
00981 init_srv_conn_info0(&ss0->info_0[num_entries], (*stot));
00982
00983
00984
00985 num_entries++;
00986 }
00987
00988 ss0->num_entries_read = num_entries;
00989 ss0->ptr_conn_info = num_entries > 0 ? 1 : 0;
00990 ss0->num_entries_read2 = num_entries;
00991
00992 if ((*snum) >= (*stot)) {
00993 (*snum) = 0;
00994 }
00995
00996 } else {
00997 ss0->num_entries_read = 0;
00998 ss0->ptr_conn_info = 0;
00999 ss0->num_entries_read2 = 0;
01000
01001 (*stot) = 0;
01002 }
01003 }
01004
01005
01006
01007
01008
01009 static void init_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1,
01010 uint32 id, uint32 type,
01011 uint32 num_opens, uint32 num_users, uint32 open_time,
01012 const char *usr_name, const char *net_name)
01013 {
01014 init_srv_conn_info1(se1 , id, type, num_opens, num_users, open_time, usr_name, net_name);
01015 init_srv_conn_info1_str(str1, usr_name, net_name);
01016 }
01017
01018
01019
01020
01021
01022 static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *stot)
01023 {
01024 uint32 num_entries = 0;
01025 (*stot) = 1;
01026
01027 if (ss1 == NULL) {
01028 (*snum) = 0;
01029 return;
01030 }
01031
01032 DEBUG(5,("init_srv_conn_1_ss1\n"));
01033
01034 if (snum) {
01035 for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) {
01036 init_srv_conn_1_info(&ss1->info_1[num_entries],
01037 &ss1->info_1_str[num_entries],
01038 (*stot), 0x3, 1, 1, 3,"dummy_user", "IPC$");
01039
01040
01041
01042 num_entries++;
01043 }
01044
01045 ss1->num_entries_read = num_entries;
01046 ss1->ptr_conn_info = num_entries > 0 ? 1 : 0;
01047 ss1->num_entries_read2 = num_entries;
01048
01049
01050 if ((*snum) >= (*stot)) {
01051 (*snum) = 0;
01052 }
01053
01054 } else {
01055 ss1->num_entries_read = 0;
01056 ss1->ptr_conn_info = 0;
01057 ss1->num_entries_read2 = 0;
01058
01059 (*stot) = 0;
01060 }
01061 }
01062
01063
01064
01065
01066
01067 static WERROR init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr,
01068 int switch_value, uint32 *resume_hnd, uint32 *total_entries)
01069 {
01070 WERROR status = WERR_OK;
01071 DEBUG(5,("init_srv_conn_info_ctr: %d\n", __LINE__));
01072
01073 ctr->switch_value = switch_value;
01074
01075 switch (switch_value) {
01076 case 0:
01077 init_srv_conn_info_0(&ctr->conn.info0, resume_hnd, total_entries);
01078 ctr->ptr_conn_ctr = 1;
01079 break;
01080 case 1:
01081 init_srv_conn_info_1(&ctr->conn.info1, resume_hnd, total_entries);
01082 ctr->ptr_conn_ctr = 1;
01083 break;
01084 default:
01085 DEBUG(5,("init_srv_conn_info_ctr: unsupported switch value %d\n", switch_value));
01086 (*resume_hnd = 0);
01087 (*total_entries) = 0;
01088 ctr->ptr_conn_ctr = 0;
01089 status = WERR_UNKNOWN_LEVEL;
01090 break;
01091 }
01092
01093 return status;
01094 }
01095
01096
01097
01098
01099
01100 static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n,
01101 uint32 resume_hnd, int conn_level, int switch_value)
01102 {
01103 DEBUG(5,("init_srv_r_net_conn_enum: %d\n", __LINE__));
01104
01105 r_n->conn_level = conn_level;
01106 if (conn_level == -1)
01107 r_n->status = WERR_UNKNOWN_LEVEL;
01108 else
01109 r_n->status = init_srv_conn_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries);
01110
01111 if (!W_ERROR_IS_OK(r_n->status))
01112 resume_hnd = 0;
01113
01114 init_enum_hnd(&r_n->enum_hnd, resume_hnd);
01115 }
01116
01117
01118
01119
01120
01121 static WERROR net_file_enum_3( SRV_R_NET_FILE_ENUM *r, uint32 resume_hnd )
01122 {
01123 TALLOC_CTX *ctx = get_talloc_ctx();
01124 SRV_FILE_INFO_CTR *ctr = &r->ctr;
01125
01126
01127
01128
01129
01130 r->status = net_enum_files( ctx, &ctr->file.info3, &ctr->num_entries, resume_hnd );
01131 if ( !W_ERROR_IS_OK(r->status))
01132 goto done;
01133
01134 r->status = net_enum_pipes( ctx, &ctr->file.info3, &ctr->num_entries, resume_hnd );
01135 if ( !W_ERROR_IS_OK(r->status))
01136 goto done;
01137
01138 r->level = ctr->level = 3;
01139 r->total_entries = ctr->num_entries;
01140
01141 ctr->num_entries2 = ctr->num_entries;
01142 ctr->ptr_file_info = 1;
01143
01144 r->status = WERR_OK;
01145
01146 done:
01147 if ( ctr->num_entries > 0 )
01148 ctr->ptr_entries = 1;
01149
01150 init_enum_hnd(&r->enum_hnd, 0);
01151
01152 return r->status;
01153 }
01154
01155
01156
01157
01158 WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u)
01159 {
01160 switch ( q_u->level ) {
01161 case 3:
01162 return net_file_enum_3( r_u, get_enum_hnd(&q_u->enum_hnd) );
01163 default:
01164 return WERR_UNKNOWN_LEVEL;
01165 }
01166
01167 return WERR_OK;
01168 }
01169
01170
01171
01172
01173
01174 WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R_NET_SRV_GET_INFO *r_u)
01175 {
01176 WERROR status = WERR_OK;
01177 SRV_INFO_CTR *ctr = TALLOC_P(p->mem_ctx, SRV_INFO_CTR);
01178
01179 if (!ctr)
01180 return WERR_NOMEM;
01181
01182 ZERO_STRUCTP(ctr);
01183
01184 DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__));
01185
01186 if (!pipe_access_check(p)) {
01187 DEBUG(3, ("access denied to srv_net_srv_get_info\n"));
01188 return WERR_ACCESS_DENIED;
01189 }
01190
01191 switch (q_u->switch_value) {
01192
01193
01194
01195
01196
01197 case 102:
01198 init_srv_info_102(&ctr->srv.sv102,
01199 500, global_myname(),
01200 string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH),
01201 lp_major_announce_version(), lp_minor_announce_version(),
01202 lp_default_server_announce(),
01203 0xffffffff,
01204 0xf,
01205 0,
01206 240,
01207 3000,
01208 100000,
01209 "c:\\");
01210 break;
01211 case 101:
01212 init_srv_info_101(&ctr->srv.sv101,
01213 500, global_myname(),
01214 lp_major_announce_version(), lp_minor_announce_version(),
01215 lp_default_server_announce(),
01216 string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH));
01217 break;
01218 case 100:
01219 init_srv_info_100(&ctr->srv.sv100, 500, global_myname());
01220 break;
01221 default:
01222 status = WERR_UNKNOWN_LEVEL;
01223 break;
01224 }
01225
01226
01227 init_srv_r_net_srv_get_info(r_u, q_u->switch_value, ctr, status);
01228
01229 DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__));
01230
01231 return r_u->status;
01232 }
01233
01234
01235
01236
01237
01238 WERROR _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV_R_NET_SRV_SET_INFO *r_u)
01239 {
01240 WERROR status = WERR_OK;
01241
01242 DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__));
01243
01244
01245
01246 init_srv_r_net_srv_set_info(r_u, 0x0, status);
01247
01248 DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__));
01249
01250 return r_u->status;
01251 }
01252
01253
01254
01255
01256
01257 WERROR _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET_CONN_ENUM *r_u)
01258 {
01259 DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__));
01260
01261 r_u->ctr = TALLOC_P(p->mem_ctx, SRV_CONN_INFO_CTR);
01262 if (!r_u->ctr)
01263 return WERR_NOMEM;
01264
01265 ZERO_STRUCTP(r_u->ctr);
01266
01267
01268 init_srv_r_net_conn_enum(r_u,
01269 get_enum_hnd(&q_u->enum_hnd),
01270 q_u->conn_level,
01271 q_u->ctr->switch_value);
01272
01273 DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__));
01274
01275 return r_u->status;
01276 }
01277
01278
01279
01280
01281
01282 WERROR _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_SESS_ENUM *r_u)
01283 {
01284 DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__));
01285
01286 r_u->ctr = TALLOC_P(p->mem_ctx, SRV_SESS_INFO_CTR);
01287 if (!r_u->ctr)
01288 return WERR_NOMEM;
01289
01290 ZERO_STRUCTP(r_u->ctr);
01291
01292
01293 init_srv_r_net_sess_enum(r_u,
01294 get_enum_hnd(&q_u->enum_hnd),
01295 q_u->sess_level,
01296 q_u->ctr->switch_value);
01297
01298 DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__));
01299
01300 return r_u->status;
01301 }
01302
01303
01304
01305
01306
01307 WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SESS_DEL *r_u)
01308 {
01309 struct sessionid *session_list;
01310 struct current_user user;
01311 int num_sessions, snum;
01312 fstring username;
01313 fstring machine;
01314 BOOL not_root = False;
01315
01316 rpcstr_pull_unistr2_fstring(username, &q_u->uni_user_name);
01317 rpcstr_pull_unistr2_fstring(machine, &q_u->uni_cli_name);
01318
01319
01320 while (machine[0] == '\\') {
01321 memmove(machine, &machine[1], strlen(machine));
01322 }
01323
01324 num_sessions = list_sessions(&session_list);
01325
01326 DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__));
01327
01328 r_u->status = WERR_ACCESS_DENIED;
01329
01330 get_current_user(&user, p);
01331
01332
01333
01334 if ((user.ut.uid != sec_initial_uid()) &&
01335 ( ! nt_token_check_domain_rid(p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS))) {
01336
01337 goto done;
01338 }
01339
01340 for (snum = 0; snum < num_sessions; snum++) {
01341
01342 if ((strequal(session_list[snum].username, username) || username[0] == '\0' ) &&
01343 strequal(session_list[snum].remote_machine, machine)) {
01344
01345 if (user.ut.uid != sec_initial_uid()) {
01346 not_root = True;
01347 become_root();
01348 }
01349
01350 if (NT_STATUS_IS_OK(message_send_pid(pid_to_procid(session_list[snum].pid), MSG_SHUTDOWN, NULL, 0, False)))
01351 r_u->status = WERR_OK;
01352
01353 if (not_root)
01354 unbecome_root();
01355 }
01356 }
01357
01358 DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__));
01359
01360
01361 done:
01362 SAFE_FREE(session_list);
01363
01364 return r_u->status;
01365 }
01366
01367
01368
01369
01370
01371 WERROR _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u)
01372 {
01373 DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
01374
01375 if (!pipe_access_check(p)) {
01376 DEBUG(3, ("access denied to srv_net_share_enum_all\n"));
01377 return WERR_ACCESS_DENIED;
01378 }
01379
01380
01381 init_srv_r_net_share_enum(p, r_u,
01382 q_u->ctr.info_level,
01383 get_enum_hnd(&q_u->enum_hnd), True);
01384
01385 DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
01386
01387 return r_u->status;
01388 }
01389
01390
01391
01392
01393
01394 WERROR _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u)
01395 {
01396 DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
01397
01398 if (!pipe_access_check(p)) {
01399 DEBUG(3, ("access denied to srv_net_share_enum\n"));
01400 return WERR_ACCESS_DENIED;
01401 }
01402
01403
01404 init_srv_r_net_share_enum(p, r_u,
01405 q_u->ctr.info_level,
01406 get_enum_hnd(&q_u->enum_hnd), False);
01407
01408 DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
01409
01410 return r_u->status;
01411 }
01412
01413
01414
01415
01416
01417 WERROR _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, SRV_R_NET_SHARE_GET_INFO *r_u)
01418 {
01419 fstring share_name;
01420
01421 DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__));
01422
01423
01424 unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name));
01425 init_srv_r_net_share_get_info(p, r_u, share_name, q_u->info_level);
01426
01427 DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__));
01428
01429 return r_u->status;
01430 }
01431
01432
01433
01434
01435
01436 char *valid_share_pathname(char *dos_pathname)
01437 {
01438 char *ptr;
01439
01440
01441 unix_format(dos_pathname);
01442 unix_clean_name(dos_pathname);
01443
01444
01445 ptr = dos_pathname;
01446 if (strlen(dos_pathname) > 2 && ptr[1] == ':' && ptr[0] != '/')
01447 ptr += 2;
01448
01449
01450 if (*ptr != '/')
01451 return NULL;
01452
01453 return ptr;
01454 }
01455
01456
01457
01458
01459
01460 WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u)
01461 {
01462 struct current_user user;
01463 pstring command;
01464 fstring share_name;
01465 fstring comment;
01466 pstring pathname;
01467 int type;
01468 int snum;
01469 int ret;
01470 char *path;
01471 SEC_DESC *psd = NULL;
01472 SE_PRIV se_diskop = SE_DISK_OPERATOR;
01473 BOOL is_disk_op = False;
01474 int max_connections = 0;
01475
01476 DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__));
01477
01478 unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name));
01479
01480 r_u->parm_error = 0;
01481
01482 if ( strequal(share_name,"IPC$")
01483 || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") )
01484 || strequal(share_name,"global") )
01485 {
01486 return WERR_ACCESS_DENIED;
01487 }
01488
01489 snum = find_service(share_name);
01490
01491
01492 if (snum < 0)
01493 return WERR_NET_NAME_NOT_FOUND;
01494
01495
01496 if (lp_print_ok(snum))
01497 return WERR_ACCESS_DENIED;
01498
01499 get_current_user(&user,p);
01500
01501 is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop );
01502
01503
01504
01505 if ( user.ut.uid != sec_initial_uid() && !is_disk_op )
01506 return WERR_ACCESS_DENIED;
01507
01508 switch (q_u->info_level) {
01509 case 1:
01510 pstrcpy(pathname, lp_pathname(snum));
01511 unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment));
01512 type = q_u->info.share.info2.info_2.type;
01513 psd = NULL;
01514 break;
01515 case 2:
01516 unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment));
01517 unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(pathname));
01518 type = q_u->info.share.info2.info_2.type;
01519 max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses;
01520 psd = NULL;
01521 break;
01522 #if 0
01523
01524 case 501:
01525 unistr2_to_ascii(comment, &q_u->info.share.info501.info_501_str.uni_remark, sizeof(comment));
01526 type = q_u->info.share.info501.info_501.type;
01527 psd = NULL;
01528 break;
01529 #endif
01530 case 502:
01531 unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(comment));
01532 unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(pathname));
01533 type = q_u->info.share.info502.info_502.type;
01534 psd = q_u->info.share.info502.info_502_str.sd;
01535 map_generic_share_sd_bits(psd);
01536 break;
01537 case 1004:
01538 pstrcpy(pathname, lp_pathname(snum));
01539 unistr2_to_ascii(comment, &q_u->info.share.info1004.info_1004_str.uni_remark, sizeof(comment));
01540 type = STYPE_DISKTREE;
01541 break;
01542 case 1005:
01543
01544
01545
01546
01547 if (((q_u->info.share.info1005.share_info_flags &
01548 SHARE_1005_CSC_POLICY_MASK) >>
01549 SHARE_1005_CSC_POLICY_SHIFT) == lp_csc_policy(snum))
01550 return WERR_OK;
01551 else {
01552 DEBUG(3, ("_srv_net_share_set_info: client is trying to change csc policy from the network; must be done with smb.conf\n"));
01553 return WERR_ACCESS_DENIED;
01554 }
01555 case 1006:
01556 case 1007:
01557 return WERR_ACCESS_DENIED;
01558 case 1501:
01559 pstrcpy(pathname, lp_pathname(snum));
01560 fstrcpy(comment, lp_comment(snum));
01561 psd = q_u->info.share.info1501.sdb->sec;
01562 map_generic_share_sd_bits(psd);
01563 type = STYPE_DISKTREE;
01564 break;
01565 default:
01566 DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", q_u->info_level));
01567 return WERR_UNKNOWN_LEVEL;
01568 }
01569
01570
01571 if (type != STYPE_DISKTREE)
01572 return WERR_ACCESS_DENIED;
01573
01574
01575 if (!(path = valid_share_pathname( pathname )))
01576 return WERR_OBJECT_PATH_INVALID;
01577
01578
01579 string_replace(share_name, '"', ' ');
01580 string_replace(path, '"', ' ');
01581 string_replace(comment, '"', ' ');
01582
01583 DEBUG(10,("_srv_net_share_set_info: change share command = %s\n",
01584 lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" ));
01585
01586
01587
01588 if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum))
01589 || (lp_max_connections(snum) != max_connections) )
01590 {
01591 if (!lp_change_share_cmd() || !*lp_change_share_cmd()) {
01592 DEBUG(10,("_srv_net_share_set_info: No change share command\n"));
01593 return WERR_ACCESS_DENIED;
01594 }
01595
01596 slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d",
01597 lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment, max_connections );
01598
01599 DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command ));
01600
01601
01602
01603 if ( is_disk_op )
01604 become_root();
01605
01606 if ( (ret = smbrun(command, NULL)) == 0 ) {
01607
01608 message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL);
01609 }
01610
01611 if ( is_disk_op )
01612 unbecome_root();
01613
01614
01615
01616 DEBUG(3,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret ));
01617
01618 if ( ret != 0 )
01619 return WERR_ACCESS_DENIED;
01620 } else {
01621 DEBUG(10,("_srv_net_share_set_info: No change to share name (%s)\n", share_name ));
01622 }
01623
01624
01625 if (psd) {
01626 SEC_DESC *old_sd;
01627 size_t sd_size;
01628
01629 old_sd = get_share_security(p->mem_ctx, lp_servicename(snum), &sd_size);
01630
01631 if (old_sd && !sec_desc_equal(old_sd, psd)) {
01632 if (!set_share_security(share_name, psd))
01633 DEBUG(0,("_srv_net_share_set_info: Failed to change security info in share %s.\n",
01634 share_name ));
01635 }
01636 }
01637
01638 DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__));
01639
01640 return WERR_OK;
01641 }
01642
01643
01644
01645
01646
01647
01648 WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u)
01649 {
01650 struct current_user user;
01651 pstring command;
01652 fstring share_name;
01653 fstring comment;
01654 pstring pathname;
01655 int type;
01656 int snum;
01657 int ret;
01658 char *path;
01659 SEC_DESC *psd = NULL;
01660 SE_PRIV se_diskop = SE_DISK_OPERATOR;
01661 BOOL is_disk_op;
01662 int max_connections = 0;
01663
01664 DEBUG(5,("_srv_net_share_add: %d\n", __LINE__));
01665
01666 r_u->parm_error = 0;
01667
01668 get_current_user(&user,p);
01669
01670 is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop );
01671
01672 if (user.ut.uid != sec_initial_uid() && !is_disk_op )
01673 return WERR_ACCESS_DENIED;
01674
01675 if (!lp_add_share_cmd() || !*lp_add_share_cmd()) {
01676 DEBUG(10,("_srv_net_share_add: No add share command\n"));
01677 return WERR_ACCESS_DENIED;
01678 }
01679
01680 switch (q_u->info_level) {
01681 case 0:
01682
01683 return WERR_ACCESS_DENIED;
01684 case 1:
01685
01686 return WERR_ACCESS_DENIED;
01687 case 2:
01688 unistr2_to_ascii(share_name, &q_u->info.share.info2.info_2_str.uni_netname, sizeof(share_name));
01689 unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(share_name));
01690 unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name));
01691 max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses;
01692 type = q_u->info.share.info2.info_2.type;
01693 break;
01694 case 501:
01695
01696 return WERR_ACCESS_DENIED;
01697 case 502:
01698 unistr2_to_ascii(share_name, &q_u->info.share.info502.info_502_str.uni_netname, sizeof(share_name));
01699 unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name));
01700 unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name));
01701 type = q_u->info.share.info502.info_502.type;
01702 psd = q_u->info.share.info502.info_502_str.sd;
01703 map_generic_share_sd_bits(psd);
01704 break;
01705
01706
01707
01708 case 1004:
01709 case 1005:
01710 case 1006:
01711 case 1007:
01712 return WERR_ACCESS_DENIED;
01713 case 1501:
01714
01715 return WERR_ACCESS_DENIED;
01716 default:
01717 DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", q_u->info_level));
01718 return WERR_UNKNOWN_LEVEL;
01719 }
01720
01721
01722
01723 if ( !validate_net_name( share_name, INVALID_SHARENAME_CHARS, sizeof(share_name) ) ) {
01724 DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", share_name));
01725 return WERR_INVALID_NAME;
01726 }
01727
01728 if ( strequal(share_name,"IPC$") || strequal(share_name,"global")
01729 || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) )
01730 {
01731 return WERR_ACCESS_DENIED;
01732 }
01733
01734 snum = find_service(share_name);
01735
01736
01737 if (snum >= 0)
01738 return WERR_ALREADY_EXISTS;
01739
01740
01741 if (type != STYPE_DISKTREE)
01742 return WERR_ACCESS_DENIED;
01743
01744
01745 if (!(path = valid_share_pathname( pathname )))
01746 return WERR_OBJECT_PATH_INVALID;
01747
01748
01749 string_replace(share_name, '"', ' ');
01750 string_replace(path, '"', ' ');
01751 string_replace(comment, '"', ' ');
01752
01753 slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d",
01754 lp_add_share_cmd(),
01755 dyn_CONFIGFILE,
01756 share_name,
01757 path,
01758 comment,
01759 max_connections);
01760
01761 DEBUG(10,("_srv_net_share_add: Running [%s]\n", command ));
01762
01763
01764
01765 if ( is_disk_op )
01766 become_root();
01767
01768 if ( (ret = smbrun(command, NULL)) == 0 ) {
01769
01770 message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL);
01771 }
01772
01773 if ( is_disk_op )
01774 unbecome_root();
01775
01776
01777
01778 DEBUG(3,("_srv_net_share_add: Running [%s] returned (%d)\n", command, ret ));
01779
01780 if ( ret != 0 )
01781 return WERR_ACCESS_DENIED;
01782
01783 if (psd) {
01784 if (!set_share_security(share_name, psd)) {
01785 DEBUG(0,("_srv_net_share_add: Failed to add security info to share %s.\n", share_name ));
01786 }
01787 }
01788
01789
01790
01791
01792
01793
01794
01795 DEBUG(5,("_srv_net_share_add: %d\n", __LINE__));
01796
01797 return WERR_OK;
01798 }
01799
01800
01801
01802
01803
01804
01805 WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u)
01806 {
01807 struct current_user user;
01808 pstring command;
01809 fstring share_name;
01810 int ret;
01811 int snum;
01812 SE_PRIV se_diskop = SE_DISK_OPERATOR;
01813 BOOL is_disk_op;
01814 struct share_params *params;
01815
01816 DEBUG(5,("_srv_net_share_del: %d\n", __LINE__));
01817
01818 unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name));
01819
01820 if ( strequal(share_name,"IPC$")
01821 || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") )
01822 || strequal(share_name,"global") )
01823 {
01824 return WERR_ACCESS_DENIED;
01825 }
01826
01827 if (!(params = get_share_params(p->mem_ctx, share_name))) {
01828 return WERR_NO_SUCH_SHARE;
01829 }
01830
01831 snum = find_service(share_name);
01832
01833
01834 if (lp_print_ok(snum))
01835 return WERR_ACCESS_DENIED;
01836
01837 get_current_user(&user,p);
01838
01839 is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop );
01840
01841 if (user.ut.uid != sec_initial_uid() && !is_disk_op )
01842 return WERR_ACCESS_DENIED;
01843
01844 if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) {
01845 DEBUG(10,("_srv_net_share_del: No delete share command\n"));
01846 return WERR_ACCESS_DENIED;
01847 }
01848
01849 slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"",
01850 lp_delete_share_cmd(), dyn_CONFIGFILE, lp_servicename(snum));
01851
01852 DEBUG(10,("_srv_net_share_del: Running [%s]\n", command ));
01853
01854
01855
01856 if ( is_disk_op )
01857 become_root();
01858
01859 if ( (ret = smbrun(command, NULL)) == 0 ) {
01860
01861 message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL);
01862 }
01863
01864 if ( is_disk_op )
01865 unbecome_root();
01866
01867
01868
01869 DEBUG(3,("_srv_net_share_del: Running [%s] returned (%d)\n", command, ret ));
01870
01871 if ( ret != 0 )
01872 return WERR_ACCESS_DENIED;
01873
01874
01875 delete_share_security(params);
01876
01877 lp_killservice(params->service);
01878
01879 return WERR_OK;
01880 }
01881
01882 WERROR _srv_net_share_del_sticky(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u)
01883 {
01884 DEBUG(5,("_srv_net_share_del_stick: %d\n", __LINE__));
01885
01886 return _srv_net_share_del(p, q_u, r_u);
01887 }
01888
01889
01890
01891
01892
01893 WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET_REMOTE_TOD *r_u)
01894 {
01895 TIME_OF_DAY_INFO *tod;
01896 struct tm *t;
01897 time_t unixdate = time(NULL);
01898
01899
01900
01901
01902 uint32 zone = get_time_zone(unixdate)/60;
01903
01904 DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__));
01905
01906 if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, TIME_OF_DAY_INFO)) )
01907 return WERR_NOMEM;
01908
01909 r_u->tod = tod;
01910 r_u->ptr_srv_tod = 0x1;
01911 r_u->status = WERR_OK;
01912
01913 DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__));
01914
01915 t = gmtime(&unixdate);
01916
01917
01918 init_time_of_day_info(tod,
01919 unixdate,
01920 0,
01921 t->tm_hour,
01922 t->tm_min,
01923 t->tm_sec,
01924 0,
01925 zone,
01926 10000,
01927 t->tm_mday,
01928 t->tm_mon + 1,
01929 1900+t->tm_year,
01930 t->tm_wday);
01931
01932 DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__));
01933
01934 return r_u->status;
01935 }
01936
01937
01938
01939
01940
01941 WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC *q_u,
01942 SRV_R_NET_FILE_QUERY_SECDESC *r_u)
01943 {
01944 SEC_DESC *psd = NULL;
01945 size_t sd_size;
01946 DATA_BLOB null_pw;
01947 pstring filename;
01948 pstring qualname;
01949 files_struct *fsp = NULL;
01950 SMB_STRUCT_STAT st;
01951 NTSTATUS nt_status;
01952 struct current_user user;
01953 connection_struct *conn = NULL;
01954 BOOL became_user = False;
01955
01956 ZERO_STRUCT(st);
01957
01958 r_u->status = WERR_OK;
01959
01960 unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname));
01961
01962
01963 null_pw = data_blob(NULL, 0);
01964
01965 get_current_user(&user, p);
01966
01967 become_root();
01968 conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status);
01969 unbecome_root();
01970
01971 if (conn == NULL) {
01972 DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", qualname));
01973 r_u->status = ntstatus_to_werror(nt_status);
01974 goto error_exit;
01975 }
01976
01977 if (!become_user(conn, conn->vuid)) {
01978 DEBUG(0,("_srv_net_file_query_secdesc: Can't become connected user!\n"));
01979 r_u->status = WERR_ACCESS_DENIED;
01980 goto error_exit;
01981 }
01982 became_user = True;
01983
01984 unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename));
01985 nt_status = unix_convert(conn, filename, False, NULL, &st);
01986 if (!NT_STATUS_IS_OK(nt_status)) {
01987 DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", filename));
01988 r_u->status = WERR_ACCESS_DENIED;
01989 goto error_exit;
01990 }
01991
01992 nt_status = check_name(conn, filename);
01993 if (!NT_STATUS_IS_OK(nt_status)) {
01994 DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", filename));
01995 r_u->status = WERR_ACCESS_DENIED;
01996 goto error_exit;
01997 }
01998
01999 nt_status = open_file_stat(conn, filename, &st, &fsp);
02000 if ( !NT_STATUS_IS_OK(nt_status)) {
02001
02002 if (errno == EISDIR)
02003 nt_status = open_directory(conn, filename, &st,
02004 READ_CONTROL_ACCESS,
02005 FILE_SHARE_READ|FILE_SHARE_WRITE,
02006 FILE_OPEN,
02007 0,
02008 FILE_ATTRIBUTE_DIRECTORY,
02009 NULL, &fsp);
02010
02011 if (!NT_STATUS_IS_OK(nt_status)) {
02012 DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename));
02013 r_u->status = ntstatus_to_werror(nt_status);
02014 goto error_exit;
02015 }
02016 }
02017
02018 sd_size = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name, (OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION), &psd);
02019
02020 if (sd_size == 0) {
02021 DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", filename));
02022 r_u->status = WERR_ACCESS_DENIED;
02023 goto error_exit;
02024 }
02025
02026 r_u->ptr_response = 1;
02027 r_u->size_response = sd_size;
02028 r_u->ptr_secdesc = 1;
02029 r_u->size_secdesc = sd_size;
02030 r_u->sec_desc = psd;
02031
02032 psd->dacl->revision = (uint16) NT4_ACL_REVISION;
02033
02034 close_file(fsp, NORMAL_CLOSE);
02035 unbecome_user();
02036 close_cnum(conn, user.vuid);
02037 return r_u->status;
02038
02039 error_exit:
02040
02041 if(fsp) {
02042 close_file(fsp, NORMAL_CLOSE);
02043 }
02044
02045 if (became_user)
02046 unbecome_user();
02047
02048 if (conn)
02049 close_cnum(conn, user.vuid);
02050
02051 return r_u->status;
02052 }
02053
02054
02055
02056
02057
02058 WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_u,
02059 SRV_R_NET_FILE_SET_SECDESC *r_u)
02060 {
02061 BOOL ret;
02062 pstring filename;
02063 pstring qualname;
02064 DATA_BLOB null_pw;
02065 files_struct *fsp = NULL;
02066 SMB_STRUCT_STAT st;
02067 NTSTATUS nt_status;
02068 struct current_user user;
02069 connection_struct *conn = NULL;
02070 BOOL became_user = False;
02071
02072 ZERO_STRUCT(st);
02073
02074 r_u->status = WERR_OK;
02075
02076 unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname));
02077
02078
02079 null_pw = data_blob(NULL, 0);
02080
02081 get_current_user(&user, p);
02082
02083 become_root();
02084 conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status);
02085 unbecome_root();
02086
02087 if (conn == NULL) {
02088 DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", qualname));
02089 r_u->status = ntstatus_to_werror(nt_status);
02090 goto error_exit;
02091 }
02092
02093 if (!become_user(conn, conn->vuid)) {
02094 DEBUG(0,("_srv_net_file_set_secdesc: Can't become connected user!\n"));
02095 r_u->status = WERR_ACCESS_DENIED;
02096 goto error_exit;
02097 }
02098 became_user = True;
02099
02100 unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename));
02101 nt_status = unix_convert(conn, filename, False, NULL, &st);
02102 if (!NT_STATUS_IS_OK(nt_status)) {
02103 DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", filename));
02104 r_u->status = WERR_ACCESS_DENIED;
02105 goto error_exit;
02106 }
02107
02108 nt_status = check_name(conn, filename);
02109 if (!NT_STATUS_IS_OK(nt_status)) {
02110 DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", filename));
02111 r_u->status = WERR_ACCESS_DENIED;
02112 goto error_exit;
02113 }
02114
02115
02116 nt_status = open_file_stat(conn, filename, &st, &fsp);
02117
02118 if ( !NT_STATUS_IS_OK(nt_status) ) {
02119
02120 if (errno == EISDIR)
02121 nt_status = open_directory(conn, filename, &st,
02122 FILE_READ_ATTRIBUTES,
02123 FILE_SHARE_READ|FILE_SHARE_WRITE,
02124 FILE_OPEN,
02125 0,
02126 FILE_ATTRIBUTE_DIRECTORY,
02127 NULL, &fsp);
02128
02129 if ( !NT_STATUS_IS_OK(nt_status) ) {
02130 DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename));
02131 r_u->status = ntstatus_to_werror(nt_status);
02132 goto error_exit;
02133 }
02134 }
02135
02136 ret = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, q_u->sec_info, q_u->sec_desc);
02137
02138 if (ret == False) {
02139 DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", filename));
02140 r_u->status = WERR_ACCESS_DENIED;
02141 goto error_exit;
02142 }
02143
02144 close_file(fsp, NORMAL_CLOSE);
02145 unbecome_user();
02146 close_cnum(conn, user.vuid);
02147 return r_u->status;
02148
02149 error_exit:
02150
02151 if(fsp) {
02152 close_file(fsp, NORMAL_CLOSE);
02153 }
02154
02155 if (became_user) {
02156 unbecome_user();
02157 }
02158
02159 if (conn) {
02160 close_cnum(conn, user.vuid);
02161 }
02162
02163 return r_u->status;
02164 }
02165
02166
02167
02168
02169
02170
02171
02172
02173
02174 static const char *server_disks[] = {"C:"};
02175
02176 static uint32 get_server_disk_count(void)
02177 {
02178 return sizeof(server_disks)/sizeof(server_disks[0]);
02179 }
02180
02181 static uint32 init_server_disk_enum(uint32 *resume)
02182 {
02183 uint32 server_disk_count = get_server_disk_count();
02184
02185
02186
02187 if(*resume & 0x80000000)
02188 *resume = 0;
02189
02190 if(*resume > server_disk_count)
02191 *resume = server_disk_count;
02192
02193 return server_disk_count - *resume;
02194 }
02195
02196 static const char *next_server_disk_enum(uint32 *resume)
02197 {
02198 const char *disk;
02199
02200 if(init_server_disk_enum(resume) == 0)
02201 return NULL;
02202
02203 disk = server_disks[*resume];
02204
02205 (*resume)++;
02206
02207 DEBUG(10, ("next_server_disk_enum: reporting disk %s. resume handle %d.\n", disk, *resume));
02208
02209 return disk;
02210 }
02211
02212 WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_DISK_ENUM *r_u)
02213 {
02214 uint32 i;
02215 const char *disk_name;
02216 TALLOC_CTX *ctx = p->mem_ctx;
02217 uint32 resume=get_enum_hnd(&q_u->enum_hnd);
02218
02219 r_u->status=WERR_OK;
02220
02221 r_u->total_entries = init_server_disk_enum(&resume);
02222
02223 r_u->disk_enum_ctr.unknown = 0;
02224
02225 if(!(r_u->disk_enum_ctr.disk_info = TALLOC_ARRAY(ctx, DISK_INFO, MAX_SERVER_DISK_ENTRIES))) {
02226 return WERR_NOMEM;
02227 }
02228
02229 r_u->disk_enum_ctr.disk_info_ptr = r_u->disk_enum_ctr.disk_info ? 1 : 0;
02230
02231
02232
02233 for(i = 0; i < MAX_SERVER_DISK_ENTRIES -1 && (disk_name = next_server_disk_enum(&resume)); i++) {
02234
02235 r_u->disk_enum_ctr.entries_read++;
02236
02237
02238
02239 init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, disk_name);
02240 }
02241
02242
02243
02244 r_u->disk_enum_ctr.entries_read++;
02245
02246 init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, "");
02247
02248 init_enum_hnd(&r_u->enum_hnd, resume);
02249
02250 return r_u->status;
02251 }
02252
02253
02254
02255
02256 WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV_R_NET_NAME_VALIDATE *r_u)
02257 {
02258 fstring sharename;
02259
02260 switch ( q_u->type ) {
02261 case 0x9:
02262 rpcstr_pull(sharename, q_u->sharename.buffer, sizeof(sharename), q_u->sharename.uni_str_len*2, 0);
02263 if ( !validate_net_name( sharename, INVALID_SHARENAME_CHARS, sizeof(sharename) ) ) {
02264 DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", sharename));
02265 return WERR_INVALID_NAME;
02266 }
02267 break;
02268
02269 default:
02270 return WERR_UNKNOWN_LEVEL;
02271 }
02272
02273 return WERR_OK;
02274 }
02275
02276
02277
02278
02279
02280 WERROR _srv_net_file_close(pipes_struct *p, SRV_Q_NET_FILE_CLOSE *q_u, SRV_R_NET_FILE_CLOSE *r_u)
02281 {
02282 return WERR_ACCESS_DENIED;
02283 }
02284