Changeset 988 for vendor/current/source3/smbd/vfs.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/smbd/vfs.c
r919 r988 28 28 #include "smbd/smbd.h" 29 29 #include "smbd/globals.h" 30 #include " memcache.h"30 #include "../lib/util/memcache.h" 31 31 #include "transfer_file.h" 32 32 #include "ntioctl.h" 33 #include "lib/util/tevent_unix.h" 33 34 34 35 #undef DBGC_CLASS … … 36 37 37 38 static_decl_vfs; 39 40 struct vfs_fsp_data { 41 struct vfs_fsp_data *next; 42 struct vfs_handle_struct *owner; 43 void (*destroy)(void *p_data); 44 void *_dummy_; 45 /* NOTE: This structure contains four pointers so that we can guarantee 46 * that the end of the structure is always both 4-byte and 8-byte aligned. 47 */ 48 }; 38 49 39 50 struct vfs_init_function_entry { … … 168 179 vfs_object)); 169 180 170 status = smb_ probe_module("vfs", module_path);181 status = smb_load_module("vfs", module_path); 171 182 if (!NT_STATUS_IS_OK(status)) { 172 183 DEBUG(0, ("error probing vfs module '%s': %s\n", … … 184 195 DEBUGADD(5,("Successfully loaded vfs module [%s] with the new modules system\n", vfs_object)); 185 196 186 handle = TALLOC_ZERO_P(conn, vfs_handle_struct);197 handle = talloc_zero(conn, vfs_handle_struct); 187 198 if (!handle) { 188 199 DEBUG(0,("TALLOC_ZERO() failed!\n")); … … 212 223 ******************************************************************/ 213 224 214 #define EXT_DATA_AREA(e) ((uint8 *)(e) + sizeof(struct vfs_fsp_data))225 #define EXT_DATA_AREA(e) ((uint8_t *)(e) + sizeof(struct vfs_fsp_data)) 215 226 216 227 void *vfs_add_fsp_extension_notype(vfs_handle_struct *handle, … … 262 273 } 263 274 275 void vfs_remove_all_fsp_extensions(files_struct *fsp) 276 { 277 struct vfs_fsp_data *curr; 278 struct vfs_fsp_data *next; 279 280 for (curr = fsp->vfs_extension; curr; curr = next) { 281 282 next = curr->next; 283 fsp->vfs_extension = next; 284 285 if (curr->destroy) { 286 curr->destroy(EXT_DATA_AREA(curr)); 287 } 288 TALLOC_FREE(curr); 289 } 290 } 291 264 292 void *vfs_memctx_fsp_extension(vfs_handle_struct *handle, files_struct *fsp) 265 293 { … … 301 329 /* Normal share - initialise with disk access functions */ 302 330 vfs_init_default(conn); 331 332 /* No need to load vfs modules for printer connections */ 333 if (conn->printer) { 334 return True; 335 } 336 303 337 vfs_objects = lp_vfs_objects(SNUM(conn)); 304 338 … … 360 394 } 361 395 362 ssize_t vfs_pread_data(files_struct *fsp, char *buf,363 size_t byte_count, SMB_OFF_T offset)364 {365 size_t total=0;366 367 while (total < byte_count)368 {369 ssize_t ret = SMB_VFS_PREAD(fsp, buf + total,370 byte_count - total, offset + total);371 372 if (ret == 0) return total;373 if (ret == -1) {374 if (errno == EINTR)375 continue;376 else377 return -1;378 }379 total += ret;380 }381 return (ssize_t)total;382 }383 384 396 /**************************************************************************** 385 397 Write data to a fd on the vfs. … … 395 407 396 408 if (req && req->unread_bytes) { 409 int sockfd = req->xconn->transport.sock; 410 int old_flags; 397 411 SMB_ASSERT(req->unread_bytes == N); 398 412 /* VFS_RECVFILE must drain the socket 399 413 * before returning. */ 400 414 req->unread_bytes = 0; 401 return SMB_VFS_RECVFILE(req->sconn->sock, 415 /* Ensure the socket is blocking. */ 416 old_flags = fcntl(sockfd, F_GETFL, 0); 417 if (set_blocking(sockfd, true) == -1) { 418 return (ssize_t)-1; 419 } 420 ret = SMB_VFS_RECVFILE(sockfd, 402 421 fsp, 403 ( SMB_OFF_T)-1,422 (off_t)-1, 404 423 N); 424 if (fcntl(sockfd, F_SETFL, old_flags) == -1) { 425 return (ssize_t)-1; 426 } 427 return ret; 405 428 } 406 429 … … 422 445 const char *buffer, 423 446 size_t N, 424 SMB_OFF_Toffset)447 off_t offset) 425 448 { 426 449 size_t total=0; … … 428 451 429 452 if (req && req->unread_bytes) { 453 int sockfd = req->xconn->transport.sock; 430 454 SMB_ASSERT(req->unread_bytes == N); 431 455 /* VFS_RECVFILE must drain the socket 432 456 * before returning. */ 433 457 req->unread_bytes = 0; 434 return SMB_VFS_RECVFILE(req->sconn->sock, 435 fsp, 436 offset, 437 N); 458 /* 459 * Leave the socket non-blocking and 460 * use SMB_VFS_RECVFILE. If it returns 461 * EAGAIN || EWOULDBLOCK temporarily set 462 * the socket blocking and retry 463 * the RECVFILE. 464 */ 465 while (total < N) { 466 ret = SMB_VFS_RECVFILE(sockfd, 467 fsp, 468 offset + total, 469 N - total); 470 if (ret == 0 || (ret == -1 && 471 (errno == EAGAIN || 472 errno == EWOULDBLOCK))) { 473 int old_flags; 474 /* Ensure the socket is blocking. */ 475 old_flags = fcntl(sockfd, F_GETFL, 0); 476 if (set_blocking(sockfd, true) == -1) { 477 return (ssize_t)-1; 478 } 479 ret = SMB_VFS_RECVFILE(sockfd, 480 fsp, 481 offset + total, 482 N - total); 483 if (fcntl(sockfd, F_SETFL, old_flags) == -1) { 484 return (ssize_t)-1; 485 } 486 if (ret == -1) { 487 return (ssize_t)-1; 488 } 489 total += ret; 490 return (ssize_t)total; 491 } 492 /* Any other error case. */ 493 if (ret == -1) { 494 return ret; 495 } 496 total += ret; 497 } 498 return (ssize_t)total; 438 499 } 439 500 … … 472 533 fsp_str_dbg(fsp), (double)len)); 473 534 474 if ((( SMB_OFF_T)len) < 0) {535 if (((off_t)len) < 0) { 475 536 DEBUG(0,("vfs_allocate_file_space: %s negative len " 476 537 "requested.\n", fsp_str_dbg(fsp))); … … 496 557 contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_ALLOC_SHRINK); 497 558 498 flush_write_cache(fsp, S IZECHANGE_FLUSH);499 if ((ret = SMB_VFS_FTRUNCATE(fsp, ( SMB_OFF_T)len)) != -1) {559 flush_write_cache(fsp, SAMBA_SIZECHANGE_FLUSH); 560 if ((ret = SMB_VFS_FTRUNCATE(fsp, (off_t)len)) != -1) { 500 561 set_filelen_write_cache(fsp, len); 501 562 } … … 506 567 } 507 568 508 if (!lp_strict_allocate(SNUM(fsp->conn)))509 return 0;510 511 569 /* Grow - we need to test if we have enough space. */ 512 570 513 571 contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_ALLOC_GROW); 514 572 515 /* See if we have a syscall that will allocate beyond end-of-file 516 without changing EOF. */ 517 ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_KEEP_SIZE, 0, len); 573 if (lp_strict_allocate(SNUM(fsp->conn))) { 574 /* See if we have a syscall that will allocate beyond 575 end-of-file without changing EOF. */ 576 ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_FL_KEEP_SIZE, 577 0, len); 578 } else { 579 ret = 0; 580 } 518 581 519 582 contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_ALLOC_GROW); … … 525 588 } 526 589 590 if (ret == -1 && errno == ENOSPC) { 591 return -1; 592 } 593 527 594 len -= fsp->fsp_name->st.st_ex_size; 528 595 len /= 1024; /* Len is now number of 1k blocks needed. */ 529 space_avail = get_dfree_info(conn, fsp->fsp_name->base_name, false,596 space_avail = get_dfree_info(conn, fsp->fsp_name->base_name, 530 597 &bsize, &dfree, &dsize); 531 598 if (space_avail == (uint64_t)-1) { … … 552 619 ****************************************************************************/ 553 620 554 int vfs_set_filelen(files_struct *fsp, SMB_OFF_Tlen)621 int vfs_set_filelen(files_struct *fsp, off_t len) 555 622 { 556 623 int ret; … … 560 627 DEBUG(10,("vfs_set_filelen: ftruncate %s to len %.0f\n", 561 628 fsp_str_dbg(fsp), (double)len)); 562 flush_write_cache(fsp, S IZECHANGE_FLUSH);629 flush_write_cache(fsp, SAMBA_SIZECHANGE_FLUSH); 563 630 if ((ret = SMB_VFS_FTRUNCATE(fsp, len)) != -1) { 564 631 set_filelen_write_cache(fsp, len); … … 579 646 as this is also called from the default SMB_VFS_FTRUNCATE code. 580 647 Always extends the file size. 581 Returns 0 on success, errnoon failure.648 Returns 0 on success, -1 on failure. 582 649 ****************************************************************************/ 583 650 584 651 #define SPARSE_BUF_WRITE_SIZE (32*1024) 585 652 586 int vfs_slow_fallocate(files_struct *fsp, SMB_OFF_T offset, SMB_OFF_Tlen)653 int vfs_slow_fallocate(files_struct *fsp, off_t offset, off_t len) 587 654 { 588 655 ssize_t pwrite_ret; … … 593 660 if (!sparse_buf) { 594 661 errno = ENOMEM; 595 return ENOMEM;662 return -1; 596 663 } 597 664 } … … 602 669 pwrite_ret = SMB_VFS_PWRITE(fsp, sparse_buf, curr_write_size, offset + total); 603 670 if (pwrite_ret == -1) { 671 int saved_errno = errno; 604 672 DEBUG(10,("vfs_slow_fallocate: SMB_VFS_PWRITE for file " 605 673 "%s failed with error %s\n", 606 fsp_str_dbg(fsp), strerror(errno))); 607 return errno; 674 fsp_str_dbg(fsp), strerror(saved_errno))); 675 errno = saved_errno; 676 return -1; 608 677 } 609 678 total += pwrite_ret; … … 620 689 ****************************************************************************/ 621 690 622 int vfs_fill_sparse(files_struct *fsp, SMB_OFF_Tlen)691 int vfs_fill_sparse(files_struct *fsp, off_t len) 623 692 { 624 693 int ret; 625 694 NTSTATUS status; 626 SMB_OFF_Toffset;695 off_t offset; 627 696 size_t num_to_write; 628 697 … … 649 718 contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_FILL_SPARSE); 650 719 651 flush_write_cache(fsp, S IZECHANGE_FLUSH);720 flush_write_cache(fsp, SAMBA_SIZECHANGE_FLUSH); 652 721 653 722 offset = fsp->fsp_name->st.st_ex_size; … … 661 730 * case we do our own emulation. fallocate implementations can 662 731 * return ENOTSUP or EINVAL in cases like that. */ 663 ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE, 664 offset, num_to_write); 665 if (ret == ENOSPC) { 666 errno = ENOSPC; 667 ret = -1; 732 ret = SMB_VFS_FALLOCATE(fsp, 0, offset, num_to_write); 733 if (ret == -1 && errno == ENOSPC) { 668 734 goto out; 669 735 } … … 676 742 677 743 ret = vfs_slow_fallocate(fsp, offset, num_to_write); 678 if (ret != 0) {679 errno = ret;680 ret = -1;681 }682 744 683 745 out: … … 695 757 ****************************************************************************/ 696 758 697 static ssize_t vfs_ read_fn(void *file, void *buf, size_t len)759 static ssize_t vfs_pread_fn(void *file, void *buf, size_t len, off_t offset) 698 760 { 699 761 struct files_struct *fsp = (struct files_struct *)file; 700 762 701 return SMB_VFS_ READ(fsp, buf, len);702 } 703 704 static ssize_t vfs_ write_fn(void *file, const void *buf, size_t len)763 return SMB_VFS_PREAD(fsp, buf, len, offset); 764 } 765 766 static ssize_t vfs_pwrite_fn(void *file, const void *buf, size_t len, off_t offset) 705 767 { 706 768 struct files_struct *fsp = (struct files_struct *)file; 707 769 708 return SMB_VFS_ WRITE(fsp, buf, len);709 } 710 711 SMB_OFF_T vfs_transfer_file(files_struct *in, files_struct *out, SMB_OFF_Tn)770 return SMB_VFS_PWRITE(fsp, buf, len, offset); 771 } 772 773 off_t vfs_transfer_file(files_struct *in, files_struct *out, off_t n) 712 774 { 713 775 return transfer_file_internal((void *)in, (void *)out, n, 714 vfs_ read_fn, vfs_write_fn);776 vfs_pread_fn, vfs_pwrite_fn); 715 777 } 716 778 … … 722 784 SMB_STRUCT_STAT *sbuf, char **talloced) 723 785 { 724 SMB_STRUCT_DIRENT*ptr= NULL;786 struct dirent *ptr= NULL; 725 787 const char *dname; 726 788 char *translated; … … 766 828 int vfs_ChDir(connection_struct *conn, const char *path) 767 829 { 768 int re s;830 int ret; 769 831 770 832 if (!LastDir) { … … 772 834 } 773 835 774 if (strcsequal(path,".")) 775 return(0); 776 777 if (*path == '/' && strcsequal(LastDir,path)) 778 return(0); 836 if (ISDOT(path)) { 837 return 0; 838 } 839 840 if (*path == '/' && strcsequal(LastDir,path)) { 841 return 0; 842 } 779 843 780 844 DEBUG(4,("vfs_ChDir to %s\n",path)); 781 845 782 res = SMB_VFS_CHDIR(conn,path); 783 if (!res) { 846 ret = SMB_VFS_CHDIR(conn,path); 847 if (ret == 0) { 848 /* Global cache. */ 784 849 SAFE_FREE(LastDir); 785 850 LastDir = SMB_STRDUP(path); 786 } 787 return(res); 851 852 /* conn cache. */ 853 TALLOC_FREE(conn->cwd); 854 conn->cwd = vfs_GetWd(conn, conn); 855 DEBUG(4,("vfs_ChDir got %s\n",conn->cwd)); 856 } 857 return ret; 788 858 } 789 859 … … 796 866 char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn) 797 867 { 798 char s[PATH_MAX+1];868 char *current_dir = NULL; 799 869 char *result = NULL; 800 870 DATA_BLOB cache_value; … … 802 872 struct smb_filename *smb_fname_dot = NULL; 803 873 struct smb_filename *smb_fname_full = NULL; 804 NTSTATUS status;805 806 *s = 0;807 874 808 875 if (!lp_getwd_cache()) { … … 810 877 } 811 878 812 status = create_synthetic_smb_fname(ctx, ".", NULL, NULL, 813 &smb_fname_dot); 814 if (!NT_STATUS_IS_OK(status)) { 815 errno = map_errno_from_nt_status(status); 879 smb_fname_dot = synthetic_smb_fname(ctx, ".", NULL, NULL); 880 if (smb_fname_dot == NULL) { 881 errno = ENOMEM; 816 882 goto out; 817 883 } … … 838 904 && (cache_value.data[cache_value.length-1] == '\0')); 839 905 840 s tatus = create_synthetic_smb_fname(ctx, (char *)cache_value.data,841 NULL, NULL, &smb_fname_full);842 if ( !NT_STATUS_IS_OK(status)) {843 errno = map_errno_from_nt_status(status);906 smb_fname_full = synthetic_smb_fname(ctx, (char *)cache_value.data, 907 NULL, NULL); 908 if (smb_fname_full == NULL) { 909 errno = ENOMEM; 844 910 goto out; 845 911 } … … 867 933 */ 868 934 869 if (!SMB_VFS_GETWD(conn,s)) { 935 current_dir = SMB_VFS_GETWD(conn); 936 if (current_dir == NULL) { 870 937 DEBUG(0, ("vfs_GetWd: SMB_VFS_GETWD call failed: %s\n", 871 938 strerror(errno))); … … 878 945 memcache_add(smbd_memcache(), GETWD_CACHE, 879 946 data_blob_const(&key, sizeof(key)), 880 data_blob_const(s, strlen(s)+1)); 881 } 882 883 result = talloc_strdup(ctx, s); 947 data_blob_const(current_dir, 948 strlen(current_dir)+1)); 949 } 950 951 result = talloc_strdup(ctx, current_dir); 884 952 if (result == NULL) { 885 953 errno = ENOMEM; … … 889 957 TALLOC_FREE(smb_fname_dot); 890 958 TALLOC_FREE(smb_fname_full); 959 SAFE_FREE(current_dir); 891 960 return result; 961 } 962 963 /******************************************************************* 964 Reduce a file name, removing .. elements and checking that 965 it is below dir in the heirachy. This uses realpath. 966 This function must run as root, and will return names 967 and valid stat structs that can be checked on open. 968 ********************************************************************/ 969 970 NTSTATUS check_reduced_name_with_privilege(connection_struct *conn, 971 const char *fname, 972 struct smb_request *smbreq) 973 { 974 NTSTATUS status; 975 TALLOC_CTX *ctx = talloc_tos(); 976 const char *conn_rootdir; 977 size_t rootdir_len; 978 char *dir_name = NULL; 979 const char *last_component = NULL; 980 char *resolved_name = NULL; 981 char *saved_dir = NULL; 982 struct smb_filename *smb_fname_cwd = NULL; 983 struct privilege_paths *priv_paths = NULL; 984 int ret; 985 986 DEBUG(3,("check_reduced_name_with_privilege [%s] [%s]\n", 987 fname, 988 conn->connectpath)); 989 990 991 priv_paths = talloc_zero(smbreq, struct privilege_paths); 992 if (!priv_paths) { 993 status = NT_STATUS_NO_MEMORY; 994 goto err; 995 } 996 997 if (!parent_dirname(ctx, fname, &dir_name, &last_component)) { 998 status = NT_STATUS_NO_MEMORY; 999 goto err; 1000 } 1001 1002 priv_paths->parent_name.base_name = talloc_strdup(priv_paths, dir_name); 1003 priv_paths->file_name.base_name = talloc_strdup(priv_paths, last_component); 1004 1005 if (priv_paths->parent_name.base_name == NULL || 1006 priv_paths->file_name.base_name == NULL) { 1007 status = NT_STATUS_NO_MEMORY; 1008 goto err; 1009 } 1010 1011 if (SMB_VFS_STAT(conn, &priv_paths->parent_name) != 0) { 1012 status = map_nt_error_from_unix(errno); 1013 goto err; 1014 } 1015 /* Remember where we were. */ 1016 saved_dir = vfs_GetWd(ctx, conn); 1017 if (!saved_dir) { 1018 status = map_nt_error_from_unix(errno); 1019 goto err; 1020 } 1021 1022 /* Go to the parent directory to lock in memory. */ 1023 if (vfs_ChDir(conn, priv_paths->parent_name.base_name) == -1) { 1024 status = map_nt_error_from_unix(errno); 1025 goto err; 1026 } 1027 1028 /* Get the absolute path of the parent directory. */ 1029 resolved_name = SMB_VFS_REALPATH(conn,"."); 1030 if (!resolved_name) { 1031 status = map_nt_error_from_unix(errno); 1032 goto err; 1033 } 1034 1035 if (*resolved_name != '/') { 1036 DEBUG(0,("check_reduced_name_with_privilege: realpath " 1037 "doesn't return absolute paths !\n")); 1038 status = NT_STATUS_OBJECT_NAME_INVALID; 1039 goto err; 1040 } 1041 1042 DEBUG(10,("check_reduced_name_with_privilege: realpath [%s] -> [%s]\n", 1043 priv_paths->parent_name.base_name, 1044 resolved_name)); 1045 1046 /* Now check the stat value is the same. */ 1047 smb_fname_cwd = synthetic_smb_fname(talloc_tos(), ".", NULL, NULL); 1048 if (smb_fname_cwd == NULL) { 1049 status = NT_STATUS_NO_MEMORY; 1050 goto err; 1051 } 1052 1053 if (SMB_VFS_LSTAT(conn, smb_fname_cwd) != 0) { 1054 status = map_nt_error_from_unix(errno); 1055 goto err; 1056 } 1057 1058 /* Ensure we're pointing at the same place. */ 1059 if (!check_same_stat(&smb_fname_cwd->st, &priv_paths->parent_name.st)) { 1060 DEBUG(0,("check_reduced_name_with_privilege: " 1061 "device/inode/uid/gid on directory %s changed. " 1062 "Denying access !\n", 1063 priv_paths->parent_name.base_name)); 1064 status = NT_STATUS_ACCESS_DENIED; 1065 goto err; 1066 } 1067 1068 /* Ensure we're below the connect path. */ 1069 1070 conn_rootdir = SMB_VFS_CONNECTPATH(conn, fname); 1071 if (conn_rootdir == NULL) { 1072 DEBUG(2, ("check_reduced_name_with_privilege: Could not get " 1073 "conn_rootdir\n")); 1074 status = NT_STATUS_ACCESS_DENIED; 1075 goto err; 1076 } 1077 1078 rootdir_len = strlen(conn_rootdir); 1079 1080 /* 1081 * In the case of rootdir_len == 1, we know that conn_rootdir is 1082 * "/", and we also know that resolved_name starts with a slash. 1083 * So, in this corner case, resolved_name is automatically a 1084 * sub-directory of the conn_rootdir. Thus we can skip the string 1085 * comparison and the next character checks (which are even 1086 * wrong in this case). 1087 */ 1088 if (rootdir_len != 1) { 1089 bool matched; 1090 1091 matched = (strncmp(conn_rootdir, resolved_name, 1092 rootdir_len) == 0); 1093 1094 if (!matched || (resolved_name[rootdir_len] != '/' && 1095 resolved_name[rootdir_len] != '\0')) { 1096 DEBUG(2, ("check_reduced_name_with_privilege: Bad " 1097 "access attempt: %s is a symlink outside the " 1098 "share path\n", 1099 dir_name)); 1100 DEBUGADD(2, ("conn_rootdir =%s\n", conn_rootdir)); 1101 DEBUGADD(2, ("resolved_name=%s\n", resolved_name)); 1102 status = NT_STATUS_ACCESS_DENIED; 1103 goto err; 1104 } 1105 } 1106 1107 /* Now ensure that the last component either doesn't 1108 exist, or is *NOT* a symlink. */ 1109 1110 ret = SMB_VFS_LSTAT(conn, &priv_paths->file_name); 1111 if (ret == -1) { 1112 /* Errno must be ENOENT for this be ok. */ 1113 if (errno != ENOENT) { 1114 status = map_nt_error_from_unix(errno); 1115 DEBUG(2, ("check_reduced_name_with_privilege: " 1116 "LSTAT on %s failed with %s\n", 1117 priv_paths->file_name.base_name, 1118 nt_errstr(status))); 1119 goto err; 1120 } 1121 } 1122 1123 if (VALID_STAT(priv_paths->file_name.st) && 1124 S_ISLNK(priv_paths->file_name.st.st_ex_mode)) { 1125 DEBUG(2, ("check_reduced_name_with_privilege: " 1126 "Last component %s is a symlink. Denying" 1127 "access.\n", 1128 priv_paths->file_name.base_name)); 1129 status = NT_STATUS_ACCESS_DENIED; 1130 goto err; 1131 } 1132 1133 smbreq->priv_paths = priv_paths; 1134 status = NT_STATUS_OK; 1135 1136 err: 1137 1138 if (saved_dir) { 1139 vfs_ChDir(conn, saved_dir); 1140 } 1141 SAFE_FREE(resolved_name); 1142 if (!NT_STATUS_IS_OK(status)) { 1143 TALLOC_FREE(priv_paths); 1144 } 1145 TALLOC_FREE(dir_name); 1146 return status; 892 1147 } 893 1148 … … 903 1158 bool allow_widelinks = false; 904 1159 905 D EBUG(3,("check_reduced_name [%s] [%s]\n", fname, conn->connectpath));1160 DBG_DEBUG("check_reduced_name [%s] [%s]\n", fname, conn->connectpath); 906 1161 907 1162 resolved_name = SMB_VFS_REALPATH(conn,fname); … … 920 1175 const char *last_component = NULL; 921 1176 char *new_name = NULL; 1177 int ret; 922 1178 923 1179 /* Last component didn't exist. … … 945 1201 return status; 946 1202 } 947 new_name = talloc_asprintf(ctx, 948 "%s/%s", 949 resolved_name, 950 last_component); 951 if (!new_name) { 1203 ret = asprintf(&new_name, "%s/%s", 1204 resolved_name, last_component); 1205 SAFE_FREE(resolved_name); 1206 if (ret == -1) { 952 1207 return NT_STATUS_NO_MEMORY; 953 1208 } 954 SAFE_FREE(resolved_name); 955 resolved_name = SMB_STRDUP(new_name); 956 if (!resolved_name) { 957 return NT_STATUS_NO_MEMORY; 958 } 1209 resolved_name = new_name; 959 1210 break; 960 1211 } … … 977 1228 978 1229 allow_widelinks = lp_widelinks(SNUM(conn)); 979 allow_symlinks = lp_ symlinks(SNUM(conn));1230 allow_symlinks = lp_follow_symlinks(SNUM(conn)); 980 1231 981 1232 /* Common widelinks and symlinks checks. */ … … 983 1234 const char *conn_rootdir; 984 1235 size_t rootdir_len; 985 bool matched;986 1236 987 1237 conn_rootdir = SMB_VFS_CONNECTPATH(conn, fname); … … 994 1244 995 1245 rootdir_len = strlen(conn_rootdir); 996 matched = (strncmp(conn_rootdir, resolved_name, 997 rootdir_len) == 0); 998 if (!matched || (resolved_name[rootdir_len] != '/' && 999 resolved_name[rootdir_len] != '\0')) { 1000 DEBUG(2, ("check_reduced_name: Bad access " 1001 "attempt: %s is a symlink outside the " 1002 "share path\n", fname)); 1003 DEBUGADD(2, ("conn_rootdir =%s\n", conn_rootdir)); 1004 DEBUGADD(2, ("resolved_name=%s\n", resolved_name)); 1005 SAFE_FREE(resolved_name); 1006 return NT_STATUS_ACCESS_DENIED; 1246 1247 /* 1248 * In the case of rootdir_len == 1, we know that 1249 * conn_rootdir is "/", and we also know that 1250 * resolved_name starts with a slash. So, in this 1251 * corner case, resolved_name is automatically a 1252 * sub-directory of the conn_rootdir. Thus we can skip 1253 * the string comparison and the next character checks 1254 * (which are even wrong in this case). 1255 */ 1256 if (rootdir_len != 1) { 1257 bool matched; 1258 1259 matched = (strncmp(conn_rootdir, resolved_name, 1260 rootdir_len) == 0); 1261 if (!matched || (resolved_name[rootdir_len] != '/' && 1262 resolved_name[rootdir_len] != '\0')) { 1263 DEBUG(2, ("check_reduced_name: Bad access " 1264 "attempt: %s is a symlink outside the " 1265 "share path\n", fname)); 1266 DEBUGADD(2, ("conn_rootdir =%s\n", 1267 conn_rootdir)); 1268 DEBUGADD(2, ("resolved_name=%s\n", 1269 resolved_name)); 1270 SAFE_FREE(resolved_name); 1271 return NT_STATUS_ACCESS_DENIED; 1272 } 1007 1273 } 1008 1274 … … 1029 1295 if (strcmp(fname, p)!=0) { 1030 1296 DEBUG(2, ("check_reduced_name: Bad access " 1031 "attempt: %s is a symlink \n",1032 fname));1297 "attempt: %s is a symlink to %s\n", 1298 fname, p)); 1033 1299 SAFE_FREE(resolved_name); 1034 1300 return NT_STATUS_ACCESS_DENIED; … … 1039 1305 out: 1040 1306 1041 DEBUG(3,("check_reduced_name: %s reduced to %s\n", fname, 1042 resolved_name)); 1307 DBG_INFO("%s reduced to %s\n", fname, resolved_name); 1043 1308 SAFE_FREE(resolved_name); 1044 1309 return NT_STATUS_OK; … … 1048 1313 * XXX: This is temporary and there should be no callers of this once 1049 1314 * smb_filename is plumbed through all path based operations. 1315 * 1316 * Called when we know stream name parsing has already been done. 1050 1317 */ 1051 int vfs_stat_smb_ fname(struct connection_struct *conn, const char *fname,1318 int vfs_stat_smb_basename(struct connection_struct *conn, const char *fname, 1052 1319 SMB_STRUCT_STAT *psbuf) 1053 1320 { 1054 struct smb_filename *smb_fname = NULL; 1055 NTSTATUS status; 1321 struct smb_filename smb_fname = { 1322 .base_name = discard_const_p(char, fname) 1323 }; 1056 1324 int ret; 1057 1325 1058 status = create_synthetic_smb_fname_split(talloc_tos(), fname, NULL,1059 &smb_fname);1060 if (!NT_STATUS_IS_OK(status)) {1061 errno = map_errno_from_nt_status(status);1062 return -1;1063 }1064 1065 1326 if (lp_posix_pathnames()) { 1066 ret = SMB_VFS_LSTAT(conn, smb_fname);1327 ret = SMB_VFS_LSTAT(conn, &smb_fname); 1067 1328 } else { 1068 ret = SMB_VFS_STAT(conn, smb_fname);1329 ret = SMB_VFS_STAT(conn, &smb_fname); 1069 1330 } 1070 1331 1071 1332 if (ret != -1) { 1072 *psbuf = smb_fname->st; 1073 } 1074 1075 TALLOC_FREE(smb_fname); 1076 return ret; 1077 } 1078 1079 /** 1080 * XXX: This is temporary and there should be no callers of this once 1081 * smb_filename is plumbed through all path based operations. 1082 */ 1083 int vfs_lstat_smb_fname(struct connection_struct *conn, const char *fname, 1084 SMB_STRUCT_STAT *psbuf) 1085 { 1086 struct smb_filename *smb_fname = NULL; 1087 NTSTATUS status; 1088 int ret; 1089 1090 status = create_synthetic_smb_fname_split(talloc_tos(), fname, NULL, 1091 &smb_fname); 1092 if (!NT_STATUS_IS_OK(status)) { 1093 errno = map_errno_from_nt_status(status); 1094 return -1; 1095 } 1096 1097 ret = SMB_VFS_LSTAT(conn, smb_fname); 1098 if (ret != -1) { 1099 *psbuf = smb_fname->st; 1100 } 1101 1102 TALLOC_FREE(smb_fname); 1333 *psbuf = smb_fname.st; 1334 } 1103 1335 return ret; 1104 1336 } … … 1113 1345 1114 1346 if(fsp->fh->fd == -1) { 1115 if (fsp->posix_ open) {1347 if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) { 1116 1348 ret = SMB_VFS_LSTAT(fsp->conn, fsp->fsp_name); 1117 1349 } else { … … 1155 1387 const char *service, const char *user) 1156 1388 { 1157 VFS_FIND(connect _fn);1389 VFS_FIND(connect); 1158 1390 return handle->fns->connect_fn(handle, service, user); 1159 1391 } … … 1162 1394 { 1163 1395 VFS_FIND(disconnect); 1164 handle->fns->disconnect (handle);1396 handle->fns->disconnect_fn(handle); 1165 1397 } 1166 1398 1167 1399 uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle, 1168 const char *path, bool small_query, 1169 uint64_t *bsize, uint64_t *dfree, 1170 uint64_t *dsize) 1400 const char *path, uint64_t *bsize, 1401 uint64_t *dfree, uint64_t *dsize) 1171 1402 { 1172 1403 VFS_FIND(disk_free); 1173 return handle->fns->disk_free(handle, path, small_query, bsize, dfree, 1174 dsize); 1175 } 1176 1177 int smb_vfs_call_get_quota(struct vfs_handle_struct *handle, 1404 return handle->fns->disk_free_fn(handle, path, bsize, dfree, dsize); 1405 } 1406 1407 int smb_vfs_call_get_quota(struct vfs_handle_struct *handle, const char *path, 1178 1408 enum SMB_QUOTA_TYPE qtype, unid_t id, 1179 1409 SMB_DISK_QUOTA *qt) 1180 1410 { 1181 1411 VFS_FIND(get_quota); 1182 return handle->fns->get_quota (handle, qtype, id, qt);1412 return handle->fns->get_quota_fn(handle, path, qtype, id, qt); 1183 1413 } 1184 1414 … … 1188 1418 { 1189 1419 VFS_FIND(set_quota); 1190 return handle->fns->set_quota (handle, qtype, id, qt);1420 return handle->fns->set_quota_fn(handle, qtype, id, qt); 1191 1421 } 1192 1422 … … 1197 1427 { 1198 1428 VFS_FIND(get_shadow_copy_data); 1199 return handle->fns->get_shadow_copy_data(handle, fsp, shadow_copy_data, 1200 labels); 1429 return handle->fns->get_shadow_copy_data_fn(handle, fsp, 1430 shadow_copy_data, 1431 labels); 1201 1432 } 1202 1433 int smb_vfs_call_statvfs(struct vfs_handle_struct *handle, const char *path, … … 1204 1435 { 1205 1436 VFS_FIND(statvfs); 1206 return handle->fns->statvfs (handle, path, statbuf);1437 return handle->fns->statvfs_fn(handle, path, statbuf); 1207 1438 } 1208 1439 … … 1211 1442 { 1212 1443 VFS_FIND(fs_capabilities); 1213 return handle->fns->fs_capabilities(handle, p_ts_res); 1214 } 1215 1216 SMB_STRUCT_DIR *smb_vfs_call_opendir(struct vfs_handle_struct *handle, 1444 return handle->fns->fs_capabilities_fn(handle, p_ts_res); 1445 } 1446 1447 NTSTATUS smb_vfs_call_get_dfs_referrals(struct vfs_handle_struct *handle, 1448 struct dfs_GetDFSReferral *r) 1449 { 1450 VFS_FIND(get_dfs_referrals); 1451 return handle->fns->get_dfs_referrals_fn(handle, r); 1452 } 1453 1454 DIR *smb_vfs_call_opendir(struct vfs_handle_struct *handle, 1217 1455 const char *fname, const char *mask, 1218 uint32 attributes)1456 uint32_t attributes) 1219 1457 { 1220 1458 VFS_FIND(opendir); 1221 return handle->fns->opendir (handle, fname, mask, attributes);1222 } 1223 1224 SMB_STRUCT_DIR *smb_vfs_call_fdopendir(struct vfs_handle_struct *handle,1459 return handle->fns->opendir_fn(handle, fname, mask, attributes); 1460 } 1461 1462 DIR *smb_vfs_call_fdopendir(struct vfs_handle_struct *handle, 1225 1463 struct files_struct *fsp, 1226 1464 const char *mask, 1227 uint32 attributes)1465 uint32_t attributes) 1228 1466 { 1229 1467 VFS_FIND(fdopendir); 1230 return handle->fns->fdopendir (handle, fsp, mask, attributes);1231 } 1232 1233 SMB_STRUCT_DIRENT*smb_vfs_call_readdir(struct vfs_handle_struct *handle,1234 SMB_STRUCT_DIR *dirp,1468 return handle->fns->fdopendir_fn(handle, fsp, mask, attributes); 1469 } 1470 1471 struct dirent *smb_vfs_call_readdir(struct vfs_handle_struct *handle, 1472 DIR *dirp, 1235 1473 SMB_STRUCT_STAT *sbuf) 1236 1474 { 1237 1475 VFS_FIND(readdir); 1238 return handle->fns->readdir (handle, dirp, sbuf);1476 return handle->fns->readdir_fn(handle, dirp, sbuf); 1239 1477 } 1240 1478 1241 1479 void smb_vfs_call_seekdir(struct vfs_handle_struct *handle, 1242 SMB_STRUCT_DIR *dirp, long offset)1480 DIR *dirp, long offset) 1243 1481 { 1244 1482 VFS_FIND(seekdir); 1245 handle->fns->seekdir (handle, dirp, offset);1483 handle->fns->seekdir_fn(handle, dirp, offset); 1246 1484 } 1247 1485 1248 1486 long smb_vfs_call_telldir(struct vfs_handle_struct *handle, 1249 SMB_STRUCT_DIR *dirp)1487 DIR *dirp) 1250 1488 { 1251 1489 VFS_FIND(telldir); 1252 return handle->fns->telldir (handle, dirp);1490 return handle->fns->telldir_fn(handle, dirp); 1253 1491 } 1254 1492 1255 1493 void smb_vfs_call_rewind_dir(struct vfs_handle_struct *handle, 1256 SMB_STRUCT_DIR *dirp)1494 DIR *dirp) 1257 1495 { 1258 1496 VFS_FIND(rewind_dir); 1259 handle->fns->rewind_dir (handle, dirp);1497 handle->fns->rewind_dir_fn(handle, dirp); 1260 1498 } 1261 1499 … … 1264 1502 { 1265 1503 VFS_FIND(mkdir); 1266 return handle->fns->mkdir (handle, path, mode);1504 return handle->fns->mkdir_fn(handle, path, mode); 1267 1505 } 1268 1506 … … 1270 1508 { 1271 1509 VFS_FIND(rmdir); 1272 return handle->fns->rmdir (handle, path);1510 return handle->fns->rmdir_fn(handle, path); 1273 1511 } 1274 1512 1275 1513 int smb_vfs_call_closedir(struct vfs_handle_struct *handle, 1276 SMB_STRUCT_DIR *dir)1514 DIR *dir) 1277 1515 { 1278 1516 VFS_FIND(closedir); 1279 return handle->fns->closedir (handle, dir);1517 return handle->fns->closedir_fn(handle, dir); 1280 1518 } 1281 1519 1282 1520 void smb_vfs_call_init_search_op(struct vfs_handle_struct *handle, 1283 SMB_STRUCT_DIR *dirp)1521 DIR *dirp) 1284 1522 { 1285 1523 VFS_FIND(init_search_op); 1286 handle->fns->init_search_op (handle, dirp);1524 handle->fns->init_search_op_fn(handle, dirp); 1287 1525 } 1288 1526 … … 1291 1529 int flags, mode_t mode) 1292 1530 { 1293 VFS_FIND(open _fn);1531 VFS_FIND(open); 1294 1532 return handle->fns->open_fn(handle, smb_fname, fsp, flags, mode); 1295 1533 } … … 1305 1543 uint32_t file_attributes, 1306 1544 uint32_t oplock_request, 1545 struct smb2_lease *lease, 1307 1546 uint64_t allocation_size, 1308 1547 uint32_t private_flags, … … 1310 1549 struct ea_list *ea_list, 1311 1550 files_struct **result, 1312 int *pinfo) 1551 int *pinfo, 1552 const struct smb2_create_blobs *in_context_blobs, 1553 struct smb2_create_blobs *out_context_blobs) 1313 1554 { 1314 1555 VFS_FIND(create_file); 1315 return handle->fns->create_file (1556 return handle->fns->create_file_fn( 1316 1557 handle, req, root_dir_fid, smb_fname, access_mask, 1317 1558 share_access, create_disposition, create_options, 1318 file_attributes, oplock_request, allocation_size,1559 file_attributes, oplock_request, lease, allocation_size, 1319 1560 private_flags, sd, ea_list, 1320 result, pinfo );1321 } 1322 1323 int smb_vfs_call_close _fn(struct vfs_handle_struct *handle,1324 1325 { 1326 VFS_FIND(close _fn);1561 result, pinfo, in_context_blobs, out_context_blobs); 1562 } 1563 1564 int smb_vfs_call_close(struct vfs_handle_struct *handle, 1565 struct files_struct *fsp) 1566 { 1567 VFS_FIND(close); 1327 1568 return handle->fns->close_fn(handle, fsp); 1328 1569 } 1329 1570 1330 ssize_t smb_vfs_call_ vfs_read(struct vfs_handle_struct *handle,1331 1332 { 1333 VFS_FIND( vfs_read);1334 return handle->fns-> vfs_read(handle, fsp, data, n);1571 ssize_t smb_vfs_call_read(struct vfs_handle_struct *handle, 1572 struct files_struct *fsp, void *data, size_t n) 1573 { 1574 VFS_FIND(read); 1575 return handle->fns->read_fn(handle, fsp, data, n); 1335 1576 } 1336 1577 1337 1578 ssize_t smb_vfs_call_pread(struct vfs_handle_struct *handle, 1338 1579 struct files_struct *fsp, void *data, size_t n, 1339 SMB_OFF_Toffset)1580 off_t offset) 1340 1581 { 1341 1582 VFS_FIND(pread); 1342 return handle->fns->pread(handle, fsp, data, n, offset); 1583 return handle->fns->pread_fn(handle, fsp, data, n, offset); 1584 } 1585 1586 struct smb_vfs_call_pread_state { 1587 ssize_t (*recv_fn)(struct tevent_req *req, int *err); 1588 ssize_t retval; 1589 }; 1590 1591 static void smb_vfs_call_pread_done(struct tevent_req *subreq); 1592 1593 struct tevent_req *smb_vfs_call_pread_send(struct vfs_handle_struct *handle, 1594 TALLOC_CTX *mem_ctx, 1595 struct tevent_context *ev, 1596 struct files_struct *fsp, 1597 void *data, 1598 size_t n, off_t offset) 1599 { 1600 struct tevent_req *req, *subreq; 1601 struct smb_vfs_call_pread_state *state; 1602 1603 req = tevent_req_create(mem_ctx, &state, 1604 struct smb_vfs_call_pread_state); 1605 if (req == NULL) { 1606 return NULL; 1607 } 1608 VFS_FIND(pread_send); 1609 state->recv_fn = handle->fns->pread_recv_fn; 1610 1611 subreq = handle->fns->pread_send_fn(handle, state, ev, fsp, data, n, 1612 offset); 1613 if (tevent_req_nomem(subreq, req)) { 1614 return tevent_req_post(req, ev); 1615 } 1616 tevent_req_set_callback(subreq, smb_vfs_call_pread_done, req); 1617 return req; 1618 } 1619 1620 static void smb_vfs_call_pread_done(struct tevent_req *subreq) 1621 { 1622 struct tevent_req *req = tevent_req_callback_data( 1623 subreq, struct tevent_req); 1624 struct smb_vfs_call_pread_state *state = tevent_req_data( 1625 req, struct smb_vfs_call_pread_state); 1626 int err; 1627 1628 state->retval = state->recv_fn(subreq, &err); 1629 TALLOC_FREE(subreq); 1630 if (state->retval == -1) { 1631 tevent_req_error(req, err); 1632 return; 1633 } 1634 tevent_req_done(req); 1635 } 1636 1637 ssize_t SMB_VFS_PREAD_RECV(struct tevent_req *req, int *perrno) 1638 { 1639 struct smb_vfs_call_pread_state *state = tevent_req_data( 1640 req, struct smb_vfs_call_pread_state); 1641 int err; 1642 1643 if (tevent_req_is_unix_error(req, &err)) { 1644 *perrno = err; 1645 return -1; 1646 } 1647 return state->retval; 1343 1648 } 1344 1649 … … 1348 1653 { 1349 1654 VFS_FIND(write); 1350 return handle->fns->write (handle, fsp, data, n);1655 return handle->fns->write_fn(handle, fsp, data, n); 1351 1656 } 1352 1657 1353 1658 ssize_t smb_vfs_call_pwrite(struct vfs_handle_struct *handle, 1354 1659 struct files_struct *fsp, const void *data, 1355 size_t n, SMB_OFF_Toffset)1660 size_t n, off_t offset) 1356 1661 { 1357 1662 VFS_FIND(pwrite); 1358 return handle->fns->pwrite(handle, fsp, data, n, offset); 1359 } 1360 1361 SMB_OFF_T smb_vfs_call_lseek(struct vfs_handle_struct *handle, 1362 struct files_struct *fsp, SMB_OFF_T offset, 1663 return handle->fns->pwrite_fn(handle, fsp, data, n, offset); 1664 } 1665 1666 struct smb_vfs_call_pwrite_state { 1667 ssize_t (*recv_fn)(struct tevent_req *req, int *err); 1668 ssize_t retval; 1669 }; 1670 1671 static void smb_vfs_call_pwrite_done(struct tevent_req *subreq); 1672 1673 struct tevent_req *smb_vfs_call_pwrite_send(struct vfs_handle_struct *handle, 1674 TALLOC_CTX *mem_ctx, 1675 struct tevent_context *ev, 1676 struct files_struct *fsp, 1677 const void *data, 1678 size_t n, off_t offset) 1679 { 1680 struct tevent_req *req, *subreq; 1681 struct smb_vfs_call_pwrite_state *state; 1682 1683 req = tevent_req_create(mem_ctx, &state, 1684 struct smb_vfs_call_pwrite_state); 1685 if (req == NULL) { 1686 return NULL; 1687 } 1688 VFS_FIND(pwrite_send); 1689 state->recv_fn = handle->fns->pwrite_recv_fn; 1690 1691 subreq = handle->fns->pwrite_send_fn(handle, state, ev, fsp, data, n, 1692 offset); 1693 if (tevent_req_nomem(subreq, req)) { 1694 return tevent_req_post(req, ev); 1695 } 1696 tevent_req_set_callback(subreq, smb_vfs_call_pwrite_done, req); 1697 return req; 1698 } 1699 1700 static void smb_vfs_call_pwrite_done(struct tevent_req *subreq) 1701 { 1702 struct tevent_req *req = tevent_req_callback_data( 1703 subreq, struct tevent_req); 1704 struct smb_vfs_call_pwrite_state *state = tevent_req_data( 1705 req, struct smb_vfs_call_pwrite_state); 1706 int err; 1707 1708 state->retval = state->recv_fn(subreq, &err); 1709 TALLOC_FREE(subreq); 1710 if (state->retval == -1) { 1711 tevent_req_error(req, err); 1712 return; 1713 } 1714 tevent_req_done(req); 1715 } 1716 1717 ssize_t SMB_VFS_PWRITE_RECV(struct tevent_req *req, int *perrno) 1718 { 1719 struct smb_vfs_call_pwrite_state *state = tevent_req_data( 1720 req, struct smb_vfs_call_pwrite_state); 1721 int err; 1722 1723 if (tevent_req_is_unix_error(req, &err)) { 1724 *perrno = err; 1725 return -1; 1726 } 1727 return state->retval; 1728 } 1729 1730 off_t smb_vfs_call_lseek(struct vfs_handle_struct *handle, 1731 struct files_struct *fsp, off_t offset, 1363 1732 int whence) 1364 1733 { 1365 1734 VFS_FIND(lseek); 1366 return handle->fns->lseek (handle, fsp, offset, whence);1735 return handle->fns->lseek_fn(handle, fsp, offset, whence); 1367 1736 } 1368 1737 1369 1738 ssize_t smb_vfs_call_sendfile(struct vfs_handle_struct *handle, int tofd, 1370 1739 files_struct *fromfsp, const DATA_BLOB *header, 1371 SMB_OFF_Toffset, size_t count)1740 off_t offset, size_t count) 1372 1741 { 1373 1742 VFS_FIND(sendfile); 1374 return handle->fns->sendfile (handle, tofd, fromfsp, header, offset,1375 1743 return handle->fns->sendfile_fn(handle, tofd, fromfsp, header, offset, 1744 count); 1376 1745 } 1377 1746 1378 1747 ssize_t smb_vfs_call_recvfile(struct vfs_handle_struct *handle, int fromfd, 1379 files_struct *tofsp, SMB_OFF_Toffset,1748 files_struct *tofsp, off_t offset, 1380 1749 size_t count) 1381 1750 { 1382 1751 VFS_FIND(recvfile); 1383 return handle->fns->recvfile (handle, fromfd, tofsp, offset, count);1752 return handle->fns->recvfile_fn(handle, fromfd, tofsp, offset, count); 1384 1753 } 1385 1754 … … 1389 1758 { 1390 1759 VFS_FIND(rename); 1391 return handle->fns->rename (handle, smb_fname_src, smb_fname_dst);1760 return handle->fns->rename_fn(handle, smb_fname_src, smb_fname_dst); 1392 1761 } 1393 1762 … … 1396 1765 { 1397 1766 VFS_FIND(fsync); 1398 return handle->fns->fsync(handle, fsp); 1399 } 1767 return handle->fns->fsync_fn(handle, fsp); 1768 } 1769 1770 struct smb_vfs_call_fsync_state { 1771 int (*recv_fn)(struct tevent_req *req, int *err); 1772 int retval; 1773 }; 1774 1775 static void smb_vfs_call_fsync_done(struct tevent_req *subreq); 1776 1777 struct tevent_req *smb_vfs_call_fsync_send(struct vfs_handle_struct *handle, 1778 TALLOC_CTX *mem_ctx, 1779 struct tevent_context *ev, 1780 struct files_struct *fsp) 1781 { 1782 struct tevent_req *req, *subreq; 1783 struct smb_vfs_call_fsync_state *state; 1784 1785 req = tevent_req_create(mem_ctx, &state, 1786 struct smb_vfs_call_fsync_state); 1787 if (req == NULL) { 1788 return NULL; 1789 } 1790 VFS_FIND(fsync_send); 1791 state->recv_fn = handle->fns->fsync_recv_fn; 1792 1793 subreq = handle->fns->fsync_send_fn(handle, state, ev, fsp); 1794 if (tevent_req_nomem(subreq, req)) { 1795 return tevent_req_post(req, ev); 1796 } 1797 tevent_req_set_callback(subreq, smb_vfs_call_fsync_done, req); 1798 return req; 1799 } 1800 1801 static void smb_vfs_call_fsync_done(struct tevent_req *subreq) 1802 { 1803 struct tevent_req *req = tevent_req_callback_data( 1804 subreq, struct tevent_req); 1805 struct smb_vfs_call_fsync_state *state = tevent_req_data( 1806 req, struct smb_vfs_call_fsync_state); 1807 int err; 1808 1809 state->retval = state->recv_fn(subreq, &err); 1810 TALLOC_FREE(subreq); 1811 if (state->retval == -1) { 1812 tevent_req_error(req, err); 1813 return; 1814 } 1815 tevent_req_done(req); 1816 } 1817 1818 int SMB_VFS_FSYNC_RECV(struct tevent_req *req, int *perrno) 1819 { 1820 struct smb_vfs_call_fsync_state *state = tevent_req_data( 1821 req, struct smb_vfs_call_fsync_state); 1822 int err; 1823 1824 if (tevent_req_is_unix_error(req, &err)) { 1825 *perrno = err; 1826 return -1; 1827 } 1828 return state->retval; 1829 } 1830 1400 1831 1401 1832 int smb_vfs_call_stat(struct vfs_handle_struct *handle, … … 1403 1834 { 1404 1835 VFS_FIND(stat); 1405 return handle->fns->stat (handle, smb_fname);1836 return handle->fns->stat_fn(handle, smb_fname); 1406 1837 } 1407 1838 … … 1410 1841 { 1411 1842 VFS_FIND(fstat); 1412 return handle->fns->fstat (handle, fsp, sbuf);1843 return handle->fns->fstat_fn(handle, fsp, sbuf); 1413 1844 } 1414 1845 … … 1417 1848 { 1418 1849 VFS_FIND(lstat); 1419 return handle->fns->lstat (handle, smb_filename);1850 return handle->fns->lstat_fn(handle, smb_filename); 1420 1851 } 1421 1852 … … 1425 1856 { 1426 1857 VFS_FIND(get_alloc_size); 1427 return handle->fns->get_alloc_size (handle, fsp, sbuf);1858 return handle->fns->get_alloc_size_fn(handle, fsp, sbuf); 1428 1859 } 1429 1860 … … 1432 1863 { 1433 1864 VFS_FIND(unlink); 1434 return handle->fns->unlink (handle, smb_fname);1865 return handle->fns->unlink_fn(handle, smb_fname); 1435 1866 } 1436 1867 … … 1439 1870 { 1440 1871 VFS_FIND(chmod); 1441 return handle->fns->chmod (handle, path, mode);1872 return handle->fns->chmod_fn(handle, path, mode); 1442 1873 } 1443 1874 … … 1446 1877 { 1447 1878 VFS_FIND(fchmod); 1448 return handle->fns->fchmod (handle, fsp, mode);1879 return handle->fns->fchmod_fn(handle, fsp, mode); 1449 1880 } 1450 1881 … … 1453 1884 { 1454 1885 VFS_FIND(chown); 1455 return handle->fns->chown (handle, path, uid, gid);1886 return handle->fns->chown_fn(handle, path, uid, gid); 1456 1887 } 1457 1888 … … 1460 1891 { 1461 1892 VFS_FIND(fchown); 1462 return handle->fns->fchown (handle, fsp, uid, gid);1893 return handle->fns->fchown_fn(handle, fsp, uid, gid); 1463 1894 } 1464 1895 … … 1467 1898 { 1468 1899 VFS_FIND(lchown); 1469 return handle->fns->lchown (handle, path, uid, gid);1900 return handle->fns->lchown_fn(handle, path, uid, gid); 1470 1901 } 1471 1902 … … 1525 1956 1526 1957 ZERO_STRUCT(local_fname); 1527 local_fname.base_name = CONST_DISCARD(char *,final_component);1958 local_fname.base_name = discard_const_p(char, final_component); 1528 1959 1529 1960 /* Must use lstat here. */ … … 1544 1975 } 1545 1976 1546 if ( fsp->posix_open|| as_root) {1977 if ((fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) || as_root) { 1547 1978 ret = SMB_VFS_LCHOWN(fsp->conn, 1548 1979 path, … … 1573 2004 { 1574 2005 VFS_FIND(chdir); 1575 return handle->fns->chdir (handle, path);1576 } 1577 1578 char *smb_vfs_call_getwd(struct vfs_handle_struct *handle , char *buf)2006 return handle->fns->chdir_fn(handle, path); 2007 } 2008 2009 char *smb_vfs_call_getwd(struct vfs_handle_struct *handle) 1579 2010 { 1580 2011 VFS_FIND(getwd); 1581 return handle->fns->getwd (handle, buf);2012 return handle->fns->getwd_fn(handle); 1582 2013 } 1583 2014 … … 1587 2018 { 1588 2019 VFS_FIND(ntimes); 1589 return handle->fns->ntimes (handle, smb_fname, ft);2020 return handle->fns->ntimes_fn(handle, smb_fname, ft); 1590 2021 } 1591 2022 1592 2023 int smb_vfs_call_ftruncate(struct vfs_handle_struct *handle, 1593 struct files_struct *fsp, SMB_OFF_Toffset)2024 struct files_struct *fsp, off_t offset) 1594 2025 { 1595 2026 VFS_FIND(ftruncate); 1596 return handle->fns->ftruncate (handle, fsp, offset);2027 return handle->fns->ftruncate_fn(handle, fsp, offset); 1597 2028 } 1598 2029 1599 2030 int smb_vfs_call_fallocate(struct vfs_handle_struct *handle, 1600 1601 enum vfs_fallocate_modemode,1602 SMB_OFF_Toffset,1603 SMB_OFF_Tlen)2031 struct files_struct *fsp, 2032 uint32_t mode, 2033 off_t offset, 2034 off_t len) 1604 2035 { 1605 2036 VFS_FIND(fallocate); 1606 return handle->fns->fallocate (handle, fsp, mode, offset, len);2037 return handle->fns->fallocate_fn(handle, fsp, mode, offset, len); 1607 2038 } 1608 2039 1609 2040 int smb_vfs_call_kernel_flock(struct vfs_handle_struct *handle, 1610 struct files_struct *fsp, uint32 share_mode,2041 struct files_struct *fsp, uint32_t share_mode, 1611 2042 uint32_t access_mask) 1612 2043 { 1613 2044 VFS_FIND(kernel_flock); 1614 return handle->fns->kernel_flock (handle, fsp, share_mode,2045 return handle->fns->kernel_flock_fn(handle, fsp, share_mode, 1615 2046 access_mask); 1616 2047 } … … 1620 2051 { 1621 2052 VFS_FIND(linux_setlease); 1622 return handle->fns->linux_setlease (handle, fsp, leasetype);2053 return handle->fns->linux_setlease_fn(handle, fsp, leasetype); 1623 2054 } 1624 2055 … … 1627 2058 { 1628 2059 VFS_FIND(symlink); 1629 return handle->fns->symlink (handle, oldpath, newpath);1630 } 1631 1632 int smb_vfs_call_ vfs_readlink(struct vfs_handle_struct *handle,2060 return handle->fns->symlink_fn(handle, oldpath, newpath); 2061 } 2062 2063 int smb_vfs_call_readlink(struct vfs_handle_struct *handle, 1633 2064 const char *path, char *buf, size_t bufsiz) 1634 2065 { 1635 VFS_FIND( vfs_readlink);1636 return handle->fns-> vfs_readlink(handle, path, buf, bufsiz);2066 VFS_FIND(readlink); 2067 return handle->fns->readlink_fn(handle, path, buf, bufsiz); 1637 2068 } 1638 2069 … … 1641 2072 { 1642 2073 VFS_FIND(link); 1643 return handle->fns->link (handle, oldpath, newpath);2074 return handle->fns->link_fn(handle, oldpath, newpath); 1644 2075 } 1645 2076 … … 1648 2079 { 1649 2080 VFS_FIND(mknod); 1650 return handle->fns->mknod (handle, path, mode, dev);2081 return handle->fns->mknod_fn(handle, path, mode, dev); 1651 2082 } 1652 2083 … … 1654 2085 { 1655 2086 VFS_FIND(realpath); 1656 return handle->fns->realpath(handle, path); 1657 } 1658 1659 NTSTATUS smb_vfs_call_notify_watch(struct vfs_handle_struct *handle, 1660 struct sys_notify_context *ctx, 1661 struct notify_entry *e, 1662 void (*callback)(struct sys_notify_context *ctx, 1663 void *private_data, 1664 struct notify_event *ev), 1665 void *private_data, void *handle_p) 1666 { 1667 VFS_FIND(notify_watch); 1668 return handle->fns->notify_watch(handle, ctx, e, callback, 1669 private_data, handle_p); 2087 return handle->fns->realpath_fn(handle, path); 1670 2088 } 1671 2089 … … 1674 2092 { 1675 2093 VFS_FIND(chflags); 1676 return handle->fns->chflags (handle, path, flags);2094 return handle->fns->chflags_fn(handle, path, flags); 1677 2095 } 1678 2096 … … 1681 2099 { 1682 2100 VFS_FIND(file_id_create); 1683 return handle->fns->file_id_create (handle, sbuf);2101 return handle->fns->file_id_create_fn(handle, sbuf); 1684 2102 } 1685 2103 … … 1692 2110 { 1693 2111 VFS_FIND(streaminfo); 1694 return handle->fns->streaminfo (handle, fsp, fname, mem_ctx,1695 2112 return handle->fns->streaminfo_fn(handle, fsp, fname, mem_ctx, 2113 num_streams, streams); 1696 2114 } 1697 2115 … … 1701 2119 { 1702 2120 VFS_FIND(get_real_filename); 1703 return handle->fns->get_real_filename (handle, path, name, mem_ctx,1704 2121 return handle->fns->get_real_filename_fn(handle, path, name, mem_ctx, 2122 found_name); 1705 2123 } 1706 2124 … … 1709 2127 { 1710 2128 VFS_FIND(connectpath); 1711 return handle->fns->connectpath (handle, filename);2129 return handle->fns->connectpath_fn(handle, filename); 1712 2130 } 1713 2131 … … 1717 2135 { 1718 2136 VFS_FIND(strict_lock); 1719 return handle->fns->strict_lock (handle, fsp, plock);2137 return handle->fns->strict_lock_fn(handle, fsp, plock); 1720 2138 } 1721 2139 … … 1725 2143 { 1726 2144 VFS_FIND(strict_unlock); 1727 handle->fns->strict_unlock (handle, fsp, plock);2145 handle->fns->strict_unlock_fn(handle, fsp, plock); 1728 2146 } 1729 2147 … … 1735 2153 { 1736 2154 VFS_FIND(translate_name); 1737 return handle->fns->translate_name(handle, name, direction, mem_ctx, 1738 mapped_name); 2155 return handle->fns->translate_name_fn(handle, name, direction, mem_ctx, 2156 mapped_name); 2157 } 2158 2159 NTSTATUS smb_vfs_call_fsctl(struct vfs_handle_struct *handle, 2160 struct files_struct *fsp, 2161 TALLOC_CTX *ctx, 2162 uint32_t function, 2163 uint16_t req_flags, 2164 const uint8_t *in_data, 2165 uint32_t in_len, 2166 uint8_t **out_data, 2167 uint32_t max_out_len, 2168 uint32_t *out_len) 2169 { 2170 VFS_FIND(fsctl); 2171 return handle->fns->fsctl_fn(handle, fsp, ctx, function, req_flags, 2172 in_data, in_len, out_data, max_out_len, 2173 out_len); 2174 } 2175 2176 struct tevent_req *smb_vfs_call_copy_chunk_send(struct vfs_handle_struct *handle, 2177 TALLOC_CTX *mem_ctx, 2178 struct tevent_context *ev, 2179 struct files_struct *src_fsp, 2180 off_t src_off, 2181 struct files_struct *dest_fsp, 2182 off_t dest_off, 2183 off_t num) 2184 { 2185 VFS_FIND(copy_chunk_send); 2186 return handle->fns->copy_chunk_send_fn(handle, mem_ctx, ev, src_fsp, 2187 src_off, dest_fsp, dest_off, num); 2188 } 2189 2190 NTSTATUS smb_vfs_call_copy_chunk_recv(struct vfs_handle_struct *handle, 2191 struct tevent_req *req, 2192 off_t *copied) 2193 { 2194 VFS_FIND(copy_chunk_recv); 2195 return handle->fns->copy_chunk_recv_fn(handle, req, copied); 2196 } 2197 2198 NTSTATUS smb_vfs_call_get_compression(vfs_handle_struct *handle, 2199 TALLOC_CTX *mem_ctx, 2200 struct files_struct *fsp, 2201 struct smb_filename *smb_fname, 2202 uint16_t *_compression_fmt) 2203 { 2204 VFS_FIND(get_compression); 2205 return handle->fns->get_compression_fn(handle, mem_ctx, fsp, smb_fname, 2206 _compression_fmt); 2207 } 2208 2209 NTSTATUS smb_vfs_call_set_compression(vfs_handle_struct *handle, 2210 TALLOC_CTX *mem_ctx, 2211 struct files_struct *fsp, 2212 uint16_t compression_fmt) 2213 { 2214 VFS_FIND(set_compression); 2215 return handle->fns->set_compression_fn(handle, mem_ctx, fsp, 2216 compression_fmt); 2217 } 2218 2219 NTSTATUS smb_vfs_call_snap_check_path(vfs_handle_struct *handle, 2220 TALLOC_CTX *mem_ctx, 2221 const char *service_path, 2222 char **base_volume) 2223 { 2224 VFS_FIND(snap_check_path); 2225 return handle->fns->snap_check_path_fn(handle, mem_ctx, service_path, 2226 base_volume); 2227 } 2228 2229 NTSTATUS smb_vfs_call_snap_create(struct vfs_handle_struct *handle, 2230 TALLOC_CTX *mem_ctx, 2231 const char *base_volume, 2232 time_t *tstamp, 2233 bool rw, 2234 char **base_path, 2235 char **snap_path) 2236 { 2237 VFS_FIND(snap_create); 2238 return handle->fns->snap_create_fn(handle, mem_ctx, base_volume, tstamp, 2239 rw, base_path, snap_path); 2240 } 2241 2242 NTSTATUS smb_vfs_call_snap_delete(struct vfs_handle_struct *handle, 2243 TALLOC_CTX *mem_ctx, 2244 char *base_path, 2245 char *snap_path) 2246 { 2247 VFS_FIND(snap_delete); 2248 return handle->fns->snap_delete_fn(handle, mem_ctx, base_path, 2249 snap_path); 1739 2250 } 1740 2251 1741 2252 NTSTATUS smb_vfs_call_fget_nt_acl(struct vfs_handle_struct *handle, 1742 2253 struct files_struct *fsp, 1743 uint32 security_info, 2254 uint32_t security_info, 2255 TALLOC_CTX *mem_ctx, 1744 2256 struct security_descriptor **ppdesc) 1745 2257 { 1746 2258 VFS_FIND(fget_nt_acl); 1747 return handle->fns->fget_nt_acl (handle, fsp, security_info,1748 ppdesc);2259 return handle->fns->fget_nt_acl_fn(handle, fsp, security_info, 2260 mem_ctx, ppdesc); 1749 2261 } 1750 2262 1751 2263 NTSTATUS smb_vfs_call_get_nt_acl(struct vfs_handle_struct *handle, 1752 2264 const char *name, 1753 uint32 security_info, 2265 uint32_t security_info, 2266 TALLOC_CTX *mem_ctx, 1754 2267 struct security_descriptor **ppdesc) 1755 2268 { 1756 2269 VFS_FIND(get_nt_acl); 1757 return handle->fns->get_nt_acl (handle, name, security_info, ppdesc);2270 return handle->fns->get_nt_acl_fn(handle, name, security_info, mem_ctx, ppdesc); 1758 2271 } 1759 2272 1760 2273 NTSTATUS smb_vfs_call_fset_nt_acl(struct vfs_handle_struct *handle, 1761 2274 struct files_struct *fsp, 1762 uint32 security_info_sent,2275 uint32_t security_info_sent, 1763 2276 const struct security_descriptor *psd) 1764 2277 { 1765 2278 VFS_FIND(fset_nt_acl); 1766 return handle->fns->fset_nt_acl(handle, fsp, security_info_sent, psd); 2279 return handle->fns->fset_nt_acl_fn(handle, fsp, security_info_sent, 2280 psd); 2281 } 2282 2283 NTSTATUS smb_vfs_call_audit_file(struct vfs_handle_struct *handle, 2284 struct smb_filename *file, 2285 struct security_acl *sacl, 2286 uint32_t access_requested, 2287 uint32_t access_denied) 2288 { 2289 VFS_FIND(audit_file); 2290 return handle->fns->audit_file_fn(handle, 2291 file, 2292 sacl, 2293 access_requested, 2294 access_denied); 1767 2295 } 1768 2296 … … 1771 2299 { 1772 2300 VFS_FIND(chmod_acl); 1773 return handle->fns->chmod_acl (handle, name, mode);2301 return handle->fns->chmod_acl_fn(handle, name, mode); 1774 2302 } 1775 2303 … … 1778 2306 { 1779 2307 VFS_FIND(fchmod_acl); 1780 return handle->fns->fchmod_acl(handle, fsp, mode); 1781 } 1782 1783 int smb_vfs_call_sys_acl_get_entry(struct vfs_handle_struct *handle, 1784 SMB_ACL_T theacl, int entry_id, 1785 SMB_ACL_ENTRY_T *entry_p) 1786 { 1787 VFS_FIND(sys_acl_get_entry); 1788 return handle->fns->sys_acl_get_entry(handle, theacl, entry_id, 1789 entry_p); 1790 } 1791 1792 int smb_vfs_call_sys_acl_get_tag_type(struct vfs_handle_struct *handle, 1793 SMB_ACL_ENTRY_T entry_d, 1794 SMB_ACL_TAG_T *tag_type_p) 1795 { 1796 VFS_FIND(sys_acl_get_tag_type); 1797 return handle->fns->sys_acl_get_tag_type(handle, entry_d, tag_type_p); 1798 } 1799 1800 int smb_vfs_call_sys_acl_get_permset(struct vfs_handle_struct *handle, 1801 SMB_ACL_ENTRY_T entry_d, 1802 SMB_ACL_PERMSET_T *permset_p) 1803 { 1804 VFS_FIND(sys_acl_get_permset); 1805 return handle->fns->sys_acl_get_permset(handle, entry_d, permset_p); 1806 } 1807 1808 void * smb_vfs_call_sys_acl_get_qualifier(struct vfs_handle_struct *handle, 1809 SMB_ACL_ENTRY_T entry_d) 1810 { 1811 VFS_FIND(sys_acl_get_qualifier); 1812 return handle->fns->sys_acl_get_qualifier(handle, entry_d); 2308 return handle->fns->fchmod_acl_fn(handle, fsp, mode); 1813 2309 } 1814 2310 1815 2311 SMB_ACL_T smb_vfs_call_sys_acl_get_file(struct vfs_handle_struct *handle, 1816 2312 const char *path_p, 1817 SMB_ACL_TYPE_T type) 2313 SMB_ACL_TYPE_T type, 2314 TALLOC_CTX *mem_ctx) 1818 2315 { 1819 2316 VFS_FIND(sys_acl_get_file); 1820 return handle->fns->sys_acl_get_file (handle, path_p, type);2317 return handle->fns->sys_acl_get_file_fn(handle, path_p, type, mem_ctx); 1821 2318 } 1822 2319 1823 2320 SMB_ACL_T smb_vfs_call_sys_acl_get_fd(struct vfs_handle_struct *handle, 1824 struct files_struct *fsp) 2321 struct files_struct *fsp, 2322 TALLOC_CTX *mem_ctx) 1825 2323 { 1826 2324 VFS_FIND(sys_acl_get_fd); 1827 return handle->fns->sys_acl_get_fd(handle, fsp); 1828 } 1829 1830 int smb_vfs_call_sys_acl_clear_perms(struct vfs_handle_struct *handle, 1831 SMB_ACL_PERMSET_T permset) 1832 { 1833 VFS_FIND(sys_acl_clear_perms); 1834 return handle->fns->sys_acl_clear_perms(handle, permset); 1835 } 1836 1837 int smb_vfs_call_sys_acl_add_perm(struct vfs_handle_struct *handle, 1838 SMB_ACL_PERMSET_T permset, 1839 SMB_ACL_PERM_T perm) 1840 { 1841 VFS_FIND(sys_acl_add_perm); 1842 return handle->fns->sys_acl_add_perm(handle, permset, perm); 1843 } 1844 1845 char * smb_vfs_call_sys_acl_to_text(struct vfs_handle_struct *handle, 1846 SMB_ACL_T theacl, ssize_t *plen) 1847 { 1848 VFS_FIND(sys_acl_to_text); 1849 return handle->fns->sys_acl_to_text(handle, theacl, plen); 1850 } 1851 1852 SMB_ACL_T smb_vfs_call_sys_acl_init(struct vfs_handle_struct *handle, 1853 int count) 1854 { 1855 VFS_FIND(sys_acl_init); 1856 return handle->fns->sys_acl_init(handle, count); 1857 } 1858 1859 int smb_vfs_call_sys_acl_create_entry(struct vfs_handle_struct *handle, 1860 SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry) 1861 { 1862 VFS_FIND(sys_acl_create_entry); 1863 return handle->fns->sys_acl_create_entry(handle, pacl, pentry); 1864 } 1865 1866 int smb_vfs_call_sys_acl_set_tag_type(struct vfs_handle_struct *handle, 1867 SMB_ACL_ENTRY_T entry, 1868 SMB_ACL_TAG_T tagtype) 1869 { 1870 VFS_FIND(sys_acl_set_tag_type); 1871 return handle->fns->sys_acl_set_tag_type(handle, entry, tagtype); 1872 } 1873 1874 int smb_vfs_call_sys_acl_set_qualifier(struct vfs_handle_struct *handle, 1875 SMB_ACL_ENTRY_T entry, void *qual) 1876 { 1877 VFS_FIND(sys_acl_set_qualifier); 1878 return handle->fns->sys_acl_set_qualifier(handle, entry, qual); 1879 } 1880 1881 int smb_vfs_call_sys_acl_set_permset(struct vfs_handle_struct *handle, 1882 SMB_ACL_ENTRY_T entry, 1883 SMB_ACL_PERMSET_T permset) 1884 { 1885 VFS_FIND(sys_acl_set_permset); 1886 return handle->fns->sys_acl_set_permset(handle, entry, permset); 1887 } 1888 1889 int smb_vfs_call_sys_acl_valid(struct vfs_handle_struct *handle, 1890 SMB_ACL_T theacl) 1891 { 1892 VFS_FIND(sys_acl_valid); 1893 return handle->fns->sys_acl_valid(handle, theacl); 2325 return handle->fns->sys_acl_get_fd_fn(handle, fsp, mem_ctx); 2326 } 2327 2328 int smb_vfs_call_sys_acl_blob_get_file(struct vfs_handle_struct *handle, 2329 const char *path_p, 2330 TALLOC_CTX *mem_ctx, 2331 char **blob_description, 2332 DATA_BLOB *blob) 2333 { 2334 VFS_FIND(sys_acl_blob_get_file); 2335 return handle->fns->sys_acl_blob_get_file_fn(handle, path_p, mem_ctx, blob_description, blob); 2336 } 2337 2338 int smb_vfs_call_sys_acl_blob_get_fd(struct vfs_handle_struct *handle, 2339 struct files_struct *fsp, 2340 TALLOC_CTX *mem_ctx, 2341 char **blob_description, 2342 DATA_BLOB *blob) 2343 { 2344 VFS_FIND(sys_acl_blob_get_fd); 2345 return handle->fns->sys_acl_blob_get_fd_fn(handle, fsp, mem_ctx, blob_description, blob); 1894 2346 } 1895 2347 … … 1899 2351 { 1900 2352 VFS_FIND(sys_acl_set_file); 1901 return handle->fns->sys_acl_set_file (handle, name, acltype, theacl);2353 return handle->fns->sys_acl_set_file_fn(handle, name, acltype, theacl); 1902 2354 } 1903 2355 … … 1906 2358 { 1907 2359 VFS_FIND(sys_acl_set_fd); 1908 return handle->fns->sys_acl_set_fd (handle, fsp, theacl);2360 return handle->fns->sys_acl_set_fd_fn(handle, fsp, theacl); 1909 2361 } 1910 2362 … … 1913 2365 { 1914 2366 VFS_FIND(sys_acl_delete_def_file); 1915 return handle->fns->sys_acl_delete_def_file(handle, path); 1916 } 1917 1918 int smb_vfs_call_sys_acl_get_perm(struct vfs_handle_struct *handle, 1919 SMB_ACL_PERMSET_T permset, 1920 SMB_ACL_PERM_T perm) 1921 { 1922 VFS_FIND(sys_acl_get_perm); 1923 return handle->fns->sys_acl_get_perm(handle, permset, perm); 1924 } 1925 1926 int smb_vfs_call_sys_acl_free_text(struct vfs_handle_struct *handle, 1927 char *text) 1928 { 1929 VFS_FIND(sys_acl_free_text); 1930 return handle->fns->sys_acl_free_text(handle, text); 1931 } 1932 1933 int smb_vfs_call_sys_acl_free_acl(struct vfs_handle_struct *handle, 1934 SMB_ACL_T posix_acl) 1935 { 1936 VFS_FIND(sys_acl_free_acl); 1937 return handle->fns->sys_acl_free_acl(handle, posix_acl); 1938 } 1939 1940 int smb_vfs_call_sys_acl_free_qualifier(struct vfs_handle_struct *handle, 1941 void *qualifier, SMB_ACL_TAG_T tagtype) 1942 { 1943 VFS_FIND(sys_acl_free_qualifier); 1944 return handle->fns->sys_acl_free_qualifier(handle, qualifier, tagtype); 2367 return handle->fns->sys_acl_delete_def_file_fn(handle, path); 1945 2368 } 1946 2369 … … 1950 2373 { 1951 2374 VFS_FIND(getxattr); 1952 return handle->fns->getxattr(handle, path, name, value, size); 1953 } 1954 1955 ssize_t smb_vfs_call_lgetxattr(struct vfs_handle_struct *handle, 1956 const char *path, const char *name, void *value, 1957 size_t size) 1958 { 1959 VFS_FIND(lgetxattr); 1960 return handle->fns->lgetxattr(handle, path, name, value, size); 2375 return handle->fns->getxattr_fn(handle, path, name, value, size); 1961 2376 } 1962 2377 … … 1966 2381 { 1967 2382 VFS_FIND(fgetxattr); 1968 return handle->fns->fgetxattr (handle, fsp, name, value, size);2383 return handle->fns->fgetxattr_fn(handle, fsp, name, value, size); 1969 2384 } 1970 2385 … … 1973 2388 { 1974 2389 VFS_FIND(listxattr); 1975 return handle->fns->listxattr(handle, path, list, size); 1976 } 1977 1978 ssize_t smb_vfs_call_llistxattr(struct vfs_handle_struct *handle, 1979 const char *path, char *list, size_t size) 1980 { 1981 VFS_FIND(llistxattr); 1982 return handle->fns->llistxattr(handle, path, list, size); 2390 return handle->fns->listxattr_fn(handle, path, list, size); 1983 2391 } 1984 2392 … … 1988 2396 { 1989 2397 VFS_FIND(flistxattr); 1990 return handle->fns->flistxattr (handle, fsp, list, size);2398 return handle->fns->flistxattr_fn(handle, fsp, list, size); 1991 2399 } 1992 2400 … … 1995 2403 { 1996 2404 VFS_FIND(removexattr); 1997 return handle->fns->removexattr(handle, path, name); 1998 } 1999 2000 int smb_vfs_call_lremovexattr(struct vfs_handle_struct *handle, 2001 const char *path, const char *name) 2002 { 2003 VFS_FIND(lremovexattr); 2004 return handle->fns->lremovexattr(handle, path, name); 2405 return handle->fns->removexattr_fn(handle, path, name); 2005 2406 } 2006 2407 … … 2009 2410 { 2010 2411 VFS_FIND(fremovexattr); 2011 return handle->fns->fremovexattr (handle, fsp, name);2412 return handle->fns->fremovexattr_fn(handle, fsp, name); 2012 2413 } 2013 2414 … … 2017 2418 { 2018 2419 VFS_FIND(setxattr); 2019 return handle->fns->setxattr(handle, path, name, value, size, flags); 2020 } 2021 2022 int smb_vfs_call_lsetxattr(struct vfs_handle_struct *handle, const char *path, 2023 const char *name, const void *value, size_t size, 2024 int flags) 2025 { 2026 VFS_FIND(lsetxattr); 2027 return handle->fns->lsetxattr(handle, path, name, value, size, flags); 2420 return handle->fns->setxattr_fn(handle, path, name, value, size, flags); 2028 2421 } 2029 2422 … … 2033 2426 { 2034 2427 VFS_FIND(fsetxattr); 2035 return handle->fns->fsetxattr(handle, fsp, name, value, size, flags); 2036 } 2037 2038 int smb_vfs_call_aio_read(struct vfs_handle_struct *handle, 2039 struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb) 2040 { 2041 VFS_FIND(aio_read); 2042 return handle->fns->aio_read(handle, fsp, aiocb); 2043 } 2044 2045 int smb_vfs_call_aio_write(struct vfs_handle_struct *handle, 2046 struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb) 2047 { 2048 VFS_FIND(aio_write); 2049 return handle->fns->aio_write(handle, fsp, aiocb); 2050 } 2051 2052 ssize_t smb_vfs_call_aio_return_fn(struct vfs_handle_struct *handle, 2053 struct files_struct *fsp, 2054 SMB_STRUCT_AIOCB *aiocb) 2055 { 2056 VFS_FIND(aio_return_fn); 2057 return handle->fns->aio_return_fn(handle, fsp, aiocb); 2058 } 2059 2060 int smb_vfs_call_aio_cancel(struct vfs_handle_struct *handle, 2061 struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb) 2062 { 2063 VFS_FIND(aio_cancel); 2064 return handle->fns->aio_cancel(handle, fsp, aiocb); 2065 } 2066 2067 int smb_vfs_call_aio_error_fn(struct vfs_handle_struct *handle, 2068 struct files_struct *fsp, 2069 SMB_STRUCT_AIOCB *aiocb) 2070 { 2071 VFS_FIND(aio_error_fn); 2072 return handle->fns->aio_error_fn(handle, fsp, aiocb); 2073 } 2074 2075 int smb_vfs_call_aio_fsync(struct vfs_handle_struct *handle, 2076 struct files_struct *fsp, int op, 2077 SMB_STRUCT_AIOCB *aiocb) 2078 { 2079 VFS_FIND(aio_fsync); 2080 return handle->fns->aio_fsync(handle, fsp, op, aiocb); 2081 } 2082 2083 int smb_vfs_call_aio_suspend(struct vfs_handle_struct *handle, 2084 struct files_struct *fsp, 2085 const SMB_STRUCT_AIOCB * const aiocb[], int n, 2086 const struct timespec *timeout) 2087 { 2088 VFS_FIND(aio_suspend); 2089 return handle->fns->aio_suspend(handle, fsp, aiocb, n, timeout); 2428 return handle->fns->fsetxattr_fn(handle, fsp, name, value, size, flags); 2090 2429 } 2091 2430 … … 2094 2433 { 2095 2434 VFS_FIND(aio_force); 2096 return handle->fns->aio_force (handle, fsp);2435 return handle->fns->aio_force_fn(handle, fsp); 2097 2436 } 2098 2437 … … 2102 2441 { 2103 2442 VFS_FIND(is_offline); 2104 return handle->fns->is_offline (handle, fname, sbuf);2443 return handle->fns->is_offline_fn(handle, fname, sbuf); 2105 2444 } 2106 2445 … … 2109 2448 { 2110 2449 VFS_FIND(set_offline); 2111 return handle->fns->set_offline(handle, fname); 2112 } 2450 return handle->fns->set_offline_fn(handle, fname); 2451 } 2452 2453 NTSTATUS smb_vfs_call_durable_cookie(struct vfs_handle_struct *handle, 2454 struct files_struct *fsp, 2455 TALLOC_CTX *mem_ctx, 2456 DATA_BLOB *cookie) 2457 { 2458 VFS_FIND(durable_cookie); 2459 return handle->fns->durable_cookie_fn(handle, fsp, mem_ctx, cookie); 2460 } 2461 2462 NTSTATUS smb_vfs_call_durable_disconnect(struct vfs_handle_struct *handle, 2463 struct files_struct *fsp, 2464 const DATA_BLOB old_cookie, 2465 TALLOC_CTX *mem_ctx, 2466 DATA_BLOB *new_cookie) 2467 { 2468 VFS_FIND(durable_disconnect); 2469 return handle->fns->durable_disconnect_fn(handle, fsp, old_cookie, 2470 mem_ctx, new_cookie); 2471 } 2472 2473 NTSTATUS smb_vfs_call_durable_reconnect(struct vfs_handle_struct *handle, 2474 struct smb_request *smb1req, 2475 struct smbXsrv_open *op, 2476 const DATA_BLOB old_cookie, 2477 TALLOC_CTX *mem_ctx, 2478 struct files_struct **fsp, 2479 DATA_BLOB *new_cookie) 2480 { 2481 VFS_FIND(durable_reconnect); 2482 return handle->fns->durable_reconnect_fn(handle, smb1req, op, 2483 old_cookie, mem_ctx, fsp, 2484 new_cookie); 2485 } 2486 2487 NTSTATUS smb_vfs_call_readdir_attr(struct vfs_handle_struct *handle, 2488 const struct smb_filename *fname, 2489 TALLOC_CTX *mem_ctx, 2490 struct readdir_attr_data **attr_data) 2491 { 2492 VFS_FIND(readdir_attr); 2493 return handle->fns->readdir_attr_fn(handle, fname, mem_ctx, attr_data); 2494 }
Note:
See TracChangeset
for help on using the changeset viewer.