Merged 1.4 to HEAD

svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4313 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4314 .
   svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4317 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4318 .


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4656 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-12-19 14:28:55 +00:00
parent cfb373ae36
commit 488450a988
17 changed files with 1807 additions and 877 deletions

View File

@@ -346,7 +346,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = null;
if (treeId != -1)
conn = m_sess.findConnection(treeId);
conn = m_sess.findTreeConnection(m_smbPkt);
if (conn != null)
{
@@ -577,9 +577,18 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Extract the parameters
// int flags = m_smbPkt.getAndXParameter(cmdOff, 2);
int pwdLen = m_smbPkt.getAndXParameter(cmdOff, 3);
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( outPkt.getUserId());
if (vc == null)
{
outPkt.setError(m_smbPkt.isLongErrorCode(), SMBStatus.NTInvalidParameter, SMBStatus.SRVNonSpecificError, SMBStatus.ErrSrv);
return endOff;
}
// Reset the byte pointer for data unpacking
m_smbPkt.setBytePointer(m_smbPkt.getAndXByteOffset(cmdOff), m_smbPkt.getAndXByteCount(cmdOff));
@@ -776,12 +785,12 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Allocate the tree id for this connection
int treeId = m_sess.addConnection(shareDev);
int treeId = vc.addConnection(shareDev);
outPkt.setTreeId(treeId);
// Set the file permission that this user has been granted for this share
tree = m_sess.findConnection(treeId);
tree = vc.findConnection(treeId);
tree.setPermission(sharePerm);
// Inform the driver that a connection has been opened
@@ -881,8 +890,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Get the tree id from the received packet and validate that it is a valid
// connection id.
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = m_sess.findTreeConnection(m_smbPkt);
if (conn == null)
{
@@ -996,8 +1004,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Get the tree id from the received packet and validate that it is a valid
// connection id.
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = m_sess.findTreeConnection(m_smbPkt);
if (conn == null)
{
@@ -1008,9 +1015,6 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Get the file id from the request
int fid = m_smbPkt.getAndXParameter(cmdOff, 0);
// int ftime = m_smbPkt.getAndXParameter(cmdOff, 1);
// int fdate = m_smbPkt.getAndXParameter(cmdOff, 2);
NetworkFile netFile = conn.findFile(fid);
if (netFile == null)
@@ -1022,7 +1026,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Debug
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_FILE))
logger.debug("Chained File Close [" + treeId + "] fid=" + fid);
logger.debug("Chained File Close [" + m_smbPkt.getTreeId() + "] fid=" + fid);
// Close the file
@@ -1093,9 +1097,16 @@ public class NTProtocolHandler extends CoreProtocolHandler
return;
}
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if ( vc == null) {
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.SRVNonSpecificError, SMBStatus.ErrSrv);
return;
}
// Extract the parameters
// int flags = m_smbPkt.getParameter(2);
int pwdLen = m_smbPkt.getParameter(3);
// Initialize the byte area pointer
@@ -1291,12 +1302,12 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Allocate a tree id for the new connection
int treeId = m_sess.addConnection(shareDev);
int treeId = vc.addConnection(shareDev);
outPkt.setTreeId(treeId);
// Set the file permission that this user has been granted for this share
TreeConnection tree = m_sess.findConnection(treeId);
TreeConnection tree = vc.findConnection(treeId);
tree.setPermission(sharePerm);
// Debug
@@ -1392,8 +1403,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Get the tree id from the received packet and validate that it is a valid
// connection id.
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = m_sess.findTreeConnection(m_smbPkt);
if (conn == null)
{
@@ -1415,8 +1425,6 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Get the file id from the request
int fid = m_smbPkt.getParameter(0);
// int ftime = m_smbPkt.getParameter(1);
// int fdate = m_smbPkt.getParameter(2);
NetworkFile netFile = conn.findFile(fid);
@@ -1429,7 +1437,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Debug
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_FILE))
logger.debug("File close [" + treeId + "] fid=" + fid);
logger.debug("File close [" + m_smbPkt.getTreeId() + "] fid=" + fid);
// Close the file
@@ -1513,11 +1521,19 @@ public class NTProtocolHandler extends CoreProtocolHandler
return;
}
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null) {
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree id from the received packet and validate that it is a valid
// connection id.
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(m_smbPkt.getTreeId());
if (conn == null)
{
@@ -1588,7 +1604,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Save the partial transaction data
m_sess.setTransaction(transBuf);
vc.setTransaction(transBuf);
// Send an intermediate acknowedgement response
@@ -1601,14 +1617,14 @@ public class NTProtocolHandler extends CoreProtocolHandler
if (conn.getSharedDevice().getType() == ShareType.ADMINPIPE)
{
IPCHandler.procTransaction(transBuf, m_sess, outPkt);
IPCHandler.procTransaction(vc, transBuf, m_sess, outPkt);
return;
}
// DEBUG
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_TRAN))
logger.debug("Transaction [" + treeId + "] tbuf=" + transBuf);
logger.debug("Transaction [" + m_smbPkt.getTreeId() + "] tbuf=" + transBuf);
// Process the transaction buffer
@@ -1635,11 +1651,19 @@ public class NTProtocolHandler extends CoreProtocolHandler
return;
}
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null) {
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree id from the received packet and validate that it is a valid
// connection id.
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(m_smbPkt.getTreeId());
if (conn == null)
{
@@ -1660,9 +1684,9 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Check if there is an active transaction, and it is an NT transaction
if (m_sess.hasTransaction() == false
|| (m_sess.getTransaction().isType() == PacketType.Transaction && m_smbPkt.getCommand() != PacketType.TransactionSecond)
|| (m_sess.getTransaction().isType() == PacketType.Transaction2 && m_smbPkt.getCommand() != PacketType.Transaction2Second))
if (vc.hasTransaction() == false
|| (vc.getTransaction().isType() == PacketType.Transaction && m_smbPkt.getCommand() != PacketType.TransactionSecond)
|| (vc.getTransaction().isType() == PacketType.Transaction2 && m_smbPkt.getCommand() != PacketType.Transaction2Second))
{
// No transaction to continue, or packet does not match the existing transaction, return
@@ -1676,7 +1700,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
SMBSrvTransPacket tpkt = new SMBSrvTransPacket(m_smbPkt.getBuffer());
byte[] buf = tpkt.getBuffer();
SrvTransactBuffer transBuf = m_sess.getTransaction();
SrvTransactBuffer transBuf = vc.getTransaction();
// Append the parameter data to the transaction buffer, if any
@@ -1705,7 +1729,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Debug
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_TRAN))
logger.debug("Transaction Secondary [" + treeId + "] paramLen=" + plen + ", dataLen=" + dlen);
logger.debug("Transaction Secondary [" + m_smbPkt.getTreeId() + "] paramLen=" + plen + ", dataLen=" + dlen);
// Check if the transaction has been received or there are more sections to be received
@@ -1725,21 +1749,21 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Clear the in progress transaction
m_sess.setTransaction(null);
vc.setTransaction(null);
// Check if the transaction is on the IPC$ named pipe, the request requires special
// processing
if (conn.getSharedDevice().getType() == ShareType.ADMINPIPE)
{
IPCHandler.procTransaction(transBuf, m_sess, outPkt);
IPCHandler.procTransaction(vc, transBuf, m_sess, outPkt);
return;
}
// DEBUG
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_TRAN))
logger.debug("Transaction second [" + treeId + "] tbuf=" + transBuf);
logger.debug("Transaction second [" + m_smbPkt.getTreeId() + "] tbuf=" + transBuf);
// Process the transaction
@@ -1843,10 +1867,18 @@ public class NTProtocolHandler extends CoreProtocolHandler
return;
}
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null) {
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree connection details
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(m_smbPkt.getTreeId());
if (conn == null)
{
@@ -1871,7 +1903,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Get the search context
SearchContext ctx = m_sess.getSearchContext(searchId);
SearchContext ctx = vc.getSearchContext(searchId);
if (ctx == null)
{
@@ -1889,7 +1921,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Deallocate the search slot, close the search.
m_sess.deallocateSearchSlot(searchId);
vc.deallocateSearchSlot(searchId);
// Return a success status SMB
@@ -1914,8 +1946,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Get the tree connection details
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = m_sess.findTreeConnection(m_smbPkt);
if (conn == null)
{
@@ -2121,10 +2152,37 @@ public class NTProtocolHandler extends CoreProtocolHandler
*/
protected final void procLogoffAndX(SMBSrvPacket outPkt) throws java.io.IOException, SMBSrvException
{
// Check that the received packet looks like a valid logoff andX request
// Return a success status SMB
if (m_smbPkt.checkPacketIsValid(2, 0) == false)
{
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.SRVNonSpecificError, SMBStatus.ErrSrv);
return;
}
m_sess.sendSuccessResponseSMB();
// Get the virtual circuit for the request
int uid = m_smbPkt.getUserId();
VirtualCircuit vc = m_sess.findVirtualCircuit( uid);
if (vc == null)
{
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// DEBUG
if ( logger.isDebugEnabled() && m_sess.hasDebug( SMBSrvSession.DBG_NEGOTIATE))
logger.debug("Logoff vc=" + vc);
// Close the virtual circuit
m_sess.removeVirtualCircuit( uid);
// Return a success status SMB
m_sess.sendSuccessResponseSMB();
}
/**
@@ -2145,8 +2203,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Get the tree connection details
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = m_sess.findTreeConnection(m_smbPkt);
if (conn == null)
{
@@ -2188,7 +2245,6 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Extract the open file parameters
// int flags = m_smbPkt.getParameter(2);
int access = m_smbPkt.getParameter(3);
int srchAttr = m_smbPkt.getParameter(4);
int fileAttr = m_smbPkt.getParameter(5);
@@ -2217,7 +2273,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Debug
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_FILE))
logger.debug("File Open AndX [" + treeId + "] params=" + params);
logger.debug("File Open AndX [" + m_smbPkt.getTreeId() + "] params=" + params);
// Access the disk interface and open the requested file
@@ -2395,8 +2451,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Get the tree connection details
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = m_sess.findTreeConnection(m_smbPkt);
if (conn == null)
{
@@ -2592,8 +2647,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Get the tree id from the received packet and validate that it is a valid
// connection id.
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = m_sess.findTreeConnection(m_smbPkt);
if (conn == null)
{
@@ -2653,7 +2707,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Debug
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_FILE))
logger.debug("File Rename [" + treeId + "] old name=" + oldName + ", new name=" + newName);
logger.debug("File Rename [" + m_smbPkt.getTreeId() + "] old name=" + oldName + ", new name=" + newName);
// Access the disk interface and rename the requested file
@@ -2748,8 +2802,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Get the tree id from the received packet and validate that it is a valid
// connection id.
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = m_sess.findTreeConnection(m_smbPkt);
if (conn == null)
{
@@ -2794,7 +2847,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Debug
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_FILE))
logger.debug("File Delete [" + treeId + "] name=" + fileName);
logger.debug("File Delete [" + m_smbPkt.getTreeId() + "] name=" + fileName);
// Access the disk interface and delete the file(s)
@@ -2871,8 +2924,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Get the tree id from the received packet and validate that it is a valid
// connection id.
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = m_sess.findTreeConnection(m_smbPkt);
if (conn == null)
{
@@ -2917,7 +2969,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Debug
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_FILE))
logger.debug("Directory Delete [" + treeId + "] name=" + dirName);
logger.debug("Directory Delete [" + m_smbPkt.getTreeId() + "] name=" + dirName);
// Access the disk interface and delete the directory
@@ -2992,11 +3044,19 @@ public class NTProtocolHandler extends CoreProtocolHandler
protected final void procTrans2FindFirst(SrvTransactBuffer tbuf, SMBSrvPacket outPkt) throws java.io.IOException,
SMBSrvException
{
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null)
{
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree connection details
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(tbuf.getTreeId());
if (conn == null)
{
@@ -3073,7 +3133,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Allocate a search slot for the new search
searchId = m_sess.allocateSearchSlot();
searchId = vc.allocateSearchSlot();
if (searchId == -1)
{
@@ -3111,7 +3171,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Store details of the search in the context
ctx.setTreeId(treeId);
ctx.setTreeId(m_smbPkt.getTreeId());
ctx.setMaximumFiles(maxFiles);
}
else
@@ -3125,7 +3185,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Save the search context
m_sess.setSearchContext(searchId, ctx);
vc.setSearchContext(searchId, ctx);
// Create the reply transact buffer
@@ -3315,7 +3375,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Release the search context
m_sess.deallocateSearchSlot(searchId);
vc.deallocateSearchSlot(searchId);
}
}
catch (FileNotFoundException ex)
@@ -3331,7 +3391,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Deallocate the search
if (searchId != -1)
m_sess.deallocateSearchSlot(searchId);
vc.deallocateSearchSlot(searchId);
// Requested path does not exist
@@ -3344,7 +3404,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Deallocate the search
if (searchId != -1)
m_sess.deallocateSearchSlot(searchId);
vc.deallocateSearchSlot(searchId);
// Failed to get/initialize the disk interface
@@ -3356,7 +3416,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Deallocate the search
if (searchId != -1)
m_sess.deallocateSearchSlot(searchId);
vc.deallocateSearchSlot(searchId);
// Requested information level is not supported
@@ -3376,10 +3436,18 @@ public class NTProtocolHandler extends CoreProtocolHandler
SMBSrvException
{
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null) {
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree connection details
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(tbuf.getTreeId());
if (conn == null)
{
@@ -3418,7 +3486,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
{
// Retrieve the search context
ctx = m_sess.getSearchContext(searchId);
ctx = vc.getSearchContext(searchId);
if (ctx == null)
{
@@ -3562,7 +3630,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Release the search context
m_sess.deallocateSearchSlot(searchId);
vc.deallocateSearchSlot(searchId);
}
}
catch (FileNotFoundException ex)
@@ -3571,7 +3639,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Deallocate the search
if (searchId != -1)
m_sess.deallocateSearchSlot(searchId);
vc.deallocateSearchSlot(searchId);
// Search path does not exist
@@ -3583,7 +3651,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Deallocate the search
if (searchId != -1)
m_sess.deallocateSearchSlot(searchId);
vc.deallocateSearchSlot(searchId);
// Requested information level is not supported
@@ -3603,10 +3671,20 @@ public class NTProtocolHandler extends CoreProtocolHandler
throws java.io.IOException, SMBSrvException
{
// Get the tree connection details
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null)
{
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree connection details
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(treeId);
if (conn == null)
{
@@ -3843,10 +3921,20 @@ public class NTProtocolHandler extends CoreProtocolHandler
SMBSrvException
{
// Get the tree connection details
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null)
{
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree connection details
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(treeId);
if (conn == null)
{
@@ -4049,11 +4137,20 @@ public class NTProtocolHandler extends CoreProtocolHandler
protected final void procTrans2QueryFile(SrvTransactBuffer tbuf, SMBSrvPacket outPkt) throws java.io.IOException,
SMBSrvException
{
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null)
{
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree connection details
// Get the tree connection details
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(treeId);
if (conn == null)
{
@@ -4256,10 +4353,20 @@ public class NTProtocolHandler extends CoreProtocolHandler
SMBSrvException
{
// Get the tree connection details
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null)
{
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree connection details
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(treeId);
if (conn == null)
{
@@ -4660,10 +4767,20 @@ public class NTProtocolHandler extends CoreProtocolHandler
SMBSrvException
{
// Get the tree connection details
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null)
{
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree connection details
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(treeId);
if (conn == null)
{
@@ -4911,8 +5028,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Get the tree connection details
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = m_sess.findTreeConnection(m_smbPkt);
if (conn == null)
{
@@ -5124,8 +5240,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Get the tree connection details
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = m_sess.findTreeConnection(m_smbPkt);
if (conn == null)
{
@@ -5246,7 +5361,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Debug
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_FILE))
logger.debug("NT Create AndX [" + treeId + "] params=" + params);
logger.debug("NT Create AndX [" + m_smbPkt.getTreeId() + "] params=" + params);
// Access the disk interface and open the requested file
@@ -5376,7 +5491,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Debug
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_FILE))
logger.debug(" [" + treeId + "] name=" + fileName + " truncated");
logger.debug(" [" + m_smbPkt.getTreeId() + "] name=" + fileName + " truncated");
}
// Set the file action response
@@ -5590,8 +5705,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Get the tree connection details
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = m_sess.findTreeConnection(m_smbPkt);
if (conn == null)
{
@@ -5670,11 +5784,19 @@ public class NTProtocolHandler extends CoreProtocolHandler
return;
}
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null) {
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree id from the received packet and validate that it is a valid
// connection id.
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(m_smbPkt.getTreeId());
if (conn == null)
{
@@ -5744,7 +5866,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Debug
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_TRAN))
logger.debug("NT Transaction [" + treeId + "] transbuf=" + transBuf);
logger.debug("NT Transaction [" + m_smbPkt.getTreeId() + "] transbuf=" + transBuf);
// Append the setup, parameter and data blocks to the transaction data
@@ -5757,7 +5879,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Debug
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_TRAN))
logger.debug("NT Transaction [" + treeId + "] pcnt=" + ntTrans.getNTParameter(4) + ", offset="
logger.debug("NT Transaction [" + m_smbPkt.getTreeId() + "] pcnt=" + ntTrans.getNTParameter(4) + ", offset="
+ ntTrans.getNTParameter(5));
cnt = ntTrans.getParameterBlockCount();
@@ -5773,7 +5895,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Debug
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_TRAN))
logger.debug("NT Transaction [" + treeId + "] cmd=0x" + Integer.toHexString(subCmd) + ", multiPkt="
logger.debug("NT Transaction [" + m_smbPkt.getTreeId() + "] cmd=0x" + Integer.toHexString(subCmd) + ", multiPkt="
+ transBuf.isMultiPacket());
// Check for a multi-packet transaction, for a multi-packet transaction we just acknowledge
@@ -5785,7 +5907,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Save the partial transaction data
m_sess.setTransaction(transBuf);
vc.setTransaction(transBuf);
// Send an intermediate acknowedgement response
@@ -5817,11 +5939,19 @@ public class NTProtocolHandler extends CoreProtocolHandler
return;
}
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null) {
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree id from the received packet and validate that it is a valid
// connection id.
int treeId = m_smbPkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(m_smbPkt.getTreeId());
if (conn == null)
{
@@ -5850,7 +5980,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Check if there is an active transaction, and it is an NT transaction
if (m_sess.hasTransaction() == false || m_sess.getTransaction().isType() != PacketType.NTTransact)
if (vc.hasTransaction() == false || vc.getTransaction().isType() != PacketType.NTTransact)
{
// No NT transaction to continue, return an error
@@ -5863,7 +5993,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
NTTransPacket ntTrans = new NTTransPacket(m_smbPkt.getBuffer());
byte[] buf = ntTrans.getBuffer();
SrvTransactBuffer transBuf = m_sess.getTransaction();
SrvTransactBuffer transBuf = vc.getTransaction();
// Append the parameter data to the transaction buffer, if any
@@ -5892,7 +6022,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Debug
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_TRAN))
logger.debug("NT Transaction Secondary [" + treeId + "] paramLen=" + plen + ", dataLen=" + dlen);
logger.debug("NT Transaction Secondary [" + m_smbPkt.getTreeId() + "] paramLen=" + plen + ", dataLen=" + dlen);
// Check if the transaction has been received or there are more sections to be received
@@ -5912,7 +6042,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Clear the in progress transaction
m_sess.setTransaction(null);
vc.setTransaction(null);
// Process the transaction
@@ -6020,10 +6150,18 @@ public class NTProtocolHandler extends CoreProtocolHandler
return;
}
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null) {
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree connection details
int treeId = tbuf.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(m_smbPkt.getTreeId());
if (conn == null)
{
@@ -6140,7 +6278,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Debug
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_FILE))
logger.debug("NT TransactCreate [" + treeId + "] params=" + params + " secDescLen=" + sdLen
logger.debug("NT TransactCreate [" + m_smbPkt.getTreeId() + "] params=" + params + " secDescLen=" + sdLen
+ ", extAttribLen=" + eaLen);
// Access the disk interface and open/create the requested file
@@ -6254,7 +6392,7 @@ public class NTProtocolHandler extends CoreProtocolHandler
// Debug
if (logger.isDebugEnabled() && m_sess.hasDebug(SMBSrvSession.DBG_FILE))
logger.debug(" [" + treeId + "] name=" + fileName + " truncated");
logger.debug(" [" + m_smbPkt.getTreeId() + "] name=" + fileName + " truncated");
}
// Set the file action response
@@ -6420,11 +6558,18 @@ public class NTProtocolHandler extends CoreProtocolHandler
protected final void procNTTransactIOCtl(SrvTransactBuffer tbuf, NTTransPacket outPkt) throws IOException,
SMBSrvException
{
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null) {
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree connection details
int treeId = tbuf.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(m_smbPkt.getTreeId());
if (conn == null) {
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
@@ -6531,11 +6676,18 @@ public class NTProtocolHandler extends CoreProtocolHandler
protected final void procNTTransactQuerySecurityDesc(SrvTransactBuffer tbuf, NTTransPacket outPkt)
throws IOException, SMBSrvException
{
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null) {
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree connection details
int treeId = tbuf.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(tbuf.getTreeId());
if (conn == null)
{
@@ -6604,10 +6756,18 @@ public class NTProtocolHandler extends CoreProtocolHandler
DataBuffer paramBuf = tbuf.getParameterBuffer();
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null) {
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree connection details
int treeId = tbuf.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(tbuf.getTreeId());
if (conn == null)
{
@@ -6653,11 +6813,19 @@ public class NTProtocolHandler extends CoreProtocolHandler
protected final void procNTTransactNotifyChange(NTTransPacket ntpkt, SMBSrvPacket outPkt) throws IOException,
SMBSrvException
{
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null) {
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Get the tree connection details
// Get the tree connection details
int treeId = ntpkt.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
TreeConnection conn = vc.findConnection(treeId);
if (conn == null)
{
@@ -6809,15 +6977,24 @@ public class NTProtocolHandler extends CoreProtocolHandler
protected final void procNTTransactRename(SrvTransactBuffer tbuf, NTTransPacket outPkt) throws IOException,
SMBSrvException
{
// Unpack the request details
DataBuffer paramBuf = tbuf.getParameterBuffer();
// Get the virtual circuit for the request
VirtualCircuit vc = m_sess.findVirtualCircuit( m_smbPkt.getUserId());
if (vc == null)
{
m_sess.sendErrorResponseSMB(SMBStatus.NTInvalidParameter, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
return;
}
// Unpack the request details
// Get the tree connection details
// DataBuffer paramBuf = tbuf.getParameterBuffer();
// Get the tree connection details
int treeId = tbuf.getTreeId();
TreeConnection conn = m_sess.findConnection(treeId);
int treeId = tbuf.getTreeId();
TreeConnection conn = vc.findConnection(treeId);
if (conn == null)
{