/*
* Test for maximum ea size - more than one ea name is checked.
*
* Additional parameters can be passed, to allow further testing:
*
* default
* maxeasize 65536 limit the max. size for a single EA name
* maxeanames 101 limit of the number of tested names
* maxeastart 1 this EA size is used to test for the 1st EA (atm)
* maxeadebug 0 if set true, further debug output is done - in addition
* the testfile is not deleted for further inspection!
*
* Set some/all of these options on the cmdline with:
* --option torture:maxeasize=1024 --option torture:maxeadebug=1 ...
*
*/
static bool test_max_eas(struct smbcli_state *cli, struct torture_context *tctx)
{
NTSTATUS status;
union smb_open io;
const char *fname = BASEDIR "\\ea_max.txt";
int fnum = -1;
bool ret = true;
bool err = false;
int i, j, k, last, total;
DATA_BLOB eablob;
char *eaname = NULL;
int maxeasize;
int maxeanames;
int maxeastart;
torture_comment(tctx, "TESTING SETFILEINFO MAX. EA_SET\n");
maxeasize = torture_setting_int(tctx, "maxeasize", 65536);
maxeanames = torture_setting_int(tctx, "maxeanames", 101);
maxeastart = torture_setting_int(tctx, "maxeastart", 1);
maxeadebug = torture_setting_int(tctx, "maxeadebug", 0);
/* Do some sanity check on possibly passed parms */
if (maxeasize <= 0) {
torture_comment(tctx, "Invalid parameter 'maxeasize=%d'",maxeasize);
err = true;
}
if (maxeanames <= 0) {
torture_comment(tctx, "Invalid parameter 'maxeanames=%d'",maxeanames);
err = true;
}
if (maxeastart <= 0) {
torture_comment(tctx, "Invalid parameter 'maxeastart=%d'",maxeastart);
err = true;
}
if (maxeadebug < 0) {
torture_comment(tctx, "Invalid parameter 'maxeadebug=%d'",maxeadebug);
err = true;
}
if (err) {
torture_comment(tctx, "\n\n");
goto done;
}
if (maxeastart > maxeasize) {
maxeastart = maxeasize;
torture_comment(tctx, "'maxeastart' outside range - corrected to %d\n",
maxeastart);
}
torture_comment(tctx, "MAXEA parms: maxeasize=%d maxeanames=%d maxeastart=%d"
" maxeadebug=%d\n", maxeasize, maxeanames, maxeastart,
maxeadebug);
io.generic.level = RAW_OPEN_NTCREATEX;
io.ntcreatex.in.root_fid.fnum = 0;
io.ntcreatex.in.flags = 0;
io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
io.ntcreatex.in.create_options = 0;
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
io.ntcreatex.in.share_access =
NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_SHARE_ACCESS_WRITE;
io.ntcreatex.in.alloc_size = 0;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = fname;
status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
eablob = data_blob_talloc(tctx, NULL, maxeasize);
if (eablob.data == NULL) {
goto done;
}
/*
* Fill in some EA data - the offset could be easily checked
* during a hexdump.
*/
for (i = 0, k = 0; i < eablob.length / 4; i++, k+=4) {
eablob.data[k] = k & 0xff;
eablob.data[k+1] = (k >> 8) & 0xff;
eablob.data[k+2] = (k >> 16) & 0xff;
eablob.data[k+3] = (k >> 24) & 0xff;
//.........这里部分代码省略.........
开发者ID:Arkhont,项目名称:samba,代码行数:101,代码来源:eas.c
示例3: xsvfSwapBytes
// Parse the XSVF, reversing the byte-ordering of all the bytestreams.
//
static FLStatus xsvfSwapBytes(XC *xc, struct Buffer *outBuf, uint32 *maxBufSize, const char **error) {
FLStatus fStatus, retVal = FL_SUCCESS;
uint32 newXSize = 0, curXSize = 0, totOffset = 0;
uint32 numBytes;
BufferStatus bStatus;
uint8 thisByte;
uint32 dummy;
bool zeroMask = false;
if ( !maxBufSize ) {
maxBufSize = &dummy;
}
*maxBufSize = 0;
thisByte = getNextByte(xc);
while ( thisByte != XCOMPLETE ) {
switch ( thisByte ) {
case XTDOMASK:{
// Swap the XTDOMASK bytes.
uint32 initLength;
const uint8 *p;
const uint8 *end;
if ( newXSize != curXSize ) {
curXSize = newXSize;
sendXSize(outBuf, curXSize, error);
}
initLength = (uint32)outBuf->length;
numBytes = bitsToBytes(curXSize);
bStatus = bufAppendByte(outBuf, XTDOMASK, error);
CHECK_STATUS(bStatus, FL_ALLOC_ERR, cleanup, "xsvfSwapBytes()");
fStatus = swapBytes(xc, numBytes, outBuf, error);
CHECK_STATUS(fStatus, fStatus, cleanup, "xsvfSwapBytes()");
p = outBuf->data + initLength + 1;
end = outBuf->data + outBuf->length;
while ( *p == 0 && p < end ) p++;
if ( p == end ) {
// All zeros so delete the command
outBuf->length = initLength;
zeroMask = true;
} else {
// Keep the command
if ( numBytes > *maxBufSize ) {
*maxBufSize = numBytes;
}
zeroMask = false;
}
break;
}
case XSDRTDO:
// Swap the tdiValue and tdoExpected bytes.
if ( newXSize != curXSize ) {
curXSize = newXSize;
sendXSize(outBuf, curXSize, error);
}
numBytes = bitsToBytes(curXSize);
if ( zeroMask ) {
// The last mask was all zeros, so replace this XSDRTDO with an XSDR and throw away
// the tdoExpected bytes.
bStatus = bufAppendByte(outBuf, XSDR, error);
CHECK_STATUS(bStatus, FL_ALLOC_ERR, cleanup, "xsvfSwapBytes()");
fStatus = swapBytes(xc, numBytes, outBuf, error);
CHECK_STATUS(fStatus, fStatus, cleanup, "xsvfSwapBytes()");
while ( numBytes-- ) {
getNextByte(xc);
}
} else {
// The last mask was not all zeros, so we must honour the XSDRTDO's tdoExpected bytes.
CHECK_STATUS(
numBytes > BUF_SIZE, FL_UNSUPPORTED_SIZE_ERR, cleanup,
"xsvfSwapBytes(): Previous mask was nonzero, but no room to compare %d bytes", numBytes);
if ( numBytes > *maxBufSize ) {
*maxBufSize = numBytes;
}
bStatus = bufAppendByte(outBuf, XSDRTDO, error);
CHECK_STATUS(bStatus, FL_ALLOC_ERR, cleanup, "xsvfSwapBytes()");
fStatus = swapAndInterleaveBytes(xc, numBytes, outBuf, error);
CHECK_STATUS(fStatus, fStatus, cleanup, "xsvfSwapBytes()");
}
break;
case XREPEAT:
// Drop XREPEAT for now. Will probably be needed for CPLDs.
getNextByte(xc);
break;
case XRUNTEST:
// Copy the XRUNTEST bytes as-is.
bStatus = bufAppendByte(outBuf, XRUNTEST, error);
CHECK_STATUS(bStatus, FL_ALLOC_ERR, cleanup, "xsvfSwapBytes()");
bStatus = bufAppendByte(outBuf, getNextByte(xc), error);
CHECK_STATUS(bStatus, FL_ALLOC_ERR, cleanup, "xsvfSwapBytes()");
bStatus = bufAppendByte(outBuf, getNextByte(xc), error);
CHECK_STATUS(bStatus, FL_ALLOC_ERR, cleanup, "xsvfSwapBytes()");
bStatus = bufAppendByte(outBuf, getNextByte(xc), error);
CHECK_STATUS(bStatus, FL_ALLOC_ERR, cleanup, "xsvfSwapBytes()");
bStatus = bufAppendByte(outBuf, getNextByte(xc), error);
CHECK_STATUS(bStatus, FL_ALLOC_ERR, cleanup, "xsvfSwapBytes()");
break;
//.........这里部分代码省略.........
static bool test_session_expire1(struct torture_context *tctx)
{
NTSTATUS status;
bool ret = false;
struct smbcli_options options;
const char *host = torture_setting_string(tctx, "host", NULL);
const char *share = torture_setting_string(tctx, "share", NULL);
struct cli_credentials *credentials = cmdline_credentials;
struct smb2_tree *tree = NULL;
enum credentials_use_kerberos use_kerberos;
char fname[256];
struct smb2_handle _h1;
struct smb2_handle *h1 = NULL;
struct smb2_create io1;
union smb_fileinfo qfinfo;
size_t i;
use_kerberos = cli_credentials_get_kerberos_state(credentials);
if (use_kerberos != CRED_MUST_USE_KERBEROS) {
torture_warning(tctx, "smb2.session.expire1 requires -k yes!");
torture_skip(tctx, "smb2.session.expire1 requires -k yes!");
}
torture_assert_int_equal(tctx, use_kerberos, CRED_MUST_USE_KERBEROS,
"please use -k yes");
lpcfg_set_option(tctx->lp_ctx, "gensec_gssapi:requested_life_time=4");
lpcfg_smbcli_options(tctx->lp_ctx, &options);
status = smb2_connect(tctx,
host,
lpcfg_smb_ports(tctx->lp_ctx),
share,
lpcfg_resolve_context(tctx->lp_ctx),
credentials,
&tree,
tctx->ev,
&options,
lpcfg_socket_options(tctx->lp_ctx),
lpcfg_gensec_settings(tctx, tctx->lp_ctx)
);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
"smb2_connect failed");
/* Add some random component to the file name. */
snprintf(fname, sizeof(fname), "session_expire1_%s.dat",
generate_random_str(tctx, 8));
smb2_util_unlink(tree, fname);
smb2_oplock_create_share(&io1, fname,
smb2_util_share_access(""),
smb2_util_oplock_level("b"));
io1.in.create_options |= NTCREATEX_OPTIONS_DELETE_ON_CLOSE;
status = smb2_create(tree, tctx, &io1);
CHECK_STATUS(status, NT_STATUS_OK);
_h1 = io1.out.file.handle;
h1 = &_h1;
CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE);
CHECK_VAL(io1.out.oplock_level, smb2_util_oplock_level("b"));
/* get the security descriptor */
ZERO_STRUCT(qfinfo);
qfinfo.access_information.level = RAW_FILEINFO_ACCESS_INFORMATION;
qfinfo.access_information.in.file.handle = _h1;
for (i=0; i < 2; i++) {
torture_comment(tctx, "query info => OK\n");
ZERO_STRUCT(qfinfo.access_information.out);
status = smb2_getinfo_file(tree, tctx, &qfinfo);
CHECK_STATUS(status, NT_STATUS_OK);
torture_comment(tctx, "sleep 5 seconds\n");
smb_msleep(5*1000);
torture_comment(tctx, "query info => EXPIRED\n");
ZERO_STRUCT(qfinfo.access_information.out);
status = smb2_getinfo_file(tree, tctx, &qfinfo);
CHECK_STATUS(status, NT_STATUS_NETWORK_SESSION_EXPIRED);
/*
* the krb5 library may not handle expired creds
* well, lets start with an empty ccache.
*/
cli_credentials_invalidate_ccache(credentials, CRED_SPECIFIED);
torture_comment(tctx, "reauth => OK\n");
status = smb2_session_setup_spnego(tree->session,
credentials,
0 /* previous_session_id */);
CHECK_STATUS(status, NT_STATUS_OK);
}
ZERO_STRUCT(qfinfo.access_information.out);
status = smb2_getinfo_file(tree, tctx, &qfinfo);
//.........这里部分代码省略.........
开发者ID:jkstrick,项目名称:samba,代码行数:101,代码来源:session.c
示例5: FT_InitChannel
/*!
* \brief Initializes a channel
*
* This function initializes the channel and the communication parameters associated with it. The
* function takes variable number of parameters. For example, if channelType is I2C then the
* number of variable parameters will be equal to the number of members in the structure
* ChannelConfig. The variable parameters will be passed to this function in the same order as
* they appear in the structure defination
* The function performs the USB function specific initialization followed by MPSSE initialization.
* Once that is done it will configure MPSSE with the legacy protocol specific initializations(SPI/
* I2C/JTAG) with the help of that parameters that are passed by the caller
*
* \param[in] Protocol Specifies the protocol type(I2C/SPI/JTAG)
* \param[in] handle Handle of the channel
* \param[in] varArg1 Clock rate
* \param[in] varArg2 Latency timer
* \param[in] varArg3 Configuration options
* \return status
* \sa
* \note
* \warning
*/
FT_STATUS FT_InitChannel(FT_LegacyProtocol Protocol, FT_HANDLE handle,...)
{
va_list argumentList;
uint32 clockRate,latencyTimer,configOptions;
FT_STATUS status;
FT_DEVICE ftDevice;
FN_ENTER;
/*initialise the argument list*/
va_start(argumentList,handle);
/*Get the value for Clockrate*/
clockRate = va_arg(argumentList,uint32);
/*latencyTimer*/
latencyTimer = va_arg(argumentList,uint32);
/* The options parameter passed in I2C_Init, SPI_Init */
configOptions = va_arg(argumentList,uint32);
/*Check parameters*/
if((clockRate<MIN_CLOCK_RATE)||(clockRate>MAX_CLOCK_RATE)||(latencyTimer<
MIN_LATENCY_TIMER)||(latencyTimer>MAX_LATENCY_TIMER))
return FT_INVALID_PARAMETER;
/*Get the device type*/
status = Mid_GetFtDeviceType(handle, &ftDevice);
CHECK_STATUS(status);
/*reset the device*/
status = Mid_ResetDevice(handle);
CHECK_STATUS(status);
/*Purge*/
status = Mid_PurgeDevice(handle);
CHECK_STATUS(status);
/*set USB buffer size*/
status = Mid_SetUSBParameters(handle,\
USB_INPUT_BUFFER_SIZE,USB_OUTPUT_BUFFER_SIZE);
CHECK_STATUS(status);
/*sets the special characters for the device,
disable event and error characters*/
status = Mid_SetDeviceSpecialChar(handle,FALSE,DISABLE_EVENT,FALSE,\
DISABLE_CHAR);
CHECK_STATUS(status);
/*SetTimeOut*/
#ifdef FT800_HACK//hack from prashanth - changed the read timeout to 0
status = Mid_SetDeviceTimeOut(handle, 0 \
/*DEVICE_READ_TIMEOUT_INFINITE*/,DEVICE_WRITE_TIMEOUT);
CHECK_STATUS(status);
#else
status = Mid_SetDeviceTimeOut(handle, 5000 \
/*DEVICE_READ_TIMEOUT_INFINITE*/,DEVICE_WRITE_TIMEOUT);
CHECK_STATUS(status);
#endif
/*SetLatencyTimer*/
status = Mid_SetLatencyTimer(handle,(UCHAR)latencyTimer);
CHECK_STATUS(status);
/*ResetMPSSE*/
status = Mid_ResetMPSSE(handle);
CHECK_STATUS(status);
/*EnableMPSSEInterface*/
status = Mid_EnableMPSSEIn(handle);
CHECK_STATUS(status);
/*20110608 - enabling loopback before sync*/
status = Mid_SetDeviceLoopbackState(handle,MID_LOOPBACK_TRUE);
CHECK_STATUS(status);
/*Sync MPSSE */
status = Mid_SyncMPSSE(handle);
CHECK_STATUS(status);
/*wait for USB*/
INFRA_SLEEP(50);
/*set Clock frequency*/
status = Mid_SetClock(handle, ftDevice, clockRate);
CHECK_STATUS(status);
DBG(MSG_INFO, "Mid_SetClock Status Ok return 0x%x\n",(unsigned)status);
INFRA_SLEEP(20);
/*Stop Loop back*/
status = Mid_SetDeviceLoopbackState(handle,MID_LOOPBACK_FALSE);
CHECK_STATUS(status);
DBG(MSG_INFO, "Mid_SetDeviceLoopbackState Status Ok return 0x%x\n",\
(unsigned)status);
status = Mid_EmptyDeviceInputBuff(handle);
//.........这里部分代码省略.........
请发表评论