BASENAME=`basename $0`
+echo "METZE1 $0: $@"
+
if [ -n "$VALGRIND" -o -n "$SMBD_VALGRIND" ]; then
echo "${BASENAME}: Not running debugger under valgrind"
exit 1
fi
# we want everything on stderr, so the program is not disturbed
-exec 1>&2
+#exec 1>&2
+echo "METZE2 $0: $@"
BASENAME=`basename $0`
UNAME=`uname`
;;
esac
+echo "METZE... $0: $@"
+
test x"${need_binary}" = x"yes" && {
# we first try to use /proc/${PID}/exe or /proc/{$PID}/path for solaris
;;
esac
/bin/rm -f ${BATCHFILE_PRE} ${BATCHFILE_MAIN}
+echo "METZE3 $0: $@"
TDB_DATA value;
void *ptr = NULL;
+ DBG_ERR("%s: HERE\n", __location__);
rec = dbwrap_fetch_locked(ctx->db_ctx, talloc_tos(), key);
if (rec == NULL) {
return NT_STATUS_INTERNAL_ERROR;
return NT_STATUS_INTERNAL_ERROR;
}
+ DBG_ERR("%s: HERE\n", __location__);
memcpy(&ptr, value.dptr, value.dsize);
TALLOC_FREE(rec);
+ DBG_ERR("%s: HERE\n", __location__);
*fsp = talloc_get_type_abort(ptr, struct files_struct);
+ DBG_ERR("%s: fsp[%p]\n", __location__, *fsp);
return NT_STATUS_OK;
}
files_struct *src_fsp,
files_struct *dst_fsp)
{
+ DBG_ERR("%s: HERE\n", __location__);
if (src_fsp->vuid != dst_fsp->vuid) {
DBG_INFO("copy chunk handles not in the same session.\n");
return NT_STATUS_ACCESS_DENIED;
}
+ DBG_ERR("%s: HERE\n", __location__);
if (!NT_STATUS_IS_OK(src_fsp->op->status)) {
DBG_INFO("copy chunk source handle invalid: %s\n",
nt_errstr(src_fsp->op->status));
return NT_STATUS_ACCESS_DENIED;
}
+ DBG_ERR("%s: HERE\n", __location__);
if (!NT_STATUS_IS_OK(dst_fsp->op->status)) {
DBG_INFO("copy chunk destination handle invalid: %s\n",
nt_errstr(dst_fsp->op->status));
return NT_STATUS_ACCESS_DENIED;
}
+ DBG_ERR("%s: HERE\n", __location__);
if (src_fsp->deferred_close != NULL) {
DBG_INFO("copy chunk src handle with deferred close.\n");
return NT_STATUS_ACCESS_DENIED;
}
+ DBG_ERR("%s: HERE\n", __location__);
if (dst_fsp->deferred_close != NULL) {
DBG_INFO("copy chunk dst handle with deferred close.\n");
return NT_STATUS_ACCESS_DENIED;
}
+ DBG_ERR("%s: HERE\n", __location__);
if (src_fsp->is_directory) {
DBG_INFO("copy chunk no read on src directory handle (%s).\n",
smb_fname_str_dbg(src_fsp->fsp_name));
return NT_STATUS_ACCESS_DENIED;
}
+ DBG_ERR("%s: HERE\n", __location__);
if (dst_fsp->is_directory) {
DBG_INFO("copy chunk no read on dst directory handle (%s).\n",
smb_fname_str_dbg(dst_fsp->fsp_name));
return NT_STATUS_ACCESS_DENIED;
}
+ DBG_ERR("%s: HERE\n", __location__);
if (IS_IPC(src_fsp->conn) || IS_IPC(dst_fsp->conn)) {
DBG_INFO("copy chunk no access on IPC$ handle.\n");
return NT_STATUS_ACCESS_DENIED;
}
+ DBG_ERR("%s: HERE\n", __location__);
if (IS_PRINT(src_fsp->conn) || IS_PRINT(dst_fsp->conn)) {
DBG_INFO("copy chunk no access on PRINT handle.\n");
return NT_STATUS_ACCESS_DENIED;
*
* A non writable dst handle also doesn't make sense for other fsctls.
*/
+ DBG_ERR("%s: HERE\n", __location__);
if (!CHECK_WRITE(dst_fsp)) {
DBG_INFO("dest handle not writable (%s).\n",
smb_fname_str_dbg(dst_fsp->fsp_name));
return NT_STATUS_ACCESS_DENIED;
}
+ DBG_ERR("%s: HERE\n", __location__);
/*
* - The Open.GrantedAccess of the destination file does not include
* FILE_READ_DATA, and the CtlCode is FSCTL_SRV_COPYCHUNK.
smb_fname_str_dbg(dst_fsp->fsp_name));
return NT_STATUS_ACCESS_DENIED;
}
+ DBG_ERR("%s: HERE\n", __location__);
/*
* - The Open.GrantedAccess of the source file does not include
* FILE_READ_DATA access.
return NT_STATUS_ACCESS_DENIED;
}
+ DBG_ERR("%s: HERE\n", __location__);
return NT_STATUS_OK;
}
state->count = n;
state->offset = offset;
+ DBG_ERR("%s: HERE\n", __location__);
SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pwrite, profile_p,
state->profile_bytes, n);
SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->profile_bytes);
.remaining = to_copy,
};
+ DBG_ERR("src_off[%lld] dst_off[%lld] to_copy[%u] num[%zu]\n",
+ (long long)state->src_off,
+ (long long)state->dst_off,
+ (unsigned)state->to_copy,
+ num);
+
tevent_req_set_cleanup_fn(req, vfswrap_offload_write_cleanup);
switch (fsctl) {
return tevent_req_post(req, ev);
}
+ DBG_ERR("%s: HERE\n", __location__);
+if (1) {
if (state->src_off > max_offset) {
/*
* Protect integer checks below.
*/
tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ DBG_ERR("%s: HERE\n", __location__);
+ //smb_panic(__location__);
return tevent_req_post(req, ev);
}
+ DBG_ERR("%s: HERE\n", __location__);
if (state->src_off < 0) {
/*
* Protect integer checks below.
*/
tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ DBG_ERR("%s: HERE\n", __location__);
+ // smb_panic(__location__);
return tevent_req_post(req, ev);
}
+ DBG_ERR("%s: HERE\n", __location__);
if (state->dst_off > max_offset) {
/*
* Protect integer checks below.
*/
tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ DBG_ERR("%s: HERE\n", __location__);
+ // smb_panic(__location__);
return tevent_req_post(req, ev);
}
+ DBG_ERR("%s: HERE\n", __location__);
if (state->dst_off < 0) {
/*
* Protect integer checks below.
*/
tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ DBG_ERR("%s: HERE\n", __location__);
+ // smb_panic(__location__);
return tevent_req_post(req, ev);
}
+}
+ DBG_ERR("%s: HERE\n", __location__);
status = vfs_offload_token_db_fetch_fsp(vfswrap_offload_ctx,
token, &src_fsp);
+ DBG_ERR("%s: src_fsp[%p] %s\n", __location__, src_fsp, nt_errstr(status));
if (tevent_req_nterror(req, status)) {
return tevent_req_post(req, ev);
}
-
DBG_DEBUG("server side copy chunk of length %" PRIu64 "\n", to_copy);
+ DBG_ERR("%s: HERE\n", __location__);
status = vfs_offload_token_check_handles(fsctl, src_fsp, dest_fsp);
if (!NT_STATUS_IS_OK(status)) {
tevent_req_nterror(req, status);
return tevent_req_post(req, ev);
}
+ DBG_ERR("%s: HERE\n", __location__);
if (src_fsp->fsp_name->st.st_ex_size < state->src_off + to_copy) {
/*
* [MS-SMB2] 3.3.5.15.6 Handling a Server-Side Data Copy Request
* <240> Section 3.3.5.15.6: Windows servers will return
* STATUS_INVALID_VIEW_SIZE instead of STATUS_END_OF_FILE.
*/
+ DBG_ERR("%s: HERE\n", __location__);
tevent_req_nterror(req, NT_STATUS_INVALID_VIEW_SIZE);
return tevent_req_post(req, ev);
}
+ DBG_ERR("%s: HERE\n", __location__);
state->buf = talloc_array(state, uint8_t, num);
if (tevent_req_nomem(state->buf, req)) {
return tevent_req_post(req, ev);
* This is called under the context of state->src_fsp.
*/
+ DBG_ERR("%s: HERE\n", __location__);
state->next_io_size = MIN(state->remaining, talloc_array_length(state->buf));
init_strict_lock_struct(state->src_fsp,
return NT_STATUS_FILE_LOCK_CONFLICT;
}
+ DBG_ERR("%s: HERE\n", __location__);
subreq = SMB_VFS_PREAD_SEND(state,
state->src_ev,
state->src_fsp,
return;
}
+ DBG_ERR("%s: HERE\n", __location__);
subreq = SMB_VFS_PWRITE_SEND(state,
state->dst_ev,
state->dst_fsp,
NTSTATUS status;
if (tevent_req_is_nterror(req, &status)) {
- DBG_DEBUG("copy chunk failed: %s\n", nt_errstr(status));
+ DBG_ERR("%s: HERE\n", __location__);
+ DBG_ERR("copy chunk failed: %s\n", nt_errstr(status));
*copied = 0;
tevent_req_received(req);
return status;
}
+ DBG_ERR("%s: HERE\n", __location__);
*copied = state->to_copy;
- DBG_DEBUG("copy chunk copied %lu\n", (unsigned long)*copied);
+ DBG_ERR("copy chunk copied %lu\n", (unsigned long)*copied);
tevent_req_received(req);
return NT_STATUS_OK;
torture_fail(torture, "setup copy chunk error");
}
- /* send huge chunk length request */
- cc_copy.chunks[0].source_off = 0;
- cc_copy.chunks[0].target_off = 0;
- cc_copy.chunks[0].length = UINT_MAX;
-
- ndr_ret = ndr_push_struct_blob(&ioctl.smb2.in.out, tmp_ctx,
- &cc_copy,
- (ndr_push_flags_fn_t)ndr_push_srv_copychunk_copy);
- torture_assert_ndr_success(torture, ndr_ret, "marshalling request");
-
- status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2);
- torture_assert_ntstatus_equal(torture, status,
- NT_STATUS_INVALID_PARAMETER,
- "bad oversize chunk response");
-
- ndr_ret = ndr_pull_struct_blob(&ioctl.smb2.out.out, tmp_ctx,
- &cc_rsp,
- (ndr_pull_flags_fn_t)ndr_pull_srv_copychunk_rsp);
- torture_assert_ndr_success(torture, ndr_ret, "unmarshalling response");
-
- torture_comment(torture, "limit max chunks, got %u\n",
- cc_rsp.chunks_written);
- torture_comment(torture, "limit max chunk len, got %u\n",
- cc_rsp.chunk_bytes_written);
- torture_comment(torture, "limit max total bytes, got %u\n",
- cc_rsp.total_bytes_written);
+// /* send huge chunk length request */
+// cc_copy.chunks[0].source_off = 0;
+// cc_copy.chunks[0].target_off = 0;
+// cc_copy.chunks[0].length = UINT_MAX;
+//
+// ndr_ret = ndr_push_struct_blob(&ioctl.smb2.in.out, tmp_ctx,
+// &cc_copy,
+// (ndr_push_flags_fn_t)ndr_push_srv_copychunk_copy);
+// torture_assert_ndr_success(torture, ndr_ret, "marshalling request");
+//
+// status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2);
+// torture_assert_ntstatus_equal(torture, status,
+// NT_STATUS_INVALID_PARAMETER,
+// "bad oversize chunk response");
+
+// ndr_ret = ndr_pull_struct_blob(&ioctl.smb2.out.out, tmp_ctx,
+// &cc_rsp,
+// (ndr_pull_flags_fn_t)ndr_pull_srv_copychunk_rsp);
+// torture_assert_ndr_success(torture, ndr_ret, "unmarshalling response");
+//
+// torture_comment(torture, "limit max chunks, got %u\n",
+// cc_rsp.chunks_written);
+// torture_comment(torture, "limit max chunk len, got %u\n",
+// cc_rsp.chunk_bytes_written);
+// torture_comment(torture, "limit max total bytes, got %u\n",
+// cc_rsp.total_bytes_written);
/* send huge chunk length request */
cc_copy.chunks[0].source_off = UINT64_MAX;
struct torture_suite *torture_smb2_ioctl_init(TALLOC_CTX *ctx)
{
struct torture_suite *suite = torture_suite_create(ctx, "ioctl");
-
+if (0) {
torture_suite_add_1smb2_test(suite, "shadow_copy",
test_ioctl_get_shadow_copy);
torture_suite_add_1smb2_test(suite, "req_resume_key",
test_ioctl_copy_chunk_over);
torture_suite_add_1smb2_test(suite, "copy_chunk_append",
test_ioctl_copy_chunk_append);
+}
torture_suite_add_1smb2_test(suite, "copy_chunk_limits",
test_ioctl_copy_chunk_limits);
+if (0) {
torture_suite_add_1smb2_test(suite, "copy_chunk_src_lock",
test_ioctl_copy_chunk_src_lck);
torture_suite_add_1smb2_test(suite, "copy_chunk_dest_lock",
test_ioctl_dup_extents_src_lck);
torture_suite_add_1smb2_test(suite, "dup_extents_dest_lock",
test_ioctl_dup_extents_dest_lck);
-
+}
suite->description = talloc_strdup(suite, "SMB2-IOCTL tests");
return suite;