Get rid of processevents calls in servers

master
Timothy Pearson 13 years ago
parent 1382b1f0c8
commit 8cc7778d9f

@ -338,8 +338,10 @@ void TDEKerberosServerSocket::setServiceName(TQString name) {
tde_krb_sasl_server_appname = name; tde_krb_sasl_server_appname = name;
} }
else { else {
if (tde_krb_sasl_server_appname != name) {
printf("[WARNING] Attempt was made to change application name after initial Kerberos connection was tried. Application name was NOT changed!\n\r"); fflush(stdout); printf("[WARNING] Attempt was made to change application name after initial Kerberos connection was tried. Application name was NOT changed!\n\r"); fflush(stdout);
} }
}
} }
void TDEKerberosServerSocket::setServerFQDN(TQString name) { void TDEKerberosServerSocket::setServerFQDN(TQString name) {

@ -28,11 +28,6 @@
#include "auth_conn.h" #include "auth_conn.h"
#define ABORT_SOCKET(s) s->close(); \
s->disconnect(); \
delete s; \
s = NULL;
/* exception handling */ /* exception handling */
struct exit_exception { struct exit_exception {
int c; 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) 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"); setServiceName("remotefpga");
line = 0; line = 0;
@ -61,6 +60,11 @@ AuthSocket::AuthSocket(int sock, TQObject *parent, const char *name) :
} }
AuthSocket::~AuthSocket() { AuthSocket::~AuthSocket() {
if (m_kerberosInitTimer) {
m_kerberosInitTimer->stop();
delete m_kerberosInitTimer;
m_kerberosInitTimer = NULL;
}
if (m_loopTimer) { if (m_loopTimer) {
m_loopTimer->stop(); m_loopTimer->stop();
delete m_loopTimer; delete m_loopTimer;
@ -110,11 +114,15 @@ void AuthSocket::connectionClosedHandler() {
} }
} }
int AuthSocket::initiateKerberosHandshake() { void AuthSocket::initiateKerberosHandshake() {
setUsingKerberos(true); setUsingKerberos(true);
while (kerberosStatus() == TDEKerberosServerSocket::KerberosInitializing) { m_kerberosInitTimer->start(100, TRUE);
// RAJA FIXME }
tqApp->processEvents();
void AuthSocket::finishKerberosHandshake() {
if (kerberosStatus() == TDEKerberosServerSocket::KerberosInitializing) {
m_kerberosInitTimer->start(100, TRUE);
return;
} }
if (kerberosStatus() == TDEKerberosServerSocket::KerberosInUse) { if (kerberosStatus() == TDEKerberosServerSocket::KerberosInUse) {
TQ_UINT32 magicnum = MAGIC_NUMBER; TQ_UINT32 magicnum = MAGIC_NUMBER;
@ -124,10 +132,13 @@ int AuthSocket::initiateKerberosHandshake() {
ds << magicnum; ds << magicnum;
ds << protover; ds << protover;
return 0; enterCommandLoop();
return;
} }
else { 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); AuthSocket *s = new AuthSocket(socket, this);
s->m_remoteHost = s->peerAddress().toString(); s->m_remoteHost = s->peerAddress().toString();
printf("[DEBUG] New connection from %s\n\r", s->m_remoteHost.ascii()); 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())); connect(s, SIGNAL(connectionClosed()), s, SLOT(deleteLater()));
s->initiateKerberosHandshake();
emit newConnect(s); emit newConnect(s);
s->enterCommandLoop();
}
} }

@ -51,10 +51,11 @@ class AuthSocket : public TDEKerberosServerSocket
public: public:
void close(); void close();
int initiateKerberosHandshake(); void initiateKerberosHandshake();
int enterCommandLoop(); int enterCommandLoop();
private slots: private slots:
void finishKerberosHandshake();
int connectToDatabase(); int connectToDatabase();
void connectionClosedHandler(); void connectionClosedHandler();
void commandLoop(); void commandLoop();
@ -74,6 +75,7 @@ class AuthSocket : public TDEKerberosServerSocket
TQString m_srvServiceHostName; TQString m_srvServiceHostName;
int m_srvServicePort; int m_srvServicePort;
TQTimer* m_kerberosInitTimer;
TQTimer* m_loopTimer; TQTimer* m_loopTimer;
KSimpleConfig* m_config; KSimpleConfig* m_config;

@ -59,6 +59,10 @@ struct exit_exception {
FPGASocket::FPGASocket(int sock, TQObject *parent, const char *name) : 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) { 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"); setServiceName("remotefpga");
line = 0; line = 0;
@ -68,6 +72,11 @@ FPGASocket::FPGASocket(int sock, TQObject *parent, const char *name) :
} }
FPGASocket::~FPGASocket() { FPGASocket::~FPGASocket() {
if (m_kerberosInitTimer) {
m_kerberosInitTimer->stop();
delete m_kerberosInitTimer;
m_kerberosInitTimer = NULL;
}
if (m_loopTimer) { if (m_loopTimer) {
m_loopTimer->stop(); m_loopTimer->stop();
delete m_loopTimer; delete m_loopTimer;
@ -91,20 +100,39 @@ void FPGASocket::connectionClosedHandler() {
} }
} }
int FPGASocket::initiateKerberosHandshake() { void FPGASocket::initiateKerberosHandshake() {
setUsingKerberos(true); setUsingKerberos(true);
while (kerberosStatus() == TDEKerberosServerSocket::KerberosInitializing) { m_kerberosInitTimer->start(100, TRUE);
// RAJA FIXME }
tqApp->processEvents();
void FPGASocket::finishKerberosHandshake() {
if (kerberosStatus() == TDEKerberosServerSocket::KerberosInitializing) {
m_kerberosInitTimer->start(100, TRUE);
return;
} }
if (kerberosStatus() == TDEKerberosServerSocket::KerberosInUse) { 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); TQDataStream ds(this);
ds << TQString("OK"); ds << TQString("OK");
return 0; enterCommandLoop();
return;
} }
else { 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) ABORT_SOCKET(s)
return; 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())); connect(s, SIGNAL(connectionClosed()), s, SLOT(deleteLater()));
s->initiateKerberosHandshake();
emit newConnect(s); emit newConnect(s);
s->enterCommandLoop();
}
} }
void FPGAServer::remoteConnectionClosed() { void FPGAServer::remoteConnectionClosed() {

@ -48,10 +48,11 @@ class FPGASocket : public TDEKerberosServerSocket
public: public:
void close(); void close();
int initiateKerberosHandshake(); void initiateKerberosHandshake();
int enterCommandLoop(); int enterCommandLoop();
private slots: private slots:
void finishKerberosHandshake();
void connectionClosedHandler(); void connectionClosedHandler();
void commandLoop(); void commandLoop();
@ -60,6 +61,7 @@ class FPGASocket : public TDEKerberosServerSocket
int m_criticalSection; int m_criticalSection;
TQString m_remoteHost; TQString m_remoteHost;
TQTimer* m_kerberosInitTimer;
TQTimer* m_loopTimer; TQTimer* m_loopTimer;
KSimpleConfig* m_config; KSimpleConfig* m_config;

@ -59,6 +59,10 @@ struct exit_exception {
FPGASocket::FPGASocket(int sock, TQObject *parent, const char *name) : 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) { 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"); setServiceName("remotefpga");
line = 0; line = 0;
@ -68,6 +72,11 @@ FPGASocket::FPGASocket(int sock, TQObject *parent, const char *name) :
} }
FPGASocket::~FPGASocket() { FPGASocket::~FPGASocket() {
if (m_kerberosInitTimer) {
m_kerberosInitTimer->stop();
delete m_kerberosInitTimer;
m_kerberosInitTimer = NULL;
}
if (m_loopTimer) { if (m_loopTimer) {
m_loopTimer->stop(); m_loopTimer->stop();
delete m_loopTimer; delete m_loopTimer;
@ -91,20 +100,44 @@ void FPGASocket::connectionClosedHandler() {
} }
} }
int FPGASocket::initiateKerberosHandshake() { void FPGASocket::initiateKerberosHandshake() {
setUsingKerberos(true); setUsingKerberos(true);
while (kerberosStatus() == TDEKerberosServerSocket::KerberosInitializing) { m_kerberosInitTimer->start(100, TRUE);
// RAJA FIXME }
tqApp->processEvents();
void FPGASocket::finishKerberosHandshake() {
if (kerberosStatus() == TDEKerberosServerSocket::KerberosInitializing) {
m_kerberosInitTimer->start(100, TRUE);
return;
} }
if (kerberosStatus() == TDEKerberosServerSocket::KerberosInUse) { 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); TQDataStream ds(this);
ds << TQString("OK"); ds << TQString("OK");
return 0; enterCommandLoop();
return;
} }
else { 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) ABORT_SOCKET(s)
return; 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())); connect(s, SIGNAL(connectionClosed()), s, SLOT(deleteLater()));
s->initiateKerberosHandshake();
emit newConnect(s); emit newConnect(s);
s->enterCommandLoop();
}
} }
void FPGAServer::remoteConnectionClosed() { void FPGAServer::remoteConnectionClosed() {

@ -48,10 +48,11 @@ class FPGASocket : public TDEKerberosServerSocket
public: public:
void close(); void close();
int initiateKerberosHandshake(); void initiateKerberosHandshake();
int enterCommandLoop(); int enterCommandLoop();
private slots: private slots:
void finishKerberosHandshake();
void connectionClosedHandler(); void connectionClosedHandler();
int setupSerial(); int setupSerial();
void commandLoop(); void commandLoop();
@ -62,6 +63,7 @@ class FPGASocket : public TDEKerberosServerSocket
TQString m_remoteHost; TQString m_remoteHost;
int m_fd_tty; int m_fd_tty;
TQTimer* m_kerberosInitTimer;
TQTimer* m_loopTimer; TQTimer* m_loopTimer;
KSimpleConfig* m_config; KSimpleConfig* m_config;

Loading…
Cancel
Save