if(!m_socket)return-1;// Any entry into the event loop could end up deleting the socket object depending on user interaction
}
if(m_socket->state()!=TQSocket::Connected){
return-1;
}
if(m_socket->setUsingKerberos(true)!=0){
if(!m_socket)return-1;// Any entry into the event loop could end up deleting the socket object depending on user interaction
m_socket->close();
KMessageBox::error(0,i18n("<qt>Unable to establish Kerberos protocol with remote server<p>Please verify that you currently hold a valid Kerberos ticket</qt>"),i18n("Connection Failed"));
printf("[DEBUG] Connection failed to %s:%d for user %s@%s\n\r",m_srvServiceHostName.ascii(),m_srvServicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii());fflush(stdout);
printf("[DEBUG] Connection failed to %s:%d for user %s@%s due to Kerberos failure\n\r",m_srvServiceHostName.ascii(),m_srvServicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii());fflush(stdout);
m_servActive=false;
deletem_servClientTimeout;
m_servClientTimeout=NULL;
}
m_servState=2;
}
else{
m_servClientSocket->close();
ds<<TQString("ERRNOTAVL");
printf("[DEBUG] Connection failed to %s:%d for user %s@%s\n\r",m_srvServiceHostName.ascii(),m_srvServicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii());fflush(stdout);
printf("[DEBUG] Connection failed to %s:%d for user %s@%s due to remote server returning %s\n\r",m_srvServiceHostName.ascii(),m_srvServicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii(),server_reply.ascii());fflush(stdout);
m_servActive=false;
deletem_servClientTimeout;
m_servClientTimeout=NULL;
}
}
else{
if(!m_servClientTimeout->isActive()){
// Timeout!
m_servClientSocket->close();
ds<<TQString("ERRNOTAVL");
printf("[DEBUG] Connection failed to %s:%d for user %s@%s\n\r",m_srvServiceHostName.ascii(),m_srvServicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii());fflush(stdout);
m_servActive=false;
deletem_servClientTimeout;
m_servClientTimeout=NULL;
}
}
}
else{
m_servClientSocket->close();
ds<<TQString("ERRNOTAVL");
printf("[DEBUG] Connection failed to %s:%d for user %s@%s\n\r",m_srvServiceHostName.ascii(),m_srvServicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii());fflush(stdout);
printf("[DEBUG] Connection terminated by remote host %s:%d for user %s@%s\n\r",m_srvServiceHostName.ascii(),m_srvServicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii());fflush(stdout);
m_servActive=false;
}
break;
}
}
}
voidAuthSocket::commandLoop(){
if(m_servActive){
servLoop();
TQTimer::singleShot(0,this,SLOT(commandLoop()));
return;
}
m_criticalSection++;
try{
if(state()==TQSocket::Connected){
if(canReadLine()){
TQStringcommand;
TQDataStreamds(this);
while(state()==TQSocket::Connected){
ds>>command;
if(command!=""){
printf("[DEBUG] Got command %s from user %s@%s\n\r",command.ascii(),m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii());fflush(stdout);
@ -259,74 +386,17 @@ int AuthSocket::enterCommandLoop() {
// Attempt to connect to the backend server
m_databaseServicesCursor->select(TQString("pk=%1 AND station=%2").arg(sid).arg(m_stationID));
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);
printf("[DEBUG] Connection failed to %s:%d for user %s@%s due to remote server returning %s\n\r",serviceHostName.ascii(),servicePort,m_authenticatedUserName.ascii(),m_authenticatedRealmName.ascii(),server_reply.ascii());fflush(stdout);
}
}
}
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);
}
m_servState=0;
m_servActive=true;
}
else{
ds<<TQString("ERRNOSERV");
@ -339,18 +409,24 @@ int AuthSocket::enterCommandLoop() {