diff options
| author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-22 19:20:28 -0500 |
|---|---|---|
| committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-22 19:20:28 -0500 |
| commit | fe54812cd70955f47af4010cedcf26e7ff6b592a (patch) | |
| tree | ec58341471422024636cb9987dde565f3321a8de /servers/auth_server_lin/src/auth_conn.cpp | |
| parent | 58cefd2d0172e7c1b51e00472a87df03e52c66c3 (diff) | |
| download | ulab-fe54812cd70955f47af4010cedcf26e7ff6b592a.tar.gz ulab-fe54812cd70955f47af4010cedcf26e7ff6b592a.zip | |
Add server index
Diffstat (limited to 'servers/auth_server_lin/src/auth_conn.cpp')
| -rw-r--r-- | servers/auth_server_lin/src/auth_conn.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/servers/auth_server_lin/src/auth_conn.cpp b/servers/auth_server_lin/src/auth_conn.cpp index e073e12..f3f3474 100644 --- a/servers/auth_server_lin/src/auth_conn.cpp +++ b/servers/auth_server_lin/src/auth_conn.cpp @@ -25,6 +25,7 @@ #include <tqtimer.h> #include <klocale.h> +#include <kcmdlineargs.h> #include "auth_conn.h" @@ -39,8 +40,8 @@ struct exit_exception { For every client that connects to the server, the server creates a new instance of this class. */ -AuthSocket::AuthSocket(int sock, TQObject *parent, const char *name) : - TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_stationID(-1), m_bound(false), m_servActive(false), m_servState(0), m_servClientSocket(NULL), m_servClientTimeout(NULL), m_loopTimer(NULL), m_config(static_cast<AuthServer*>(parent)->m_config), m_database(NULL), m_databaseStationsCursor(NULL), +AuthSocket::AuthSocket(int sock, int serverID, TQObject *parent, const char *name) : + TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_stationID(-1), m_bound(false), m_serverID(serverID), m_servActive(false), m_servState(0), m_servClientSocket(NULL), m_servClientTimeout(NULL), m_loopTimer(NULL), m_config(static_cast<AuthServer*>(parent)->m_config), m_database(NULL), m_databaseStationsCursor(NULL), m_databaseServicesCursor(NULL), m_databaseServiceTypesCursor(NULL), m_databasePermissionsCursor(NULL), m_databaseActivityCursor(NULL) { @@ -445,6 +446,7 @@ void AuthSocket::commandLoop() { buffer->setValue("username", m_authenticatedUserName); buffer->setValue("realmname", m_authenticatedRealmName); buffer->setValue("logontime", TQDateTime::currentDateTime().toTime_t()); + buffer->setValue("serverid", m_serverID); m_databaseActivityCursor->insert(); ds << TQString("OK"); @@ -578,6 +580,20 @@ AuthServer::AuthServer(TQObject* parent) : exit(1); } + m_serverID = 0; + KCmdLineArgs* const args = KCmdLineArgs::parsedArgs(); + if ((args) && (args->count() > 0)) { + m_serverID = TQString(args->arg(0)).toInt(); + } + + // Delete existing activity entries for this server ID + TQSqlCursor databaseActivityCursor("activity", TRUE, m_database); + databaseActivityCursor.select(TQString("serverid='%1'").arg(m_serverID)); + if (databaseActivityCursor.next()) { + databaseActivityCursor.primeDelete(); + databaseActivityCursor.del(true); + } + if ( !ok() ) { printf("[ERROR] Failed to bind to port 4004\n\r"); exit(1); @@ -675,7 +691,7 @@ void AuthServer::pingSQLServer() { } void AuthServer::newConnection(int socket) { - AuthSocket *s = new AuthSocket(socket, this); + AuthSocket *s = new AuthSocket(socket, m_serverID, this); s->m_remoteHost = s->peerAddress().toString(); printf("[DEBUG] New connection from %s\n\r", s->m_remoteHost.ascii()); connect(s, SIGNAL(connectionClosed()), s, SLOT(deleteLater())); |
