diff options
-rw-r--r-- | modules.c | 33 | ||||
-rw-r--r-- | modules.h | 3 | ||||
-rw-r--r-- | omfwd.c | 1 | ||||
-rw-r--r-- | ommysql.c | 1 | ||||
-rw-r--r-- | omshell.c | 1 | ||||
-rw-r--r-- | syslogd.c | 45 |
6 files changed, 50 insertions, 34 deletions
@@ -69,6 +69,14 @@ static void moduleDestruct(modInfo_t *pThis) } +/* get the name of a module + */ +uchar *modGetName(modInfo_t *pThis) +{ + return((pThis->pszName == NULL) ? (uchar*) "" : pThis->pszName); +} + + /* Add a module to the loaded module linked list */ static inline void addModToList(modInfo_t *pThis) @@ -105,6 +113,17 @@ modInfo_t *modGetNxt(modInfo_t *pThis) } +/* this function is like modGetNxt(), but it returns pointers to + * output modules only. As we currently deal just with output modules, + * it is a dummy, to be filled with real code later. + * rgerhards, 2007-07-24 + */ +modInfo_t *omodGetNxt(modInfo_t *pThis) +{ + return(modGetNxt(pThis)); +} + + /* Add an already-loaded module to the module linked list. This function does * anything that is needed to fully initialize the module. */ @@ -137,6 +156,10 @@ rsRetVal doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)()), uchar *name) moduleDestruct(pNew); return iRet; } + if((iRet = (*pNew->modQueryEtryPt)((uchar*)"parseSelectorAct", &pNew->mod.om.parseSelectorAct)) != RS_RET_OK) { + moduleDestruct(pNew); + return iRet; + } /* later... if((iRet = (*pNew->modQueryEtryPt)((uchar*)"freeInstance", &pNew->freeInstance)) != RS_RET_OK) { moduleDestruct(pNew); @@ -164,8 +187,7 @@ void modPrintList(void) pMod = modGetNxt(NULL); while(pMod != NULL) { dprintf("Loaded Module: Name='%s', IFVersion=%d, ", - (pMod->pszName == NULL) ? "NULL" : (char*)pMod->pszName, - pMod->iIFVers); + (char*) modGetName(pMod), pMod->iIFVers); dprintf("type="); switch(pMod->eType) { case eMOD_OUT: @@ -180,9 +202,10 @@ void modPrintList(void) } dprintf(" module.\n"); dprintf("Entry points:\n"); - dprintf("\tqueryEtryPt: 0x%x\n", (unsigned) pMod->modQueryEtryPt); - dprintf("\tdoAction: 0x%x\n", (unsigned) pMod->mod.om.doAction); - dprintf("\tfreeInstance: 0x%x\n", (unsigned) pMod->freeInstance); + dprintf("\tqueryEtryPt: 0x%x\n", (unsigned) pMod->modQueryEtryPt); + dprintf("\tdoAction: 0x%x\n", (unsigned) pMod->mod.om.doAction); + dprintf("\tparseSelectorAct: 0x%x\n", (unsigned) pMod->mod.om.parseSelectorAct); + dprintf("\tfreeInstance: 0x%x\n", (unsigned) pMod->freeInstance); dprintf("\n"); pMod = modGetNxt(pMod); /* done, go next */ } @@ -73,12 +73,15 @@ typedef struct moduleInfo { /* below: perform the configured action */ rsRetVal (*doAction)(); + rsRetVal (*parseSelectorAct)(uchar**, selector_t*); } om; } mod; } modInfo_t; /* prototypes */ rsRetVal doModInit(rsRetVal (*modInit)(), uchar *name); +modInfo_t *omodGetNxt(modInfo_t *pThis); +uchar *modGetName(modInfo_t *pThis); void modPrintList(void); #endif /* #ifndef MODULES_H_INCLUDED */ @@ -424,6 +424,7 @@ static rsRetVal parseSelectorAct(uchar **pp, selector_t *f) * host). We try to get the ip number later, like * FORW_SUSP. */ + break; default: iRet = RS_RET_CONFLINE_UNPROCESSED; break; @@ -370,6 +370,7 @@ static rsRetVal parseSelectorAct(uchar **pp, selector_t *f) initMySQL(f); } #endif /* #ifdef WITH_DB */ + break; default: iRet = RS_RET_CONFLINE_UNPROCESSED; break; @@ -86,6 +86,7 @@ static rsRetVal parseSelectorAct(uchar **pp, selector_t *f) f->f_type = F_SHELL; f->doAction = doActionShell; } + break; default: iRet = RS_RET_CONFLINE_UNPROCESSED; break; @@ -5036,7 +5036,7 @@ static rsRetVal cfline(char *line, register selector_t *f) { uchar *p; rsRetVal iRet; - modInfo_t pMod; + modInfo_t *pMod; dprintf("cfline(%s)", line); @@ -5090,35 +5090,22 @@ static rsRetVal cfline(char *line, register selector_t *f) f->f_type = F_DISCARD; } else { /* loop through all modules and see if one picks up the line */ - pMod = modGetNxt(NULL); + pMod = omodGetNxt(NULL); while(pMod != NULL) { - pMod = modGetNxt(pMod); - } -#if 0 - switch (*p) - { - case '@': - parseSelectorActFwd(&p, f); - break; - case '$': - case '?': - case '|': - case '/': - parseSelectorActFile(&p, f); - break; - case '*': - parseSelectorActUsrMsg(&p, f); - break; - case '>': - parseSelectorActMySQL(&p, f); - break; - case '^': /* bkalkbrenner 2005-09-20: execute shell command */ - parseSelectorActShell(&p, f); - break; - default: - parseSelectorActUsrMsg(&p, f); - break; -#endif + iRet = pMod->mod.om.parseSelectorAct(&p , f); + if(iRet == RS_RET_CONFLINE_PROCESSED) { + dprintf("Module %s processed this config line.\n", + modGetName(pMod)); + break; + } + else if(iRet != RS_RET_CONFLINE_UNPROCESSED) { + /* we ignore any errors that might have occured - we can + * not do anything at all, and it would block other modules + * from initializing. -- rgerhards, 2007-07-24 + */ + dprintf("error %d parsing config line - continuing\n", (int) iRet); + } + pMod = omodGetNxt(pMod); } } |