/*
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
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 .
*/
#include "includes.h"
#include "libcli/smb2/smb2.h"
#include "libcli/smb2/smb2_calls.h"
#include "libcli/smb/smbXcli_base.h"
#include "torture/torture.h"
#include "torture/smb2/proto.h"
#include "torture/util.h"
static struct {
const char *name;
uint16_t level;
NTSTATUS fstatus;
NTSTATUS dstatus;
union smb_fileinfo finfo;
union smb_fileinfo dinfo;
} file_levels[] = {
#define LEVEL(x) #x, x
{ 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) },
{ LEVEL(RAW_FILEINFO_SMB2_ALL_EAS) },
{ 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) },
{ LEVEL(RAW_QFS_OBJECTID_INFORMATION) }
};
#define FNAME "testsmb2_file.dat"
#define DNAME "testsmb2_dir"
/*
test fileinfo levels
*/
static bool torture_smb2_fileinfo(struct torture_context *tctx, struct smb2_tree *tree)
{
struct smb2_handle hfile, hdir;
NTSTATUS status;
int i;
status = torture_smb2_testfile(tree, FNAME, &hfile);
torture_assert_ntstatus_ok(tctx, status, "Unable to create test file "
FNAME "\n");
status = torture_smb2_testdir(tree, DNAME, &hdir);
torture_assert_ntstatus_ok(tctx, status, "Unable to create test dir "
DNAME "\n");
printf("Testing file info levels\n");
torture_smb2_all_info(tree, hfile);
torture_smb2_all_info(tree, hdir);
for (i=0;iin.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 (iout.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)
{
bool ret;
struct smb2_tree *tree;
NTSTATUS status;
struct smb2_handle handle;
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 },
};
printf("Testing SMB2_GETINFO_FS buffer sizes\n");
ret = torture_smb2_connection(tctx, &tree);
torture_assert(tctx, ret, "connection failed");
status = smb2_util_roothandle(tree, &handle);
torture_assert_ntstatus_ok(
tctx, status, "Unable to create root handle");
for (i=0; i