- repaired commandlog tail command (inserted SCPureSocketWrite)
- fixed mechanism for suppressing double lines in config listen mode
This commit is contained in:
33
conman.c
33
conman.c
@ -99,7 +99,7 @@ typedef struct {
|
||||
static int iName = 0;
|
||||
static long lastIdent = 0;
|
||||
/*------------- sending connection (prevent double write when listening) ----*/
|
||||
static SConnection *sendingConnection = NULL;
|
||||
static int sendingConnection = 0;
|
||||
/*------------- storing connection and context for later use ----*/
|
||||
struct SCStore {
|
||||
SConnection *pCon;
|
||||
@ -679,10 +679,14 @@ static void testAndWriteCommandLog(SConnection * pCon, char *buffer,
|
||||
{
|
||||
if (SCGetRights(pCon) <= usUser) {
|
||||
if (SCinMacro(pCon) != 1) {
|
||||
sendingConnection = pCon->sockHandle;
|
||||
WriteToCommandLogId(NULL, pCon->sockHandle, buffer);
|
||||
sendingConnection = 0;
|
||||
} else {
|
||||
if (iOut == eLog || iOut == eLogError) {
|
||||
sendingConnection = pCon->sockHandle;
|
||||
WriteToCommandLogId(NULL, pCon->sockHandle, buffer);
|
||||
sendingConnection = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -910,6 +914,19 @@ int SCOnlySockWrite(SConnection * self, char *buffer, int iOut)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int SCPureSockWrite(SConnection * self, char *buffer, int iOut)
|
||||
{
|
||||
/* for commandlog tail */
|
||||
if (!VerifyConnection(self)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
testAndWriteSocket(self, buffer, iOut);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int SCNotWrite(SConnection * self, char *buffer, int iOut)
|
||||
{
|
||||
@ -1337,13 +1354,13 @@ int SCInvoke(SConnection * self, SicsInterp * pInter, char *pCommand)
|
||||
* case
|
||||
*/
|
||||
if (SCGetWriteFunc(self) != SCNotWrite) {
|
||||
sendingConnection = self;
|
||||
sendingConnection = self->sockHandle;
|
||||
if (self->sockHandle >= 0) {
|
||||
WriteToCommandLogCmd(self->sockHandle, pCommand);
|
||||
} else {
|
||||
WriteToCommandLog("CRON>>", pCommand);
|
||||
}
|
||||
sendingConnection = NULL;
|
||||
sendingConnection = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1436,6 +1453,7 @@ int ConfigCon(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
pMaster->listening = pCon->listening;
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
@ -1500,10 +1518,9 @@ int ConfigCon(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
if (CompactCommandLog()) {
|
||||
if (pCon->iUserRights < 3 || i < 3) {
|
||||
ANETinfo(pCon->sockHandle, pHost, sizeof pHost);
|
||||
sprintf(pBueffel, "User %s from %s switched to %d privilege",
|
||||
argv[2], pHost, i);
|
||||
snprintf(pBueffel, 512, "User at %d switched to %d privilige",
|
||||
pCon->sockHandle, i);
|
||||
snprintf(pBueffel, sizeof pBueffel,
|
||||
"User %s from %s switched to %d privilege",
|
||||
argv[2], pHost, i);
|
||||
WriteToCommandLogId("SYS>", pCon->sockHandle, pBueffel);
|
||||
}
|
||||
} else {
|
||||
@ -1888,7 +1905,7 @@ void SCSignalFunction(void *pData, int iSignal, void *pSigData)
|
||||
}
|
||||
} else if (iSignal == COMLOG && self->listening == 1) {
|
||||
pPtr = (char *) pSigData;
|
||||
if (pPtr != NULL && self != sendingConnection) {
|
||||
if (pPtr != NULL && self->sockHandle != sendingConnection) {
|
||||
doSockWrite(self, pPtr);
|
||||
}
|
||||
} else if (iSignal == TOKENRELEASE) {
|
||||
|
Reference in New Issue
Block a user