This is the first working version of the new logging system. Some work
in fine tuning still needs to be done. But is reasonably OK now.
This commit is contained in:
339
conman.c
339
conman.c
@ -62,13 +62,11 @@
|
||||
#include "passwd.h"
|
||||
#include "splitter.h"
|
||||
#include "macro.h"
|
||||
#include "servlog.h"
|
||||
#include "status.h"
|
||||
#include "interrupt.h"
|
||||
#include "ifile.h"
|
||||
#include "token.h"
|
||||
#include "uubuffer.h"
|
||||
#include "commandlog.h"
|
||||
#include "stptok.h"
|
||||
#include "statusfile.h"
|
||||
#include "sicshipadaba.h"
|
||||
@ -89,7 +87,7 @@ extern struct json_object *mkJSON_Object(SConnection * pCon, char *pBuffer,
|
||||
|
||||
extern pServer pServ;
|
||||
|
||||
#include "outcode.c" /* text for OutCode */
|
||||
#include "outcode.h" /* text for OutCode */
|
||||
|
||||
int KillCapture(SConnection * pCon);
|
||||
|
||||
@ -158,9 +156,9 @@ char *ConID(SConnection *pCon)
|
||||
|
||||
if(ANETvalidHandle(pCon->sockHandle)){
|
||||
ANETinfo(pCon->sockHandle, host, sizeof(host));
|
||||
snprintf(id,sizeof(id),"%s:%2.2d", host, pCon->sockHandle);
|
||||
snprintf(id,sizeof(id),"%s:sock%3.3d", host, pCon->sockHandle);
|
||||
} else {
|
||||
snprintf(id,sizeof(id),"disconnected:%2.2ld", pCon->ident);
|
||||
snprintf(id,sizeof(id),"disconnected:con%ld", pCon->ident);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
@ -200,7 +198,7 @@ static SConnection *SCMakeConnection()
|
||||
pRes = (SConnection *) malloc(sizeof(SConnection));
|
||||
if (!pRes) {
|
||||
/* This is a serious, very serious error! */
|
||||
SICSLogWrite("ERROR: No memory to allocate connection!!", eInternal);
|
||||
Log(ERROR,"sys","%s","No memory to allocate connection!!");
|
||||
return NULL;
|
||||
}
|
||||
memset(pRes, 0, sizeof(SConnection));
|
||||
@ -223,8 +221,7 @@ static SConnection *CreateConnection(SicsInterp * pSics)
|
||||
used name */
|
||||
if (lastIdent == LONG_MAX) {
|
||||
/* This is a serious, very serious error! */
|
||||
SICSLogWrite("ERROR: Run out of connection identifiers!!",
|
||||
eInternal);
|
||||
Log(FATAL,"sys""%s","Run out of connection identifiers!!");
|
||||
return NULL;
|
||||
}
|
||||
lastIdent++;
|
||||
@ -235,7 +232,7 @@ static SConnection *CreateConnection(SicsInterp * pSics)
|
||||
pRes->pDes = CreateDescriptor("Connection");
|
||||
if (!pRes->pDes) {
|
||||
/* This is a serious, very serious error! */
|
||||
SICSLogWrite("ERROR: No memory to allocate connection!!", eInternal);
|
||||
Log(ERROR,"sys","%s","No memory to allocate connection!!");
|
||||
FreeConnection(pRes);
|
||||
return NULL;
|
||||
}
|
||||
@ -247,7 +244,7 @@ static SConnection *CreateConnection(SicsInterp * pSics)
|
||||
pRes->pStack = CreateCommandStack();
|
||||
if ((pRes->iList < 0) || (!pRes->pStack)) {
|
||||
/* This is a serious, very serious error! */
|
||||
SICSLogWrite("ERROR: No memory to allocate connection!!", eInternal);
|
||||
Log(ERROR,"sys","%s","No memory to allocate connection!!");
|
||||
DeleteDescriptor(pRes->pDes);
|
||||
FreeConnection(pRes);
|
||||
return NULL;
|
||||
@ -310,7 +307,7 @@ SConnection *SCCreateDummyConnection(SicsInterp * pSics)
|
||||
pRes->iUserRights = usInternal;
|
||||
pRes->iGrab = 0;
|
||||
|
||||
SICSLogWrite("Accepted dummy connection ", eInternal);
|
||||
Log(INFO,"SYS","%s","Accepted dummy connection ");
|
||||
|
||||
return pRes;
|
||||
}
|
||||
@ -319,11 +316,11 @@ SConnection *SCCreateDummyConnection(SicsInterp * pSics)
|
||||
int VerifyConnection(SConnection * self)
|
||||
{
|
||||
if (!self) {
|
||||
SICSLogWrite("MAGICERROR: Invalid call to NULL connection", eError);
|
||||
Log(ERROR,"sys","%s","MAGICERROR: Invalid call to NULL connection");
|
||||
return 0;
|
||||
}
|
||||
if (self->lMagic != CONMAGIC) {
|
||||
SICSLogWrite("MAGICERROR: corrupted connection object", eError);
|
||||
Log(ERROR,"sys","%s","MAGICERROR: corrupted connection object");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@ -379,8 +376,7 @@ void SCDeleteMasterFields(SConnection * pVictim)
|
||||
if (SCActive(pVictim)) {
|
||||
SCnoSock(pVictim);
|
||||
ANETclose(pVictim->sockHandle);
|
||||
WriteToCommandLog("SYS>",
|
||||
"ERROR: Erraneous deletion of used Connection stopped");
|
||||
Log(ERROR,"sys","%s","Erraneous deletion of used Connection stopped");
|
||||
pVictim->sockHandle = -1;
|
||||
return;
|
||||
}
|
||||
@ -410,10 +406,9 @@ void SCDeleteMasterFields(SConnection * pVictim)
|
||||
|
||||
/* log the kill */
|
||||
if (pVictim->sockHandle >= 0 && pVictim->iLogin == 1 &&
|
||||
(pVictim->iUserRights < 3 || !CompactCommandLog())) {
|
||||
pVictim->iUserRights < 3) {
|
||||
sprintf(pBueffel, "Deleting connection %d", pVictim->sockHandle);
|
||||
WriteToCommandLog("SYS>", pBueffel);
|
||||
SICSLogWrite(pBueffel, eInternal);
|
||||
Log(DEBUG,"sys","%s", pBueffel);
|
||||
}
|
||||
|
||||
/* close all open files and sockets */
|
||||
@ -660,9 +655,6 @@ int SCWrite(SConnection * self, char *pBuffer, int iOut)
|
||||
if (pBuffer == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if(!SCinMacro(self) || mustWrite(iOut) ){
|
||||
traceCommand(ConID(self),"out:%s", pBuffer);
|
||||
}
|
||||
return self->write(self, pBuffer, iOut);
|
||||
}
|
||||
|
||||
@ -748,8 +740,8 @@ static int doSockWrite(SConnection * self, char *buffer)
|
||||
if (!iRet) {
|
||||
SCnoSock(self);
|
||||
if (!self->listening && self->iLogin == 1 &&
|
||||
(self->iUserRights < 3 || !CompactCommandLog())) {
|
||||
WriteToCommandLog("SYS>", "Connection broken on send");
|
||||
self->iUserRights < 3) {
|
||||
Log(ERROR,"sys","%s", "Connection broken on send");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -762,25 +754,6 @@ static int doSockWrite(SConnection * self, char *buffer)
|
||||
return iRet;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static void testAndWriteCommandLog(SConnection * pCon, char *buffer,
|
||||
int iOut)
|
||||
{
|
||||
if (SCGetRights(pCon) <= usUser) {
|
||||
if (SCinMacro(pCon) != 1) {
|
||||
SetSendingConnection(pCon);
|
||||
WriteToCommandLogId(NULL, pCon->sockHandle, buffer);
|
||||
SetSendingConnection(NULL);
|
||||
} else {
|
||||
if (iOut == eLog || iOut == eLogError) {
|
||||
SetSendingConnection(pCon);
|
||||
WriteToCommandLogId(NULL, pCon->sockHandle, buffer);
|
||||
SetSendingConnection(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static void testAndStoreInTcl(SConnection * pCon, char *buffer, int iOut)
|
||||
{
|
||||
@ -827,56 +800,69 @@ static int isOK(const char *buffer)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static void testAndWriteSICSLog(SConnection * self, char *buffer, int iOut)
|
||||
static void testAndWriteLog(SConnection * self, char *buffer, int iOut)
|
||||
{
|
||||
char tp;
|
||||
/* We don't want to log the "OK" messages */
|
||||
if (isOK(buffer))
|
||||
return;
|
||||
|
||||
if (SCinMacro(self)) {
|
||||
tp = 'M';
|
||||
if (sicsdebug())
|
||||
tp = 'D';
|
||||
} else
|
||||
tp = 'N';
|
||||
switch (iOut) {
|
||||
case eStatus:
|
||||
case eStart:
|
||||
case eFinish:
|
||||
case eEvent:
|
||||
case eHdbValue:
|
||||
case eHdbEvent:
|
||||
case eLog:
|
||||
case eLogError:
|
||||
case eError:
|
||||
case eWarning:
|
||||
/* Log it */
|
||||
SICSLogWriteCode(buffer, iOut, tp);
|
||||
return;
|
||||
case eValue:
|
||||
if (sicsdebug() || !SCinMacro(self)) {
|
||||
/* Log it */
|
||||
SICSLogWriteCode(buffer, iOut, tp);
|
||||
return;
|
||||
} else {
|
||||
/* Suppressed */
|
||||
#if 0
|
||||
tp = tolower(tp);
|
||||
SICSLogWriteCode(buffer, iOut, tp);
|
||||
#endif
|
||||
return;
|
||||
/*
|
||||
first those which allways go into the log
|
||||
*/
|
||||
switch(iOut){
|
||||
case eInternal:
|
||||
Log(ERROR,"sys","%s",buffer);
|
||||
break;
|
||||
case eCommand:
|
||||
if(!SCinMacro(self)){
|
||||
Log(DEBUG,"sys","%s",buffer);
|
||||
}
|
||||
break;
|
||||
case eHWError:
|
||||
case eInError:
|
||||
Log(ERROR,"dev","%s",buffer);
|
||||
break;
|
||||
case eStatus:
|
||||
Log(DEBUG,"IO","%s",buffer);
|
||||
break;
|
||||
case eEvent:
|
||||
if(strstr(buffer,"ERROR") != NULL){
|
||||
Log(ERROR,"notify",buffer);
|
||||
}else if(strstr(buffer,"WARNING") != NULL) {
|
||||
Log(WARN,"notify",buffer);
|
||||
} else {
|
||||
Log(INFO,"notify",buffer);
|
||||
}
|
||||
break;
|
||||
case eHdbEvent:
|
||||
case eHdbValue:
|
||||
Log(INFO,"notify","%s",buffer);
|
||||
break;
|
||||
case eLog:
|
||||
Log(INFO,"com","sock%03.3d:%s",self->sockHandle,buffer);
|
||||
break;
|
||||
case eLogError:
|
||||
Log(ERROR,"com","sock%03.3d:%s",self->sockHandle,buffer);
|
||||
break;
|
||||
case eError:
|
||||
if(!SCinMacro(self)){
|
||||
Log(ERROR,"com","sock%03.3d:%s",self->sockHandle,buffer);
|
||||
}
|
||||
break;
|
||||
case eWarning:
|
||||
if(!SCinMacro(self)){
|
||||
Log(WARN,"com","sock%03.3d:%s",self->sockHandle,buffer);
|
||||
}
|
||||
break;
|
||||
case eValue:
|
||||
if(!SCinMacro(self)){
|
||||
Log(INFO,"com","sock%03.3d:%s",self->sockHandle,buffer);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf("Unrecognized ouput code %d in testAndWriteSICSLog: FIXME!!!\n", iOut);
|
||||
SICSLogWriteCode(buffer, iOut, tp);
|
||||
return;
|
||||
Log(DEBUG,"sys","Unknown outcode %d detected, FIXME ASAP!!!", iOut);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int SCNormalWrite(SConnection * self, char *buffer, int iOut)
|
||||
{
|
||||
@ -891,13 +877,7 @@ int SCNormalWrite(SConnection * self, char *buffer, int iOut)
|
||||
}
|
||||
|
||||
/* log it for any case */
|
||||
#if 0
|
||||
SICSLogWrite(buffer, iOut);
|
||||
#else
|
||||
testAndWriteSICSLog(self, buffer, iOut);
|
||||
#endif
|
||||
|
||||
testAndWriteCommandLog(self, buffer, iOut);
|
||||
testAndWriteLog(self, buffer, iOut);
|
||||
|
||||
testAndStoreInTcl(self, buffer, iOut);
|
||||
|
||||
@ -918,10 +898,7 @@ int SCAllWrite(SConnection * self, char *buffer, int iOut)
|
||||
return 1; /* do not write empty line */
|
||||
}
|
||||
|
||||
/* log it for any case */
|
||||
SICSLogWrite(buffer, iOut);
|
||||
|
||||
testAndWriteCommandLog(self, buffer, iOut);
|
||||
testAndWriteLog(self, buffer, iOut);
|
||||
|
||||
testAndStoreInTcl(self, buffer, iOut);
|
||||
|
||||
@ -946,10 +923,7 @@ int SCACTWrite(SConnection * self, char *buffer, int iOut)
|
||||
}
|
||||
|
||||
/* log it for any case */
|
||||
sprintf(pBueffel, "Next line intended for socket: %d", self->sockHandle);
|
||||
SICSLogWrite(buffer, iOut);
|
||||
|
||||
testAndWriteCommandLog(self, buffer, iOut);
|
||||
testAndWriteLog(self, buffer, iOut);
|
||||
|
||||
testAndStoreInTcl(self, buffer, iOut);
|
||||
|
||||
@ -986,11 +960,7 @@ int SCWriteWithOutcode(SConnection * self, char *buffer, int iOut)
|
||||
}
|
||||
|
||||
/* log it for any case */
|
||||
sprintf(pBueffel, "Next line intended for socket: %d", self->sockHandle);
|
||||
SICSLogWrite(pBueffel, eInternal);
|
||||
SICSLogWrite(buffer, iOut);
|
||||
|
||||
testAndWriteCommandLog(self, buffer, iOut);
|
||||
testAndWriteLog(self, buffer, iOut);
|
||||
|
||||
testAndStoreInTcl(self, buffer, iOut);
|
||||
/*
|
||||
@ -999,8 +969,7 @@ int SCWriteWithOutcode(SConnection * self, char *buffer, int iOut)
|
||||
length = strlen(buffer) + strlen(pCode[iOut]) + 10;
|
||||
bufPtr = (char *) malloc(length * sizeof(char));
|
||||
if (!bufPtr) {
|
||||
SICSLogWrite("SYS>>ERROR: out of memory in SCWriteWithOutcode",
|
||||
eError);
|
||||
Log(ERROR,"sys","%s","out of memory in SCWriteWithOutcode");
|
||||
return 0;
|
||||
}
|
||||
memset(bufPtr, 0, length * sizeof(char));
|
||||
@ -1078,9 +1047,7 @@ int SCOnlySockWrite(SConnection * self, char *buffer, int iOut)
|
||||
}
|
||||
|
||||
/* log it for any case */
|
||||
sprintf(pBueffel, "Next line intended for socket: %d", self->sockHandle);
|
||||
SICSLogWrite(pBueffel, eInternal);
|
||||
SICSLogWrite(buffer, iOut);
|
||||
testAndWriteLog(self,buffer,iOut);
|
||||
|
||||
testAndStoreInTcl(self, buffer, iOut);
|
||||
|
||||
@ -1138,7 +1105,7 @@ int SCLogWrite(SConnection * self, char *buffer, int iOut)
|
||||
return 0;
|
||||
}
|
||||
SetSendingConnection(self);
|
||||
WriteToCommandLogId(NULL, self->sockHandle, buffer);
|
||||
Log(INFO,"com","sock%03.3d%s", self->sockHandle, buffer);
|
||||
SetSendingConnection(NULL);
|
||||
|
||||
if(self->iProtocolID == PROTACT) { /* act */
|
||||
@ -1212,12 +1179,8 @@ int SCFileWrite(SConnection * self, char *buffer, int iOut)
|
||||
}
|
||||
|
||||
/* log it for any case */
|
||||
sprintf(pBueffel, "Next line intended for socket: %d", self->sockHandle);
|
||||
SICSLogWrite(pBueffel, eInternal);
|
||||
|
||||
SICSLogWrite(buffer, iOut);
|
||||
|
||||
testAndWriteCommandLog(self, buffer, iOut);
|
||||
testAndWriteLog(self, buffer, iOut);
|
||||
|
||||
testAndStoreInTcl(self, buffer, iOut);
|
||||
|
||||
@ -1694,7 +1657,7 @@ int SCPrompt(SConnection * pCon, char *pPrompt, char *pResult, int iLen)
|
||||
if (iRet == 1) {
|
||||
CostaLock(master->pStack);
|
||||
strlcpy(pResult, pPtr, iLen);
|
||||
WriteToCommandLogId(" prompted>", pCon->sockHandle, pPtr);
|
||||
Log(INFO,"sys","prompted%03.3d:", pCon->sockHandle, pPtr);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -1739,7 +1702,7 @@ int SCPromptTMO(SConnection * pCon, char *pPrompt, char *pResult, int iLen, int
|
||||
if (iRet == 1) {
|
||||
CostaLock(master->pStack);
|
||||
strlcpy(pResult, pPtr, iLen);
|
||||
WriteToCommandLogId(" prompted>", pCon->sockHandle, pPtr);
|
||||
Log(INFO,"com"," prompted%03.3d:", pCon->sockHandle, pPtr);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -1840,10 +1803,10 @@ int SCInvoke(SConnection * self, SicsInterp * pInter, char *pCommand)
|
||||
SetSendingConnection(self);
|
||||
if (self->sockHandle >= 0) {
|
||||
if(strstr(pCommand,"Poch") == NULL){
|
||||
WriteToCommandLogCmd(self->sockHandle, pCommand);
|
||||
Log(INFO,"com","sock%03.3d:",self->sockHandle, pCommand);
|
||||
}
|
||||
} else {
|
||||
WriteToCommandLog("CRON>>", pCommand);
|
||||
Log(INFO,"sys","CRON:%s", pCommand);
|
||||
}
|
||||
SetSendingConnection(NULL);
|
||||
}
|
||||
@ -2004,19 +1967,9 @@ int ConfigCon(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
if (CompactCommandLog()) {
|
||||
if (pCon->iUserRights < 3 || i < 3) {
|
||||
ANETinfo(pCon->sockHandle, pHost, sizeof pHost);
|
||||
snprintf(pBueffel, sizeof pBueffel,
|
||||
"User %s from %s switched to %d privilege",
|
||||
argv[2], pHost, i);
|
||||
WriteToCommandLogId("SYS>", pCon->sockHandle, pBueffel);
|
||||
}
|
||||
} else {
|
||||
snprintf(pBueffel, 511, "User %s handle %d switched to %d privilege",
|
||||
snprintf(pBueffel, 511, "User %s handle %d switched to %d privilege",
|
||||
argv[2], pCon->sockHandle, i);
|
||||
WriteToCommandLog("SYS>", pBueffel);
|
||||
}
|
||||
Log(INFO,"sys","%s", pBueffel);
|
||||
pCon->iUserRights = i;
|
||||
pMaster->iUserRights = i;
|
||||
SCWrite(pCon, "Change of Authorisation Acknowledged", eWarning);
|
||||
@ -2279,114 +2232,9 @@ static void hookFunc(const char *pText, OutCode eOut, void*pData)
|
||||
|
||||
int KillCapture(SConnection * pCon)
|
||||
{
|
||||
RemSICSLogHook(pCon);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
the command function:
|
||||
Syntax:
|
||||
Kill kills all logging
|
||||
Log OutCode starts loggin OutCode events
|
||||
All starts logging all events
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
int LogCapture(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
SConnection * pConMaster;
|
||||
char pBueffel[512];
|
||||
int i;
|
||||
|
||||
pConMaster = SCfindMaster(pCon);
|
||||
if (pConMaster == NULL)
|
||||
return 0;
|
||||
/* check no af args */
|
||||
if (argc < 2) {
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "Insufficient number of arguments to %s", argv[0]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
argtolower(argc, argv);
|
||||
|
||||
/* Branch according to argv[1] */
|
||||
if (strcmp(argv[1], "kill") == 0 || strcmp(argv[1], "none") == 0) {
|
||||
SCPrintf(pCon, eLog, "getlog %s", argv[1]);
|
||||
KillCapture(pConMaster);
|
||||
return 1;
|
||||
} else if (strcmp(argv[1], "what") == 0) {
|
||||
unsigned int code_bits = 0;
|
||||
pDynString buffer;
|
||||
code_bits = (1 << iNoCodes) - 1;
|
||||
buffer = CreateDynString(100, 100);
|
||||
for (i = 0; i < iNoCodes; ++i) {
|
||||
if (code_bits & (1 << i)) {
|
||||
if (GetDynStringLength(buffer) > 0)
|
||||
DynStringConcatChar(buffer, ',');
|
||||
DynStringConcat(buffer, (char *)OutCodeToTxt(i));
|
||||
}
|
||||
}
|
||||
SCPrintf(pCon, eLog, "getlog %s", GetCharArray(buffer));
|
||||
DeleteDynString(buffer);
|
||||
return 1;
|
||||
} else if (strcmp(argv[1], "list") == 0) {
|
||||
unsigned int code_bits = 0;
|
||||
pDynString buffer;
|
||||
code_bits = GetSICSLogHook(pConMaster);
|
||||
if (code_bits == 0) {
|
||||
SCPrintf(pCon, eLog, "getlog none");
|
||||
return 1;
|
||||
}
|
||||
buffer = CreateDynString(100, 100);
|
||||
for (i = 0; i < iNoCodes; ++i) {
|
||||
if (code_bits & (1 << i)) {
|
||||
if (GetDynStringLength(buffer) > 0)
|
||||
DynStringConcatChar(buffer, ',');
|
||||
DynStringConcat(buffer, (char *)OutCodeToTxt(i));
|
||||
}
|
||||
}
|
||||
SCPrintf(pCon, eLog, "getlog %s", GetCharArray(buffer));
|
||||
DeleteDynString(buffer);
|
||||
return 1;
|
||||
} else if (strcmp(argv[1], "all") == 0) {
|
||||
SCPrintf(pCon, eLog, "getlog all");
|
||||
AddSICSLogHook(hookFunc, "all", pConMaster);
|
||||
return 1;
|
||||
} else if (argc == 2) {
|
||||
/* must be outcode, try find it */
|
||||
SCPrintf(pCon, eLog, "getlog %s", argv[1]);
|
||||
AddSICSLogHook(hookFunc, argv[1], pConMaster);
|
||||
return 1;
|
||||
} else {
|
||||
/* make it a list */
|
||||
int i;
|
||||
size_t len;
|
||||
char *pBuff;
|
||||
for (i = 1, len = 0; i < argc; ++i)
|
||||
len += strlen(argv[i]) + 1;
|
||||
if (len > sizeof(pBueffel))
|
||||
pBuff = malloc(len);
|
||||
else
|
||||
pBuff = pBueffel;
|
||||
if (pBuff == NULL) {
|
||||
SCWrite(pCon, "Out of memory in LogCapture\n", eError);
|
||||
return 1;
|
||||
}
|
||||
for (i = 1, len = 0; i < argc; ++i) {
|
||||
if (i > 1)
|
||||
pBuff[len++] = ',';
|
||||
strcpy(&pBuff[len], argv[i]);
|
||||
len += strlen(argv[i]);
|
||||
}
|
||||
SCPrintf(pCon, eLog, "getlog %s", pBuff);
|
||||
AddSICSLogHook(hookFunc, pBuff, pConMaster);
|
||||
if (pBuff != pBueffel)
|
||||
free(pBuff);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* ------------------------------------------------------------------------
|
||||
the command function:
|
||||
Syntax:
|
||||
@ -2437,7 +2285,7 @@ int LogOutput(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
strcpy(&pBuff[len], argv[i]);
|
||||
len += strlen(argv[i]);
|
||||
}
|
||||
SICSLogWrite(pBuff, outcode);
|
||||
Log(INFO,"com","%s",pBuff);
|
||||
if (pBuff != pBueffel)
|
||||
free(pBuff);
|
||||
return 1;
|
||||
@ -2516,22 +2364,11 @@ int SCTaskFunction(void *pData)
|
||||
self->iLogin = 1;
|
||||
SCSetRights(self, iRet);
|
||||
pHost[0] = '\0';
|
||||
if (CompactCommandLog()) {
|
||||
if (iRet < 3) {
|
||||
ANETinfo(self->sockHandle, pHost, 131);
|
||||
sprintf(pBueffel, "Accepted connection %s from %s as %s",
|
||||
ConName(self->ident), pHost, pUser);
|
||||
SICSLogWrite(pBueffel, eInternal);
|
||||
WriteToCommandLogId("SYS>", self->sockHandle, pBueffel);
|
||||
}
|
||||
} else {
|
||||
ANETinfo(self->sockHandle, pHost, 131);
|
||||
snprintf(pBueffel, 511,
|
||||
ANETinfo(self->sockHandle, pHost, 131);
|
||||
snprintf(pBueffel, 511,
|
||||
"Accepted connection %s on socket %d from %s",
|
||||
ConName(self->ident), self->sockHandle, pHost);
|
||||
SICSLogWrite(pBueffel, eInternal);
|
||||
WriteToCommandLog("SYS >", pBueffel);
|
||||
}
|
||||
Log(INFO,"sys","%s",pBueffel);
|
||||
free(pPtr);
|
||||
return 1;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user