|
|
|
@ -99,11 +99,11 @@ static int logSASLMessages(void *context __attribute__((unused)), int priority,
|
|
|
|
|
return SASL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDEKerberosClientSocket::TDEKerberosClientSocket(TQObject *parent, const char *name) : TQSocket(parent, name), m_kerberosRequested(false), m_criticalSection(0), m_bufferLength(0), m_bufferReadPointer(0), m_krbInitRunning(false), m_krbInitState(-1), m_dataTimeout(-1), kerberosInitLoopTimer(NULL), m_canary(NULL), m_negotiatedMaxBufferSize(NET_SEC_BUF_SIZE) {
|
|
|
|
|
TDEKerberosClientSocket::TDEKerberosClientSocket(TQObject *parent, const char *name) : TQSocket(parent, name), m_kerberosRequested(false), m_criticalSection(0), m_readBufferLength(0), m_readBufferReadPointer(0), m_krbInitRunning(false), m_krbInitState(-1), m_dataTimeout(-1), kerberosInitLoopTimer(NULL), m_canary(NULL), m_negotiatedMaxBufferSize(NET_SEC_BUF_SIZE) {
|
|
|
|
|
saslData = new SASLDataPrivate;
|
|
|
|
|
saslData->m_krbConnection = NULL;
|
|
|
|
|
m_buffer = new TQBuffer();
|
|
|
|
|
m_buffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_readBuffer = new TQBuffer();
|
|
|
|
|
m_readBuffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDEKerberosClientSocket::~TDEKerberosClientSocket() {
|
|
|
|
@ -116,8 +116,8 @@ TDEKerberosClientSocket::~TDEKerberosClientSocket() {
|
|
|
|
|
kerberosInitLoopTimer = NULL;
|
|
|
|
|
}
|
|
|
|
|
setUsingKerberos(false);
|
|
|
|
|
m_buffer->close();
|
|
|
|
|
delete m_buffer;
|
|
|
|
|
m_readBuffer->close();
|
|
|
|
|
delete m_readBuffer;
|
|
|
|
|
delete saslData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -154,7 +154,7 @@ TQIODevice::Offset TDEKerberosClientSocket::size() const {
|
|
|
|
|
TQIODevice::Offset ret;
|
|
|
|
|
|
|
|
|
|
if (kerberosStatus() == KerberosInUse) {
|
|
|
|
|
ret = m_bufferLength;
|
|
|
|
|
ret = m_readBufferLength;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ret = TQSocket::size();
|
|
|
|
@ -174,18 +174,18 @@ bool TDEKerberosClientSocket::at(TQIODevice::Offset off, int hidebasehack) {
|
|
|
|
|
if (kerberosStatus() == KerberosInUse) {
|
|
|
|
|
if (off > 0) {
|
|
|
|
|
// Prevent overflow
|
|
|
|
|
if (off > (unsigned long)m_bufferLength) {
|
|
|
|
|
off = m_bufferLength;
|
|
|
|
|
if (off > (unsigned long)m_readBufferLength) {
|
|
|
|
|
off = m_readBufferLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove the specified bytes from the buffer
|
|
|
|
|
m_bufferLength = m_bufferLength-off;
|
|
|
|
|
m_bufferReadPointer = m_bufferReadPointer+off;
|
|
|
|
|
if (m_bufferLength < 1) {
|
|
|
|
|
m_readBufferLength = m_readBufferLength-off;
|
|
|
|
|
m_readBufferReadPointer = m_readBufferReadPointer+off;
|
|
|
|
|
if (m_readBufferLength < 1) {
|
|
|
|
|
// Clear the buffer from memory
|
|
|
|
|
m_buffer->close();
|
|
|
|
|
m_buffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_bufferReadPointer = 0;
|
|
|
|
|
m_readBuffer->close();
|
|
|
|
|
m_readBuffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_readBufferReadPointer = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
@ -201,7 +201,7 @@ bool TDEKerberosClientSocket::atEnd() const {
|
|
|
|
|
bool ret;
|
|
|
|
|
|
|
|
|
|
if (kerberosStatus() == KerberosInUse) {
|
|
|
|
|
ret = ((m_bufferLength < 1) && TQSocket::atEnd());
|
|
|
|
|
ret = ((m_readBufferLength < 1) && TQSocket::atEnd());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ret = TQSocket::atEnd();
|
|
|
|
@ -270,7 +270,7 @@ TQ_ULONG TDEKerberosClientSocket::bytesAvailable() const {
|
|
|
|
|
TQ_ULONG ret;
|
|
|
|
|
|
|
|
|
|
if (kerberosStatus() == KerberosInUse) {
|
|
|
|
|
ret = m_bufferLength;
|
|
|
|
|
ret = m_readBufferLength;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ret = TQSocket::bytesAvailable();
|
|
|
|
@ -291,10 +291,10 @@ int TDEKerberosClientSocket::processPendingData() {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (reclen > 0) {
|
|
|
|
|
m_buffer->at(m_bufferLength+m_bufferReadPointer);
|
|
|
|
|
wrlen = m_buffer->writeBlock(buf, reclen);
|
|
|
|
|
m_readBuffer->at(m_readBufferLength+m_readBufferReadPointer);
|
|
|
|
|
wrlen = m_readBuffer->writeBlock(buf, reclen);
|
|
|
|
|
if (wrlen > 0) {
|
|
|
|
|
m_bufferLength = m_bufferLength + wrlen;
|
|
|
|
|
m_readBufferLength = m_readBufferLength + wrlen;
|
|
|
|
|
emit(newDataReceived());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -343,7 +343,7 @@ TQ_LONG TDEKerberosClientSocket::readBlock(char *data, TQ_ULONG maxlen) {
|
|
|
|
|
if (kerberosStatus() == KerberosInUse) {
|
|
|
|
|
int reclen;
|
|
|
|
|
int wrlen;
|
|
|
|
|
if (m_bufferLength <= 0) {
|
|
|
|
|
if (m_readBufferLength <= 0) {
|
|
|
|
|
char* buf = (char*)malloc(m_negotiatedMaxBufferSize);
|
|
|
|
|
reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize, false);
|
|
|
|
|
if (reclen < 0) {
|
|
|
|
@ -351,30 +351,30 @@ TQ_LONG TDEKerberosClientSocket::readBlock(char *data, TQ_ULONG maxlen) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (reclen > 0) {
|
|
|
|
|
m_buffer->at(m_bufferLength+m_bufferReadPointer);
|
|
|
|
|
wrlen = m_buffer->writeBlock(buf, reclen);
|
|
|
|
|
m_readBuffer->at(m_readBufferLength+m_readBufferReadPointer);
|
|
|
|
|
wrlen = m_readBuffer->writeBlock(buf, reclen);
|
|
|
|
|
if (wrlen > 0) {
|
|
|
|
|
m_bufferLength = m_bufferLength + wrlen;
|
|
|
|
|
m_readBufferLength = m_readBufferLength + wrlen;
|
|
|
|
|
emit(newDataReceived());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
free(buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (maxlen > (unsigned int)m_bufferLength) {
|
|
|
|
|
maxlen = m_bufferLength;
|
|
|
|
|
if (maxlen > (unsigned int)m_readBufferLength) {
|
|
|
|
|
maxlen = m_readBufferLength;
|
|
|
|
|
}
|
|
|
|
|
m_buffer->at(m_bufferReadPointer);
|
|
|
|
|
ret = m_buffer->readBlock(data, maxlen);
|
|
|
|
|
m_readBuffer->at(m_readBufferReadPointer);
|
|
|
|
|
ret = m_readBuffer->readBlock(data, maxlen);
|
|
|
|
|
if (ret > 0) {
|
|
|
|
|
// Remove the read bytes from the buffer
|
|
|
|
|
m_bufferLength = m_bufferLength-ret;
|
|
|
|
|
m_bufferReadPointer = m_bufferReadPointer+ret;
|
|
|
|
|
if (m_bufferLength < 1) {
|
|
|
|
|
m_readBufferLength = m_readBufferLength-ret;
|
|
|
|
|
m_readBufferReadPointer = m_readBufferReadPointer+ret;
|
|
|
|
|
if (m_readBufferLength < 1) {
|
|
|
|
|
// Clear the buffer from memory
|
|
|
|
|
m_buffer->close();
|
|
|
|
|
m_buffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_bufferReadPointer = 0;
|
|
|
|
|
m_readBuffer->close();
|
|
|
|
|
m_readBuffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_readBufferReadPointer = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -404,7 +404,7 @@ TQ_LONG TDEKerberosClientSocket::readLine(char *data, TQ_ULONG maxlen) {
|
|
|
|
|
if (kerberosStatus() == KerberosInUse) {
|
|
|
|
|
int reclen;
|
|
|
|
|
int wrlen;
|
|
|
|
|
if (m_bufferLength <= 0) {
|
|
|
|
|
if (m_readBufferLength <= 0) {
|
|
|
|
|
char* buf = (char*)malloc(m_negotiatedMaxBufferSize);
|
|
|
|
|
reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize, false);
|
|
|
|
|
if (reclen < 0) {
|
|
|
|
@ -412,30 +412,30 @@ TQ_LONG TDEKerberosClientSocket::readLine(char *data, TQ_ULONG maxlen) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (reclen > 0) {
|
|
|
|
|
m_buffer->at(m_bufferLength+m_bufferReadPointer);
|
|
|
|
|
wrlen = m_buffer->writeBlock(buf, reclen);
|
|
|
|
|
m_readBuffer->at(m_readBufferLength+m_readBufferReadPointer);
|
|
|
|
|
wrlen = m_readBuffer->writeBlock(buf, reclen);
|
|
|
|
|
if (wrlen > 0) {
|
|
|
|
|
m_bufferLength = m_bufferLength + wrlen;
|
|
|
|
|
m_readBufferLength = m_readBufferLength + wrlen;
|
|
|
|
|
emit(newDataReceived());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
free(buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (maxlen > (unsigned int)m_bufferLength) {
|
|
|
|
|
maxlen = m_bufferLength;
|
|
|
|
|
if (maxlen > (unsigned int)m_readBufferLength) {
|
|
|
|
|
maxlen = m_readBufferLength;
|
|
|
|
|
}
|
|
|
|
|
m_buffer->at(m_bufferReadPointer);
|
|
|
|
|
ret = m_buffer->readLine(data, maxlen);
|
|
|
|
|
m_readBuffer->at(m_readBufferReadPointer);
|
|
|
|
|
ret = m_readBuffer->readLine(data, maxlen);
|
|
|
|
|
if (ret > 0) {
|
|
|
|
|
// Remove the read bytes from the buffer
|
|
|
|
|
m_bufferLength = m_bufferLength-ret;
|
|
|
|
|
m_bufferReadPointer = m_bufferReadPointer+ret;
|
|
|
|
|
if (m_bufferLength < 1) {
|
|
|
|
|
m_readBufferLength = m_readBufferLength-ret;
|
|
|
|
|
m_readBufferReadPointer = m_readBufferReadPointer+ret;
|
|
|
|
|
if (m_readBufferLength < 1) {
|
|
|
|
|
// Clear the buffer from memory
|
|
|
|
|
m_buffer->close();
|
|
|
|
|
m_buffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_bufferReadPointer = 0;
|
|
|
|
|
m_readBuffer->close();
|
|
|
|
|
m_readBuffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_readBufferReadPointer = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -456,7 +456,7 @@ TQString TDEKerberosClientSocket::readLine() {
|
|
|
|
|
int readlen;
|
|
|
|
|
char* buf;
|
|
|
|
|
maxlen = m_negotiatedMaxBufferSize;
|
|
|
|
|
if (m_bufferLength <= 0) {
|
|
|
|
|
if (m_readBufferLength <= 0) {
|
|
|
|
|
buf = (char*)malloc(m_negotiatedMaxBufferSize);
|
|
|
|
|
reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize, false);
|
|
|
|
|
if (reclen < 0) {
|
|
|
|
@ -464,31 +464,31 @@ TQString TDEKerberosClientSocket::readLine() {
|
|
|
|
|
return TQString::null;
|
|
|
|
|
}
|
|
|
|
|
if (reclen > 0) {
|
|
|
|
|
m_buffer->at(m_bufferLength+m_bufferReadPointer);
|
|
|
|
|
wrlen = m_buffer->writeBlock(buf, reclen);
|
|
|
|
|
m_readBuffer->at(m_readBufferLength+m_readBufferReadPointer);
|
|
|
|
|
wrlen = m_readBuffer->writeBlock(buf, reclen);
|
|
|
|
|
if (wrlen > 0) {
|
|
|
|
|
m_bufferLength = m_bufferLength + wrlen;
|
|
|
|
|
m_readBufferLength = m_readBufferLength + wrlen;
|
|
|
|
|
emit(newDataReceived());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
free(buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (maxlen > m_bufferLength) {
|
|
|
|
|
maxlen = m_bufferLength;
|
|
|
|
|
if (maxlen > m_readBufferLength) {
|
|
|
|
|
maxlen = m_readBufferLength;
|
|
|
|
|
}
|
|
|
|
|
m_buffer->at(m_bufferReadPointer);
|
|
|
|
|
m_readBuffer->at(m_readBufferReadPointer);
|
|
|
|
|
buf = (char*)malloc(maxlen);
|
|
|
|
|
readlen = m_buffer->readLine(buf, maxlen);
|
|
|
|
|
readlen = m_readBuffer->readLine(buf, maxlen);
|
|
|
|
|
if (readlen > 0) {
|
|
|
|
|
// Remove the read bytes from the buffer
|
|
|
|
|
m_bufferLength = m_bufferLength-readlen;
|
|
|
|
|
m_bufferReadPointer = m_bufferReadPointer+readlen;
|
|
|
|
|
if (m_bufferLength < 1) {
|
|
|
|
|
m_readBufferLength = m_readBufferLength-readlen;
|
|
|
|
|
m_readBufferReadPointer = m_readBufferReadPointer+readlen;
|
|
|
|
|
if (m_readBufferLength < 1) {
|
|
|
|
|
// Clear the buffer from memory
|
|
|
|
|
m_buffer->close();
|
|
|
|
|
m_buffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_bufferReadPointer = 0;
|
|
|
|
|
m_readBuffer->close();
|
|
|
|
|
m_readBuffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_readBufferReadPointer = 0;
|
|
|
|
|
}
|
|
|
|
|
ret = TQString(buf);
|
|
|
|
|
}
|
|
|
|
@ -697,7 +697,7 @@ TDEKerberosClientSocket::KerberosStatus TDEKerberosClientSocket::kerberosStatus(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDEKerberosClientSocket::canReadData() {
|
|
|
|
|
return (TQSocket::canReadLine() || (m_bufferLength > 0));
|
|
|
|
|
return (TQSocket::canReadLine() || (m_readBufferLength > 0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TDEKerberosClientSocket::clearIncomingData() {
|
|
|
|
@ -716,8 +716,8 @@ int TDEKerberosClientSocket::writeEndOfFrame() {
|
|
|
|
|
|
|
|
|
|
bool TDEKerberosClientSocket::canReadFrame() {
|
|
|
|
|
processPendingData();
|
|
|
|
|
if (m_bufferLength > 0) {
|
|
|
|
|
if (m_buffer->buffer().find(255, m_bufferReadPointer) >= 0) {
|
|
|
|
|
if (m_readBufferLength > 0) {
|
|
|
|
|
if (m_readBuffer->buffer().find(255, m_readBufferReadPointer) >= 0) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
@ -731,17 +731,17 @@ bool TDEKerberosClientSocket::canReadFrame() {
|
|
|
|
|
|
|
|
|
|
void TDEKerberosClientSocket::clearFrameTail() {
|
|
|
|
|
int eofLoc;
|
|
|
|
|
if (m_bufferLength > 0) {
|
|
|
|
|
eofLoc = m_buffer->buffer().find(255, m_bufferReadPointer) + 1;
|
|
|
|
|
if ((eofLoc > 0) && (eofLoc <= (m_bufferLength+m_bufferReadPointer))) {
|
|
|
|
|
if (m_readBufferLength > 0) {
|
|
|
|
|
eofLoc = m_readBuffer->buffer().find(255, m_readBufferReadPointer) + 1;
|
|
|
|
|
if ((eofLoc > 0) && (eofLoc <= (m_readBufferLength+m_readBufferReadPointer))) {
|
|
|
|
|
// Remove the remaining frame bytes (including the End of Frame marker) from the buffer
|
|
|
|
|
m_bufferLength = m_bufferLength-(eofLoc-m_bufferReadPointer);
|
|
|
|
|
m_bufferReadPointer = m_bufferReadPointer+(eofLoc-m_bufferReadPointer);
|
|
|
|
|
if (m_bufferLength < 1) {
|
|
|
|
|
m_readBufferLength = m_readBufferLength-(eofLoc-m_readBufferReadPointer);
|
|
|
|
|
m_readBufferReadPointer = m_readBufferReadPointer+(eofLoc-m_readBufferReadPointer);
|
|
|
|
|
if (m_readBufferLength < 1) {
|
|
|
|
|
// Clear the buffer from memory
|
|
|
|
|
m_buffer->close();
|
|
|
|
|
m_buffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_bufferReadPointer = 0;
|
|
|
|
|
m_readBuffer->close();
|
|
|
|
|
m_readBuffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_readBufferReadPointer = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -953,9 +953,9 @@ int TDEKerberosClientSocket::initializeKerberosInterface() {
|
|
|
|
|
++callback;
|
|
|
|
|
|
|
|
|
|
// Clear the buffer from memory
|
|
|
|
|
m_buffer->close();
|
|
|
|
|
m_buffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_bufferReadPointer = 0;
|
|
|
|
|
m_readBuffer->close();
|
|
|
|
|
m_readBuffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_readBufferReadPointer = 0;
|
|
|
|
|
|
|
|
|
|
// Initialize default data structures
|
|
|
|
|
memset(&secprops, 0L, sizeof(secprops));
|
|
|
|
|