summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cfsysline.c34
-rw-r--r--cfsysline.h19
-rw-r--r--omfile.c20
-rw-r--r--rsyslog.h1
-rw-r--r--syslogd.c28
5 files changed, 47 insertions, 55 deletions
diff --git a/cfsysline.c b/cfsysline.c
index c42675d0..af197269 100644
--- a/cfsysline.c
+++ b/cfsysline.c
@@ -50,7 +50,7 @@ linkedList_t llCmdList; /* this is NOT a pointer - no typo here ;) */
* HINT: check if char is ' and, if so, use 'c' where c may also be things
* like \t etc.
*/
-rsRetVal doGetChar(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal)
+static rsRetVal doGetChar(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal)
{
DEFiRet;
@@ -83,7 +83,7 @@ finalize_it:
* a shell to call the custom handler.
* rgerhards, 2007-07-31
*/
-rsRetVal doCustomHdlr(uchar **pp, rsRetVal (*pSetHdlr)(uchar**, void*), void *pVal)
+static rsRetVal doCustomHdlr(uchar **pp, rsRetVal (*pSetHdlr)(uchar**, void*), void *pVal)
{
DEFiRet;
@@ -100,7 +100,7 @@ finalize_it:
/* Parse a number from the configuration line.
* rgerhards, 2007-07-31
*/
-rsRetVal doGetInt(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal)
+static rsRetVal doGetInt(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal)
{
uchar *p;
DEFiRet;
@@ -149,7 +149,7 @@ finalize_it:
* Parameter **pp has a pointer to the current config line.
* On exit, it will be updated to the processed position.
*/
-rsRetVal doFileCreateMode(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal)
+static rsRetVal doFileCreateMode(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal)
{
uchar *p;
DEFiRet;
@@ -236,7 +236,7 @@ static int doParseOnOffOption(uchar **pp)
/* extract a groupname and return its gid.
* rgerhards, 2007-07-17
*/
-rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal)
+static rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal)
{
struct group *pgBuf;
struct group gBuf;
@@ -278,7 +278,7 @@ finalize_it:
/* extract a username and return its uid.
* rgerhards, 2007-07-17
*/
-rsRetVal doGetUID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal)
+static rsRetVal doGetUID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal)
{
struct passwd *ppwBuf;
struct passwd pwBuf;
@@ -322,7 +322,7 @@ finalize_it:
* value.
* rgerhards, 2007-07-15
*/
-rsRetVal doBinaryOptionLine(uchar **pp, rsRetVal (*pSetHdlr)(void*, int), void *pVal)
+static rsRetVal doBinaryOptionLine(uchar **pp, rsRetVal (*pSetHdlr)(void*, int), void *pVal)
{
int iOption;
DEFiRet;
@@ -354,7 +354,7 @@ finalize_it:
* pThis is actually a cslCmdHdlr_t, but we do not cast it as all we currently
* need to do is free it.
*/
-rsRetVal cslchDestruct(void *pThis)
+static rsRetVal cslchDestruct(void *pThis)
{
assert(pThis != NULL);
free(pThis);
@@ -365,7 +365,7 @@ rsRetVal cslchDestruct(void *pThis)
/* constructor for cslCmdHdlr
*/
-rsRetVal cslchConstruct(cslCmdHdlr_t **ppThis)
+static rsRetVal cslchConstruct(cslCmdHdlr_t **ppThis)
{
cslCmdHdlr_t *pThis;
DEFiRet;
@@ -397,7 +397,7 @@ rsRetVal cslchSetEntry(cslCmdHdlr_t *pThis, ecslCmdHdrlType eType, rsRetVal (*pH
/* call the specified handler
*/
-rsRetVal cslchCallHdlr(cslCmdHdlr_t *pThis, uchar **ppConfLine)
+static rsRetVal cslchCallHdlr(cslCmdHdlr_t *pThis, uchar **ppConfLine)
{
DEFiRet;
rsRetVal (*pHdlr)() = NULL;
@@ -469,7 +469,7 @@ static rsRetVal cslcDestruct(void *pData)
/* constructor for cslCmd
*/
-rsRetVal cslcConstruct(cslCmd_t **ppThis)
+static rsRetVal cslcConstruct(cslCmd_t **ppThis, int bChainingPermitted)
{
cslCmd_t *pThis;
DEFiRet;
@@ -479,6 +479,8 @@ rsRetVal cslcConstruct(cslCmd_t **ppThis)
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
}
+ pThis->bChainingPermitted = bChainingPermitted;
+
CHKiRet(llInit(&pThis->llCmdHdlrs, cslchDestruct, NULL, NULL));
finalize_it:
@@ -489,7 +491,7 @@ finalize_it:
/* add a handler entry to a known command
*/
-rsRetVal cslcAddHdlr(cslCmd_t *pThis, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData)
+static rsRetVal cslcAddHdlr(cslCmd_t *pThis, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData)
{
DEFiRet;
cslCmdHdlr_t *pCmdHdlr = NULL;
@@ -526,7 +528,7 @@ finalize_it:
/* function that registers cfsysline handlers.
*/
-rsRetVal regCfSysLineHdlr(uchar *pCmdName, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData)
+rsRetVal regCfSysLineHdlr(uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData)
{
cslCmd_t *pThis;
DEFiRet;
@@ -534,7 +536,7 @@ rsRetVal regCfSysLineHdlr(uchar *pCmdName, ecslCmdHdrlType eType, rsRetVal (*pHd
iRet = llFind(&llCmdList, (void *) pCmdName, (void**) &pThis);
if(iRet == RS_RET_NOT_FOUND) {
/* new command */
- CHKiRet(cslcConstruct(&pThis));
+ CHKiRet(cslcConstruct(&pThis, bChainingPermitted));
CHKiRet_Hdlr(cslcAddHdlr(pThis, eType, pHdlr, pData)) {
cslcDestruct(pThis);
goto finalize_it;
@@ -548,7 +550,9 @@ rsRetVal regCfSysLineHdlr(uchar *pCmdName, ecslCmdHdrlType eType, rsRetVal (*pHd
}
} else {
/* command already exists, are we allowed to chain? */
- /* TODO: check permission to chain */
+ if(pThis->bChainingPermitted == 0 || bChainingPermitted == 0) {
+ ABORT_FINALIZE(RS_RET_CHAIN_NOT_PERMITTED);
+ }
CHKiRet_Hdlr(cslcAddHdlr(pThis, eType, pHdlr, pData)) {
cslcDestruct(pThis);
goto finalize_it;
diff --git a/cfsysline.h b/cfsysline.h
index 42edc0ec..99217e64 100644
--- a/cfsysline.h
+++ b/cfsysline.h
@@ -54,28 +54,15 @@ typedef struct cslCmdHdlr_s cslCmdHdlr_t;
* The short name is cslc (Configfile SysLine Command)
*/
struct cslCmd_s { /* config file sysline parse entry */
+ int bChainingPermitted; /* may multiple handlers be chained for this command? */
linkedList_t llCmdHdlrs; /* linked list of command handlers */
};
typedef struct cslCmd_s cslCmd_t;
/* prototypes */
-rsRetVal cslchDestruct(void *pThis);
-rsRetVal cslchConstruct(cslCmdHdlr_t **ppThis);
-rsRetVal cslchSetEntry(cslCmdHdlr_t *pThis, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData);
-rsRetVal cslchCallHdlr(cslCmdHdlr_t *pThis, uchar **ppConfLine);
-rsRetVal cslcConstruct(cslCmd_t **ppThis);
-rsRetVal regCfSysLineHdlr(uchar *pCmdName, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData);
-rsRetVal cfsyslineInit(void);
+rsRetVal regCfSysLineHdlr(uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData);
rsRetVal processCfSysLineCommand(uchar *pCmd, uchar **p);
+rsRetVal cfsyslineInit(void);
void dbgPrintCfSysLineHandlers(void);
-/* the next ones go away later */
-rsRetVal doBinaryOptionLine(uchar **pp, rsRetVal (*pSetHdlr)(void*, int), void *pVal);
-rsRetVal doGetUID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal);
-rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal);
-rsRetVal doFileCreateMode(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal);
-rsRetVal doGetChar(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal);
-rsRetVal doGetInt(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal);
-rsRetVal doCustomHdlr(uchar **pp, rsRetVal (*pSetHdlr)(uchar**, void*), void *pVal);
-
#endif /* #ifndef CFSYSLINE_H_INCLUDED */
diff --git a/omfile.c b/omfile.c
index 5c45f58d..0a0798aa 100644
--- a/omfile.c
+++ b/omfile.c
@@ -779,16 +779,16 @@ BEGINmodInit(File)
CODESTARTmodInit
*ipIFVersProvided = 1; /* so far, we only support the initial definition */
CODEmodInit_QueryRegCFSLineHdlr
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"dynafilecachesize", eCmdHdlrInt, (void*) setDynaFileCacheSize, NULL));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"dirowner", eCmdHdlrUID, NULL, &dirUID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"dirgroup", eCmdHdlrGID, NULL, &dirGID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"fileowner", eCmdHdlrUID, NULL, &fileUID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"filegroup", eCmdHdlrGID, NULL, &fileGID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"dircreatemode", eCmdHdlrFileCreateMode, NULL, &fDirCreateMode));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"filecreatemode", eCmdHdlrFileCreateMode, NULL, &fCreateMode));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"createdirs", eCmdHdlrBinary, NULL, &bCreateDirs));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"failonchownfailure", eCmdHdlrBinary, NULL, &bFailOnChown));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", eCmdHdlrCustomHandler, resetConfigVariables, NULL));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"dynafilecachesize", 0, eCmdHdlrInt, (void*) setDynaFileCacheSize, NULL));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"dirowner", 0, eCmdHdlrUID, NULL, &dirUID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"dirgroup", 0, eCmdHdlrGID, NULL, &dirGID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"fileowner", 0, eCmdHdlrUID, NULL, &fileUID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"filegroup", 0, eCmdHdlrGID, NULL, &fileGID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"dircreatemode", 0, eCmdHdlrFileCreateMode, NULL, &fDirCreateMode));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"filecreatemode", 0, eCmdHdlrFileCreateMode, NULL, &fCreateMode));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"createdirs", 0, eCmdHdlrBinary, NULL, &bCreateDirs));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"failonchownfailure", 0, eCmdHdlrBinary, NULL, &bFailOnChown));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL));
ENDmodInit
/*
diff --git a/rsyslog.h b/rsyslog.h
index b781383c..c4165bac 100644
--- a/rsyslog.h
+++ b/rsyslog.h
@@ -66,6 +66,7 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth
RS_RET_VAL_OUT_OF_RANGE = -2012, /**< value out of range */
RS_RET_FOPEN_FAILURE = -2013, /**< failure during fopen, for example file not found - see errno */
RS_RET_END_OF_LINKEDLIST = -2014, /**< end of linked list, not an error, but a status */
+ RS_RET_CHAIN_NOT_PERMITTED = -2015, /**< chaining (e.g. of config command handlers) not permitted */
RS_RET_OK = 0 /**< operation successful */
};
typedef enum rsRetVal_ rsRetVal; /**< friendly type for global return value */
diff --git a/syslogd.c b/syslogd.c
index 3cb51b09..bdefe6da 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -5220,21 +5220,21 @@ static rsRetVal loadBuildInModules(void)
* is that rsyslog will terminate if we can not register our built-in config commands.
* This, I think, is the right thing to do. -- rgerhards, 2007-07-31
*/
- CHKiRet(regCfSysLineHdlr((uchar *)"repeatedmsgreduction", eCmdHdlrBinary, NULL, &bReduceRepeatMsgs));
- CHKiRet(regCfSysLineHdlr((uchar *)"controlcharacterescapeprefix", eCmdHdlrGetChar, NULL, &cCCEscapeChar));
- CHKiRet(regCfSysLineHdlr((uchar *)"escapecontrolcharactersonreceive", eCmdHdlrBinary, NULL, &bEscapeCCOnRcv));
- CHKiRet(regCfSysLineHdlr((uchar *)"dropmsgswithmaliciousdnsptrrecords", eCmdHdlrBinary, NULL, &bDropMalPTRMsgs));
- CHKiRet(regCfSysLineHdlr((uchar *)"droptrailinglfonreception", eCmdHdlrBinary, NULL, &bDropTrailingLF));
- CHKiRet(regCfSysLineHdlr((uchar *)"template", eCmdHdlrCustomHandler, doNameLine, (void*)DIR_TEMPLATE));
- CHKiRet(regCfSysLineHdlr((uchar *)"outchannel", eCmdHdlrCustomHandler, doNameLine, (void*)DIR_OUTCHANNEL));
- CHKiRet(regCfSysLineHdlr((uchar *)"allowedsender", eCmdHdlrCustomHandler, doNameLine, (void*)DIR_ALLOWEDSENDER));
- CHKiRet(regCfSysLineHdlr((uchar *)"modload", eCmdHdlrCustomHandler, doModLoad, NULL));
- CHKiRet(regCfSysLineHdlr((uchar *)"umask", eCmdHdlrFileCreateMode, setUmask, NULL));
- CHKiRet(regCfSysLineHdlr((uchar *)"debugprinttemplatelist", eCmdHdlrBinary, NULL, &bDebugPrintTemplateList));
- CHKiRet(regCfSysLineHdlr((uchar *)"debugprintmodulelist", eCmdHdlrBinary, NULL, &bDebugPrintModuleList));
- CHKiRet(regCfSysLineHdlr((uchar *)"debugprintcfsyslinehandlerlist", eCmdHdlrBinary,
+ CHKiRet(regCfSysLineHdlr((uchar *)"repeatedmsgreduction", 0, eCmdHdlrBinary, NULL, &bReduceRepeatMsgs));
+ CHKiRet(regCfSysLineHdlr((uchar *)"controlcharacterescapeprefix", 0, eCmdHdlrGetChar, NULL, &cCCEscapeChar));
+ CHKiRet(regCfSysLineHdlr((uchar *)"escapecontrolcharactersonreceive", 0, eCmdHdlrBinary, NULL, &bEscapeCCOnRcv));
+ CHKiRet(regCfSysLineHdlr((uchar *)"dropmsgswithmaliciousdnsptrrecords", 0, eCmdHdlrBinary, NULL, &bDropMalPTRMsgs));
+ CHKiRet(regCfSysLineHdlr((uchar *)"droptrailinglfonreception", 0, eCmdHdlrBinary, NULL, &bDropTrailingLF));
+ CHKiRet(regCfSysLineHdlr((uchar *)"template", 0, eCmdHdlrCustomHandler, doNameLine, (void*)DIR_TEMPLATE));
+ CHKiRet(regCfSysLineHdlr((uchar *)"outchannel", 0, eCmdHdlrCustomHandler, doNameLine, (void*)DIR_OUTCHANNEL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"allowedsender", 0, eCmdHdlrCustomHandler, doNameLine, (void*)DIR_ALLOWEDSENDER));
+ CHKiRet(regCfSysLineHdlr((uchar *)"modload", 0, eCmdHdlrCustomHandler, doModLoad, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"umask", 0, eCmdHdlrFileCreateMode, setUmask, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"debugprinttemplatelist", 0, eCmdHdlrBinary, NULL, &bDebugPrintTemplateList));
+ CHKiRet(regCfSysLineHdlr((uchar *)"debugprintmodulelist", 0, eCmdHdlrBinary, NULL, &bDebugPrintModuleList));
+ CHKiRet(regCfSysLineHdlr((uchar *)"debugprintcfsyslinehandlerlist", 0, eCmdHdlrBinary,
NULL, &bDebugPrintCfSysLineHandlerList));
- CHKiRet(regCfSysLineHdlr((uchar *)"resetconfigvariables", eCmdHdlrCustomHandler, resetConfigVariables, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL));
finalize_it:
return iRet;