PSI update
r1464 | ffr | 2007-02-12 12:20:21 +1100 (Mon, 12 Feb 2007) | 2 lines
This commit is contained in:
committed by
Douglas Clowes
parent
634f2023b1
commit
3168325921
91
conman.c
91
conman.c
@@ -39,6 +39,8 @@
|
||||
fields.
|
||||
Mark Koennecke, December 2004
|
||||
|
||||
Aded buffering support, Mark Koennecke, July 2006
|
||||
|
||||
Copyright: see copyright.h
|
||||
-----------------------------------------------------------------------------*/
|
||||
#include "fortify.h"
|
||||
@@ -92,6 +94,8 @@ extern pServer pServ;
|
||||
static int iName = 0;
|
||||
static SConnection *freeConnections = NULL;
|
||||
static long lastIdent = 0;
|
||||
/*------------- sending connection (prevent double write when listening) ----*/
|
||||
static SConnection *sendingConnection = NULL;
|
||||
/*===========================================================================*/
|
||||
static char *ConName(long ident) {
|
||||
static char name[32];
|
||||
@@ -457,6 +461,11 @@ extern pServer pServ;
|
||||
DeleteCommandStack(pVictim->pStack);
|
||||
}
|
||||
|
||||
/* remove possible buffers */
|
||||
if(pVictim->data != NULL)
|
||||
{
|
||||
DeleteDynString(pVictim->data);
|
||||
}
|
||||
|
||||
pVictim->lMagic=0; /* make a write to a freed connection harmless */
|
||||
/* finally free pVictim*/
|
||||
@@ -692,10 +701,21 @@ static void writeToLogFiles(SConnection *self, char *buffer)
|
||||
SICSLogWrite(buffer,iOut);
|
||||
|
||||
/* write to commandlog if user or manager privilege */
|
||||
if(SCGetRights(self) <= usUser && self->iMacro != 1)
|
||||
if(SCGetRights(self) <= usUser)
|
||||
{
|
||||
sprintf(pBueffel,"To sock %d :",iRet);
|
||||
WriteToCommandLog(pBueffel,buffer);
|
||||
if(self->iMacro != 1)
|
||||
{
|
||||
sprintf(pBueffel,"To sock %d :",iRet);
|
||||
WriteToCommandLog(pBueffel,buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(iOut == eError || iOut == eWarning)
|
||||
{
|
||||
sprintf(pBueffel,"To sock %d :",iRet);
|
||||
WriteToCommandLog(pBueffel,buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* put it into the interpreter if present */
|
||||
@@ -754,7 +774,9 @@ static void writeToLogFiles(SConnection *self, char *buffer)
|
||||
if(SCGetRights(self) <= usUser && self->iMacro != 1)
|
||||
{
|
||||
sprintf(pBueffel,"To sock %d :",iRet);
|
||||
sendingConnection = self;
|
||||
WriteToCommandLog(pBueffel,buffer);
|
||||
sendingConnection = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -809,6 +831,52 @@ static void writeToLogFiles(SConnection *self, char *buffer)
|
||||
free(bufPtr);
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int SCBufferWrite(SConnection *self, char *buffer, int iOut)
|
||||
{
|
||||
if(!VerifyConnection(self))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
assert(self->data != NULL);
|
||||
DynStringConcat(self->data,buffer);
|
||||
if(strchr(buffer,'\n') == NULL){
|
||||
DynStringConcat(self->data,"\n");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int SCStartBuffering(SConnection *pCon)
|
||||
{
|
||||
if(!VerifyConnection(pCon))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(pCon->data != NULL)
|
||||
{
|
||||
DeleteDynString(pCon->data);
|
||||
}
|
||||
pCon->data = CreateDynString(128,128);
|
||||
if(pCon->data == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
pCon->oldWriteFunc = pCon->write;
|
||||
pCon->write = SCBufferWrite;
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
pDynString SCEndBuffering(SConnection *pCon)
|
||||
{
|
||||
if(!VerifyConnection(pCon))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
assert(pCon->oldWriteFunc != NULL);
|
||||
pCon->write = pCon->oldWriteFunc;
|
||||
pCon->oldWriteFunc = NULL;
|
||||
return pCon->data;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int SCOnlySockWrite(SConnection *self, char *buffer, int iOut)
|
||||
{
|
||||
@@ -1378,7 +1446,16 @@ static void writeToLogFiles(SConnection *self, char *buffer)
|
||||
{
|
||||
strcat(pBueffel,"CONT or CRON>> ");
|
||||
}
|
||||
WriteToCommandLog(pBueffel,pCommand);
|
||||
/*
|
||||
* This is a fix to suppress cron messages in the success
|
||||
* case
|
||||
*/
|
||||
if(SCGetWriteFunc(self) != SCNotWrite)
|
||||
{
|
||||
sendingConnection = self;
|
||||
WriteToCommandLog(pBueffel,pCommand);
|
||||
sendingConnection = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* invoke */
|
||||
@@ -1900,8 +1977,8 @@ static void writeToLogFiles(SConnection *self, char *buffer)
|
||||
SCSetRights(self,iRet);
|
||||
pHost[0] = '\0';
|
||||
NETInfo(self->pSock,pHost,131);
|
||||
sprintf(pBueffel,"Accepted connection on socket %d from %s",
|
||||
self->pSock->sockid, pHost);
|
||||
sprintf(pBueffel,"Accepted connection %s on socket %d from %s",
|
||||
ConName(self->ident), self->pSock->sockid, pHost);
|
||||
SICSLogWrite(pBueffel,eInternal);
|
||||
WriteToCommandLog("SYS >", pBueffel);
|
||||
free(pPtr);
|
||||
@@ -1965,7 +2042,7 @@ static void writeToLogFiles(SConnection *self, char *buffer)
|
||||
else if(iSignal == COMLOG && self->listening == 1)
|
||||
{
|
||||
pPtr = (char *)pSigData;
|
||||
if(pPtr != NULL)
|
||||
if(pPtr != NULL && self != sendingConnection)
|
||||
{
|
||||
doSockWrite(self,pPtr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user