2005-11-15 07:38:59 +03:00
/*
Unix SMB / CIFS implementation .
SMB2 getinfo test suite
Copyright ( C ) Andrew Tridgell 2005
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
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2005-11-15 07:38:59 +03:00
( 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
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2005-11-15 07:38:59 +03:00
*/
# include "includes.h"
# include "libcli/smb2/smb2.h"
# include "libcli/smb2/smb2_calls.h"
2013-08-27 13:41:13 +04:00
# include "libcli/smb/smbXcli_base.h"
2005-11-15 07:38:59 +03:00
2006-03-25 19:01:28 +03:00
# include "torture/torture.h"
2006-02-04 17:08:24 +03:00
# include "torture/smb2/proto.h"
2013-08-27 13:41:13 +04:00
# include "torture/util.h"
2006-02-04 17:08:24 +03:00
2005-11-15 07:38:59 +03:00
static struct {
const char * name ;
uint16_t level ;
NTSTATUS fstatus ;
NTSTATUS dstatus ;
2005-11-17 14:06:13 +03:00
union smb_fileinfo finfo ;
union smb_fileinfo dinfo ;
} file_levels [ ] = {
2018-12-13 15:42:23 +03:00
# define LEVEL(x) .name = #x, .level = x
2005-11-17 14:06:13 +03:00
{ LEVEL ( RAW_FILEINFO_BASIC_INFORMATION ) } ,
{ LEVEL ( RAW_FILEINFO_STANDARD_INFORMATION ) } ,
{ LEVEL ( RAW_FILEINFO_INTERNAL_INFORMATION ) } ,
{ LEVEL ( RAW_FILEINFO_EA_INFORMATION ) } ,
{ LEVEL ( RAW_FILEINFO_ACCESS_INFORMATION ) } ,
{ LEVEL ( RAW_FILEINFO_POSITION_INFORMATION ) } ,
{ LEVEL ( RAW_FILEINFO_MODE_INFORMATION ) } ,
{ LEVEL ( RAW_FILEINFO_ALIGNMENT_INFORMATION ) } ,
{ LEVEL ( RAW_FILEINFO_ALL_INFORMATION ) } ,
{ LEVEL ( RAW_FILEINFO_ALT_NAME_INFORMATION ) } ,
{ LEVEL ( RAW_FILEINFO_STREAM_INFORMATION ) } ,
{ LEVEL ( RAW_FILEINFO_COMPRESSION_INFORMATION ) } ,
{ LEVEL ( RAW_FILEINFO_NETWORK_OPEN_INFORMATION ) } ,
{ LEVEL ( RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION ) } ,
2009-07-14 15:32:23 +04:00
2008-05-22 08:50:36 +04:00
{ LEVEL ( RAW_FILEINFO_SMB2_ALL_EAS ) } ,
2009-07-14 15:32:23 +04:00
2005-11-17 14:06:13 +03:00
{ LEVEL ( RAW_FILEINFO_SMB2_ALL_INFORMATION ) } ,
{ LEVEL ( RAW_FILEINFO_SEC_DESC ) }
} ;
static struct {
const char * name ;
uint16_t level ;
NTSTATUS status ;
union smb_fsinfo info ;
} fs_levels [ ] = {
{ LEVEL ( RAW_QFS_VOLUME_INFORMATION ) } ,
{ LEVEL ( RAW_QFS_SIZE_INFORMATION ) } ,
{ LEVEL ( RAW_QFS_DEVICE_INFORMATION ) } ,
{ LEVEL ( RAW_QFS_ATTRIBUTE_INFORMATION ) } ,
{ LEVEL ( RAW_QFS_QUOTA_INFORMATION ) } ,
{ LEVEL ( RAW_QFS_FULL_SIZE_INFORMATION ) } ,
2015-03-13 03:06:26 +03:00
{ LEVEL ( RAW_QFS_OBJECTID_INFORMATION ) } ,
{ LEVEL ( RAW_QFS_SECTOR_SIZE_INFORMATION ) } ,
2005-11-15 07:38:59 +03:00
} ;
# define FNAME "testsmb2_file.dat"
# define DNAME "testsmb2_dir"
2005-11-17 14:06:13 +03:00
/*
test fileinfo levels
2005-11-15 07:38:59 +03:00
*/
2007-12-03 17:53:17 +03:00
static bool torture_smb2_fileinfo ( struct torture_context * tctx , struct smb2_tree * tree )
2005-11-15 07:38:59 +03:00
{
struct smb2_handle hfile , hdir ;
NTSTATUS status ;
int i ;
status = torture_smb2_testfile ( tree , FNAME , & hfile ) ;
2012-02-28 17:19:49 +04:00
torture_assert_ntstatus_ok ( tctx , status , " Unable to create test file "
FNAME " \n " ) ;
2005-11-15 07:38:59 +03:00
status = torture_smb2_testdir ( tree , DNAME , & hdir ) ;
2012-02-28 17:19:49 +04:00
torture_assert_ntstatus_ok ( tctx , status , " Unable to create test dir "
DNAME " \n " ) ;
2005-11-15 07:38:59 +03:00
2016-02-22 17:51:06 +03:00
torture_comment ( tctx , " Testing file info levels \n " ) ;
2016-02-22 17:40:50 +03:00
torture_smb2_all_info ( tctx , tree , hfile ) ;
torture_smb2_all_info ( tctx , tree , hdir ) ;
2005-11-15 07:38:59 +03:00
2005-11-17 14:06:13 +03:00
for ( i = 0 ; i < ARRAY_SIZE ( file_levels ) ; i + + ) {
if ( file_levels [ i ] . level = = RAW_FILEINFO_SEC_DESC ) {
2006-03-10 23:49:20 +03:00
file_levels [ i ] . finfo . query_secdesc . in . secinfo_flags = 0x7 ;
file_levels [ i ] . dinfo . query_secdesc . in . secinfo_flags = 0x7 ;
2005-11-15 07:38:59 +03:00
}
2005-11-19 08:55:08 +03:00
if ( file_levels [ i ] . level = = RAW_FILEINFO_SMB2_ALL_EAS ) {
2012-02-28 17:19:49 +04:00
file_levels [ i ] . finfo . all_eas . in . continue_flags =
2005-11-19 09:39:12 +03:00
SMB2_CONTINUE_FLAG_RESTART ;
2012-02-28 17:19:49 +04:00
file_levels [ i ] . dinfo . all_eas . in . continue_flags =
2005-11-19 09:39:12 +03:00
SMB2_CONTINUE_FLAG_RESTART ;
2005-11-19 08:55:08 +03:00
}
2005-11-17 14:06:13 +03:00
file_levels [ i ] . finfo . generic . level = file_levels [ i ] . level ;
2006-03-13 01:48:25 +03:00
file_levels [ i ] . finfo . generic . in . file . handle = hfile ;
2005-11-17 14:06:13 +03:00
file_levels [ i ] . fstatus = smb2_getinfo_file ( tree , tree , & file_levels [ i ] . finfo ) ;
2012-02-28 17:19:49 +04:00
torture_assert_ntstatus_ok ( tctx , file_levels [ i ] . fstatus ,
talloc_asprintf ( tctx , " %s on file " ,
file_levels [ i ] . name ) ) ;
2005-11-17 14:06:13 +03:00
file_levels [ i ] . dinfo . generic . level = file_levels [ i ] . level ;
2006-03-13 01:48:25 +03:00
file_levels [ i ] . dinfo . generic . in . file . handle = hdir ;
2005-11-17 14:06:13 +03:00
file_levels [ i ] . dstatus = smb2_getinfo_file ( tree , tree , & file_levels [ i ] . dinfo ) ;
2012-02-28 17:19:49 +04:00
torture_assert_ntstatus_ok ( tctx , file_levels [ i ] . dstatus ,
talloc_asprintf ( tctx , " %s on dir " ,
file_levels [ i ] . name ) ) ;
2005-11-15 07:38:59 +03:00
}
2007-10-07 02:28:14 +04:00
return true ;
2005-11-15 07:38:59 +03:00
}
2005-11-17 14:06:13 +03:00
2016-08-13 21:23:34 +03:00
/*
test granted access when desired access includes
FILE_EXECUTE and does not include FILE_READ_DATA
*/
static bool torture_smb2_fileinfo_grant_read ( struct torture_context * tctx )
{
struct smb2_tree * tree ;
bool ret ;
struct smb2_handle hfile , hdir ;
NTSTATUS status ;
uint32_t file_granted_access , dir_granted_access ;
ret = torture_smb2_connection ( tctx , & tree ) ;
torture_assert ( tctx , ret , " connection failed " ) ;
status = torture_smb2_testfile_access (
tree , FNAME , & hfile , SEC_FILE_EXECUTE | SEC_FILE_READ_ATTRIBUTE ) ;
torture_assert_ntstatus_ok ( tctx , status ,
" Unable to create test file " FNAME " \n " ) ;
status =
torture_smb2_get_allinfo_access ( tree , hfile , & file_granted_access ) ;
torture_assert_ntstatus_ok ( tctx , status ,
" Unable to query test file access " ) ;
torture_assert_int_equal ( tctx , file_granted_access ,
SEC_FILE_EXECUTE | SEC_FILE_READ_ATTRIBUTE ,
" granted file access " ) ;
smb2_util_close ( tree , hfile ) ;
status = torture_smb2_testdir_access (
tree , DNAME , & hdir , SEC_FILE_EXECUTE | SEC_FILE_READ_ATTRIBUTE ) ;
torture_assert_ntstatus_ok ( tctx , status ,
" Unable to create test dir " DNAME " \n " ) ;
status =
torture_smb2_get_allinfo_access ( tree , hdir , & dir_granted_access ) ;
torture_assert_ntstatus_ok ( tctx , status ,
" Unable to query test dir access " ) ;
torture_assert_int_equal ( tctx , dir_granted_access ,
SEC_FILE_EXECUTE | SEC_FILE_READ_ATTRIBUTE ,
" granted dir access " ) ;
smb2_util_close ( tree , hdir ) ;
return true ;
}
2005-11-17 14:06:13 +03:00
2019-04-25 15:57:02 +03:00
static bool torture_smb2_fileinfo_normalized ( struct torture_context * tctx )
{
struct smb2_tree * tree = NULL ;
bool ret ;
struct smb2_handle hroot ;
const char * d1 = NULL , * d1l = NULL , * d1u = NULL ;
struct smb2_handle hd1 , hd1l , hd1u ;
const char * d2 = NULL , * d2l = NULL , * d2u = NULL ;
struct smb2_handle hd2 , hd2l , hd2u ;
const char * d3 = NULL , * d3l = NULL , * d3u = NULL ;
struct smb2_handle hd3 , hd3l , hd3u ;
const char * d3s = NULL , * d3sl = NULL , * d3su = NULL , * d3sd = NULL ;
struct smb2_handle hd3s , hd3sl , hd3su , hd3sd ;
const char * f4 = NULL , * f4l = NULL , * f4u = NULL , * f4d = NULL ;
struct smb2_handle hf4 , hf4l , hf4u , hf4d ;
const char * f4s = NULL , * f4sl = NULL , * f4su = NULL , * f4sd = NULL ;
struct smb2_handle hf4s , hf4sl , hf4su , hf4sd ;
union smb_fileinfo info = {
. normalized_name_info = {
. level = RAW_FILEINFO_NORMALIZED_NAME_INFORMATION ,
} ,
} ;
NTSTATUS status ;
enum protocol_types protocol ;
struct smb2_tree * tree_3_0 = NULL ;
struct smbcli_options options3_0 ;
struct smb2_handle hroot_3_0 ;
ret = torture_smb2_connection ( tctx , & tree ) ;
torture_assert ( tctx , ret , " connection failed " ) ;
protocol = smbXcli_conn_protocol ( tree - > session - > transport - > conn ) ;
d1 = talloc_asprintf ( tctx , " torture_dIr1N " ) ;
torture_assert_not_null ( tctx , d1 , " d1 " ) ;
d1l = strlower_talloc ( tctx , d1 ) ;
torture_assert_not_null ( tctx , d1l , " d1l " ) ;
d1u = strupper_talloc ( tctx , d1 ) ;
torture_assert_not_null ( tctx , d1u , " d1u " ) ;
d2 = talloc_asprintf ( tctx , " %s \\ dIr2Na " , d1 ) ;
torture_assert_not_null ( tctx , d2 , " d2 " ) ;
d2l = strlower_talloc ( tctx , d2 ) ;
torture_assert_not_null ( tctx , d2l , " d2l " ) ;
d2u = strupper_talloc ( tctx , d2 ) ;
torture_assert_not_null ( tctx , d2u , " d2u " ) ;
d3 = talloc_asprintf ( tctx , " %s \\ dIr3NaM " , d2 ) ;
torture_assert_not_null ( tctx , d3 , " d3 " ) ;
d3l = strlower_talloc ( tctx , d3 ) ;
torture_assert_not_null ( tctx , d3l , " d3l " ) ;
d3u = strupper_talloc ( tctx , d3 ) ;
torture_assert_not_null ( tctx , d3u , " d3u " ) ;
d3s = talloc_asprintf ( tctx , " %s:sTrEaM3 " , d3 ) ;
torture_assert_not_null ( tctx , d3s , " d3s " ) ;
d3sl = strlower_talloc ( tctx , d3s ) ;
torture_assert_not_null ( tctx , d3sl , " d3sl " ) ;
d3su = strupper_talloc ( tctx , d3s ) ;
torture_assert_not_null ( tctx , d3su , " d3su " ) ;
d3sd = talloc_asprintf ( tctx , " %s:$DaTa " , d3s ) ;
torture_assert_not_null ( tctx , d3sd , " d3sd " ) ;
f4 = talloc_asprintf ( tctx , " %s \\ fIlE4NaMe " , d3 ) ;
torture_assert_not_null ( tctx , f4 , " f4 " ) ;
f4l = strlower_talloc ( tctx , f4 ) ;
torture_assert_not_null ( tctx , f4l , " f4l " ) ;
f4u = strupper_talloc ( tctx , f4 ) ;
torture_assert_not_null ( tctx , f4u , " f4u " ) ;
f4d = talloc_asprintf ( tctx , " %s::$dAtA " , f4 ) ;
torture_assert_not_null ( tctx , f4d , " f4d " ) ;
f4s = talloc_asprintf ( tctx , " %s:StReAm4 " , f4 ) ;
torture_assert_not_null ( tctx , f4s , " f4s " ) ;
f4sl = strlower_talloc ( tctx , f4s ) ;
torture_assert_not_null ( tctx , f4sl , " f4sl " ) ;
f4su = strupper_talloc ( tctx , f4s ) ;
torture_assert_not_null ( tctx , f4su , " f4su " ) ;
f4sd = talloc_asprintf ( tctx , " %s:$dAtA " , f4s ) ;
torture_assert_not_null ( tctx , f4sd , " f4sd " ) ;
status = smb2_util_roothandle ( tree , & hroot ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to create root handle " ) ;
info . normalized_name_info . in . file . handle = hroot ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
if ( protocol < PROTOCOL_SMB3_11 ) {
/*
* Only SMB 3.1 .1 and above should offer this .
*/
torture_assert_ntstatus_equal ( tctx , status ,
NT_STATUS_NOT_SUPPORTED ,
" getinfo hroot " ) ;
torture_skip ( tctx , " SMB 3.1.1 not supported " ) ;
}
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NOT_SUPPORTED ) ) {
/*
* Not all servers support this .
* ( only Windows 10 1803 and higher )
*/
torture_skip ( tctx , " NORMALIZED_NAME_INFORMATION not supported " ) ;
}
torture_assert_ntstatus_ok ( tctx , status , " getinfo hroot " ) ;
torture_assert ( tctx , info . normalized_name_info . out . fname . s = = NULL ,
" getinfo hroot should be empty " ) ;
smb2_deltree ( tree , d1 ) ;
status = torture_smb2_testdir ( tree , d1 , & hd1 ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to create hd1 " ) ;
status = torture_smb2_open ( tree , d1l , SEC_RIGHTS_FILE_ALL , & hd1l ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to open hd1l " ) ;
status = torture_smb2_open ( tree , d1u , SEC_RIGHTS_FILE_ALL , & hd1u ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to open hd1u " ) ;
status = torture_smb2_testdir ( tree , d2 , & hd2 ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to create hd2 " ) ;
status = torture_smb2_open ( tree , d2l , SEC_RIGHTS_FILE_ALL , & hd2l ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to open hd2l " ) ;
status = torture_smb2_open ( tree , d2u , SEC_RIGHTS_FILE_ALL , & hd2u ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to open hd2u " ) ;
status = torture_smb2_testdir ( tree , d3 , & hd3 ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to create hd3 " ) ;
status = torture_smb2_open ( tree , d3l , SEC_RIGHTS_FILE_ALL , & hd3l ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to open hd3l " ) ;
status = torture_smb2_open ( tree , d3u , SEC_RIGHTS_FILE_ALL , & hd3u ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to open hd3u " ) ;
status = torture_smb2_testfile ( tree , d3s , & hd3s ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to create hd3s " ) ;
status = torture_smb2_open ( tree , d3sl , SEC_RIGHTS_FILE_ALL , & hd3sl ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to open hd3sl " ) ;
status = torture_smb2_open ( tree , d3su , SEC_RIGHTS_FILE_ALL , & hd3su ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to open hd3su " ) ;
status = torture_smb2_open ( tree , d3sd , SEC_RIGHTS_FILE_ALL , & hd3sd ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to open hd3sd " ) ;
status = torture_smb2_testfile ( tree , f4 , & hf4 ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to create hf4 " ) ;
status = torture_smb2_open ( tree , f4l , SEC_RIGHTS_FILE_ALL , & hf4l ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to open hf4l " ) ;
status = torture_smb2_open ( tree , f4u , SEC_RIGHTS_FILE_ALL , & hf4u ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to open hf4u " ) ;
status = torture_smb2_open ( tree , f4d , SEC_RIGHTS_FILE_ALL , & hf4d ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to open hf4d " ) ;
status = torture_smb2_testfile ( tree , f4s , & hf4s ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to create hf4s " ) ;
status = torture_smb2_open ( tree , f4sl , SEC_RIGHTS_FILE_ALL , & hf4sl ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to open hf4sl " ) ;
status = torture_smb2_open ( tree , f4su , SEC_RIGHTS_FILE_ALL , & hf4su ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to open hf4su " ) ;
status = torture_smb2_open ( tree , f4sd , SEC_RIGHTS_FILE_ALL , & hf4sd ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to open hf4sd " ) ;
info . normalized_name_info . in . file . handle = hd1 ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hd1 " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
d1 , " getinfo hd1 " ) ;
info . normalized_name_info . in . file . handle = hd1l ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hd1l " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
d1 , " getinfo hd1l " ) ;
info . normalized_name_info . in . file . handle = hd1u ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hd1u " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
d1 , " getinfo hd1u " ) ;
info . normalized_name_info . in . file . handle = hd2 ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hd2 " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
d2 , " getinfo hd2 " ) ;
info . normalized_name_info . in . file . handle = hd2l ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hd2l " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
d2 , " getinfo hd2l " ) ;
info . normalized_name_info . in . file . handle = hd2u ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hd2u " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
d2 , " getinfo hd2u " ) ;
info . normalized_name_info . in . file . handle = hd3 ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hd3 " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
d3 , " getinfo hd3 " ) ;
info . normalized_name_info . in . file . handle = hd3l ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hd3l " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
d3 , " getinfo hd3l " ) ;
info . normalized_name_info . in . file . handle = hd3u ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hd3u " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
d3 , " getinfo hd3u " ) ;
info . normalized_name_info . in . file . handle = hd3s ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hd3s " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
d3s , " getinfo hd3s " ) ;
info . normalized_name_info . in . file . handle = hd3sl ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hd3sl " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
d3s , " getinfo hd3sl " ) ;
info . normalized_name_info . in . file . handle = hd3su ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hd3su " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
d3s , " getinfo hd3su " ) ;
info . normalized_name_info . in . file . handle = hd3sd ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hd3sd " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
d3s , " getinfo hd3sd " ) ;
info . normalized_name_info . in . file . handle = hf4 ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hf4 " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
f4 , " getinfo hf4 " ) ;
info . normalized_name_info . in . file . handle = hf4l ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hf4l " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
f4 , " getinfo hf4l " ) ;
info . normalized_name_info . in . file . handle = hf4u ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hf4u " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
f4 , " getinfo hf4u " ) ;
info . normalized_name_info . in . file . handle = hf4d ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hf4d " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
f4 , " getinfo hf4d " ) ;
info . normalized_name_info . in . file . handle = hf4s ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hf4s " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
f4s , " getinfo hf4s " ) ;
info . normalized_name_info . in . file . handle = hf4sl ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hf4sl " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
f4s , " getinfo hf4sl " ) ;
info . normalized_name_info . in . file . handle = hf4su ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hf4su " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
f4s , " getinfo hf4su " ) ;
info . normalized_name_info . in . file . handle = hf4sd ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree , tree , & info ) ;
torture_assert_ntstatus_ok ( tctx , status , " getinfo hf4sd " ) ;
torture_assert_str_equal ( tctx , info . normalized_name_info . out . fname . s ,
f4s , " getinfo hf4sd " ) ;
/* Set max protocol to SMB 3.0.2 */
options3_0 = tree - > session - > transport - > options ;
options3_0 . max_protocol = PROTOCOL_SMB3_02 ;
options3_0 . client_guid = GUID_zero ( ) ;
ret = torture_smb2_connection_ext ( tctx , 0 , & options3_0 , & tree_3_0 ) ;
torture_assert ( tctx , ret , " connection with SMB < 3.1.1 failed " ) ;
status = smb2_util_roothandle ( tree_3_0 , & hroot_3_0 ) ;
torture_assert_ntstatus_ok ( tctx , status , " Unable to create root handle 3_0 " ) ;
info . normalized_name_info . in . file . handle = hroot_3_0 ;
ZERO_STRUCT ( info . normalized_name_info . out ) ;
status = smb2_getinfo_file ( tree_3_0 , tree_3_0 , & info ) ;
torture_assert_ntstatus_equal ( tctx , status ,
NT_STATUS_NOT_SUPPORTED ,
" getinfo hroot " ) ;
return true ;
}
2005-11-17 14:06:13 +03:00
/*
test fsinfo levels
*/
2013-08-22 15:47:21 +04:00
static bool torture_smb2_fsinfo ( struct torture_context * tctx )
2005-11-17 14:06:13 +03:00
{
2013-08-22 15:47:21 +04:00
bool ret ;
struct smb2_tree * tree ;
2005-11-17 14:06:13 +03:00
int i ;
NTSTATUS status ;
struct smb2_handle handle ;
2016-02-22 17:51:06 +03:00
torture_comment ( tctx , " Testing fsinfo levels \n " ) ;
2013-08-22 15:47:21 +04:00
ret = torture_smb2_connection ( tctx , & tree ) ;
torture_assert ( tctx , ret , " connection failed " ) ;
2005-11-19 08:55:08 +03:00
status = smb2_util_roothandle ( tree , & handle ) ;
2012-02-28 17:19:49 +04:00
torture_assert_ntstatus_ok ( tctx , status , " Unable to create root handle " ) ;
2005-11-17 14:06:13 +03:00
for ( i = 0 ; i < ARRAY_SIZE ( fs_levels ) ; i + + ) {
fs_levels [ i ] . info . generic . level = fs_levels [ i ] . level ;
fs_levels [ i ] . info . generic . handle = handle ;
fs_levels [ i ] . status = smb2_getinfo_fs ( tree , tree , & fs_levels [ i ] . info ) ;
2012-02-28 17:19:49 +04:00
torture_assert_ntstatus_ok ( tctx , fs_levels [ i ] . status ,
fs_levels [ i ] . name ) ;
2005-11-17 14:06:13 +03:00
}
2007-10-07 02:28:14 +04:00
return true ;
2005-11-17 14:06:13 +03:00
}
2013-08-27 13:41:13 +04:00
static bool torture_smb2_buffercheck_err ( struct torture_context * tctx ,
struct smb2_tree * tree ,
struct smb2_getinfo * b ,
size_t fixed ,
DATA_BLOB full )
{
size_t i ;
2005-11-17 14:06:13 +03:00
2013-08-27 13:41:13 +04:00
for ( i = 0 ; i < = full . length ; i + + ) {
NTSTATUS status ;
b - > in . output_buffer_length = i ;
status = smb2_getinfo ( tree , tree , b ) ;
if ( i < fixed ) {
torture_assert_ntstatus_equal (
tctx , status , NT_STATUS_INFO_LENGTH_MISMATCH ,
" Wrong error code small buffer " ) ;
continue ;
}
if ( i < full . length ) {
torture_assert_ntstatus_equal (
tctx , status , STATUS_BUFFER_OVERFLOW ,
" Wrong error code for large buffer " ) ;
/*
* TODO : compare the output buffer . That seems a bit
* difficult , because for level 5 for example the
* label length is adjusted to what is there . And some
* reserved fields seem to be not initialized to 0.
*/
TALLOC_FREE ( b - > out . blob . data ) ;
continue ;
}
torture_assert_ntstatus_equal (
tctx , status , NT_STATUS_OK ,
" Wrong error code for right sized buffer " ) ;
}
return true ;
}
struct level_buffersize {
int level ;
size_t fixed ;
} ;
static bool torture_smb2_qfs_buffercheck ( struct torture_context * tctx )
2008-05-31 07:39:51 +04:00
{
2013-08-22 15:23:22 +04:00
bool ret ;
struct smb2_tree * tree ;
2008-05-31 07:39:51 +04:00
NTSTATUS status ;
struct smb2_handle handle ;
2013-08-27 13:41:13 +04:00
int i ;
struct level_buffersize levels [ ] = {
{ 1 , 24 } , /* We don't have proper defines here */
{ 3 , 24 } ,
{ 4 , 8 } ,
{ 5 , 16 } ,
{ 6 , 48 } ,
{ 7 , 32 } ,
{ 11 , 28 } ,
} ;
2008-05-31 07:39:51 +04:00
2016-02-22 17:51:06 +03:00
torture_comment ( tctx , " Testing SMB2_GETINFO_FS buffer sizes \n " ) ;
2013-08-22 15:23:22 +04:00
ret = torture_smb2_connection ( tctx , & tree ) ;
torture_assert ( tctx , ret , " connection failed " ) ;
2008-05-31 07:39:51 +04:00
status = smb2_util_roothandle ( tree , & handle ) ;
2013-08-27 13:41:13 +04:00
torture_assert_ntstatus_ok (
tctx , status , " Unable to create root handle " ) ;
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
struct smb2_getinfo b ;
if ( TARGET_IS_SAMBA3 ( tctx ) & &
( ( levels [ i ] . level = = 6 ) | | ( levels [ i ] . level = = 11 ) ) ) {
continue ;
}
ZERO_STRUCT ( b ) ;
2019-03-29 13:08:12 +03:00
b . in . info_type = SMB2_0_INFO_FILESYSTEM ;
2013-08-27 13:41:13 +04:00
b . in . info_class = levels [ i ] . level ;
b . in . file . handle = handle ;
b . in . output_buffer_length = 65535 ;
status = smb2_getinfo ( tree , tree , & b ) ;
torture_assert_ntstatus_equal (
tctx , status , NT_STATUS_OK ,
" Wrong error code for large buffer " ) ;
ret = torture_smb2_buffercheck_err (
tctx , tree , & b , levels [ i ] . fixed , b . out . blob ) ;
if ( ! ret ) {
return ret ;
}
}
return true ;
}
static bool torture_smb2_qfile_buffercheck ( struct torture_context * tctx )
{
bool ret ;
struct smb2_tree * tree ;
struct smb2_create c ;
NTSTATUS status ;
struct smb2_handle handle ;
int i ;
struct level_buffersize levels [ ] = {
{ 4 , 40 } ,
{ 5 , 24 } ,
{ 6 , 8 } ,
{ 7 , 4 } ,
{ 8 , 4 } ,
{ 16 , 4 } ,
{ 17 , 4 } ,
{ 18 , 104 } ,
{ 21 , 8 } ,
{ 22 , 32 } ,
{ 28 , 16 } ,
{ 34 , 56 } ,
{ 35 , 8 } ,
} ;
2016-02-22 17:51:06 +03:00
torture_comment ( tctx , " Testing SMB2_GETINFO_FILE buffer sizes \n " ) ;
2013-08-27 13:41:13 +04:00
ret = torture_smb2_connection ( tctx , & tree ) ;
torture_assert ( tctx , ret , " connection failed " ) ;
ZERO_STRUCT ( c ) ;
c . in . desired_access = SEC_FLAG_MAXIMUM_ALLOWED ;
c . in . file_attributes = FILE_ATTRIBUTE_NORMAL ;
c . in . create_disposition = NTCREATEX_DISP_OVERWRITE_IF ;
c . in . share_access =
NTCREATEX_SHARE_ACCESS_DELETE |
NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_SHARE_ACCESS_WRITE ;
c . in . create_options = 0 ;
c . in . fname = " bufsize.txt " ;
c . in . eas . num_eas = 2 ;
c . in . eas . eas = talloc_array ( tree , struct ea_struct , 2 ) ;
c . in . eas . eas [ 0 ] . flags = 0 ;
c . in . eas . eas [ 0 ] . name . s = " EAONE " ;
c . in . eas . eas [ 0 ] . value = data_blob_talloc ( c . in . eas . eas , " VALUE1 " , 6 ) ;
c . in . eas . eas [ 1 ] . flags = 0 ;
c . in . eas . eas [ 1 ] . name . s = " SECONDEA " ;
c . in . eas . eas [ 1 ] . value = data_blob_talloc ( c . in . eas . eas , " ValueTwo " , 8 ) ;
status = smb2_create ( tree , tree , & c ) ;
torture_assert_ntstatus_ok (
tctx , status , " Unable to create test file " ) ;
handle = c . out . file . handle ;
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
struct smb2_getinfo b ;
ZERO_STRUCT ( b ) ;
2019-03-29 13:08:12 +03:00
b . in . info_type = SMB2_0_INFO_FILE ;
2013-08-27 13:41:13 +04:00
b . in . info_class = levels [ i ] . level ;
b . in . file . handle = handle ;
b . in . output_buffer_length = 65535 ;
status = smb2_getinfo ( tree , tree , & b ) ;
2013-09-27 08:21:21 +04:00
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NOT_IMPLEMENTED ) ) {
continue ;
}
2013-08-27 13:41:13 +04:00
torture_assert_ntstatus_equal (
tctx , status , NT_STATUS_OK ,
" Wrong error code for large buffer " ) ;
ret = torture_smb2_buffercheck_err (
tctx , tree , & b , levels [ i ] . fixed , b . out . blob ) ;
if ( ! ret ) {
return ret ;
}
}
return true ;
}
static bool torture_smb2_qsec_buffercheck ( struct torture_context * tctx )
{
struct smb2_getinfo b ;
bool ret ;
struct smb2_tree * tree ;
struct smb2_create c ;
NTSTATUS status ;
struct smb2_handle handle ;
2016-02-22 17:51:06 +03:00
torture_comment ( tctx , " Testing SMB2_GETINFO_SECURITY buffer sizes \n " ) ;
2013-08-27 13:41:13 +04:00
ret = torture_smb2_connection ( tctx , & tree ) ;
torture_assert ( tctx , ret , " connection failed " ) ;
ZERO_STRUCT ( c ) ;
c . in . oplock_level = 0 ;
c . in . desired_access = SEC_STD_SYNCHRONIZE | SEC_DIR_READ_ATTRIBUTE |
SEC_DIR_LIST | SEC_STD_READ_CONTROL ;
c . in . file_attributes = 0 ;
c . in . create_disposition = NTCREATEX_DISP_OPEN ;
c . in . share_access = NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_SHARE_ACCESS_DELETE ;
c . in . create_options = NTCREATEX_OPTIONS_ASYNC_ALERT ;
c . in . fname = " " ;
status = smb2_create ( tree , tree , & c ) ;
torture_assert_ntstatus_ok (
tctx , status , " Unable to create root handle " ) ;
handle = c . out . file . handle ;
2008-05-31 07:39:51 +04:00
ZERO_STRUCT ( b ) ;
2019-03-29 13:08:12 +03:00
b . in . info_type = SMB2_0_INFO_SECURITY ;
2013-08-27 13:41:13 +04:00
b . in . info_class = 0 ;
b . in . file . handle = handle ;
b . in . output_buffer_length = 0 ;
2008-05-31 07:39:51 +04:00
status = smb2_getinfo ( tree , tree , & b ) ;
2013-08-27 13:41:13 +04:00
torture_assert_ntstatus_equal (
tctx , status , NT_STATUS_BUFFER_TOO_SMALL ,
" Wrong error code for large buffer " ) ;
b . in . output_buffer_length = 1 ;
status = smb2_getinfo ( tree , tree , & b ) ;
torture_assert_ntstatus_equal (
tctx , status , NT_STATUS_BUFFER_TOO_SMALL ,
" Wrong error code for large buffer " ) ;
2008-05-31 07:39:51 +04:00
return true ;
}
2005-11-17 14:06:13 +03:00
/* basic testing of all SMB2 getinfo levels
*/
2016-02-22 17:40:50 +03:00
static bool torture_smb2_getinfo ( struct torture_context * tctx )
2005-11-17 14:06:13 +03:00
{
struct smb2_tree * tree ;
2007-10-07 02:28:14 +04:00
bool ret = true ;
2005-11-18 12:51:13 +03:00
NTSTATUS status ;
2005-11-17 14:06:13 +03:00
2016-02-22 17:40:50 +03:00
ret = torture_smb2_connection ( tctx , & tree ) ;
torture_assert ( tctx , ret , " connection failed " ) ;
2005-11-17 14:06:13 +03:00
2008-05-22 08:50:36 +04:00
smb2_deltree ( tree , FNAME ) ;
smb2_deltree ( tree , DNAME ) ;
2016-02-22 17:40:50 +03:00
status = torture_setup_complex_file ( tctx , tree , FNAME ) ;
torture_assert_ntstatus_ok ( tctx , status ,
2012-02-28 17:19:49 +04:00
" setup complex file " FNAME ) ;
2016-02-22 17:40:50 +03:00
status = torture_setup_complex_file ( tctx , tree , FNAME " :streamtwo " ) ;
torture_assert_ntstatus_ok ( tctx , status ,
2012-03-06 14:48:52 +04:00
" setup complex file " FNAME " :streamtwo " ) ;
2012-02-28 17:19:49 +04:00
2016-02-22 17:40:50 +03:00
status = torture_setup_complex_dir ( tctx , tree , DNAME ) ;
torture_assert_ntstatus_ok ( tctx , status ,
2012-02-28 17:19:49 +04:00
" setup complex dir " DNAME ) ;
2016-02-22 17:40:50 +03:00
status = torture_setup_complex_file ( tctx , tree , DNAME " :streamtwo " ) ;
torture_assert_ntstatus_ok ( tctx , status ,
2012-03-06 14:48:52 +04:00
" setup complex dir " DNAME " :streamtwo " ) ;
2005-11-17 14:06:13 +03:00
2016-02-22 17:40:50 +03:00
ret & = torture_smb2_fileinfo ( tctx , tree ) ;
2005-11-17 14:06:13 +03:00
return ret ;
}
2013-08-22 15:06:59 +04:00
2022-08-19 18:29:55 +03:00
# undef LEVEL
# define LEVEL(l, u, ua, ra) \
. name = # l , \
. level = l , \
. unrestricted = u , \
. unrestricted_access = ua , \
. required_access = ra
static struct {
const char * name ;
uint16_t level ;
bool unrestricted ;
uint32_t unrestricted_access ;
uint32_t required_access ;
} file_levels_access [ ] = {
/*
* The following info levels are not checked :
* - FileFullEaInformation and FileIdInformation :
* not implemented by the s4 / libcli / raw
* - all pipe infolevels : that should be tested elsewhere by RPC tests
*/
/*
* The following allow unrestricted access , so requesting
* SEC_FILE_READ_ATTRIBUTE works , SEC_FILE_READ_ATTRIBUTE or
* SEC_FILE_READ_EA as well of course .
*/
{ LEVEL ( RAW_FILEINFO_STANDARD_INFORMATION , true , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_ATTRIBUTE ) } ,
{ LEVEL ( RAW_FILEINFO_INTERNAL_INFORMATION , true , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_ATTRIBUTE ) } ,
{ LEVEL ( RAW_FILEINFO_ACCESS_INFORMATION , true , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_ATTRIBUTE ) } ,
{ LEVEL ( RAW_FILEINFO_POSITION_INFORMATION , true , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_ATTRIBUTE ) } ,
{ LEVEL ( RAW_FILEINFO_MODE_INFORMATION , true , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_ATTRIBUTE ) } ,
{ LEVEL ( RAW_FILEINFO_ALIGNMENT_INFORMATION , true , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_ATTRIBUTE ) } ,
{ LEVEL ( RAW_FILEINFO_ALT_NAME_INFORMATION , true , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_ATTRIBUTE ) } ,
{ LEVEL ( RAW_FILEINFO_STREAM_INFORMATION , true , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_ATTRIBUTE ) } ,
{ LEVEL ( RAW_FILEINFO_COMPRESSION_INFORMATION , true , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_ATTRIBUTE ) } ,
{ LEVEL ( RAW_FILEINFO_NORMALIZED_NAME_INFORMATION , true , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_ATTRIBUTE ) } ,
{ LEVEL ( RAW_FILEINFO_EA_INFORMATION , true , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_EA ) } ,
/*
* The following require either SEC_FILE_READ_ATTRIBUTE or
* SEC_FILE_READ_EA .
*/
{ LEVEL ( RAW_FILEINFO_BASIC_INFORMATION , false , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_ATTRIBUTE ) } ,
{ LEVEL ( RAW_FILEINFO_ALL_INFORMATION , false , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_ATTRIBUTE ) } ,
{ LEVEL ( RAW_FILEINFO_NETWORK_OPEN_INFORMATION , false , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_ATTRIBUTE ) } ,
{ LEVEL ( RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION , false , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_ATTRIBUTE ) } ,
{ LEVEL ( RAW_FILEINFO_SMB2_ALL_INFORMATION , false , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_ATTRIBUTE ) } ,
{ LEVEL ( RAW_FILEINFO_SMB2_ALL_EAS , false , SEC_STD_SYNCHRONIZE , SEC_FILE_READ_EA ) } ,
/* Also try SEC_FILE_READ_ATTRIBUTE to show that it is the wrong one */
{ LEVEL ( RAW_FILEINFO_SMB2_ALL_EAS , false , SEC_FILE_READ_ATTRIBUTE , SEC_FILE_READ_EA ) } ,
{ LEVEL ( RAW_FILEINFO_SEC_DESC , false , SEC_STD_SYNCHRONIZE , SEC_STD_READ_CONTROL ) } ,
/* Also try SEC_FILE_READ_ATTRIBUTE to show that it is the wrong one */
{ LEVEL ( RAW_FILEINFO_SEC_DESC , false , SEC_FILE_READ_ATTRIBUTE , SEC_STD_READ_CONTROL ) }
} ;
/*
test fileinfo levels
*/
static bool torture_smb2_getfinfo_access ( struct torture_context * tctx ,
struct smb2_tree * tree )
{
const char * fname = " torture_smb2_getfinfo_access " ;
struct smb2_handle hfile ;
NTSTATUS status ;
bool ret = true ;
int i ;
smb2_deltree ( tree , fname ) ;
torture_setup_complex_file ( tctx , tree , fname ) ;
for ( i = 0 ; i < ARRAY_SIZE ( file_levels_access ) ; i + + ) {
union smb_fileinfo finfo ;
NTSTATUS expected_status ;
/*
* First open with unrestricted_access , SEC_STD_SYNCHRONIZE for
* most tests , info levels with unrestricted = true should allow
* this .
*/
status = torture_smb2_testfile_access (
tree , fname , & hfile , file_levels_access [ i ] . unrestricted_access ) ;
torture_assert_ntstatus_ok_goto ( tctx , status , ret , done ,
" Unable to open test file \n " ) ;
if ( file_levels_access [ i ] . level = = RAW_FILEINFO_SEC_DESC ) {
finfo . query_secdesc . in . secinfo_flags = 0x7 ;
}
if ( file_levels_access [ i ] . level = = RAW_FILEINFO_SMB2_ALL_EAS ) {
finfo . all_eas . in . continue_flags =
SMB2_CONTINUE_FLAG_RESTART ;
}
finfo . generic . level = file_levels_access [ i ] . level ;
finfo . generic . in . file . handle = hfile ;
if ( file_levels_access [ i ] . unrestricted ) {
expected_status = NT_STATUS_OK ;
} else {
expected_status = NT_STATUS_ACCESS_DENIED ;
}
status = smb2_getinfo_file ( tree , tree , & finfo ) ;
torture_assert_ntstatus_equal_goto (
tctx , status , expected_status , ret , done ,
talloc_asprintf ( tctx , " Level %s failed \n " ,
file_levels_access [ i ] . name ) ) ;
smb2_util_close ( tree , hfile ) ;
/*
* Now open with expected access , getinfo should work .
*/
status = torture_smb2_testfile_access (
tree , fname , & hfile , file_levels_access [ i ] . required_access ) ;
torture_assert_ntstatus_ok_goto (
tctx , status , ret , done ,
" Unable to open test file \n " ) ;
if ( file_levels_access [ i ] . level = = RAW_FILEINFO_SEC_DESC ) {
finfo . query_secdesc . in . secinfo_flags = 0x7 ;
}
if ( file_levels_access [ i ] . level = = RAW_FILEINFO_SMB2_ALL_EAS ) {
finfo . all_eas . in . continue_flags =
SMB2_CONTINUE_FLAG_RESTART ;
}
finfo . generic . level = file_levels_access [ i ] . level ;
finfo . generic . in . file . handle = hfile ;
status = smb2_getinfo_file ( tree , tree , & finfo ) ;
torture_assert_ntstatus_ok_goto (
tctx , status , ret , done ,
talloc_asprintf ( tctx , " %s on file " ,
file_levels_access [ i ] . name ) ) ;
smb2_util_close ( tree , hfile ) ;
}
done :
smb2_deltree ( tree , fname ) ;
return ret ;
}
2017-04-25 02:04:10 +03:00
struct torture_suite * torture_smb2_getinfo_init ( TALLOC_CTX * ctx )
2013-08-22 15:06:59 +04:00
{
struct torture_suite * suite = torture_suite_create (
2017-04-25 02:04:10 +03:00
ctx , " getinfo " ) ;
2013-08-22 15:06:59 +04:00
torture_suite_add_simple_test ( suite , " complex " , torture_smb2_getinfo ) ;
2013-08-22 15:47:21 +04:00
torture_suite_add_simple_test ( suite , " fsinfo " , torture_smb2_fsinfo ) ;
2013-08-27 13:41:13 +04:00
torture_suite_add_simple_test ( suite , " qfs_buffercheck " ,
torture_smb2_qfs_buffercheck ) ;
torture_suite_add_simple_test ( suite , " qfile_buffercheck " ,
torture_smb2_qfile_buffercheck ) ;
torture_suite_add_simple_test ( suite , " qsec_buffercheck " ,
torture_smb2_qsec_buffercheck ) ;
2016-08-13 21:23:34 +03:00
torture_suite_add_simple_test ( suite , " granted " ,
torture_smb2_fileinfo_grant_read ) ;
2019-04-25 15:57:02 +03:00
torture_suite_add_simple_test ( suite , " normalized " ,
torture_smb2_fileinfo_normalized ) ;
2022-08-19 18:29:55 +03:00
torture_suite_add_1smb2_test ( suite , " getinfo_access " ,
torture_smb2_getfinfo_access ) ;
2013-08-22 15:06:59 +04:00
return suite ;
}