diff options
-rw-r--r-- | lib/libtdekrb/src/tdekrbclientsocket.cpp | 121 | ||||
-rw-r--r-- | lib/libtdekrb/src/tdekrbclientsocket.h | 3 | ||||
-rw-r--r-- | lib/libtdekrb/src/tdekrbserversocket.cpp | 121 | ||||
-rw-r--r-- | lib/libtdekrb/src/tdekrbserversocket.h | 3 | ||||
-rw-r--r-- | servers/auth_server_lin/src/auth_conn.cpp | 8 | ||||
-rw-r--r-- | servers/fpga_server_lin/src/fpga_conn.cpp | 2 |
6 files changed, 181 insertions, 77 deletions
diff --git a/lib/libtdekrb/src/tdekrbclientsocket.cpp b/lib/libtdekrb/src/tdekrbclientsocket.cpp index 7e39fcf..6ba35e5 100644 --- a/lib/libtdekrb/src/tdekrbclientsocket.cpp +++ b/lib/libtdekrb/src/tdekrbclientsocket.cpp @@ -204,6 +204,44 @@ bool TDEKerberosClientSocket::atEnd() const { return ret; } +TQ_ULONG TDEKerberosClientSocket::bytesAvailable() const { + bool ret; + + if (kerberosStatus() == KerberosInUse) { + ret = m_bufferLength; + } + else { + ret = TQSocket::bytesAvailable(); + } + + return ret; +} + +int TDEKerberosClientSocket::processPendingData() { + if (kerberosStatus() == KerberosInUse) { + int reclen; + int wrlen; + if (m_bufferLength <= 0) { + char* buf = (char*)malloc(m_negotiatedMaxBufferSize); + reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); + if (reclen < 0) { + free(buf); + return -1; + } + if (reclen > 0) { + m_buffer->at(m_bufferLength); + wrlen = m_buffer->writeBlock(buf, reclen); + if (wrlen > 0) { + m_bufferLength = m_bufferLength + wrlen; + } + } + free(buf); + } + } + + return 0; +} + int TDEKerberosClientSocket::setUsingKerberos(bool krbactive) { int ret = 0; @@ -243,20 +281,22 @@ TQ_LONG TDEKerberosClientSocket::readBlock(char *data, TQ_ULONG maxlen) { if (kerberosStatus() == KerberosInUse) { int reclen; int wrlen; - char* buf = (char*)malloc(m_negotiatedMaxBufferSize); - reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); - if (reclen < 0) { - free(buf); - return -1; - } - if (reclen > 0) { - m_buffer->at(m_bufferLength); - wrlen = m_buffer->writeBlock(buf, reclen); - if (wrlen > 0) { - m_bufferLength = m_bufferLength + wrlen; + if (m_bufferLength <= 0) { + char* buf = (char*)malloc(m_negotiatedMaxBufferSize); + reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); + if (reclen < 0) { + free(buf); + return -1; + } + if (reclen > 0) { + m_buffer->at(m_bufferLength); + wrlen = m_buffer->writeBlock(buf, reclen); + if (wrlen > 0) { + m_bufferLength = m_bufferLength + wrlen; + } } + free(buf); } - free(buf); if (maxlen > (unsigned int)m_bufferLength) { maxlen = m_bufferLength; @@ -304,20 +344,22 @@ TQ_LONG TDEKerberosClientSocket::readLine(char *data, TQ_ULONG maxlen) { if (kerberosStatus() == KerberosInUse) { int reclen; int wrlen; - char* buf = (char*)malloc(m_negotiatedMaxBufferSize); - reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); - if (reclen < 0) { - free(buf); - return -1; - } - if (reclen > 0) { - m_buffer->at(m_bufferLength); - wrlen = m_buffer->writeBlock(buf, reclen); - if (wrlen > 0) { - m_bufferLength = m_bufferLength + wrlen; + if (m_bufferLength <= 0) { + char* buf = (char*)malloc(m_negotiatedMaxBufferSize); + reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); + if (reclen < 0) { + free(buf); + return -1; } + if (reclen > 0) { + m_buffer->at(m_bufferLength); + wrlen = m_buffer->writeBlock(buf, reclen); + if (wrlen > 0) { + m_bufferLength = m_bufferLength + wrlen; + } + } + free(buf); } - free(buf); if (maxlen > (unsigned int)m_bufferLength) { maxlen = m_bufferLength; @@ -354,21 +396,24 @@ TQString TDEKerberosClientSocket::readLine() { int reclen; int wrlen; int readlen; + char* buf; maxlen = m_negotiatedMaxBufferSize; - char* buf = (char*)malloc(m_negotiatedMaxBufferSize); - reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); - if (reclen < 0) { - free(buf); - return TQString::null; - } - if (reclen > 0) { - m_buffer->at(m_bufferLength); - wrlen = m_buffer->writeBlock(buf, reclen); - if (wrlen > 0) { - m_bufferLength = m_bufferLength + wrlen; + if (m_bufferLength <= 0) { + buf = (char*)malloc(m_negotiatedMaxBufferSize); + reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); + if (reclen < 0) { + free(buf); + return TQString::null; } + if (reclen > 0) { + m_buffer->at(m_bufferLength); + wrlen = m_buffer->writeBlock(buf, reclen); + if (wrlen > 0) { + m_bufferLength = m_bufferLength + wrlen; + } + } + free(buf); } - free(buf); if (maxlen > m_bufferLength) { maxlen = m_bufferLength; @@ -596,6 +641,10 @@ TDEKerberosClientSocket::KerberosStatus TDEKerberosClientSocket::kerberosStatus( return KerberosInUse; } +bool TDEKerberosClientSocket::canReadData() { + return TQSocket::canReadLine(); +} + void TDEKerberosClientSocket::setStatusMessage(TQString message) { if (message != m_prevStatusMessage) { emit(statusMessageUpdated(message)); diff --git a/lib/libtdekrb/src/tdekrbclientsocket.h b/lib/libtdekrb/src/tdekrbclientsocket.h index 8f4a287..f058220 100644 --- a/lib/libtdekrb/src/tdekrbclientsocket.h +++ b/lib/libtdekrb/src/tdekrbclientsocket.h @@ -57,6 +57,7 @@ class TDEKerberosClientSocket : public TQSocket TQ_LONG readLine(char *data, TQ_ULONG maxlen); TQString readLine(); void writeLine(TQString); + TQ_ULONG bytesAvailable() const; int setUsingKerberos(bool krbactive); void setServiceName(TQString name); @@ -65,6 +66,8 @@ class TDEKerberosClientSocket : public TQSocket void setDataTimeout(int timeoutms); KerberosStatus kerberosStatus() const; + bool canReadData(); + int processPendingData(); private: int initializeKerberosInterface(); diff --git a/lib/libtdekrb/src/tdekrbserversocket.cpp b/lib/libtdekrb/src/tdekrbserversocket.cpp index 4840c16..3134738 100644 --- a/lib/libtdekrb/src/tdekrbserversocket.cpp +++ b/lib/libtdekrb/src/tdekrbserversocket.cpp @@ -204,6 +204,44 @@ bool TDEKerberosServerSocket::atEnd() const { return ret; } +TQ_ULONG TDEKerberosServerSocket::bytesAvailable() const { + bool ret; + + if (kerberosStatus() == KerberosInUse) { + ret = m_bufferLength; + } + else { + ret = TQSocket::bytesAvailable(); + } + + return ret; +} + +int TDEKerberosServerSocket::processPendingData() { + if (kerberosStatus() == KerberosInUse) { + int reclen; + int wrlen; + if (m_bufferLength <= 0) { + char* buf = (char*)malloc(m_negotiatedMaxBufferSize); + reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); + if (reclen < 0) { + free(buf); + return -1; + } + if (reclen > 0) { + m_buffer->at(m_bufferLength); + wrlen = m_buffer->writeBlock(buf, reclen); + if (wrlen > 0) { + m_bufferLength = m_bufferLength + wrlen; + } + } + free(buf); + } + } + + return 0; +} + int TDEKerberosServerSocket::setUsingKerberos(bool krbactive) { int ret = 0; @@ -243,20 +281,22 @@ TQ_LONG TDEKerberosServerSocket::readBlock(char *data, TQ_ULONG maxlen) { if (m_kerberosRequested) { int reclen; int wrlen; - char* buf = (char*)malloc(m_negotiatedMaxBufferSize); - reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); - if (reclen < 0) { - free(buf); - return -1; - } - if (reclen > 0) { - m_buffer->at(m_bufferLength); - wrlen = m_buffer->writeBlock(buf, reclen); - if (wrlen > 0) { - m_bufferLength = m_bufferLength + wrlen; + if (m_bufferLength <= 0) { + char* buf = (char*)malloc(m_negotiatedMaxBufferSize); + reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); + if (reclen < 0) { + free(buf); + return -1; } + if (reclen > 0) { + m_buffer->at(m_bufferLength); + wrlen = m_buffer->writeBlock(buf, reclen); + if (wrlen > 0) { + m_bufferLength = m_bufferLength + wrlen; + } + } + free(buf); } - free(buf); if (maxlen > (unsigned int)m_bufferLength) { maxlen = m_bufferLength; @@ -304,20 +344,22 @@ TQ_LONG TDEKerberosServerSocket::readLine(char *data, TQ_ULONG maxlen) { if (m_kerberosRequested) { int reclen; int wrlen; - char* buf = (char*)malloc(m_negotiatedMaxBufferSize); - reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); - if (reclen < 0) { - free(buf); - return -1; - } - if (reclen > 0) { - m_buffer->at(m_bufferLength); - wrlen = m_buffer->writeBlock(buf, reclen); - if (wrlen > 0) { - m_bufferLength = m_bufferLength + wrlen; + if (m_bufferLength <= 0) { + char* buf = (char*)malloc(m_negotiatedMaxBufferSize); + reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); + if (reclen < 0) { + free(buf); + return -1; } + if (reclen > 0) { + m_buffer->at(m_bufferLength); + wrlen = m_buffer->writeBlock(buf, reclen); + if (wrlen > 0) { + m_bufferLength = m_bufferLength + wrlen; + } + } + free(buf); } - free(buf); if (maxlen > (unsigned int)m_bufferLength) { maxlen = m_bufferLength; @@ -354,21 +396,24 @@ TQString TDEKerberosServerSocket::readLine() { int reclen; int wrlen; int readlen; + char* buf; maxlen = m_negotiatedMaxBufferSize; - char* buf = (char*)malloc(m_negotiatedMaxBufferSize); - reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); - if (reclen < 0) { - free(buf); - return TQString::null; - } - if (reclen > 0) { - m_buffer->at(m_bufferLength); - wrlen = m_buffer->writeBlock(buf, reclen); - if (wrlen > 0) { - m_bufferLength = m_bufferLength + wrlen; + if (m_bufferLength <= 0) { + buf = (char*)malloc(m_negotiatedMaxBufferSize); + reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); + if (reclen < 0) { + free(buf); + return TQString::null; } + if (reclen > 0) { + m_buffer->at(m_bufferLength); + wrlen = m_buffer->writeBlock(buf, reclen); + if (wrlen > 0) { + m_bufferLength = m_bufferLength + wrlen; + } + } + free(buf); } - free(buf); if (maxlen > m_bufferLength) { maxlen = m_bufferLength; @@ -596,6 +641,10 @@ TDEKerberosServerSocket::KerberosStatus TDEKerberosServerSocket::kerberosStatus( return KerberosInUse; } +bool TDEKerberosServerSocket::canReadData() { + return TQSocket::canReadLine(); +} + void TDEKerberosServerSocket::setStatusMessage(TQString message) { if (message != m_prevStatusMessage) { emit(statusMessageUpdated(message)); diff --git a/lib/libtdekrb/src/tdekrbserversocket.h b/lib/libtdekrb/src/tdekrbserversocket.h index 4a315ca..6276358 100644 --- a/lib/libtdekrb/src/tdekrbserversocket.h +++ b/lib/libtdekrb/src/tdekrbserversocket.h @@ -57,6 +57,7 @@ class TDEKerberosServerSocket : public TQSocket TQ_LONG readLine(char *data, TQ_ULONG maxlen); TQString readLine(); void writeLine(TQString); + TQ_ULONG bytesAvailable() const; int setUsingKerberos(bool krbactive); void setServiceName(TQString name); @@ -65,6 +66,8 @@ class TDEKerberosServerSocket : public TQSocket void setDataTimeout(int timeoutms); KerberosStatus kerberosStatus() const; + bool canReadData(); + int processPendingData(); private: int initializeKerberosInterface(); diff --git a/servers/auth_server_lin/src/auth_conn.cpp b/servers/auth_server_lin/src/auth_conn.cpp index 65c131f..177a0e3 100644 --- a/servers/auth_server_lin/src/auth_conn.cpp +++ b/servers/auth_server_lin/src/auth_conn.cpp @@ -193,7 +193,7 @@ void AuthSocket::servLoop() { m_servClientTimeout->start(5000, TRUE); } if (m_servClientSocket->state() == TQSocket::Connected) { - if (m_servClientSocket->canReadLine()) { + if (m_servClientSocket->canReadData()) { TQDataStream clientDS(m_servClientSocket); TQString server_reply; @@ -237,11 +237,11 @@ void AuthSocket::servLoop() { TQByteArray ba(8192); TQ_ULONG reclen; - if (canReadLine()) { + if (canReadData()) { reclen = readBlock(ba.data(), 8192); m_servClientSocket->writeBlock(ba.data(), reclen); } - if (m_servClientSocket->canReadLine()) { + if (m_servClientSocket->canReadData()) { reclen = m_servClientSocket->readBlock(ba.data(), 8192); writeBlock(ba.data(), reclen); } @@ -267,7 +267,7 @@ void AuthSocket::commandLoop() { m_criticalSection++; try { if (state() == TQSocket::Connected) { - if (canReadLine()) { + if (canReadData()) { TQString command; TQDataStream ds(this); diff --git a/servers/fpga_server_lin/src/fpga_conn.cpp b/servers/fpga_server_lin/src/fpga_conn.cpp index b1b0451..f0ab39d 100644 --- a/servers/fpga_server_lin/src/fpga_conn.cpp +++ b/servers/fpga_server_lin/src/fpga_conn.cpp @@ -166,7 +166,7 @@ void FPGASocket::commandLoop() { writeBlock(buffer, cc); printf("[DEBUG] Got %d bytes from the serial port\n\r", cc); fflush(stdout); } - if (canReadLine()) { + if (canReadData()) { cc = readBlock(buffer, 10000); if (cc > 0) { if (write(m_fd_tty, buffer, cc) < 0) { |