Changeset 599 for trunk/server/source3/modules
- Timestamp:
- Jul 6, 2011, 8:21:13 PM (14 years ago)
- Location:
- trunk/server/source3/modules
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/source3/modules/gpfs.c
r414 r599 25 25 #include "vfs_gpfs.h" 26 26 27 static bool gpfs_share_modes;28 static bool gpfs_leases;29 27 static bool gpfs_getrealfilename; 30 28 static bool gpfs_winattr; 29 static bool gpfs_do_ftruncate; 31 30 32 31 static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny); … … 39 38 static int (*gpfs_get_winattrs_path_fn)(char *pathname, struct gpfs_winattr *attrs); 40 39 static int (*gpfs_get_winattrs_fn)(int fd, struct gpfs_winattr *attrs); 41 40 static int (*gpfs_ftruncate_fn)(int fd, gpfs_off64_t length); 42 41 43 42 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask, … … 47 46 unsigned int deny = GPFS_DENY_NONE; 48 47 int result; 49 50 if (!gpfs_share_modes) {51 return True;52 }53 48 54 49 if (gpfs_set_share_fn == NULL) { … … 97 92 int gpfs_type = GPFS_LEASE_NONE; 98 93 99 if (!gpfs_leases) {100 return True;101 }102 103 94 if (gpfs_set_lease_fn == NULL) { 104 95 errno = EINVAL; … … 140 131 141 132 return gpfs_putacl_fn(pathname, flags, acl); 133 } 134 135 int smbd_gpfs_ftrunctate(int fd, gpfs_off64_t length) 136 { 137 if (!gpfs_do_ftruncate || (gpfs_ftruncate_fn == NULL)) { 138 errno = ENOSYS; 139 return -1; 140 } 141 142 return gpfs_ftruncate_fn(fd, length); 142 143 } 143 144 … … 248 249 init_gpfs_function(&gpfs_set_winattrs_path_fn,"gpfs_set_winattrs_path"); 249 250 init_gpfs_function(&gpfs_get_winattrs_fn,"gpfs_get_winattrs"); 250 251 252 gpfs_share_modes = lp_parm_bool(-1, "gpfs", "sharemodes", True); 253 gpfs_leases = lp_parm_bool(-1, "gpfs", "leases", True); 251 init_gpfs_function(&gpfs_ftruncate_fn,"gpfs_ftruncate"); 252 254 253 gpfs_getrealfilename = lp_parm_bool(-1, "gpfs", "getrealfilename", 255 254 True); 256 255 gpfs_winattr = lp_parm_bool(-1, "gpfs", "winattr", False); 256 257 gpfs_do_ftruncate = lp_parm_bool(-1, "gpfs", "ftruncate", True); 257 258 258 259 return; -
trunk/server/source3/modules/vfs_acl_common.c
r596 r599 442 442 NTSTATUS status = NT_STATUS_OK; 443 443 struct security_descriptor *psd = NULL; 444 struct dom_sid *owner_sid = NULL; 445 struct dom_sid *group_sid = NULL; 446 uint32_t security_info_sent = (OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION); 444 447 size_t size; 445 446 if (!sd_has_inheritable_components(parent_desc, is_directory)) { 448 bool inherit_owner = lp_inherit_owner(SNUM(handle->conn)); 449 bool inheritable_components = sd_has_inheritable_components(parent_desc, 450 is_directory); 451 452 if (!inheritable_components && !inherit_owner) { 453 /* Nothing to inherit and not setting owner. */ 447 454 return NT_STATUS_OK; 448 455 } … … 456 463 } 457 464 465 /* Inherit from parent descriptor if "inherit owner" set. */ 466 if (inherit_owner) { 467 owner_sid = parent_desc->owner_sid; 468 group_sid = parent_desc->group_sid; 469 } 470 471 if (owner_sid == NULL) { 472 owner_sid = &handle->conn->server_info->ptok->user_sids[PRIMARY_USER_SID_INDEX]; 473 } 474 if (group_sid == NULL) { 475 group_sid = &handle->conn->server_info->ptok->user_sids[PRIMARY_GROUP_SID_INDEX]; 476 } 477 458 478 status = se_create_child_secdesc(ctx, 459 479 &psd, 460 480 &size, 461 481 parent_desc, 462 &handle->conn->server_info->ptok->user_sids[PRIMARY_USER_SID_INDEX],463 &handle->conn->server_info->ptok->user_sids[PRIMARY_GROUP_SID_INDEX],482 owner_sid, 483 group_sid, 464 484 is_directory); 465 485 if (!NT_STATUS_IS_OK(status)) { 466 486 return status; 487 } 488 489 /* If inheritable_components == false, 490 se_create_child_secdesc() 491 creates a security desriptor with a NULL dacl 492 entry, but with SEC_DESC_DACL_PRESENT. We need 493 to remove that flag. */ 494 495 if (!inheritable_components) { 496 security_info_sent &= ~SECINFO_DACL; 497 psd->type &= ~SEC_DESC_DACL_PRESENT; 467 498 } 468 499 … … 470 501 DEBUG(10,("inherit_new_acl: child acl for %s is:\n", 471 502 fsp_str_dbg(fsp) )); 472 NDR_PRINT_DEBUG(security_descriptor, parent_desc); 473 } 474 475 return SMB_VFS_FSET_NT_ACL(fsp, 476 (OWNER_SECURITY_INFORMATION | 477 GROUP_SECURITY_INFORMATION | 478 DACL_SECURITY_INFORMATION), 503 NDR_PRINT_DEBUG(security_descriptor, psd); 504 } 505 506 if (inherit_owner) { 507 /* We need to be root to force this. */ 508 become_root(); 509 } 510 status = SMB_VFS_FSET_NT_ACL(fsp, 511 security_info_sent, 479 512 psd); 480 } 481 482 static NTSTATUS check_parent_acl_common(vfs_handle_struct *handle, 513 if (inherit_owner) { 514 unbecome_root(); 515 } 516 return status; 517 } 518 519 static NTSTATUS get_parent_acl_common(vfs_handle_struct *handle, 483 520 const char *path, 484 uint32_t access_mask,485 521 struct security_descriptor **pp_parent_desc) 486 522 { 487 523 char *parent_name = NULL; 488 struct security_descriptor *parent_desc = NULL;489 uint32_t access_granted = 0;490 524 NTSTATUS status; 491 525 … … 497 531 NULL, 498 532 parent_name, 499 ( OWNER_SECURITY_INFORMATION|500 GROUP_SECURITY_INFORMATION|501 DACL_SECURITY_INFORMATION),502 &parent_desc);503 504 if (!NT_STATUS_IS_OK(status)) { 505 DEBUG(10,(" check_parent_acl_common: get_nt_acl_internal "533 (SECINFO_OWNER | 534 SECINFO_GROUP | 535 SECINFO_DACL), 536 pp_parent_desc); 537 538 if (!NT_STATUS_IS_OK(status)) { 539 DEBUG(10,("get_parent_acl_common: get_nt_acl_internal " 506 540 "on directory %s for " 507 541 "path %s returned %s\n", … … 509 543 path, 510 544 nt_errstr(status) )); 545 } 546 return status; 547 } 548 549 static NTSTATUS check_parent_acl_common(vfs_handle_struct *handle, 550 const char *path, 551 uint32_t access_mask, 552 struct security_descriptor **pp_parent_desc) 553 { 554 char *parent_name = NULL; 555 struct security_descriptor *parent_desc = NULL; 556 uint32_t access_granted = 0; 557 NTSTATUS status; 558 559 status = get_parent_acl_common(handle, path, &parent_desc); 560 if (!NT_STATUS_IS_OK(status)) { 511 561 return status; 562 } 563 if (pp_parent_desc) { 564 *pp_parent_desc = parent_desc; 512 565 } 513 566 status = smb1_file_se_access_check(handle->conn, … … 526 579 return status; 527 580 } 528 if (pp_parent_desc) {529 *pp_parent_desc = parent_desc;530 }531 581 return NT_STATUS_OK; 532 }533 534 static void free_sd_common(void **ptr)535 {536 TALLOC_FREE(*ptr);537 582 } 538 583 … … 549 594 uint32_t access_granted = 0; 550 595 struct security_descriptor *pdesc = NULL; 551 struct security_descriptor *parent_desc = NULL;552 596 bool file_existed = true; 553 597 char *fname = NULL; … … 595 639 */ 596 640 if (flags & O_CREAT) { 597 struct security_descriptor *psd = NULL; 641 struct security_descriptor *parent_desc = NULL; 642 struct security_descriptor **pp_psd = NULL; 598 643 599 644 status = check_parent_acl_common(handle, fname, … … 602 647 goto err; 603 648 } 649 604 650 /* Cache the parent security descriptor for 605 * later use. We do have an fsp here, but to 606 * keep the code consistent with the directory 607 * case which doesn't, use the handle. */ 608 609 /* Attach this to the conn, move from talloc_tos(). */ 610 psd = (struct security_descriptor *)talloc_move(handle->conn, 611 &parent_desc); 612 613 if (!psd) { 651 * later use. */ 652 653 pp_psd = VFS_ADD_FSP_EXTENSION(handle, 654 fsp, 655 struct security_descriptor *, 656 NULL); 657 if (!pp_psd) { 614 658 status = NT_STATUS_NO_MEMORY; 615 659 goto err; 616 660 } 617 status = NT_STATUS_NO_MEMORY; 618 SMB_VFS_HANDLE_SET_DATA(handle, psd, free_sd_common, 619 struct security_descriptor *, goto err); 661 662 *pp_psd = parent_desc; 620 663 status = NT_STATUS_OK; 621 664 } … … 644 687 ret = vfs_stat_smb_fname(handle->conn, path, &sbuf); 645 688 if (ret == -1 && errno == ENOENT) { 646 struct security_descriptor *parent_desc = NULL;647 struct security_descriptor *psd = NULL;648 649 689 /* We're creating a new directory. */ 650 690 status = check_parent_acl_common(handle, path, 651 SEC_DIR_ADD_SUBDIR, &parent_desc);691 SEC_DIR_ADD_SUBDIR, NULL); 652 692 if (!NT_STATUS_IS_OK(status)) { 653 693 errno = map_errno_from_nt_status(status); 654 694 return -1; 655 695 } 656 657 /* Cache the parent security descriptor for658 * later use. We don't have an fsp here so659 * use the handle. */660 661 /* Attach this to the conn, move from talloc_tos(). */662 psd = (struct security_descriptor *)talloc_move(handle->conn,663 &parent_desc);664 665 if (!psd) {666 return -1;667 }668 SMB_VFS_HANDLE_SET_DATA(handle, psd, free_sd_common,669 struct security_descriptor *, return -1);670 696 } 671 697 … … 910 936 int info; 911 937 struct security_descriptor *parent_sd = NULL; 938 struct security_descriptor **pp_parent_sd = NULL; 912 939 913 940 status = SMB_VFS_NEXT_CREATE_FILE(handle, … … 953 980 } 954 981 955 956 /* We must have a cached parent sd in this case. 957 * attached to the handle. */ 958 959 SMB_VFS_HANDLE_GET_DATA(handle, parent_sd, 960 struct security_descriptor, 961 goto err); 982 /* See if we have a cached parent sd, if so, use it. */ 983 pp_parent_sd = (struct security_descriptor **)VFS_FETCH_FSP_EXTENSION(handle, fsp); 984 if (!pp_parent_sd) { 985 /* Must be a directory, fetch again (sigh). */ 986 status = get_parent_acl_common(handle, 987 fsp->fsp_name->base_name, 988 &parent_sd); 989 if (!NT_STATUS_IS_OK(status)) { 990 goto out; 991 } 992 } else { 993 parent_sd = *pp_parent_sd; 994 } 962 995 963 996 if (!parent_sd) { … … 977 1010 out: 978 1011 979 /* Ensure we never leave attached data around. */ 980 SMB_VFS_HANDLE_FREE_DATA(handle); 1012 if (fsp) { 1013 VFS_REMOVE_FSP_EXTENSION(handle, fsp); 1014 } 981 1015 982 1016 if (NT_STATUS_IS_OK(status) && pinfo) { … … 1013 1047 false); 1014 1048 } 1049 1050 static int chmod_acl_module_common(struct vfs_handle_struct *handle, 1051 const char *path, mode_t mode) 1052 { 1053 if (lp_posix_pathnames()) { 1054 /* Only allow this on POSIX pathnames. */ 1055 return SMB_VFS_NEXT_CHMOD(handle, path, mode); 1056 } 1057 return 0; 1058 } 1059 1060 static int fchmod_acl_module_common(struct vfs_handle_struct *handle, 1061 struct files_struct *fsp, mode_t mode) 1062 { 1063 if (fsp->posix_open) { 1064 /* Only allow this on POSIX opens. */ 1065 return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode); 1066 } 1067 return 0; 1068 } 1069 1070 static int chmod_acl_acl_module_common(struct vfs_handle_struct *handle, 1071 const char *name, mode_t mode) 1072 { 1073 if (lp_posix_pathnames()) { 1074 /* Only allow this on POSIX pathnames. */ 1075 return SMB_VFS_NEXT_CHMOD_ACL(handle, name, mode); 1076 } 1077 return 0; 1078 } 1079 1080 static int fchmod_acl_acl_module_common(struct vfs_handle_struct *handle, 1081 struct files_struct *fsp, mode_t mode) 1082 { 1083 if (fsp->posix_open) { 1084 /* Only allow this on POSIX opens. */ 1085 return SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode); 1086 } 1087 return 0; 1088 } -
trunk/server/source3/modules/vfs_acl_tdb.c
r596 r599 398 398 .opendir = opendir_acl_common, 399 399 .mkdir = mkdir_acl_common, 400 .rmdir = rmdir_acl_tdb, 400 401 .open = open_acl_common, 401 402 .create_file = create_file_acl_common, 402 403 .unlink = unlink_acl_tdb, 403 .rmdir = rmdir_acl_tdb, 404 .chmod = chmod_acl_module_common, 405 .fchmod = fchmod_acl_module_common, 404 406 .fget_nt_acl = fget_nt_acl_common, 405 407 .get_nt_acl = get_nt_acl_common, 406 408 .fset_nt_acl = fset_nt_acl_common, 409 .chmod_acl = chmod_acl_acl_module_common, 410 .fchmod_acl = fchmod_acl_acl_module_common, 407 411 .sys_acl_set_file = sys_acl_set_file_tdb, 408 412 .sys_acl_set_fd = sys_acl_set_fd_tdb -
trunk/server/source3/modules/vfs_acl_xattr.c
r596 r599 208 208 .create_file = create_file_acl_common, 209 209 .unlink = unlink_acl_common, 210 .chmod = chmod_acl_module_common, 211 .fchmod = fchmod_acl_module_common, 210 212 .fget_nt_acl = fget_nt_acl_common, 211 213 .get_nt_acl = get_nt_acl_common, 212 214 .fset_nt_acl = fset_nt_acl_common, 215 .chmod_acl = chmod_acl_acl_module_common, 216 .fchmod_acl = fchmod_acl_acl_module_common, 213 217 .sys_acl_set_file = sys_acl_set_file_xattr, 214 218 .sys_acl_set_fd = sys_acl_set_fd_xattr -
trunk/server/source3/modules/vfs_gpfs.c
r596 r599 31 31 #include "vfs_gpfs.h" 32 32 33 struct gpfs_config_data { 34 bool sharemodes; 35 bool leases; 36 }; 37 38 33 39 static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp, 34 40 uint32 share_mode, uint32 access_mask) 35 41 { 36 42 43 struct gpfs_config_data *config; 44 45 SMB_VFS_HANDLE_GET_DATA(handle, config, 46 struct gpfs_config_data, 47 return -1); 48 37 49 START_PROFILE(syscall_kernel_flock); 38 50 39 51 kernel_flock(fsp->fh->fd, share_mode, access_mask); 40 52 41 if (!set_gpfs_sharemode(fsp, access_mask, fsp->share_access)) { 42 43 return -1; 44 53 if (config->sharemodes 54 && !set_gpfs_sharemode(fsp, access_mask, fsp->share_access)) { 55 return -1; 45 56 } 46 57 … … 52 63 static int vfs_gpfs_close(vfs_handle_struct *handle, files_struct *fsp) 53 64 { 54 if ((fsp->fh != NULL) && (fsp->fh->fd != -1)) { 65 66 struct gpfs_config_data *config; 67 68 SMB_VFS_HANDLE_GET_DATA(handle, config, 69 struct gpfs_config_data, 70 return -1); 71 72 if (config->sharemodes && (fsp->fh != NULL) && (fsp->fh->fd != -1)) { 55 73 set_gpfs_sharemode(fsp, 0, 0); 56 74 } … … 62 80 int leasetype) 63 81 { 64 int ret; 82 struct gpfs_config_data *config; 83 int ret=0; 84 85 SMB_VFS_HANDLE_GET_DATA(handle, config, 86 struct gpfs_config_data, 87 return -1); 65 88 66 89 START_PROFILE(syscall_linux_setlease); 67 90 68 if ( linux_set_lease_sighandler(fsp->fh->fd) == -1) 69 return -1; 70 71 ret = set_gpfs_lease(fsp->fh->fd,leasetype); 72 73 if ( ret < 0 ) { 91 if (linux_set_lease_sighandler(fsp->fh->fd) == -1) 92 return -1; 93 94 if (config->leases) { 95 ret = set_gpfs_lease(fsp->fh->fd,leasetype); 96 } 97 98 if (ret < 0) { 74 99 /* This must have come from GPFS not being available */ 75 100 /* or some other error, hence call the default */ … … 959 984 struct gpfs_winattr attrs; 960 985 int ret = 0; 986 ssize_t result; 961 987 962 988 DEBUG(10, ("gpfs_get_xattr: %s \n",path)); … … 995 1021 } 996 1022 997 snprintf(attrstr, size, "0x%x", dosmode & SAMBA_ATTRIBUTES_MASK); 1023 result = snprintf(attrstr, size, "0x%x", 1024 dosmode & SAMBA_ATTRIBUTES_MASK) + 1; 1025 998 1026 DEBUG(10, ("gpfs_get_xattr: returning %s\n",attrstr)); 999 return size;1027 return result; 1000 1028 } 1001 1029 … … 1114 1142 } 1115 1143 1144 int vfs_gpfs_connect(struct vfs_handle_struct *handle, const char *service, 1145 const char *user) 1146 { 1147 struct gpfs_config_data *config; 1148 int ret = SMB_VFS_NEXT_CONNECT(handle, service, user); 1149 1150 if (ret < 0) { 1151 return ret; 1152 } 1153 1154 config = talloc_zero(handle->conn, struct gpfs_config_data); 1155 if (!config) { 1156 SMB_VFS_NEXT_DISCONNECT(handle); 1157 DEBUG(0, ("talloc_zero() failed\n")); return -1; 1158 } 1159 1160 config->sharemodes = lp_parm_bool(SNUM(handle->conn), "gpfs", 1161 "sharemodes", true); 1162 1163 config->leases = lp_parm_bool(SNUM(handle->conn), "gpfs", 1164 "leases", true); 1165 1166 SMB_VFS_HANDLE_SET_DATA(handle, config, 1167 NULL, struct gpfs_config_data, 1168 return -1); 1169 1170 return 0; 1171 } 1172 1173 1174 static int vfs_gpfs_ftruncate(struct vfs_handle_struct *handle, 1175 struct files_struct *fsp, 1176 SMB_OFF_T len) 1177 { 1178 int result; 1179 1180 result = smbd_gpfs_ftrunctate(fsp->fh->fd, len); 1181 if ((result == -1) && (errno == ENOSYS)) { 1182 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len); 1183 } 1184 return result; 1185 } 1186 1116 1187 static struct vfs_fn_pointers vfs_gpfs_fns = { 1188 .connect_fn = vfs_gpfs_connect, 1117 1189 .kernel_flock = vfs_gpfs_kernel_flock, 1118 1190 .linux_setlease = vfs_gpfs_setlease, … … 1135 1207 .lstat = vfs_gpfs_lstat, 1136 1208 .ntimes = vfs_gpfs_ntimes, 1209 .ftruncate = vfs_gpfs_ftruncate, 1137 1210 }; 1138 1211 -
trunk/server/source3/modules/vfs_gpfs.h
r414 r599 35 35 int get_gpfs_winattrs(char * pathname,struct gpfs_winattr *attrs); 36 36 int set_gpfs_winattrs(char * pathname,int flags,struct gpfs_winattr *attrs); 37 int smbd_gpfs_ftrunctate(int fd, gpfs_off64_t length); 37 38 void init_gpfs(void); -
trunk/server/source3/modules/vfs_shadow_copy2.c
r414 r599 583 583 const char *fname) 584 584 { 585 TALLOC_CTX *tmp_ctx = talloc_stackframe();585 TALLOC_CTX *tmp_ctx; 586 586 const char *snapdir, *baseoffset, *basedir, *gmt_start; 587 587 size_t baselen; … … 594 594 } 595 595 596 fname = shadow_copy2_normalise_path(talloc_tos(), fname, gmt_start); 596 /* 597 * We have to create a real temporary context because we have 598 * to put our result on talloc_tos(). Thus we can't use a 599 * talloc_stackframe() here. 600 */ 601 tmp_ctx = talloc_new(talloc_tos()); 602 603 fname = shadow_copy2_normalise_path(tmp_ctx, fname, gmt_start); 597 604 if (fname == NULL) { 598 605 TALLOC_FREE(tmp_ctx);
Note:
See TracChangeset
for help on using the changeset viewer.