diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-06-26 21:52:21 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-06-26 21:52:21 -0500 |
commit | 9c9085621bf01f9b39e15eb856ff521ecb01fccf (patch) | |
tree | 0d912f472a89ffccbcc3bb79ceed6a2b3a350118 /servers/auth_server_lin/src/auth_conn.cpp | |
parent | b2f2dba837c0d28bf73ec36933af901f484633f5 (diff) | |
download | ulab-9c9085621bf01f9b39e15eb856ff521ecb01fccf.tar.gz ulab-9c9085621bf01f9b39e15eb856ff521ecb01fccf.zip |
Fix krb client/server sockets
Diffstat (limited to 'servers/auth_server_lin/src/auth_conn.cpp')
-rw-r--r-- | servers/auth_server_lin/src/auth_conn.cpp | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/servers/auth_server_lin/src/auth_conn.cpp b/servers/auth_server_lin/src/auth_conn.cpp index b71b608..e531099 100644 --- a/servers/auth_server_lin/src/auth_conn.cpp +++ b/servers/auth_server_lin/src/auth_conn.cpp @@ -115,6 +115,8 @@ int AuthSocket::initiateKerberosHandshake() { } int AuthSocket::enterCommandLoop() { + bool bound = false; + m_criticalSection++; try { TQString command; @@ -194,6 +196,8 @@ int AuthSocket::enterCommandLoop() { ds << TQString("ERRUNAVAL"); } else { + bound = true; + // Update database TQSqlRecord *buffer = m_databaseActivityCursor->primeInsert(); buffer->setValue("station", m_stationID); @@ -201,12 +205,66 @@ int AuthSocket::enterCommandLoop() { buffer->setValue("realmname", m_authenticatedRealmName); buffer->setValue("logontime", TQDateTime::currentDateTime().toTime_t()); m_databaseActivityCursor->insert(); - + ds << TQString("OK"); } } + else if (command == "SERV") { + // Get desired Service ID from client + TQ_UINT32 sid; + ds >> sid; + + m_databaseActivityCursor->select(TQString("username='%1' AND realmname='%2'").arg(m_authenticatedUserName).arg(m_authenticatedRealmName)); + if (m_databaseActivityCursor->next()) { + m_stationID = m_databaseActivityCursor->value("station").toInt(); + } + + if (bound == true) { + ds << TQString("ERRINVCMD"); + } + + if (m_stationID < 0) { + ds << TQString("ERRNOCONN"); + } + + // Attempt to connect to the backend server + m_databaseServicesCursor->select(TQString("pk=%1 AND station=%2").arg(sid).arg(m_stationID)); + if (m_databaseServicesCursor->next()) { + TQString serviceHostName = m_databaseServicesCursor->value("hostname").toString(); + int servicePort = m_databaseServicesCursor->value("port").toInt(); + + TDEKerberosClientSocket clientSocket; + clientSocket.setServiceName("remotefpga"); + + clientSocket.setServerFQDN(serviceHostName); + clientSocket.connectToHost(serviceHostName, servicePort); + + while ((clientSocket.state() == TQSocket::Connecting) || (clientSocket.state() == TQSocket::HostLookup)) { + tqApp->processEvents(); + } + if (clientSocket.state() == TQSocket::Connected) { + if (clientSocket.setUsingKerberos(true) != 0) { + clientSocket.close(); + ds << TQString("ERRNOTAVL"); + printf("[DEBUG] Connection failed to %s:%d for user %s@%s due to Kerberos failure\n\r", serviceHostName.ascii(), servicePort, m_authenticatedUserName.ascii(), m_authenticatedRealmName.ascii()); fflush(stdout); + } + else { + printf("[RAJA DEBUG 600.0] Connect OK!\n\r"); fflush(stdout); + // RAJA FIXME + } + } + else { + clientSocket.close(); + ds << TQString("ERRNOTAVL"); + printf("[DEBUG] Connection failed to %s:%d for user %s@%s\n\r", serviceHostName.ascii(), servicePort, m_authenticatedUserName.ascii(), m_authenticatedRealmName.ascii()); fflush(stdout); + } + } + else { + ds << TQString("ERRNOTAVL"); + } + } else { - ds << "ERRINVCMD"; + ds << TQString("ERRINVCMD"); } } tqApp->processEvents(); |