static int streams_xattr_unlink(vfs_handle_struct *handle, const struct smb_filename *smb_fname) { NTSTATUS status; int ret = -1; char *xattr_name = NULL; if (!is_ntfs_stream_smb_fname(smb_fname)) { return SMB_VFS_NEXT_UNLINK(handle, smb_fname); } /* If the default stream is requested, just open the base file. */ if (is_ntfs_default_stream_smb_fname(smb_fname)) { struct smb_filename *smb_fname_base = NULL; smb_fname_base = cp_smb_filename(talloc_tos(), smb_fname); if (smb_fname_base == NULL) { errno = ENOMEM; return -1; } ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname_base); TALLOC_FREE(smb_fname_base); return ret; } status = streams_xattr_get_name(handle, talloc_tos(), smb_fname->stream_name, &xattr_name); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); goto fail; } ret = SMB_VFS_REMOVEXATTR(handle->conn, smb_fname, xattr_name); if ((ret == -1) && (errno == ENOATTR)) { errno = ENOENT; goto fail; } ret = 0; fail: TALLOC_FREE(xattr_name); return ret; }
static int sys_acl_set_file_xattr(vfs_handle_struct *handle, const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T theacl) { int ret = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, type, theacl); if (ret == -1) { return -1; } become_root(); SMB_VFS_REMOVEXATTR(handle->conn, name, XATTR_NTACL_NAME); unbecome_root(); return ret; }
static int streams_xattr_rename(vfs_handle_struct *handle, const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_dst) { NTSTATUS status; int ret = -1; char *src_xattr_name = NULL; char *dst_xattr_name = NULL; bool src_is_stream, dst_is_stream; ssize_t oret; ssize_t nret; struct ea_struct ea; src_is_stream = is_ntfs_stream_smb_fname(smb_fname_src); dst_is_stream = is_ntfs_stream_smb_fname(smb_fname_dst); if (!src_is_stream && !dst_is_stream) { return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst); } /* For now don't allow renames from or to the default stream. */ if (is_ntfs_default_stream_smb_fname(smb_fname_src) || is_ntfs_default_stream_smb_fname(smb_fname_dst)) { errno = ENOSYS; goto done; } /* Don't rename if the streams are identical. */ if (strcasecmp_m(smb_fname_src->stream_name, smb_fname_dst->stream_name) == 0) { goto done; } /* Get the xattr names. */ status = streams_xattr_get_name(handle, talloc_tos(), smb_fname_src->stream_name, &src_xattr_name); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); goto fail; } status = streams_xattr_get_name(handle, talloc_tos(), smb_fname_dst->stream_name, &dst_xattr_name); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); goto fail; } /* read the old stream */ status = get_ea_value(talloc_tos(), handle->conn, NULL, smb_fname_src, src_xattr_name, &ea); if (!NT_STATUS_IS_OK(status)) { errno = ENOENT; goto fail; } /* (over)write the new stream */ nret = SMB_VFS_SETXATTR(handle->conn, smb_fname_src, dst_xattr_name, ea.value.data, ea.value.length, 0); if (nret < 0) { if (errno == ENOATTR) { errno = ENOENT; } goto fail; } /* remove the old stream */ oret = SMB_VFS_REMOVEXATTR(handle->conn, smb_fname_src, src_xattr_name); if (oret < 0) { if (errno == ENOATTR) { errno = ENOENT; } goto fail; } done: errno = 0; ret = 0; fail: TALLOC_FREE(src_xattr_name); TALLOC_FREE(dst_xattr_name); return ret; }