|
|
|
@ -100,11 +100,13 @@ static int logSASLMessages(void *context __attribute__((unused)), int priority,
|
|
|
|
|
return SASL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDEKerberosServerSocket::TDEKerberosServerSocket(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) {
|
|
|
|
|
TDEKerberosServerSocket::TDEKerberosServerSocket(TQObject *parent, const char *name) : TQSocket(parent, name), m_kerberosRequested(false), m_criticalSection(0), m_readBufferLength(0), m_readBufferReadPointer(0), m_writeBufferLength(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_readBuffer = new TQBuffer();
|
|
|
|
|
m_readBuffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_writeBuffer = new TQBuffer();
|
|
|
|
|
m_writeBuffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDEKerberosServerSocket::~TDEKerberosServerSocket() {
|
|
|
|
@ -117,7 +119,9 @@ TDEKerberosServerSocket::~TDEKerberosServerSocket() {
|
|
|
|
|
kerberosInitLoopTimer = NULL;
|
|
|
|
|
}
|
|
|
|
|
setUsingKerberos(false);
|
|
|
|
|
m_writeBuffer->close();
|
|
|
|
|
m_readBuffer->close();
|
|
|
|
|
delete m_writeBuffer;
|
|
|
|
|
delete m_readBuffer;
|
|
|
|
|
delete saslData;
|
|
|
|
|
}
|
|
|
|
@ -140,10 +144,11 @@ void TDEKerberosServerSocket::close() {
|
|
|
|
|
setStatusMessage(i18n("Socket closed"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TDEKerberosServerSocket::flush() {
|
|
|
|
|
if (m_kerberosRequested) {
|
|
|
|
|
// FIXME
|
|
|
|
|
// If a write buffer is implemented, it will need to be flushed before the following call is made
|
|
|
|
|
void TDEKerberosServerSocket::flush(int hidebasehack) {
|
|
|
|
|
Q_UNUSED(hidebasehack);
|
|
|
|
|
|
|
|
|
|
if (kerberosStatus() == KerberosInUse) {
|
|
|
|
|
writeBufferedData();
|
|
|
|
|
TQSocket::flush();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
@ -397,8 +402,14 @@ TQ_LONG TDEKerberosServerSocket::readBlock(char *data, TQ_ULONG maxlen) {
|
|
|
|
|
TQ_LONG TDEKerberosServerSocket::writeBlock(const char *data, TQ_ULONG len) {
|
|
|
|
|
TQ_LONG ret;
|
|
|
|
|
|
|
|
|
|
if (m_kerberosRequested) {
|
|
|
|
|
ret = transmitEncryptedData(data, len);
|
|
|
|
|
if (kerberosStatus() == KerberosInUse) {
|
|
|
|
|
int wrlen;
|
|
|
|
|
m_writeBuffer->at(m_writeBufferLength);
|
|
|
|
|
wrlen = m_writeBuffer->writeBlock(data, len);
|
|
|
|
|
if (wrlen > 0) {
|
|
|
|
|
m_writeBufferLength = m_writeBufferLength + wrlen;
|
|
|
|
|
}
|
|
|
|
|
ret = wrlen;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ret = TQSocket::writeBlock(data, len);
|
|
|
|
@ -407,6 +418,20 @@ TQ_LONG TDEKerberosServerSocket::writeBlock(const char *data, TQ_ULONG len) {
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TDEKerberosServerSocket::writeBufferedData() {
|
|
|
|
|
if (kerberosStatus() == KerberosInUse) {
|
|
|
|
|
if (m_writeBufferLength > 0) {
|
|
|
|
|
if (transmitEncryptedData(m_writeBuffer->buffer().data(), m_writeBufferLength) < 0) {
|
|
|
|
|
printf("[WARNING] Attempt to transmit buffered data resulted in a short write\n\r"); fflush(stdout);
|
|
|
|
|
}
|
|
|
|
|
// Clear the buffer from memory
|
|
|
|
|
m_writeBuffer->close();
|
|
|
|
|
m_writeBuffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_writeBufferLength = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQ_LONG TDEKerberosServerSocket::readLine(char *data, TQ_ULONG maxlen) {
|
|
|
|
|
TQ_LONG ret;
|
|
|
|
|
|
|
|
|
@ -718,9 +743,12 @@ void TDEKerberosServerSocket::clearIncomingData() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TDEKerberosServerSocket::writeEndOfFrame() {
|
|
|
|
|
int ret;
|
|
|
|
|
char data[1];
|
|
|
|
|
data[0] = 255;
|
|
|
|
|
return writeBlock(data, 1);
|
|
|
|
|
ret = writeBlock(data, 1);
|
|
|
|
|
writeBufferedData();
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDEKerberosServerSocket::canReadFrame() {
|
|
|
|
@ -976,7 +1004,11 @@ int TDEKerberosServerSocket::initializeKerberosInterface() {
|
|
|
|
|
// Clear the buffer from memory
|
|
|
|
|
m_readBuffer->close();
|
|
|
|
|
m_readBuffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_readBufferLength = 0;
|
|
|
|
|
m_readBufferReadPointer = 0;
|
|
|
|
|
m_writeBuffer->close();
|
|
|
|
|
m_writeBuffer->open(IO_ReadWrite|IO_Truncate);
|
|
|
|
|
m_writeBufferLength = 0;
|
|
|
|
|
|
|
|
|
|
// Initialize default data structures
|
|
|
|
|
memset(&secprops, 0L, sizeof(secprops));
|
|
|
|
|