Changeset 862 for trunk/server/source3/smbd/reply.c
- Timestamp:
- May 13, 2014, 11:39:04 AM (11 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 860
- Property svn:mergeinfo changed
-
trunk/server/source3/smbd/reply.c
r751 r862 1749 1749 } 1750 1750 1751 if (!map_open_params_to_ntcreate(fname, deny_mode, 1752 OPENX_FILE_EXISTS_OPEN, &access_mask, 1753 &share_mode, &create_disposition, 1754 &create_options, &private_flags)) { 1755 reply_force_doserror(req, ERRDOS, ERRbadaccess); 1756 goto out; 1757 } 1758 1751 1759 status = filename_convert(ctx, 1752 1760 conn, 1753 1761 req->flags2 & FLAGS2_DFS_PATHNAMES, 1754 1762 fname, 1755 0, 1763 (create_disposition == FILE_CREATE) 1764 ? UCF_CREATING_FILE : 0, 1756 1765 NULL, 1757 1766 &smb_fname); … … 1764 1773 } 1765 1774 reply_nterror(req, status); 1766 goto out;1767 }1768 1769 if (!map_open_params_to_ntcreate(smb_fname->base_name, deny_mode,1770 OPENX_FILE_EXISTS_OPEN, &access_mask,1771 &share_mode, &create_disposition,1772 &create_options, &private_flags)) {1773 reply_force_doserror(req, ERRDOS, ERRbadaccess);1774 1775 goto out; 1775 1776 } … … 1924 1925 } 1925 1926 1927 if (!map_open_params_to_ntcreate(fname, deny_mode, 1928 smb_ofun, 1929 &access_mask, &share_mode, 1930 &create_disposition, 1931 &create_options, 1932 &private_flags)) { 1933 reply_force_doserror(req, ERRDOS, ERRbadaccess); 1934 goto out; 1935 } 1936 1926 1937 status = filename_convert(ctx, 1927 1938 conn, 1928 1939 req->flags2 & FLAGS2_DFS_PATHNAMES, 1929 1940 fname, 1930 0, 1941 (create_disposition == FILE_CREATE) 1942 ? UCF_CREATING_FILE : 0, 1931 1943 NULL, 1932 1944 &smb_fname); … … 1939 1951 } 1940 1952 reply_nterror(req, status); 1941 goto out;1942 }1943 1944 if (!map_open_params_to_ntcreate(smb_fname->base_name, deny_mode,1945 smb_ofun,1946 &access_mask, &share_mode,1947 &create_disposition,1948 &create_options,1949 &private_flags)) {1950 reply_force_doserror(req, ERRDOS, ERRbadaccess);1951 1953 goto out; 1952 1954 } … … 2146 2148 req->flags2 & FLAGS2_DFS_PATHNAMES, 2147 2149 fname, 2148 0,2150 UCF_CREATING_FILE, 2149 2151 NULL, 2150 2152 &smb_fname); … … 2240 2242 connection_struct *conn = req->conn; 2241 2243 struct smb_filename *smb_fname = NULL; 2244 char *wire_name = NULL; 2242 2245 char *fname = NULL; 2243 2246 uint32 fattr; 2244 2247 files_struct *fsp; 2245 2248 int oplock_request; 2246 int tmpfd;2247 2249 char *s; 2248 2250 NTSTATUS status; 2251 int i; 2249 2252 TALLOC_CTX *ctx = talloc_tos(); 2250 2253 … … 2259 2262 oplock_request = CORE_OPLOCK_REQUEST(req->inbuf); 2260 2263 2261 srvstr_get_path_req(ctx, req, & fname, (const char *)req->buf+1,2264 srvstr_get_path_req(ctx, req, &wire_name, (const char *)req->buf+1, 2262 2265 STR_TERMINATE, &status); 2263 2266 if (!NT_STATUS_IS_OK(status)) { … … 2265 2268 goto out; 2266 2269 } 2267 if (*fname) { 2268 fname = talloc_asprintf(ctx, 2269 "%s/TMXXXXXX", 2270 fname); 2271 } else { 2272 fname = talloc_strdup(ctx, "TMXXXXXX"); 2273 } 2274 2275 if (!fname) { 2276 reply_nterror(req, NT_STATUS_NO_MEMORY); 2277 goto out; 2278 } 2279 2280 status = filename_convert(ctx, conn, 2270 2271 for (i = 0; i < 10; i++) { 2272 if (*wire_name) { 2273 fname = talloc_asprintf(ctx, 2274 "%s/TMP%s", 2275 wire_name, 2276 generate_random_str_list(ctx, 5, "0123456789")); 2277 } else { 2278 fname = talloc_asprintf(ctx, 2279 "TMP%s", 2280 generate_random_str_list(ctx, 5, "0123456789")); 2281 } 2282 2283 if (!fname) { 2284 reply_nterror(req, NT_STATUS_NO_MEMORY); 2285 goto out; 2286 } 2287 2288 status = filename_convert(ctx, conn, 2281 2289 req->flags2 & FLAGS2_DFS_PATHNAMES, 2282 2290 fname, 2283 0,2291 UCF_CREATING_FILE, 2284 2292 NULL, 2285 2293 &smb_fname); 2286 if (!NT_STATUS_IS_OK(status)) {2287 if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {2288 reply_botherror(req, NT_STATUS_PATH_NOT_COVERED,2294 if (!NT_STATUS_IS_OK(status)) { 2295 if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) { 2296 reply_botherror(req, NT_STATUS_PATH_NOT_COVERED, 2289 2297 ERRSRV, ERRbadpath); 2298 goto out; 2299 } 2300 reply_nterror(req, status); 2290 2301 goto out; 2291 2302 } 2303 2304 /* Create the file. */ 2305 status = SMB_VFS_CREATE_FILE( 2306 conn, /* conn */ 2307 req, /* req */ 2308 0, /* root_dir_fid */ 2309 smb_fname, /* fname */ 2310 FILE_GENERIC_READ | FILE_GENERIC_WRITE, /* access_mask */ 2311 FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */ 2312 FILE_CREATE, /* create_disposition*/ 2313 0, /* create_options */ 2314 fattr, /* file_attributes */ 2315 oplock_request, /* oplock_request */ 2316 0, /* allocation_size */ 2317 0, /* private_flags */ 2318 NULL, /* sd */ 2319 NULL, /* ea_list */ 2320 &fsp, /* result */ 2321 NULL); /* pinfo */ 2322 2323 if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) { 2324 TALLOC_FREE(fname); 2325 TALLOC_FREE(smb_fname); 2326 continue; 2327 } 2328 2329 if (!NT_STATUS_IS_OK(status)) { 2330 if (open_was_deferred(req->mid)) { 2331 /* We have re-scheduled this call. */ 2332 goto out; 2333 } 2334 reply_openerror(req, status); 2335 goto out; 2336 } 2337 2338 break; 2339 } 2340 2341 if (i == 10) { 2342 /* Collision after 10 times... */ 2292 2343 reply_nterror(req, status); 2293 goto out;2294 }2295 2296 tmpfd = mkstemp(smb_fname->base_name);2297 if (tmpfd == -1) {2298 reply_nterror(req, map_nt_error_from_unix(errno));2299 goto out;2300 }2301 2302 SMB_VFS_STAT(conn, smb_fname);2303 2304 /* We should fail if file does not exist. */2305 status = SMB_VFS_CREATE_FILE(2306 conn, /* conn */2307 req, /* req */2308 0, /* root_dir_fid */2309 smb_fname, /* fname */2310 FILE_GENERIC_READ | FILE_GENERIC_WRITE, /* access_mask */2311 FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */2312 FILE_OPEN, /* create_disposition*/2313 0, /* create_options */2314 fattr, /* file_attributes */2315 oplock_request, /* oplock_request */2316 0, /* allocation_size */2317 0, /* private_flags */2318 NULL, /* sd */2319 NULL, /* ea_list */2320 &fsp, /* result */2321 NULL); /* pinfo */2322 2323 /* close fd from mkstemp() */2324 close(tmpfd);2325 2326 if (!NT_STATUS_IS_OK(status)) {2327 if (open_was_deferred(req->mid)) {2328 /* We have re-scheduled this call. */2329 goto out;2330 }2331 reply_openerror(req, status);2332 2344 goto out; 2333 2345 } … … 2370 2382 out: 2371 2383 TALLOC_FREE(smb_fname); 2384 TALLOC_FREE(fname); 2385 TALLOC_FREE(wire_name); 2372 2386 END_PROFILE(SMBctemp); 2373 2387 return; … … 3137 3151 START_PROFILE(SMBreadbraw); 3138 3152 3139 if (srv_is_signing_active(sconn) || 3140 is_encrypted_packet(req->inbuf)) { 3153 if (srv_is_signing_active(sconn) || req->encrypted) { 3141 3154 exit_server_cleanly("reply_readbraw: SMB signing/sealing is active - " 3142 3155 "raw reads/writes are disallowed."); … … 3531 3544 int saved_errno = 0; 3532 3545 3533 if(fsp_stat(fsp) == -1) {3534 reply_nterror(req, map_nt_error_from_unix(errno));3535 return;3536 }3537 3538 3546 init_strict_lock_struct(fsp, (uint64_t)req->smbpid, 3539 3547 (uint64_t)startpos, (uint64_t)smb_maxcnt, READ_LOCK, … … 3543 3551 reply_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT); 3544 3552 return; 3545 }3546 3547 if (!S_ISREG(fsp->fsp_name->st.st_ex_mode) ||3548 (startpos > fsp->fsp_name->st.st_ex_size)3549 || (smb_maxcnt > (fsp->fsp_name->st.st_ex_size - startpos))) {3550 /*3551 * We already know that we would do a short read, so don't3552 * try the sendfile() path.3553 */3554 goto nosendfile_read;3555 3553 } 3556 3554 … … 3562 3560 3563 3561 if (!req_is_in_chain(req) && 3564 ! is_encrypted_packet(req->inbuf)&& (fsp->base_fsp == NULL) &&3562 !req->encrypted && (fsp->base_fsp == NULL) && 3565 3563 (fsp->wcp == NULL) && 3566 3564 lp_use_sendfile(SNUM(conn), req->sconn->smb1.signing_state) ) { 3567 3565 uint8 headerbuf[smb_size + 12 * 2]; 3568 3566 DATA_BLOB header; 3567 3568 if(fsp_stat(fsp) == -1) { 3569 reply_nterror(req, map_nt_error_from_unix(errno)); 3570 goto strict_unlock; 3571 } 3572 3573 if (!S_ISREG(fsp->fsp_name->st.st_ex_mode) || 3574 (startpos > fsp->fsp_name->st.st_ex_size) || 3575 (smb_maxcnt > (fsp->fsp_name->st.st_ex_size - startpos))) { 3576 /* 3577 * We already know that we would do a short read, so don't 3578 * try the sendfile() path. 3579 */ 3580 goto nosendfile_read; 3581 } 3569 3582 3570 3583 /* … … 3766 3779 } 3767 3780 /* We currently don't do this on signed or sealed data. */ 3768 if (srv_is_signing_active(req->sconn) || 3769 is_encrypted_packet(req->inbuf)) { 3781 if (srv_is_signing_active(req->sconn) || req->encrypted) { 3770 3782 reply_nterror(req, NT_STATUS_NOT_SUPPORTED); 3771 3783 END_PROFILE(SMBreadX); … … 5530 5542 req->flags2 & FLAGS2_DFS_PATHNAMES, 5531 5543 directory, 5532 0,5544 UCF_CREATING_FILE, 5533 5545 NULL, 5534 5546 &smb_dname); … … 6195 6207 smb_fname_str_dbg(smb_fname_dst))); 6196 6208 6197 if (!lp_posix_pathnames() && 6209 if (!fsp->is_directory && 6210 !lp_posix_pathnames() && 6198 6211 (lp_map_archive(SNUM(conn)) || 6199 6212 lp_store_dos_attributes(SNUM(conn)))) {
Note:
See TracChangeset
for help on using the changeset viewer.