First commit towards replacing pCon-> with someFunc(pCon)
This is accompanied with the removal of dead code in conman.c and else
This commit is contained in:
120
telnet.c
120
telnet.c
@ -99,113 +99,6 @@ static void SendGA(SConnection * pCon)
|
||||
NETWrite(pCon->pSock, pReply, 2);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int TelnetTaskOld(void *pData)
|
||||
{
|
||||
pTelTask self = NULL;
|
||||
char *pPtr = NULL;
|
||||
char *pLogin = NULL;
|
||||
char *pUser = NULL, *pPasswd = NULL;
|
||||
char pBuffer[512], pHost[131];
|
||||
int iRet;
|
||||
time_t shit;
|
||||
|
||||
self = (pTelTask) pData;
|
||||
assert(self);
|
||||
|
||||
if (self->pCon->iEnd) {
|
||||
if (SCActive(self->pCon)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* pop and execute */
|
||||
iRet = CostaPop(self->pCon->pStack, &pPtr);
|
||||
if (iRet) {
|
||||
if (pPtr) {
|
||||
if (self->iLogin) { /* handle normal command */
|
||||
/* check for logoff */
|
||||
if (strstr(pPtr, "logoff") != NULL) {
|
||||
NetReadRemove(pServ->pReader, self->pCon->pSock);
|
||||
free(pPtr);
|
||||
self->pCon->iEnd = 1;
|
||||
return 0;
|
||||
}
|
||||
/* invoke command */
|
||||
CostaLock(self->pCon->pStack);
|
||||
SCInvoke(self->pCon, pServ->pSics, pPtr);
|
||||
CostaUnlock(self->pCon->pStack);
|
||||
SendGA(self->pCon);
|
||||
free(pPtr);
|
||||
} else { /* handle login messages */
|
||||
|
||||
pLogin = strstr(pPtr, self->pLoginWord);
|
||||
if (!pLogin) {
|
||||
SCWrite(self->pCon,
|
||||
"------------------- Get Lost -------------------",
|
||||
eError);
|
||||
if (time(&shit) > self->tStart + LOGINWAIT) {
|
||||
SCWrite(self->pCon,
|
||||
"I cannot stand your login attempts anymore!", eError);
|
||||
NetReadRemove(pServ->pReader, self->pCon->pSock);
|
||||
self->pCon->iEnd = 1;
|
||||
free(pPtr);
|
||||
return 0;
|
||||
}
|
||||
free(pPtr);
|
||||
return 1;
|
||||
} else { /* check username / password */
|
||||
|
||||
pLogin += strlen(self->pLoginWord);
|
||||
pUser = strtok(pLogin, " \t");
|
||||
pPasswd = strtok(NULL, " \t\r\n");
|
||||
iRet = IsValidUser(pUser, pPasswd);
|
||||
if (iRet < 0) {
|
||||
snprintf(pBuffer,sizeof(pBuffer)-1, "SYSTEM ATTACK by %s / %s", pUser, pPasswd);
|
||||
Log(FATAL,"sys","%s",pBuffer);
|
||||
SCWrite(self->pCon,
|
||||
"I do not know you, I do not let you in", eError);
|
||||
SendGA(self->pCon);
|
||||
free(pPtr);
|
||||
return 1;
|
||||
} else {
|
||||
NETInfo(self->pCon->pSock, pHost, 131);
|
||||
snprintf(pBuffer,sizeof(pBuffer)-1, "Accepted connection on socket %d from %s",
|
||||
self->pCon->pSock->sockid, pHost);
|
||||
Log(INFO,"com",pBuffer);
|
||||
SendWelcome(self->pCon);
|
||||
SCSetRights(self->pCon, iRet);
|
||||
self->iLogin = 1;
|
||||
SendGA(self->pCon);
|
||||
free(pPtr);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* check for no commands but timeout on telnet */
|
||||
if (!self->iLogin && (time(&shit) > self->tStart + LOGINWAIT)) {
|
||||
self->pCon->iEnd = 1;
|
||||
NetReadRemove(pServ->pReader, self->pCon->pSock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* check for end */
|
||||
if (self->pCon->iEnd) {
|
||||
if (SCActive(self->pCon)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int TelnetTask(void *pData)
|
||||
{
|
||||
@ -357,18 +250,6 @@ void InstallTelnet(void)
|
||||
return;
|
||||
}
|
||||
i = sscanf(pPtr, "%d", &iPort);
|
||||
/*
|
||||
if(i > 0)
|
||||
{
|
||||
pTelnet = NETOpenPort(iPort);
|
||||
}
|
||||
|
||||
if(pTelnet)
|
||||
{
|
||||
NetReadRegister(pServ->pReader,pTelnet, taccept, NULL);
|
||||
}
|
||||
*/
|
||||
/* when we have a port have the NetReader listen and handle it */
|
||||
NetReadInstallANETPort(pServ->pReader, taccept, iPort);
|
||||
|
||||
}
|
||||
@ -378,7 +259,6 @@ void KillTelnet(void)
|
||||
{
|
||||
if (pTelnet) {
|
||||
NETClosePort(pTelnet);
|
||||
/* NetReadRemove(pServ->pReader,pTelnet); */
|
||||
free(pTelnet);
|
||||
pTelnet = NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user