summaryrefslogtreecommitdiffstats
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/auth_server_lin/src/auth_conn.cpp46
-rw-r--r--servers/auth_server_lin/src/auth_conn.h4
-rw-r--r--servers/fpga_programming_server_lin/src/fpga_conn.cpp65
-rw-r--r--servers/fpga_programming_server_lin/src/fpga_conn.h4
-rw-r--r--servers/fpga_server_lin/src/fpga_conn.cpp75
-rw-r--r--servers/fpga_server_lin/src/fpga_conn.h4
6 files changed, 113 insertions, 85 deletions
diff --git a/servers/auth_server_lin/src/auth_conn.cpp b/servers/auth_server_lin/src/auth_conn.cpp
index 0f0912b..a8f7459 100644
--- a/servers/auth_server_lin/src/auth_conn.cpp
+++ b/servers/auth_server_lin/src/auth_conn.cpp
@@ -28,11 +28,6 @@
#include "auth_conn.h"
-#define ABORT_SOCKET(s) s->close(); \
- s->disconnect(); \
- delete s; \
- s = NULL;
-
/* exception handling */
struct exit_exception {
int c;
@@ -49,6 +44,10 @@ AuthSocket::AuthSocket(int sock, TQObject *parent, const char *name) :
m_databaseServicesCursor(NULL), m_databaseServiceTypesCursor(NULL), m_databasePermissionsCursor(NULL), m_databaseActivityCursor(NULL)
{
+ // Initialize timers
+ m_kerberosInitTimer = new TQTimer();
+ connect(m_kerberosInitTimer, SIGNAL(timeout()), this, SLOT(finishKerberosHandshake()));
+
setServiceName("remotefpga");
line = 0;
@@ -61,6 +60,11 @@ AuthSocket::AuthSocket(int sock, TQObject *parent, const char *name) :
}
AuthSocket::~AuthSocket() {
+ if (m_kerberosInitTimer) {
+ m_kerberosInitTimer->stop();
+ delete m_kerberosInitTimer;
+ m_kerberosInitTimer = NULL;
+ }
if (m_loopTimer) {
m_loopTimer->stop();
delete m_loopTimer;
@@ -110,11 +114,15 @@ void AuthSocket::connectionClosedHandler() {
}
}
-int AuthSocket::initiateKerberosHandshake() {
+void AuthSocket::initiateKerberosHandshake() {
setUsingKerberos(true);
- while (kerberosStatus() == TDEKerberosServerSocket::KerberosInitializing) {
- // RAJA FIXME
- tqApp->processEvents();
+ m_kerberosInitTimer->start(100, TRUE);
+}
+
+void AuthSocket::finishKerberosHandshake() {
+ if (kerberosStatus() == TDEKerberosServerSocket::KerberosInitializing) {
+ m_kerberosInitTimer->start(100, TRUE);
+ return;
}
if (kerberosStatus() == TDEKerberosServerSocket::KerberosInUse) {
TQ_UINT32 magicnum = MAGIC_NUMBER;
@@ -124,10 +132,13 @@ int AuthSocket::initiateKerberosHandshake() {
ds << magicnum;
ds << protover;
- return 0;
+ enterCommandLoop();
+ return;
}
else {
- return -1;
+ printf("[DEBUG] Connection from %s closed due to Kerberos failure\n\r", m_remoteHost.ascii()); fflush(stdout);
+ close();
+ return;
}
}
@@ -609,14 +620,7 @@ void AuthServer::newConnection(int socket) {
AuthSocket *s = new AuthSocket(socket, this);
s->m_remoteHost = s->peerAddress().toString();
printf("[DEBUG] New connection from %s\n\r", s->m_remoteHost.ascii());
- if (s->initiateKerberosHandshake() != 0) {
- printf("[DEBUG] Connection from %s closed due to Kerberos failure\n\r", s->m_remoteHost.ascii()); fflush(stdout);
- ABORT_SOCKET(s)
- return;
- }
- else {
- connect(s, SIGNAL(connectionClosed()), s, SLOT(deleteLater()));
- emit newConnect(s);
- s->enterCommandLoop();
- }
+ connect(s, SIGNAL(connectionClosed()), s, SLOT(deleteLater()));
+ s->initiateKerberosHandshake();
+ emit newConnect(s);
}
diff --git a/servers/auth_server_lin/src/auth_conn.h b/servers/auth_server_lin/src/auth_conn.h
index ca938f6..277a48a 100644
--- a/servers/auth_server_lin/src/auth_conn.h
+++ b/servers/auth_server_lin/src/auth_conn.h
@@ -51,10 +51,11 @@ class AuthSocket : public TDEKerberosServerSocket
public:
void close();
- int initiateKerberosHandshake();
+ void initiateKerberosHandshake();
int enterCommandLoop();
private slots:
+ void finishKerberosHandshake();
int connectToDatabase();
void connectionClosedHandler();
void commandLoop();
@@ -74,6 +75,7 @@ class AuthSocket : public TDEKerberosServerSocket
TQString m_srvServiceHostName;
int m_srvServicePort;
+ TQTimer* m_kerberosInitTimer;
TQTimer* m_loopTimer;
KSimpleConfig* m_config;
diff --git a/servers/fpga_programming_server_lin/src/fpga_conn.cpp b/servers/fpga_programming_server_lin/src/fpga_conn.cpp
index 08c5d38..2d02964 100644
--- a/servers/fpga_programming_server_lin/src/fpga_conn.cpp
+++ b/servers/fpga_programming_server_lin/src/fpga_conn.cpp
@@ -59,6 +59,10 @@ struct exit_exception {
FPGASocket::FPGASocket(int sock, TQObject *parent, const char *name) :
TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_loopTimer(NULL), m_config(static_cast<FPGAServer*>(parent)->m_config), m_commandLoopState(0) {
+ // Initialize timers
+ m_kerberosInitTimer = new TQTimer();
+ connect(m_kerberosInitTimer, SIGNAL(timeout()), this, SLOT(finishKerberosHandshake()));
+
setServiceName("remotefpga");
line = 0;
@@ -68,6 +72,11 @@ FPGASocket::FPGASocket(int sock, TQObject *parent, const char *name) :
}
FPGASocket::~FPGASocket() {
+ if (m_kerberosInitTimer) {
+ m_kerberosInitTimer->stop();
+ delete m_kerberosInitTimer;
+ m_kerberosInitTimer = NULL;
+ }
if (m_loopTimer) {
m_loopTimer->stop();
delete m_loopTimer;
@@ -91,20 +100,39 @@ void FPGASocket::connectionClosedHandler() {
}
}
-int FPGASocket::initiateKerberosHandshake() {
+void FPGASocket::initiateKerberosHandshake() {
setUsingKerberos(true);
- while (kerberosStatus() == TDEKerberosServerSocket::KerberosInitializing) {
- // RAJA FIXME
- tqApp->processEvents();
+ m_kerberosInitTimer->start(100, TRUE);
+}
+
+void FPGASocket::finishKerberosHandshake() {
+ if (kerberosStatus() == TDEKerberosServerSocket::KerberosInitializing) {
+ m_kerberosInitTimer->start(100, TRUE);
+ return;
}
if (kerberosStatus() == TDEKerberosServerSocket::KerberosInUse) {
+ m_config->setGroup("Security");
+ TQString masterUser = m_config->readEntry("masteruser");
+ TQString masterRealm = m_config->readEntry("masterrealm");
+ if (masterRealm == "") {
+ masterRealm = "(NULL)";
+ }
+ if ((m_authenticatedUserName != masterUser) || (m_authenticatedRealmName != masterRealm)) {
+ printf("[DEBUG] Connection from %s closed due to authentication failure (attempted connection as user %s@%s)\n\r", m_remoteHost.ascii(), masterUser.ascii(), masterRealm.ascii());
+ close();
+ return;
+ }
+
TQDataStream ds(this);
ds << TQString("OK");
- return 0;
+ enterCommandLoop();
+ return;
}
else {
- return -1;
+ printf("[DEBUG] Connection from %s closed due to Kerberos failure\n\r", m_remoteHost.ascii()); fflush(stdout);
+ close();
+ return;
}
}
@@ -173,28 +201,9 @@ void FPGAServer::newConnection(int socket) {
ABORT_SOCKET(s)
return;
}
- if (s->initiateKerberosHandshake() != 0) {
- printf("[DEBUG] Connection from %s closed due to Kerberos failure\n\r", s->m_remoteHost.ascii());
- ABORT_SOCKET(s)
- return;
- }
- m_config->setGroup("Security");
- TQString masterUser = m_config->readEntry("masteruser");
- TQString masterRealm = m_config->readEntry("masterrealm");
- if (masterRealm == "") {
- masterRealm = "(NULL)";
- }
- if ((s->m_authenticatedUserName != masterUser) || (s->m_authenticatedRealmName != masterRealm)) {
- printf("[DEBUG] Connection from %s closed due to authentication failure (attempted connection as user %s@%s)\n\r", s->m_remoteHost.ascii(), masterUser.ascii(), masterRealm.ascii());
- ABORT_SOCKET(s)
- return;
- }
- else {
- m_numberOfConnections++;
- connect(s, SIGNAL(connectionClosed()), s, SLOT(deleteLater()));
- emit newConnect(s);
- s->enterCommandLoop();
- }
+ connect(s, SIGNAL(connectionClosed()), s, SLOT(deleteLater()));
+ s->initiateKerberosHandshake();
+ emit newConnect(s);
}
void FPGAServer::remoteConnectionClosed() {
diff --git a/servers/fpga_programming_server_lin/src/fpga_conn.h b/servers/fpga_programming_server_lin/src/fpga_conn.h
index 69c7c73..c9b109b 100644
--- a/servers/fpga_programming_server_lin/src/fpga_conn.h
+++ b/servers/fpga_programming_server_lin/src/fpga_conn.h
@@ -48,10 +48,11 @@ class FPGASocket : public TDEKerberosServerSocket
public:
void close();
- int initiateKerberosHandshake();
+ void initiateKerberosHandshake();
int enterCommandLoop();
private slots:
+ void finishKerberosHandshake();
void connectionClosedHandler();
void commandLoop();
@@ -60,6 +61,7 @@ class FPGASocket : public TDEKerberosServerSocket
int m_criticalSection;
TQString m_remoteHost;
+ TQTimer* m_kerberosInitTimer;
TQTimer* m_loopTimer;
KSimpleConfig* m_config;
diff --git a/servers/fpga_server_lin/src/fpga_conn.cpp b/servers/fpga_server_lin/src/fpga_conn.cpp
index 15c34c7..1a4bbdb 100644
--- a/servers/fpga_server_lin/src/fpga_conn.cpp
+++ b/servers/fpga_server_lin/src/fpga_conn.cpp
@@ -59,6 +59,10 @@ struct exit_exception {
FPGASocket::FPGASocket(int sock, TQObject *parent, const char *name) :
TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_loopTimer(NULL), m_config(static_cast<FPGAServer*>(parent)->m_config) {
+ // Initialize timers
+ m_kerberosInitTimer = new TQTimer();
+ connect(m_kerberosInitTimer, SIGNAL(timeout()), this, SLOT(finishKerberosHandshake()));
+
setServiceName("remotefpga");
line = 0;
@@ -68,6 +72,11 @@ FPGASocket::FPGASocket(int sock, TQObject *parent, const char *name) :
}
FPGASocket::~FPGASocket() {
+ if (m_kerberosInitTimer) {
+ m_kerberosInitTimer->stop();
+ delete m_kerberosInitTimer;
+ m_kerberosInitTimer = NULL;
+ }
if (m_loopTimer) {
m_loopTimer->stop();
delete m_loopTimer;
@@ -91,20 +100,44 @@ void FPGASocket::connectionClosedHandler() {
}
}
-int FPGASocket::initiateKerberosHandshake() {
+void FPGASocket::initiateKerberosHandshake() {
setUsingKerberos(true);
- while (kerberosStatus() == TDEKerberosServerSocket::KerberosInitializing) {
- // RAJA FIXME
- tqApp->processEvents();
+ m_kerberosInitTimer->start(100, TRUE);
+}
+
+void FPGASocket::finishKerberosHandshake() {
+ if (kerberosStatus() == TDEKerberosServerSocket::KerberosInitializing) {
+ m_kerberosInitTimer->start(100, TRUE);
+ return;
}
if (kerberosStatus() == TDEKerberosServerSocket::KerberosInUse) {
+ m_config->setGroup("Security");
+ TQString masterUser = m_config->readEntry("masteruser");
+ TQString masterRealm = m_config->readEntry("masterrealm");
+ if (masterRealm == "") {
+ masterRealm = "(NULL)";
+ }
+ if ((m_authenticatedUserName != masterUser) || (m_authenticatedRealmName != masterRealm)) {
+ printf("[DEBUG] Connection from %s closed due to authentication failure (attempted connection as user %s@%s)\n\r", m_remoteHost.ascii(), masterUser.ascii(), masterRealm.ascii());
+ close();
+ return;
+ }
+ if (setupSerial() != 0) {
+ printf("[DEBUG] Connection from %s closed due to serial port initialization failure\n\r", m_remoteHost.ascii());
+ close();
+ return;
+ }
+
TQDataStream ds(this);
ds << TQString("OK");
- return 0;
+ enterCommandLoop();
+ return;
}
else {
- return -1;
+ printf("[DEBUG] Connection from %s closed due to Kerberos failure\n\r", m_remoteHost.ascii()); fflush(stdout);
+ close();
+ return;
}
}
@@ -237,33 +270,9 @@ void FPGAServer::newConnection(int socket) {
ABORT_SOCKET(s)
return;
}
- if (s->initiateKerberosHandshake() != 0) {
- printf("[DEBUG] Connection from %s closed due to Kerberos failure\n\r", s->m_remoteHost.ascii());
- ABORT_SOCKET(s)
- return;
- }
- m_config->setGroup("Security");
- TQString masterUser = m_config->readEntry("masteruser");
- TQString masterRealm = m_config->readEntry("masterrealm");
- if (masterRealm == "") {
- masterRealm = "(NULL)";
- }
- if ((s->m_authenticatedUserName != masterUser) || (s->m_authenticatedRealmName != masterRealm)) {
- printf("[DEBUG] Connection from %s closed due to authentication failure (attempted connection as user %s@%s)\n\r", s->m_remoteHost.ascii(), masterUser.ascii(), masterRealm.ascii());
- ABORT_SOCKET(s)
- return;
- }
- if (s->setupSerial() != 0) {
- printf("[DEBUG] Connection from %s closed due to serial port initialization failure\n\r", s->m_remoteHost.ascii());
- ABORT_SOCKET(s)
- return;
- }
- else {
- m_numberOfConnections++;
- connect(s, SIGNAL(connectionClosed()), s, SLOT(deleteLater()));
- emit newConnect(s);
- s->enterCommandLoop();
- }
+ connect(s, SIGNAL(connectionClosed()), s, SLOT(deleteLater()));
+ s->initiateKerberosHandshake();
+ emit newConnect(s);
}
void FPGAServer::remoteConnectionClosed() {
diff --git a/servers/fpga_server_lin/src/fpga_conn.h b/servers/fpga_server_lin/src/fpga_conn.h
index 717a35b..7dcc0f6 100644
--- a/servers/fpga_server_lin/src/fpga_conn.h
+++ b/servers/fpga_server_lin/src/fpga_conn.h
@@ -48,10 +48,11 @@ class FPGASocket : public TDEKerberosServerSocket
public:
void close();
- int initiateKerberosHandshake();
+ void initiateKerberosHandshake();
int enterCommandLoop();
private slots:
+ void finishKerberosHandshake();
void connectionClosedHandler();
int setupSerial();
void commandLoop();
@@ -62,6 +63,7 @@ class FPGASocket : public TDEKerberosServerSocket
TQString m_remoteHost;
int m_fd_tty;
+ TQTimer* m_kerberosInitTimer;
TQTimer* m_loopTimer;
KSimpleConfig* m_config;