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

📄 qfileinfo.c

📁 samba最新软件
💻 C
📖 第 1 页 / 共 3 页
字号:
	ATTRIB_CHECK("BASIC_INFORMATION",         basic_info,                attrib);	ATTRIB_CHECK("ALL_INFO",                  all_info,                  attrib);	ATTRIB_CHECK("ALL_INFORMATION",           all_info,                  attrib);	ATTRIB_CHECK("NETWORK_OPEN_INFORMATION",  network_open_information,  attrib);	ATTRIB_CHECK("ATTRIBUTE_TAG_INFORMATION", attribute_tag_information, attrib);	correct_name = fname;	torture_comment(torture, "name: %s\n", correct_name);#define NAME_CHECK(sname, stype, tfield, flags) do { \	s1 = fnum_find(sname); \	if (s1 && (strcmp_safe(s1->stype.out.tfield.s, correct_name) != 0 || \	    		wire_bad_flags(&s1->stype.out.tfield, flags, tree->session->transport))) { \		printf("(%d) handle %s/%s incorrect - '%s/%d'\n", __LINE__, #stype, #tfield,  \		       s1->stype.out.tfield.s, s1->stype.out.tfield.private_length); \		ret = false; \	} \	s1 = fname_find(is_ipc, sname); \	if (s1 && (strcmp_safe(s1->stype.out.tfield.s, correct_name) != 0 || \	    		wire_bad_flags(&s1->stype.out.tfield, flags, tree->session->transport))) { \		printf("(%d) path %s/%s incorrect - '%s/%d'\n", __LINE__, #stype, #tfield,  \		       s1->stype.out.tfield.s, s1->stype.out.tfield.private_length); \		ret = false; \	}} while (0)	NAME_CHECK("NAME_INFO",        name_info, fname, STR_UNICODE);	NAME_CHECK("NAME_INFORMATION", name_info, fname, STR_UNICODE);	/* the ALL_INFO file name is the full path on the filesystem */	s1 = fnum_find("ALL_INFO");	if (s1 && !s1->all_info.out.fname.s) {		torture_fail(torture, "ALL_INFO didn't give a filename");	}	if (s1 && s1->all_info.out.fname.s) {		char *p = strrchr(s1->all_info.out.fname.s, '\\');		if (!p) {			printf("Not a full path in all_info/fname? - '%s'\n", 			       s1->all_info.out.fname.s);			ret = false;		} else {			if (strcmp_safe(correct_name, p) != 0) {				printf("incorrect basename in all_info/fname - '%s'\n",				       s1->all_info.out.fname.s);				ret = false;			}		}		if (wire_bad_flags(&s1->all_info.out.fname, STR_UNICODE, tree->session->transport)) {			printf("Should not null terminate all_info/fname\n");			ret = false;		}	}	s1 = fnum_find("ALT_NAME_INFO");	if (s1) {		correct_name = s1->alt_name_info.out.fname.s;		torture_comment(torture, "alt_name: %s\n", correct_name);				NAME_CHECK("ALT_NAME_INFO",        alt_name_info, fname, STR_UNICODE);		NAME_CHECK("ALT_NAME_INFORMATION", alt_name_info, fname, STR_UNICODE);				/* and make sure we can open by alternate name */		smbcli_close(tree, fnum);		fnum = smbcli_nt_create_full(tree, correct_name, 0, 					     SEC_RIGHTS_FILE_ALL,					     FILE_ATTRIBUTE_NORMAL,					     NTCREATEX_SHARE_ACCESS_DELETE|					     NTCREATEX_SHARE_ACCESS_READ|					     NTCREATEX_SHARE_ACCESS_WRITE, 					     NTCREATEX_DISP_OVERWRITE_IF, 					     0, 0);		if (fnum == -1) {			printf("Unable to open by alt_name - %s\n", smbcli_errstr(tree));			ret = false;		}				if (!skip_streams) {			correct_name = "::$DATA";			torture_comment(torture, "stream_name: %s\n", correct_name);						NAME_CHECK("STREAM_INFO",        stream_info, streams[0].stream_name, STR_UNICODE);			NAME_CHECK("STREAM_INFORMATION", stream_info, streams[0].stream_name, STR_UNICODE);		}	}			/* make sure the EAs look right */	s1 = fnum_find("ALL_EAS");	s2 = fnum_find("ALL_INFO");	if (s1) {		for (i=0;i<s1->all_eas.out.num_eas;i++) {			printf("  flags=%d %s=%*.*s\n", 			       s1->all_eas.out.eas[i].flags,			       s1->all_eas.out.eas[i].name.s,			       (int)s1->all_eas.out.eas[i].value.length,			       (int)s1->all_eas.out.eas[i].value.length,			       s1->all_eas.out.eas[i].value.data);		}	}	if (s1 && s2) {		if (s1->all_eas.out.num_eas == 0) {			if (s2->all_info.out.ea_size != 0) {				printf("ERROR: num_eas==0 but fnum all_info.out.ea_size == %d\n",				       s2->all_info.out.ea_size);			}		} else {			if (s2->all_info.out.ea_size != 			    ea_list_size(s1->all_eas.out.num_eas, s1->all_eas.out.eas)) {				printf("ERROR: ea_list_size=%d != fnum all_info.out.ea_size=%d\n",				       (int)ea_list_size(s1->all_eas.out.num_eas, s1->all_eas.out.eas),				       (int)s2->all_info.out.ea_size);			}		}	}	s2 = fname_find(is_ipc, "ALL_EAS");	if (s2) {		VAL_EQUAL(all_eas, num_eas, all_eas, num_eas);		for (i=0;i<s1->all_eas.out.num_eas;i++) {			VAL_EQUAL(all_eas, eas[i].flags, all_eas, eas[i].flags);			STR_EQUAL(all_eas, eas[i].name, all_eas, eas[i].name);			VAL_EQUAL(all_eas, eas[i].value.length, all_eas, eas[i].value.length);		}	}#define VAL_CHECK(sname1, stype1, tfield1, sname2, stype2, tfield2) do { \	s1 = fnum_find(sname1); s2 = fnum_find(sname2); \	if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \		printf("(%d) handle %s/%s != %s/%s - 0x%x vs 0x%x\n", __LINE__, \                       #stype1, #tfield1, #stype2, #tfield2,  \		       s1->stype1.out.tfield1, s2->stype2.out.tfield2); \		ret = false; \	} \	s1 = fname_find(is_ipc, sname1); s2 = fname_find(is_ipc, sname2); \	if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \		printf("(%d) path %s/%s != %s/%s - 0x%x vs 0x%x\n", __LINE__, \                       #stype1, #tfield1, #stype2, #tfield2,  \		       s1->stype1.out.tfield1, s2->stype2.out.tfield2); \		ret = false; \	} \	s1 = fnum_find(sname1); s2 = fname_find(is_ipc, sname2); \	if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \		printf("(%d) handle %s/%s != path %s/%s - 0x%x vs 0x%x\n", __LINE__, \                       #stype1, #tfield1, #stype2, #tfield2,  \		       s1->stype1.out.tfield1, s2->stype2.out.tfield2); \		ret = false; \	} \	s1 = fname_find(is_ipc, sname1); s2 = fnum_find(sname2); \	if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \		printf("(%d) path %s/%s != handle %s/%s - 0x%x vs 0x%x\n", __LINE__, \                       #stype1, #tfield1, #stype2, #tfield2,  \		       s1->stype1.out.tfield1, s2->stype2.out.tfield2); \		ret = false; \	}} while (0)	VAL_CHECK("STANDARD_INFO", standard_info, delete_pending, 		  "ALL_INFO",      all_info,      delete_pending);	VAL_CHECK("STANDARD_INFO", standard_info, directory, 		  "ALL_INFO",      all_info,      directory);	VAL_CHECK("STANDARD_INFO", standard_info, nlink, 		  "ALL_INFO",      all_info,      nlink);	s1 = fnum_find("BASIC_INFO");	if (s1 && is_ipc) {		if (s1->basic_info.out.attrib != FILE_ATTRIBUTE_NORMAL) {			printf("(%d) attrib basic_info/nlink incorrect - %d should be %d\n", __LINE__, s1->basic_info.out.attrib, FILE_ATTRIBUTE_NORMAL);			ret = false;		}	}	s1 = fnum_find("STANDARD_INFO");	if (s1 && is_ipc) {		if (s1->standard_info.out.nlink != 1) {			printf("(%d) nlinks standard_info/nlink incorrect - %d should be 1\n", __LINE__, s1->standard_info.out.nlink);			ret = false;		}		if (s1->standard_info.out.delete_pending != 1) {			printf("(%d) nlinks standard_info/delete_pending incorrect - %d should be 1\n", __LINE__, s1->standard_info.out.delete_pending);			ret = false;		}	}	VAL_CHECK("EA_INFO",       ea_info,       ea_size, 		  "ALL_INFO",      all_info,      ea_size);	if (!is_ipc) {		VAL_CHECK("EA_SIZE",       ea_size,       ea_size, 			  "ALL_INFO",      all_info,      ea_size);	}#define NAME_PATH_CHECK(sname, stype, field) do { \	s1 = fname_find(is_ipc, sname); s2 = fnum_find(sname); \        if (s1 && s2) { \		VAL_EQUAL(stype, field, stype, field); \	} \} while (0)	s1 = fnum_find("INTERNAL_INFORMATION");	if (s1) {		torture_comment(torture, "file_id=%.0f\n", (double)s1->internal_information.out.file_id);	}	NAME_PATH_CHECK("INTERNAL_INFORMATION", internal_information, file_id);	NAME_PATH_CHECK("POSITION_INFORMATION", position_information, position);	if (s1 && s2) {		printf("fnum pos = %.0f, fname pos = %.0f\n",		       (double)s2->position_information.out.position,		       (double)s1->position_information.out.position );	}	NAME_PATH_CHECK("MODE_INFORMATION", mode_information, mode);	NAME_PATH_CHECK("ALIGNMENT_INFORMATION", alignment_information, alignment_requirement);	NAME_PATH_CHECK("ATTRIBUTE_TAG_INFORMATION", attribute_tag_information, attrib);	NAME_PATH_CHECK("ATTRIBUTE_TAG_INFORMATION", attribute_tag_information, reparse_tag);#if 0	/* these are expected to differ */	NAME_PATH_CHECK("ACCESS_INFORMATION", access_information, access_flags);#endif#if 0 /* unused */#define UNKNOWN_CHECK(sname, stype, tfield) do { \	s1 = fnum_find(sname); \	if (s1 && s1->stype.out.tfield != 0) { \		printf("(%d) handle %s/%s unknown != 0 (0x%x)\n", __LINE__, \                       #stype, #tfield, \		       (uint_t)s1->stype.out.tfield); \	} \	s1 = fname_find(is_ipc, sname); \	if (s1 && s1->stype.out.tfield != 0) { \		printf("(%d) path %s/%s unknown != 0 (0x%x)\n", __LINE__, \                       #stype, #tfield, \		       (uint_t)s1->stype.out.tfield); \	}} while (0)#endif	/* now get a bit fancier .... */		/* when we set the delete disposition then the link count should drop	   to 0 and delete_pending should be 1 */		return ret;}/* basic testing of all RAW_FILEINFO_* calls    for each call we test that it succeeds, and where possible test    for consistency between the calls. */bool torture_raw_qfileinfo(struct torture_context *torture, 						   struct smbcli_state *cli){	int fnum;	bool ret;	const char *fname = "\\torture_qfileinfo.txt";	fnum = create_complex_file(cli, torture, fname);	if (fnum == -1) {		printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));		return false;	}	ret = torture_raw_qfileinfo_internals(torture, torture, cli->tree, fnum, fname, false /* is_ipc */);		smbcli_close(cli->tree, fnum);	smbcli_unlink(cli->tree, fname);	return ret;}bool torture_raw_qfileinfo_pipe(struct torture_context *torture, 				struct smbcli_state *cli){	bool ret = true;	int fnum;	const char *fname = "\\lsass";	struct dcerpc_pipe *p;	struct smbcli_tree *ipc_tree;	NTSTATUS status;	if (!(p = dcerpc_pipe_init(torture, cli->tree->session->transport->socket->event.ctx,				   lp_iconv_convenience(torture->lp_ctx)))) {		return false;	}	status = dcerpc_pipe_open_smb(p, cli->tree, fname);	torture_assert_ntstatus_ok(torture, status, "dcerpc_pipe_open_smb failed");	ipc_tree = dcerpc_smb_tree(p->conn);	fnum = dcerpc_smb_fnum(p->conn);	ret = torture_raw_qfileinfo_internals(torture, torture, ipc_tree, fnum, fname, true /* is_ipc */);		talloc_free(p);	return ret;}

⌨️ 快捷键说明

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