Get rid of processevents calls in servers

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

@ -338,7 +338,9 @@ void TDEKerberosServerSocket::setServiceName(TQString name) {
tde_krb_sasl_server_appname = name;
}
else {
printf("[WARNING] Attempt was made to change application name after initial Kerberos connection was tried. Application name was NOT changed!\n\r"); fflush(stdout);
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);
}
}
}

@ -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);
}

@ -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;

@ -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() {

@ -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;

@ -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() {

@ -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;

Loading…
Cancel
Save