⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lock.c

📁 samba最新软件
💻 C
📖 第 1 页 / 共 2 页
字号:
/*    Unix SMB/CIFS implementation.   SMB2 lock test suite   Copyright (C) Stefan Metzmacher 2006      This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 3 of the License, or   (at your option) any later version.      This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.      You should have received a copy of the GNU General Public License   along with this program.  If not, see <http://www.gnu.org/licenses/>.*/#include "includes.h"#include "libcli/smb2/smb2.h"#include "libcli/smb2/smb2_calls.h"#include "torture/torture.h"#include "torture/smb2/proto.h"#include "librpc/gen_ndr/ndr_security.h"#define CHECK_STATUS(status, correct) do { \	if (!NT_STATUS_EQUAL(status, correct)) { \		printf("(%s) Incorrect status %s - should be %s\n", \		       __location__, nt_errstr(status), nt_errstr(correct)); \		ret = false; \		goto done; \	}} while (0)#define CHECK_VALUE(v, correct) do { \	if ((v) != (correct)) { \		printf("(%s) Incorrect value %s=%d - should be %d\n", \		       __location__, #v, v, correct); \		ret = false; \		goto done; \	}} while (0)static bool test_valid_request(struct torture_context *torture, struct smb2_tree *tree){	bool ret = true;	NTSTATUS status;	struct smb2_handle h;	uint8_t buf[200];	struct smb2_lock lck;	struct smb2_lock_element el[2];	ZERO_STRUCT(buf);	status = torture_smb2_testfile(tree, "lock1.txt", &h);	CHECK_STATUS(status, NT_STATUS_OK);	status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));	CHECK_STATUS(status, NT_STATUS_OK);	lck.in.locks		= el;	lck.in.lock_count	= 0x0000;	lck.in.reserved		= 0x00000000;	lck.in.file.handle	= h;	el[0].offset		= 0x0000000000000000;	el[0].length		= 0x0000000000000000;	el[0].reserved		= 0x0000000000000000;	el[0].flags		= 0x00000000;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);	lck.in.lock_count	= 0x0001;	lck.in.reserved		= 0x00000000;	lck.in.file.handle	= h;	el[0].offset		= 0;	el[0].length		= 0;	el[0].reserved		= 0x00000000;	el[0].flags		= SMB2_LOCK_FLAG_NONE;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	CHECK_VALUE(lck.out.reserved, 0);	lck.in.file.handle.data[0] +=1;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);	lck.in.file.handle.data[0] -=1;	lck.in.lock_count	= 0x0001;	lck.in.reserved		= 0x123ab1;	lck.in.file.handle	= h;	el[0].offset		= UINT64_MAX;	el[0].length		= UINT64_MAX;	el[0].reserved		= 0x00000000;	el[0].flags		= SMB2_LOCK_FLAG_EXCLUSIVE|SMB2_LOCK_FLAG_FAIL_IMMEDIATELY;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	CHECK_VALUE(lck.out.reserved, 0);	lck.in.reserved		= 0x123ab2;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);	lck.in.reserved		= 0x123ab3;	status = smb2_lock(tree, &lck);	if (torture_setting_bool(torture, "windows", false)) {		CHECK_STATUS(status, NT_STATUS_OK);	} else {		CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);	}	CHECK_VALUE(lck.out.reserved, 0);	lck.in.reserved		= 0x123ab4;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);	lck.in.reserved		= 0x123ab5;	status = smb2_lock(tree, &lck);	if (torture_setting_bool(torture, "windows", false)) {		CHECK_STATUS(status, NT_STATUS_OK);	} else {		CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);	}	CHECK_VALUE(lck.out.reserved, 0);	lck.in.lock_count	= 0x0001;	lck.in.reserved		= 0x12345678;	lck.in.file.handle	= h;	el[0].offset		= UINT32_MAX;	el[0].length		= UINT32_MAX;	el[0].reserved		= 0x87654321;	el[0].flags		= SMB2_LOCK_FLAG_EXCLUSIVE|SMB2_LOCK_FLAG_FAIL_IMMEDIATELY;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	CHECK_VALUE(lck.out.reserved, 0);	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);	status = smb2_lock(tree, &lck);	if (torture_setting_bool(torture, "windows", false)) {		CHECK_STATUS(status, NT_STATUS_OK);	} else {		CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);	}	CHECK_VALUE(lck.out.reserved, 0);	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);	status = smb2_lock(tree, &lck);	if (torture_setting_bool(torture, "windows", false)) {		CHECK_STATUS(status, NT_STATUS_OK);	} else {		CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);	}	CHECK_VALUE(lck.out.reserved, 0);	el[0].flags		= 0x00000000;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	CHECK_VALUE(lck.out.reserved, 0);	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	CHECK_VALUE(lck.out.reserved, 0);	el[0].flags		= 0x00000001;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	CHECK_VALUE(lck.out.reserved, 0);	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	CHECK_VALUE(lck.out.reserved, 0);	lck.in.lock_count	= 0x0001;	lck.in.reserved		= 0x87654321;	lck.in.file.handle	= h;	el[0].offset		= 0x00000000FFFFFFFF;	el[0].length		= 0x00000000FFFFFFFF;	el[0].reserved		= 0x1234567;	el[0].flags		= SMB2_LOCK_FLAG_UNLOCK;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	lck.in.lock_count	= 0x0001;	lck.in.reserved		= 0x1234567;	lck.in.file.handle	= h;	el[0].offset		= 0x00000000FFFFFFFF;	el[0].length		= 0x00000000FFFFFFFF;	el[0].reserved		= 0x00000000;	el[0].flags		= SMB2_LOCK_FLAG_UNLOCK;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);	lck.in.lock_count	= 0x0001;	lck.in.reserved		= 0;	lck.in.file.handle	= h;	el[0].offset		= 1;	el[0].length		= 1;	el[0].reserved		= 0x00000000;	el[0].flags		= ~SMB2_LOCK_FLAG_ALL_MASK;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	el[0].flags		= SMB2_LOCK_FLAG_UNLOCK;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	el[0].flags		= SMB2_LOCK_FLAG_UNLOCK;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);	el[0].flags		= SMB2_LOCK_FLAG_UNLOCK | SMB2_LOCK_FLAG_EXCLUSIVE;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);	el[0].flags		= SMB2_LOCK_FLAG_UNLOCK | SMB2_LOCK_FLAG_SHARED;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);	el[0].flags		= SMB2_LOCK_FLAG_UNLOCK | SMB2_LOCK_FLAG_FAIL_IMMEDIATELY;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);	lck.in.lock_count	= 2;	lck.in.reserved		= 0;	lck.in.file.handle	= h;	el[0].offset		= 9999;	el[0].length		= 1;	el[0].reserved		= 0x00000000;	el[1].offset		= 9999;	el[1].length		= 1;	el[1].reserved		= 0x00000000;	lck.in.lock_count	= 2;	el[0].flags		= 0;	el[1].flags		= SMB2_LOCK_FLAG_UNLOCK;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);	lck.in.lock_count	= 2;	el[0].flags		= 0;	el[1].flags		= 0;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	lck.in.lock_count	= 2;	el[0].flags		= SMB2_LOCK_FLAG_UNLOCK;	el[1].flags		= 0;	status = smb2_lock(tree, &lck);	CHECK_STATUS(status, NT_STATUS_OK);	lck.in.lock_count	= 1;	el[0].flags		= SMB2_LOCK_FLAG_UNLOCK;	status = smb2_lock(tree, &lck);	if (torture_setting_bool(torture, "windows", false)) {		CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);	} else {		CHECK_STATUS(status, NT_STATUS_OK);	}	lck.in.lock_count	= 1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -