Changeset 745 for trunk/server/source3/smbd/trans2.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
source3/smbd/trans2.c (modified) (95 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/smbd/trans2.c
r599 r745 25 25 26 26 #include "includes.h" 27 27 28 #include "version.h" 29 28 30 #include "smbd/globals.h" 29 31 #include "../libcli/auth/libcli_auth.h" 32 33 34 35 36 37 38 39 30 40 31 41 #define DIR_ENTRY_SAFETY_MARGIN 4096 … … 150 160 } else { 151 161 #else 152 {162 { 153 163 #endif 154 164 pea->name = talloc_strdup(mem_ctx, ea_name); … … 508 518 if (!lp_ea_support(SNUM(conn))) { 509 519 return NT_STATUS_EAS_NOT_SUPPORTED; 520 521 522 523 510 524 } 511 525 … … 792 806 int data_alignment_offset = 0; 793 807 bool overflow = False; 794 struct smbd_server_connection *sconn = smbd_server_conn;808 struct smbd_server_connection *sconn = conn; 795 809 int max_send = sconn->smb1.sessions.max_send; 796 810 … … 812 826 reply_outbuf(req, 10, 0); 813 827 show_msg((char *)req->outbuf); 814 if (!srv_send_smb(s mbd_server_fd(),828 if (!srv_send_smb(s, 815 829 (char *)req->outbuf, 816 830 true, req->seqnum+1, … … 951 965 /* Send the packet */ 952 966 show_msg((char *)req->outbuf); 953 if (!srv_send_smb(s mbd_server_fd(),967 if (!srv_send_smb(s, 954 968 (char *)req->outbuf, 955 969 true, req->seqnum+1, … … 1014 1028 uint32 create_disposition; 1015 1029 uint32 create_options = 0; 1030 1016 1031 TALLOC_CTX *ctx = talloc_tos(); 1017 1032 … … 1085 1100 &access_mask, &share_mode, 1086 1101 &create_disposition, 1087 &create_options)) { 1102 &create_options, 1103 &private_flags)) { 1088 1104 reply_nterror(req, NT_STATUS_ACCESS_DENIED); 1089 1105 goto out; … … 1129 1145 oplock_request, /* oplock_request */ 1130 1146 open_size, /* allocation_size */ 1147 1131 1148 NULL, /* sd */ 1132 1149 ea_list, /* ea_list */ … … 1147 1164 mtime = convert_timespec_to_time_t(smb_fname->st.st_ex_mtime); 1148 1165 inode = smb_fname->st.st_ex_ino; 1149 if (fattr & aDIR) {1166 if (fattr & ) { 1150 1167 close_file(req, fsp, ERROR_CLOSE); 1151 1168 reply_nterror(req, NT_STATUS_ACCESS_DENIED); … … 1492 1509 const char *fname, 1493 1510 const struct smb_filename *smb_fname, 1494 uint64_t space_remaining,1511 t space_remaining, 1495 1512 uint8_t align, 1496 1513 bool do_pad, … … 1513 1530 char *last_entry_ptr; 1514 1531 bool was_8_3; 1515 off_t off;1516 off_t pad = 0;1532 t off; 1533 t pad = 0; 1517 1534 1518 1535 *out_of_space = false; … … 1523 1540 ZERO_STRUCT(cdate_ts); 1524 1541 1525 if (!(mode & aDIR)) {1542 if (!(mode & )) { 1526 1543 file_size = get_file_size_stat(&smb_fname->st); 1527 1544 } … … 1548 1565 1549 1566 /* align the record */ 1550 off = PTR_DIFF(pdata, base_data); 1567 SMB_ASSERT(align >= 1); 1568 1569 off = (int)PTR_DIFF(pdata, base_data); 1551 1570 pad = (off + (align-1)) & ~(align-1); 1552 1571 pad -= off; 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1553 1582 off += pad; 1554 1583 /* initialize padding to 0 */ … … 1557 1586 } 1558 1587 space_remaining -= pad; 1588 1589 1590 1559 1591 1560 1592 pdata += pad; … … 1672 1704 if (PTR_DIFF(p + 255 + ea_len,pdata) > space_remaining) { 1673 1705 *out_of_space = true; 1674 DEBUG(9,("smbd_marshall_dir_entry: out of space\n")); 1706 DEBUG(9,("smbd_marshall_dir_entry: out of space " 1707 "(wanted %u, had %d)\n", 1708 (unsigned int)PTR_DIFF(p + 255 + ea_len,pdata), 1709 space_remaining )); 1675 1710 return False; /* Not finished - just out of space */ 1676 1711 } … … 2050 2085 if (PTR_DIFF(p,pdata) > space_remaining) { 2051 2086 *out_of_space = true; 2052 DEBUG(9,("smbd_marshall_dir_entry: out of space\n")); 2087 DEBUG(9,("smbd_marshall_dir_entry: out of space " 2088 "(wanted %u, had %d)\n", 2089 (unsigned int)PTR_DIFF(p,pdata), 2090 space_remaining )); 2053 2091 return false; /* Not finished - just out of space */ 2054 2092 } … … 2245 2283 TALLOC_CTX *ctx = talloc_tos(); 2246 2284 struct dptr_struct *dirptr = NULL; 2247 struct smbd_server_connection *sconn = smbd_server_conn;2285 struct smbd_server_connection *sconn = conn; 2248 2286 2249 2287 if (total_params < 13) { … … 2335 2373 mask_contains_wcard = True; 2336 2374 } 2337 directory = talloc_strdup(talloc_tos(), "./"); 2375 } else { 2376 *p = 0; 2377 } 2378 2379 if (p == NULL || p == directory) { 2380 /* Ensure we don't have a directory name of "". */ 2381 directory = talloc_strdup(talloc_tos(), "."); 2338 2382 if (!directory) { 2339 2383 reply_nterror(req, NT_STATUS_NO_MEMORY); 2340 2384 goto out; 2341 2385 } 2342 } else {2343 *p = 0;2344 2386 } 2345 2387 … … 2396 2438 2397 2439 ntstatus = dptr_create(conn, 2440 2398 2441 directory, 2399 2442 False, … … 2584 2627 TALLOC_CTX *ctx = talloc_tos(); 2585 2628 struct dptr_struct *dirptr; 2586 struct smbd_server_connection *sconn = smbd_server_conn;2629 struct smbd_server_connection *sconn = conn; 2587 2630 2588 2631 if (total_params < 13) { … … 2879 2922 #endif 2880 2923 extended_info->samba_gitcommitdate = 0; 2881 #ifdef SAMBA_VERSION_ GIT_COMMIT_TIME2882 unix_to_nt_time(&extended_info->samba_gitcommitdate, SAMBA_VERSION_ GIT_COMMIT_TIME);2924 #ifdef SAMBA_VERSION_COMMIT_TIME 2925 unix_to_nt_time(&extended_info->samba_gitcommitdate, SAMBA_VERSION_COMMIT_TIME); 2883 2926 #endif 2884 2927 … … 3130 3173 case SMB_QUERY_FS_DEVICE_INFO: 3131 3174 case SMB_FS_DEVICE_INFORMATION: 3175 3176 3177 3178 3179 3180 3132 3181 data_len = 8; 3133 SIVAL(pdata,0,0); /* dev type */ 3134 SIVAL(pdata,4,0); /* characteristics */ 3135 break; 3182 SIVAL(pdata,0,FILE_DEVICE_DISK); /* dev type */ 3183 SIVAL(pdata,4,characteristics); 3184 break; 3185 } 3136 3186 3137 3187 #ifdef HAVE_SYS_QUOTAS … … 3170 3220 3171 3221 /* access check */ 3172 if (conn->server_info->utok.uid != sec_initial_uid() && 3173 !conn->admin_user) { 3222 if (get_current_uid(conn) != 0) { 3174 3223 DEBUG(0,("set_user_quota: access_denied " 3175 3224 "service [%s] user [%s]\n", 3176 3225 lp_servicename(SNUM(conn)), 3177 conn->se rver_info->unix_name));3226 conn->se_info->unix_name)); 3178 3227 return NT_STATUS_ACCESS_DENIED; 3179 3228 } … … 3233 3282 { 3234 3283 bool large_write = lp_min_receive_file_size() && 3235 !srv_is_signing_active( smbd_server_conn);3236 bool large_read = !srv_is_signing_active( smbd_server_conn);3284 !srv_is_signing_active(conn); 3285 bool large_read = !srv_is_signing_active(conn); 3237 3286 int encrypt_caps = 0; 3238 3287 … … 3328 3377 */ 3329 3378 if (nt_token_check_sid(&global_sid_Builtin_Guests, 3330 conn->se rver_info->ptok)) {3379 conn->se)) { 3331 3380 flags |= SMB_WHOAMI_GUEST; 3332 3381 } … … 3336 3385 */ 3337 3386 if (nt_token_check_sid(&global_sid_Authenticated_Users, 3338 conn->se rver_info->ptok)) {3387 conn->se)) { 3339 3388 flags &= ~SMB_WHOAMI_GUEST; 3340 3389 } … … 3352 3401 + 4 /* SID bytes */ 3353 3402 + 4 /* pad/reserved */ 3354 + (conn->se rver_info->utok.ngroups * 8)3403 + (conn->se_info->utok.ngroups * 8) 3355 3404 /* groups list */ 3356 + (conn->se rver_info->ptok->num_sids *3405 + (conn->se->num_sids * 3357 3406 SID_MAX_SIZE) 3358 3407 /* SID list */; … … 3361 3410 SIVAL(pdata, 4, SMB_WHOAMI_MASK); 3362 3411 SBIG_UINT(pdata, 8, 3363 (uint64_t)conn->se rver_info->utok.uid);3412 (uint64_t)conn->se_info->utok.uid); 3364 3413 SBIG_UINT(pdata, 16, 3365 (uint64_t)conn->se rver_info->utok.gid);3414 (uint64_t)conn->se_info->utok.gid); 3366 3415 3367 3416 … … 3378 3427 } 3379 3428 3380 SIVAL(pdata, 24, conn->se rver_info->utok.ngroups);3381 SIVAL(pdata, 28, conn->se rver_info->num_sids);3429 SIVAL(pdata, 24, conn->se_info->utok.ngroups); 3430 SIVAL(pdata, 28, conn->se->num_sids); 3382 3431 3383 3432 /* We walk the SID list twice, but this call is fairly … … 3386 3435 */ 3387 3436 for (i = 0, sid_bytes = 0; 3388 i < conn->se rver_info->ptok->num_sids; ++i) {3437 i < conn->se->num_sids; ++i) { 3389 3438 sid_bytes += ndr_size_dom_sid( 3390 &conn->server_info->ptok->user_sids[i], 3391 NULL, 3439 &conn->session_info->security_token->sids[i], 3392 3440 0); 3393 3441 } … … 3401 3449 3402 3450 /* GID list */ 3403 for (i = 0; i < conn->se rver_info->utok.ngroups; ++i) {3451 for (i = 0; i < conn->se_info->utok.ngroups; ++i) { 3404 3452 SBIG_UINT(pdata, data_len, 3405 (uint64_t)conn->se rver_info->utok.groups[i]);3453 (uint64_t)conn->se_info->utok.groups[i]); 3406 3454 data_len += 8; 3407 3455 } … … 3409 3457 /* SID list */ 3410 3458 for (i = 0; 3411 i < conn->se rver_info->ptok->num_sids; ++i) {3459 i < conn->se->num_sids; ++i) { 3412 3460 int sid_len = ndr_size_dom_sid( 3413 &conn->server_info->ptok->user_sids[i], 3414 NULL, 3461 &conn->session_info->security_token->sids[i], 3415 3462 0); 3416 3463 3417 3464 sid_linearize(pdata + data_len, sid_len, 3418 &conn->se rver_info->ptok->user_sids[i]);3465 &conn->sesids[i]); 3419 3466 data_len += sid_len; 3420 3467 } … … 3615 3662 } 3616 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3617 3674 DEBUG( 4,("call_trans2setfsinfo: " 3618 3675 "request transport encryption.\n")); … … 3658 3715 3659 3716 /* access check */ 3660 if (((conn->server_info->utok.uid != sec_initial_uid()) && !conn->admin_user) 3661 ||!CAN_WRITE(conn)) { 3717 if ((get_current_uid(conn) != 0) || !CAN_WRITE(conn)) { 3662 3718 DEBUG(0,("set_user_quota: access_denied service [%s] user [%s]\n", 3663 3719 lp_servicename(SNUM(conn)), 3664 conn->se rver_info->unix_name));3720 conn->se_info->unix_name)); 3665 3721 reply_nterror(req, NT_STATUS_ACCESS_DENIED); 3666 3722 return; … … 3693 3749 3694 3750 /* the soft quotas 8 bytes (uint64_t)*/ 3695 quotas.softlim = (uint64_t)IVAL(pdata,24); 3696 #ifdef LARGE_SMB_OFF_T 3697 quotas.softlim |= (((uint64_t)IVAL(pdata,28)) << 32); 3698 #else /* LARGE_SMB_OFF_T */ 3699 if ((IVAL(pdata,28) != 0)&& 3700 ((quotas.softlim != 0xFFFFFFFF)|| 3701 (IVAL(pdata,28)!=0xFFFFFFFF))) { 3702 /* more than 32 bits? */ 3703 reply_nterror( 3704 req, 3705 NT_STATUS_INVALID_PARAMETER); 3706 return; 3707 } 3708 #endif /* LARGE_SMB_OFF_T */ 3751 quotas.softlim = BVAL(pdata,24); 3709 3752 3710 3753 /* the hard quotas 8 bytes (uint64_t)*/ 3711 quotas.hardlim = (uint64_t)IVAL(pdata,32); 3712 #ifdef LARGE_SMB_OFF_T 3713 quotas.hardlim |= (((uint64_t)IVAL(pdata,36)) << 32); 3714 #else /* LARGE_SMB_OFF_T */ 3715 if ((IVAL(pdata,36) != 0)&& 3716 ((quotas.hardlim != 0xFFFFFFFF)|| 3717 (IVAL(pdata,36)!=0xFFFFFFFF))) { 3718 /* more than 32 bits? */ 3719 reply_nterror( 3720 req, 3721 NT_STATUS_INVALID_PARAMETER); 3722 return; 3723 } 3724 #endif /* LARGE_SMB_OFF_T */ 3754 quotas.hardlim = BVAL(pdata,32); 3725 3755 3726 3756 /* quota_flags 2 bytes **/ … … 4176 4206 bool delete_pending, 4177 4207 struct timespec write_time_ts, 4178 bool ms_dfs_link,4179 4208 struct ea_list *ea_list, 4180 4209 int lock_data_count, … … 4211 4240 info_level, max_data_bytes)); 4212 4241 4213 if (ms_dfs_link) { 4214 mode = dos_mode_msdfs(conn, smb_fname); 4215 } else { 4216 mode = dos_mode(conn, smb_fname); 4217 } 4218 4242 mode = dos_mode(conn, smb_fname); 4219 4243 nlink = psbuf->st_ex_nlink; 4220 4244 4221 if (nlink && (mode& aDIR)) {4245 if (nlink && (mode&)) { 4222 4246 nlink = 1; 4223 4247 } … … 4294 4318 files_struct *fsp1; 4295 4319 struct file_id fileid = vfs_file_id_from_sbuf(conn, psbuf); 4296 fsp1 = file_find_di_first( fileid);4320 fsp1 = file_find_di_first(fileid); 4297 4321 if (fsp1 && fsp1->initial_allocation_size) { 4298 4322 allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn, fsp1, psbuf); … … 4300 4324 } 4301 4325 4302 if (!(mode & aDIR)) {4326 if (!(mode & )) { 4303 4327 file_size = get_file_size_stat(psbuf); 4304 4328 } … … 4470 4494 SIVAL(pdata,16,nlink); 4471 4495 SCVAL(pdata,20,delete_pending?1:0); 4472 SCVAL(pdata,21,(mode& aDIR)?1:0);4496 SCVAL(pdata,21,(mode&)?1:0); 4473 4497 SSVAL(pdata,22,0); /* Padding. */ 4474 4498 break; … … 4553 4577 SIVAL(pdata,16,nlink); 4554 4578 SCVAL(pdata,20,delete_pending); 4555 SCVAL(pdata,21,(mode& aDIR)?1:0);4579 SCVAL(pdata,21,(mode&)?1:0); 4556 4580 SSVAL(pdata,22,0); 4557 4581 pdata += 24; … … 4584 4608 SIVAL(pdata, 0x38, nlink); 4585 4609 SCVAL(pdata, 0x3C, delete_pending); 4586 SCVAL(pdata, 0x3D, (mode& aDIR)?1:0);4610 SCVAL(pdata, 0x3D, (mode&)?1:0); 4587 4611 SSVAL(pdata, 0x3E, 0); /* padding */ 4588 4612 SBVAL(pdata, 0x40, file_index); … … 4734 4758 data_size = PTR_DIFF(pdata,(*ppdata)); 4735 4759 4736 { 4737 int i; 4738 DEBUG(4,("smbd_do_qfilepathinfo: SMB_QUERY_FILE_UNIX_BASIC ")); 4739 4740 for (i=0; i<100; i++) 4741 DEBUG(4,("%d=%x, ",i, (*ppdata)[i])); 4742 DEBUG(4,("\n")); 4743 } 4760 DEBUG(4,("smbd_do_qfilepathinfo: " 4761 "SMB_QUERY_FILE_UNIX_BASIC\n")); 4762 dump_data(4, (uint8_t *)(*ppdata), data_size); 4744 4763 4745 4764 break; … … 4803 4822 uint16 num_def_acls = 0; 4804 4823 4805 if (fsp && !fsp->is_directory && (fsp->fh->fd != -1)) {4824 if (fsp && ) { 4806 4825 file_acl = SMB_VFS_SYS_ACL_GET_FD(fsp); 4807 4826 } else { … … 4892 4911 uint64_t count; 4893 4912 uint64_t offset; 4894 uint 32 lock_pid;4913 uint; 4895 4914 enum brl_type lock_type; 4896 4915 4897 4916 /* We need an open file with a real fd for this. */ 4898 if (!fsp || fsp-> is_directory || fsp->fh->fd == -1) {4917 if (!fsp || fsp->fh->fd == -1) { 4899 4918 return NT_STATUS_INVALID_LEVEL; 4900 4919 } … … 4917 4936 } 4918 4937 4919 lock_pid =IVAL(pdata, POSIX_LOCK_PID_OFFSET);4938 IVAL(pdata, POSIX_LOCK_PID_OFFSET); 4920 4939 #if defined(HAVE_LONGLONG) 4921 4940 offset = (((uint64_t) IVAL(pdata,(POSIX_LOCK_START_OFFSET+4))) << 32) | … … 4929 4948 4930 4949 status = query_lock(fsp, 4931 & lock_pid,4950 &, 4932 4951 &count, 4933 4952 &offset, … … 4941 4960 SSVAL(pdata, POSIX_LOCK_TYPE_OFFSET, lock_type); 4942 4961 SSVAL(pdata, POSIX_LOCK_FLAGS_OFFSET, 0); 4943 SIVAL(pdata, POSIX_LOCK_PID_OFFSET, lock_pid);4962 SIVAL(pdata, POSIX_LOCK_PID_OFFSET, ); 4944 4963 #if defined(HAVE_LONGLONG) 4945 4964 SIVAL(pdata, POSIX_LOCK_START_OFFSET, (uint32)(offset & 0xFFFFFFFF)); … … 4997 5016 int lock_data_count = 0; 4998 5017 char *lock_data = NULL; 4999 bool ms_dfs_link = false;5000 5018 NTSTATUS status = NT_STATUS_OK; 5001 5019 … … 5050 5068 /* We know this name is ok, it's already passed the checks. */ 5051 5069 5052 } else if(fsp-> is_directory || fsp->fh->fd == -1) {5070 } else if(fsp->fh->fd == -1) { 5053 5071 /* 5054 5072 * This is actually a QFILEINFO on a directory … … 5080 5098 5081 5099 fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st); 5082 get_file_infos(fileid, &delete_pending, &write_time_ts);5100 get_file_infos(fileid, &delete_pending, &write_time_ts); 5083 5101 } else { 5084 5102 /* 5085 5103 * Original code - this is an open file. 5086 5104 */ 5087 if (!check_fsp(conn, req, fsp)) {5088 return;5089 }5090 5091 5105 if (SMB_VFS_FSTAT(fsp, &smb_fname->st) != 0) { 5092 5106 DEBUG(3, ("fstat of fnum %d failed (%s)\n", … … 5097 5111 } 5098 5112 fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st); 5099 get_file_infos(fileid, &delete_pending, &write_time_ts);5113 get_file_infos(fileid, &delete_pending, &write_time_ts); 5100 5114 } 5101 5115 5102 5116 } else { 5117 5103 5118 char *fname = NULL; 5104 5119 … … 5187 5202 } 5188 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5189 5213 fileid = vfs_file_id_from_sbuf(conn, 5190 5214 &smb_fname_base->st); 5191 5215 TALLOC_FREE(smb_fname_base); 5192 get_file_infos(fileid, &delete_pending, NULL);5216 get_file_infos(fileid, &delete_pending, NULL); 5193 5217 if (delete_pending) { 5194 5218 reply_nterror(req, NT_STATUS_DELETE_PENDING); … … 5209 5233 } 5210 5234 5211 } else if (!VALID_STAT(smb_fname->st) && 5212 SMB_VFS_STAT(conn, smb_fname) && 5213 (info_level != SMB_INFO_IS_NAME_VALID)) { 5214 ms_dfs_link = check_msdfs_link(conn, 5215 smb_fname->base_name, 5216 &smb_fname->st); 5217 5218 if (!ms_dfs_link) { 5235 } else { 5236 if (SMB_VFS_STAT(conn, smb_fname) != 0) { 5219 5237 DEBUG(3,("call_trans2qfilepathinfo: " 5220 5238 "SMB_VFS_STAT of %s failed (%s)\n", … … 5227 5245 } 5228 5246 5247 5248 5249 5250 5251 5252 5253 5254 5229 5255 fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st); 5230 get_file_infos(fileid, &delete_pending, &write_time_ts);5256 get_file_infos(fileid, &delete_pending, &write_time_ts); 5231 5257 if (delete_pending) { 5232 5258 reply_nterror(req, NT_STATUS_DELETE_PENDING); … … 5340 5366 fsp, smb_fname, 5341 5367 delete_pending, write_time_ts, 5342 ms_dfs_link,ea_list,5368 ea_list, 5343 5369 lock_data_count, lock_data, 5344 5370 req->flags2, max_data_bytes, … … 5362 5388 NTSTATUS hardlink_internals(TALLOC_CTX *ctx, 5363 5389 connection_struct *conn, 5390 5391 5364 5392 const struct smb_filename *smb_fname_old, 5365 conststruct smb_filename *smb_fname_new)5393 struct smb_filename *smb_fname_new) 5366 5394 { 5367 5395 NTSTATUS status = NT_STATUS_OK; … … 5372 5400 } 5373 5401 5374 /* Disallow if newname already exists. */5375 5402 if (VALID_STAT(smb_fname_new->st)) { 5376 return NT_STATUS_OBJECT_NAME_COLLISION; 5403 if (overwrite_if_exists) { 5404 if (S_ISDIR(smb_fname_new->st.st_ex_mode)) { 5405 return NT_STATUS_FILE_IS_A_DIRECTORY; 5406 } 5407 status = unlink_internals(conn, 5408 req, 5409 FILE_ATTRIBUTE_NORMAL, 5410 smb_fname_new, 5411 false); 5412 if (!NT_STATUS_IS_OK(status)) { 5413 return status; 5414 } 5415 } else { 5416 /* Disallow if newname already exists. */ 5417 return NT_STATUS_OBJECT_NAME_COLLISION; 5418 } 5377 5419 } 5378 5420 … … 5421 5463 } 5422 5464 5465 5466 5467 5468 5423 5469 /* get some defaults (no modifications) if any info is zero or -1. */ 5424 5470 if (null_timespec(ft->create_time)) { … … 5533 5579 if (dosmode) { 5534 5580 if (S_ISDIR(smb_fname_base->st.st_ex_mode)) { 5535 dosmode |= aDIR;5581 dosmode |= ; 5536 5582 } else { 5537 dosmode &= ~ aDIR;5583 dosmode &= ~; 5538 5584 } 5539 5585 } … … 5583 5629 } 5584 5630 5631 5632 5633 5634 5585 5635 DEBUG(6,("smb_set_file_size: size: %.0f ", (double)size)); 5586 5636 … … 5613 5663 0, /* root_dir_fid */ 5614 5664 smb_fname_tmp, /* fname */ 5615 FILE_WRITE_ ATTRIBUTES, /* access_mask */5665 FILE_WRITE_, /* access_mask */ 5616 5666 (FILE_SHARE_READ | FILE_SHARE_WRITE | /* share_access */ 5617 5667 FILE_SHARE_DELETE), … … 5621 5671 FORCE_OPLOCK_BREAK_TO_NONE, /* oplock_request */ 5622 5672 0, /* allocation_size */ 5673 5623 5674 NULL, /* sd */ 5624 5675 NULL, /* ea_list */ … … 5688 5739 return NT_STATUS_INVALID_PARAMETER; 5689 5740 } 5741 5742 5743 5744 5745 5690 5746 status = set_ea(conn, fsp, smb_fname, ea_list); 5691 5747 … … 5730 5786 return NT_STATUS_INVALID_PARAMETER; 5731 5787 } 5788 5789 5790 5791 5792 5732 5793 status = set_ea(conn, fsp, fsp->fsp_name, ea_list); 5733 5794 … … 5780 5841 /* The set is across all open files on this dev/inode pair. */ 5781 5842 if (!set_delete_on_close(fsp, delete_on_close, 5782 &conn->se rver_info->utok)) {5843 &conn->se_info->utok)) { 5783 5844 return NT_STATUS_ACCESS_DENIED; 5784 5845 } … … 5892 5953 struct smb_request *req, 5893 5954 const char *pdata, int total_data, 5894 conststruct smb_filename *smb_fname_new)5955 struct smb_filename *smb_fname_new) 5895 5956 { 5896 5957 char *oldname = NULL; … … 5924 5985 } 5925 5986 5926 return hardlink_internals(ctx, conn, smb_fname_old, smb_fname_new); 5987 return hardlink_internals(ctx, conn, req, false, 5988 smb_fname_old, smb_fname_new); 5989 } 5990 5991 /**************************************************************************** 5992 Deal with SMB2_FILE_RENAME_INFORMATION_INTERNAL 5993 ****************************************************************************/ 5994 5995 static NTSTATUS smb2_file_rename_information(connection_struct *conn, 5996 struct smb_request *req, 5997 const char *pdata, 5998 int total_data, 5999 files_struct *fsp, 6000 struct smb_filename *smb_fname_src) 6001 { 6002 bool overwrite; 6003 uint32_t len; 6004 char *newname = NULL; 6005 struct smb_filename *smb_fname_dst = NULL; 6006 NTSTATUS status = NT_STATUS_OK; 6007 TALLOC_CTX *ctx = talloc_tos(); 6008 6009 if (!fsp) { 6010 return NT_STATUS_INVALID_HANDLE; 6011 } 6012 6013 if (total_data < 20) { 6014 return NT_STATUS_INVALID_PARAMETER; 6015 } 6016 6017 overwrite = (CVAL(pdata,0) ? True : False); 6018 len = IVAL(pdata,16); 6019 6020 if (len > (total_data - 20) || (len == 0)) { 6021 return NT_STATUS_INVALID_PARAMETER; 6022 } 6023 6024 srvstr_get_path(ctx, pdata, req->flags2, &newname, 6025 &pdata[20], len, STR_TERMINATE, 6026 &status); 6027 if (!NT_STATUS_IS_OK(status)) { 6028 return status; 6029 } 6030 6031 DEBUG(10,("smb2_file_rename_information: got name |%s|\n", 6032 newname)); 6033 6034 status = filename_convert(ctx, 6035 conn, 6036 req->flags2 & FLAGS2_DFS_PATHNAMES, 6037 newname, 6038 UCF_SAVE_LCOMP, 6039 NULL, 6040 &smb_fname_dst); 6041 if (!NT_STATUS_IS_OK(status)) { 6042 return status; 6043 } 6044 6045 if (fsp->base_fsp) { 6046 /* newname must be a stream name. */ 6047 if (newname[0] != ':') { 6048 return NT_STATUS_NOT_SUPPORTED; 6049 } 6050 6051 /* Create an smb_fname to call rename_internals_fsp() with. */ 6052 status = create_synthetic_smb_fname(talloc_tos(), 6053 fsp->base_fsp->fsp_name->base_name, newname, NULL, 6054 &smb_fname_dst); 6055 if (!NT_STATUS_IS_OK(status)) { 6056 goto out; 6057 } 6058 6059 /* 6060 * Set the original last component, since 6061 * rename_internals_fsp() requires it. 6062 */ 6063 smb_fname_dst->original_lcomp = talloc_strdup(smb_fname_dst, 6064 newname); 6065 if (smb_fname_dst->original_lcomp == NULL) { 6066 status = NT_STATUS_NO_MEMORY; 6067 goto out; 6068 } 6069 6070 } 6071 6072 DEBUG(10,("smb2_file_rename_information: " 6073 "SMB_FILE_RENAME_INFORMATION (fnum %d) %s -> %s\n", 6074 fsp->fnum, fsp_str_dbg(fsp), 6075 smb_fname_str_dbg(smb_fname_dst))); 6076 status = rename_internals_fsp(conn, fsp, smb_fname_dst, 6077 (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM), 6078 overwrite); 6079 6080 out: 6081 TALLOC_FREE(smb_fname_dst); 6082 return status; 6083 } 6084 6085 static NTSTATUS smb_file_link_information(connection_struct *conn, 6086 struct smb_request *req, 6087 const char *pdata, 6088 int total_data, 6089 files_struct *fsp, 6090 struct smb_filename *smb_fname_src) 6091 { 6092 bool overwrite; 6093 uint32_t len; 6094 char *newname = NULL; 6095 struct smb_filename *smb_fname_dst = NULL; 6096 NTSTATUS status = NT_STATUS_OK; 6097 TALLOC_CTX *ctx = talloc_tos(); 6098 6099 if (!fsp) { 6100 return NT_STATUS_INVALID_HANDLE; 6101 } 6102 6103 if (total_data < 20) { 6104 return NT_STATUS_INVALID_PARAMETER; 6105 } 6106 6107 overwrite = (CVAL(pdata,0) ? true : false); 6108 len = IVAL(pdata,16); 6109 6110 if (len > (total_data - 20) || (len == 0)) { 6111 return NT_STATUS_INVALID_PARAMETER; 6112 } 6113 6114 srvstr_get_path(ctx, pdata, req->flags2, &newname, 6115 &pdata[20], len, STR_TERMINATE, 6116 &status); 6117 if (!NT_STATUS_IS_OK(status)) { 6118 return status; 6119 } 6120 6121 DEBUG(10,("smb_file_link_information: got name |%s|\n", 6122 newname)); 6123 6124 status = filename_convert(ctx, 6125 conn, 6126 req->flags2 & FLAGS2_DFS_PATHNAMES, 6127 newname, 6128 UCF_SAVE_LCOMP, 6129 NULL, 6130 &smb_fname_dst); 6131 if (!NT_STATUS_IS_OK(status)) { 6132 return status; 6133 } 6134 6135 if (fsp->base_fsp) { 6136 /* No stream names. */ 6137 return NT_STATUS_NOT_SUPPORTED; 6138 } 6139 6140 DEBUG(10,("smb_file_link_information: " 6141 "SMB_FILE_LINK_INFORMATION (fnum %d) %s -> %s\n", 6142 fsp->fnum, fsp_str_dbg(fsp), 6143 smb_fname_str_dbg(smb_fname_dst))); 6144 status = hardlink_internals(ctx, 6145 conn, 6146 req, 6147 overwrite, 6148 fsp->fsp_name, 6149 smb_fname_dst); 6150 6151 TALLOC_FREE(smb_fname_dst); 6152 return status; 5927 6153 } 5928 6154 … … 6035 6261 p[1] = '\0'; 6036 6262 } else { 6037 base_name = talloc_strdup(ctx, " ./");6263 base_name = talloc_strdup(ctx, ""); 6038 6264 if (!base_name) { 6039 6265 return NT_STATUS_NO_MEMORY; … … 6171 6397 uint64_t count; 6172 6398 uint64_t offset; 6173 uint 32 lock_pid;6399 uint; 6174 6400 bool blocking_lock = False; 6175 6401 enum brl_type lock_type; … … 6215 6441 } 6216 6442 6217 lock_pid =IVAL(pdata, POSIX_LOCK_PID_OFFSET);6443 IVAL(pdata, POSIX_LOCK_PID_OFFSET); 6218 6444 #if defined(HAVE_LONGLONG) 6219 6445 offset = (((uint64_t) IVAL(pdata,(POSIX_LOCK_START_OFFSET+4))) << 32) | … … 6227 6453 6228 6454 DEBUG(10,("smb_set_posix_lock: file %s, lock_type = %u," 6229 " lock_pid = %u, count = %.0f, offset = %.0f\n",6455 "u, count = %.0f, offset = %.0f\n", 6230 6456 fsp_str_dbg(fsp), 6231 6457 (unsigned int)lock_type, 6232 (unsigned int)lock_pid,6458 (unsigned , 6233 6459 (double)count, 6234 6460 (double)offset )); 6235 6461 6236 6462 if (lock_type == UNLOCK_LOCK) { 6237 status = do_unlock( smbd_messaging_context(),6463 status = do_unlock(, 6238 6464 fsp, 6239 lock_pid,6465 , 6240 6466 count, 6241 6467 offset, 6242 6468 POSIX_LOCK); 6243 6469 } else { 6244 uint 32 block_smbpid;6245 6246 struct byte_range_lock *br_lck = do_lock( smbd_messaging_context(),6470 uint; 6471 6472 struct byte_range_lock *br_lck = do_lock(, 6247 6473 fsp, 6248 lock_pid,6474 , 6249 6475 count, 6250 6476 offset, … … 6253 6479 blocking_lock, 6254 6480 &status, 6255 &block_smb pid,6481 &block_smb, 6256 6482 NULL); 6257 6483 … … 6267 6493 -1, /* infinite timeout. */ 6268 6494 0, 6269 lock_pid,6495 , 6270 6496 lock_type, 6271 6497 POSIX_LOCK, 6272 6498 offset, 6273 6499 count, 6274 block_smb pid)) {6500 block_smb)) { 6275 6501 TALLOC_FREE(br_lck); 6276 6502 return status; … … 6304 6530 } 6305 6531 6532 6533 6534 6535 6306 6536 /* Set the attributes */ 6307 6537 dosmode = IVAL(pdata,32); … … 6346 6576 if (total_data < 12) { 6347 6577 return NT_STATUS_INVALID_PARAMETER; 6578 6579 6580 6581 6348 6582 } 6349 6583 … … 6404 6638 if (allocation_size) { 6405 6639 allocation_size = smb_roundup(conn, allocation_size); 6640 6641 6642 6643 6406 6644 } 6407 6645 … … 6441 6679 FORCE_OPLOCK_BREAK_TO_NONE, /* oplock_request */ 6442 6680 0, /* allocation_size */ 6681 6443 6682 NULL, /* sd */ 6444 6683 NULL, /* ea_list */ … … 6501 6740 "file %s to %.0f\n", smb_fname_str_dbg(smb_fname), 6502 6741 (double)size)); 6742 6743 6744 6745 6503 6746 6504 6747 return smb_set_file_size(conn, req, … … 6806 7049 6807 7050 id = vfs_file_id_from_sbuf(conn, &sbuf); 6808 for(all_fsps = file_find_di_first( id); all_fsps;7051 for(all_fsps = file_find_di_first(id); all_fsps; 6809 7052 all_fsps = file_find_di_next(all_fsps)) { 6810 7053 /* … … 6950 7193 0, /* oplock_request */ 6951 7194 0, /* allocation_size */ 7195 6952 7196 NULL, /* sd */ 6953 7197 NULL, /* ea_list */ … … 7006 7250 Open/Create a file with POSIX semantics. 7007 7251 ****************************************************************************/ 7252 7253 7254 7008 7255 7009 7256 static NTSTATUS smb_posix_open(connection_struct *conn, … … 7022 7269 uint32 create_disp = 0; 7023 7270 uint32 access_mask = 0; 7024 uint32 create_options = 0;7271 uint32 create_options = ; 7025 7272 NTSTATUS status = NT_STATUS_OK; 7026 7273 mode_t unixmode = (mode_t)0; … … 7052 7299 switch (wire_open_mode & SMB_ACCMODE) { 7053 7300 case SMB_O_RDONLY: 7054 access_mask = FILE_READ_DATA;7301 access_mask = ; 7055 7302 break; 7056 7303 case SMB_O_WRONLY: 7057 access_mask = FILE_WRITE_DATA;7304 access_mask = ; 7058 7305 break; 7059 7306 case SMB_O_RDWR: 7060 access_mask = FILE_READ_DATA|FILE_WRITE_DATA; 7307 access_mask = (SMB_O_RDONLY_MAPPING| 7308 SMB_O_WRONLY_MAPPING); 7061 7309 break; 7062 7310 default: … … 7143 7391 } 7144 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7145 7402 DEBUG(10,("smb_posix_open: file %s, smb_posix_flags = %u, mode 0%o\n", 7146 7403 smb_fname_str_dbg(smb_fname), … … 7157 7414 FILE_SHARE_DELETE), 7158 7415 create_disp, /* create_disposition*/ 7159 FILE_NON_DIRECTORY_FILE,/* create_options */7416 /* create_options */ 7160 7417 mod_unixmode, /* file_attributes */ 7161 7418 oplock_request, /* oplock_request */ 7162 7419 0, /* allocation_size */ 7420 7163 7421 NULL, /* sd */ 7164 7422 NULL, /* ea_list */ … … 7290 7548 0, /* oplock_request */ 7291 7549 0, /* allocation_size */ 7550 7292 7551 NULL, /* sd */ 7293 7552 NULL, /* ea_list */ … … 7550 7809 pdata, total_data, 7551 7810 fsp, smb_fname); 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7552 7828 break; 7553 7829 } … … 7660 7936 } 7661 7937 7662 if(fsp-> is_directory || fsp->fh->fd == -1) {7938 if(fsp->fh->fd == -1) { 7663 7939 /* 7664 7940 * This is actually a SETFILEINFO on a directory … … 7692 7968 */ 7693 7969 if ((info_level == SMB_SET_FILE_DISPOSITION_INFO) && CVAL(pdata,0)) { 7694 fsp->fh->private_options |= FILE_DELETE_ON_CLOSE;7970 fsp->fh->private_options |= E_DELETE_ON_CLOSE; 7695 7971 7696 7972 DEBUG(3,("call_trans2setfilepathinfo: " … … 7712 7988 * Original code - this is an open file. 7713 7989 */ 7714 if (!check_fsp(conn, req, fsp)) {7715 return;7716 }7717 7718 7990 if (SMB_VFS_FSTAT(fsp, &smb_fname->st) != 0) { 7719 7991 DEBUG(3,("call_trans2setfilepathinfo: fstat " … … 7803 8075 return; 7804 8076 } 7805 if (blocking_lock_was_deferred (req->mid)) {8077 if (blocking_lock_was_deferredreq->mid)) { 7806 8078 /* We have re-scheduled this call. */ 7807 8079 return; … … 8122 8394 CAN ACCEPT THIS IN UNICODE. JRA. */ 8123 8395 8124 SSVAL(pdata,0,fsp->rap_print_jobid); /* Job number */ 8396 /* Job number */ 8397 if (fsp->print_file) { 8398 SSVAL(pdata, 0, fsp->print_file->rap_jobid); 8399 } else { 8400 SSVAL(pdata, 0, 0); 8401 } 8125 8402 srvstr_push(pdata, req->flags2, pdata + 2, 8126 8403 global_myname(), 15, … … 8145 8422 { 8146 8423 int dptr_num; 8147 struct smbd_server_connection *sconn = smbd_server_conn;8424 struct smbd_server_connection *sconn = conn; 8148 8425 8149 8426 START_PROFILE(SMBfindclose);
Note:
See TracChangeset
for help on using the changeset viewer.
