summaryrefslogtreecommitdiffstats
path: root/runtime/rsconf.c
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/rsconf.c')
-rw-r--r--runtime/rsconf.c140
1 files changed, 26 insertions, 114 deletions
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
index 118e9c11..dcaa1ad9 100644
--- a/runtime/rsconf.c
+++ b/runtime/rsconf.c
@@ -36,7 +36,6 @@
#include "rsyslog.h"
#include "obj.h"
#include "srUtils.h"
-#include "rule.h"
#include "ruleset.h"
#include "modules.h"
#include "conf.h"
@@ -68,9 +67,9 @@
#include "dirty.h"
#include "template.h"
+extern char* yytext;
/* static data */
DEFobjStaticHelpers
-DEFobjCurrIf(rule)
DEFobjCurrIf(ruleset)
DEFobjCurrIf(module)
DEFobjCurrIf(conf)
@@ -254,54 +253,6 @@ CODESTARTobjDebugPrint(rsconf)
ENDobjDebugPrint(rsconf)
-rsRetVal
-cnfDoActlst(struct cnfactlst *actlst, rule_t *pRule)
-{
- struct cnfcfsyslinelst *cflst;
- action_t *pAction;
- uchar *str;
- rsRetVal localRet;
- DEFiRet;
-
- while(actlst != NULL) {
- dbgprintf("aclst %p: ", actlst);
- if(actlst->actType == CNFACT_V2) {
- dbgprintf("v6+ action object\n");
- if(actionNewInst(actlst->data.lst, &pAction) == RS_RET_OK) {
- iRet = llAppend(&(pRule)->llActList, NULL, (void*) pAction);
- } else {
- errmsg.LogError(0, RS_RET_ERR, "errors occured in file '%s' "
- "around line %d", actlst->cnfFile, actlst->lineno);
- }
- } else {
- DBGPRINTF("legacy action line:%s\n", actlst->data.legActLine);
- str = (uchar*) actlst->data.legActLine;
- if((localRet = cflineDoAction(loadConf, &str, &pAction)) != RS_RET_OK) {
- uchar szErrLoc[MAXFNAME + 64];
- if(localRet != RS_RET_OK_WARN) {
- DBGPRINTF("legacy action line NOT successfully processed\n");
- }
- snprintf((char*)szErrLoc, sizeof(szErrLoc) / sizeof(uchar),
- "%s, line %d", actlst->cnfFile, actlst->lineno);
- errmsg.LogError(0, NO_ERRCODE, "the last %s occured in %s:\"%s\"",
- (localRet == RS_RET_OK_WARN) ? "warning" : "error",
- (char*)szErrLoc, (char*)actlst->data.legActLine);
- if(localRet != RS_RET_OK_WARN) {
- ABORT_FINALIZE(localRet);
- }
- }
- iRet = llAppend(&(pRule)->llActList, NULL, (void*) pAction);
- }
- for( cflst = actlst->syslines
- ; cflst != NULL ; cflst = cflst->next) {
- cnfDoCfsysline(cflst->line);
- }
- actlst = actlst->next;
- }
-finalize_it:
- RETiRet;
-}
-
/* This function returns the current date in different
* variants. It is used to construct the $NOW series of
* system properties. The returned buffer must be freed
@@ -397,15 +348,11 @@ inputProcessCnf(struct cnfobj *o)
pvals = nvlstGetParams(o->nvlst, &inppblk, NULL);
if(pvals == NULL) {
- ABORT_FINALIZE(RS_RET_ERR);
+ ABORT_FINALIZE(RS_RET_CONFIG_ERROR);
}
DBGPRINTF("input param blk after inputProcessCnf:\n");
cnfparamsPrint(&inppblk, pvals);
typeIdx = cnfparamGetIdx(&inppblk, "type");
- if(pvals[typeIdx].bUsed == 0) {
- errmsg.LogError(0, RS_RET_CONF_RQRD_PARAM_MISSING, "input type missing");
- ABORT_FINALIZE(RS_RET_CONF_RQRD_PARAM_MISSING); // TODO: move this into rainerscript handlers
- }
cnfModName = (uchar*)es_str2cstr(pvals[typeIdx].val.d.estr, NULL);
if((pMod = module.FindWithCnfName(loadConf, cnfModName, eMOD_IN)) == NULL) {
errmsg.LogError(0, RS_RET_MOD_UNKNOWN, "input module name '%s' is unknown", cnfModName);
@@ -435,9 +382,6 @@ parser_errmsg(char *fmt, ...)
va_start(ap, fmt);
if(vsnprintf(errBuf, sizeof(errBuf), fmt, ap) == sizeof(errBuf))
errBuf[sizeof(errBuf)-1] = '\0';
-dbgprintf("XXXX: msg: %s\n", errBuf);
-dbgprintf("XXXX: cnfcurrfn: %s\n", cnfcurrfn);
-dbgprintf("XXXX: yylineno: %d\n", yylineno);
errmsg.LogError(0, RS_RET_CONF_PARSE_ERROR,
"error during parsing file %s, on or before line %d: %s",
cnfcurrfn, yylineno, errBuf);
@@ -447,7 +391,7 @@ dbgprintf("XXXX: yylineno: %d\n", yylineno);
int
yyerror(char *s)
{
- parser_errmsg("%s", s);
+ parser_errmsg("%s on token '%s'", s, yytext);
return 0;
}
void cnfDoObj(struct cnfobj *o)
@@ -463,75 +407,34 @@ void cnfDoObj(struct cnfobj *o)
case CNFOBJ_MODULE:
modulesProcessCnf(o);
break;
- case CNFOBJ_ACTION:
- actionProcessCnf(o);
- break;
case CNFOBJ_INPUT:
inputProcessCnf(o);
break;
case CNFOBJ_TPL:
tplProcessCnf(o);
break;
+ case CNFOBJ_RULESET:
+ rulesetProcessCnf(o);
+ break;
case CNFOBJ_PROPERTY:
case CNFOBJ_CONSTANT:
/* these types are processed at a later stage */
bChkUnuse = 0;
break;
+ default:
+ dbgprintf("cnfDoObj program error: unexpected object type %u\n",
+ o->objType);
+ break;
}
if(bChkUnuse)
nvlstChkUnused(o->nvlst);
cnfobjDestruct(o);
}
-void cnfDoRule(struct cnfrule *cnfrule)
+void cnfDoScript(struct cnfstmt *script)
{
- rule_t *pRule;
- uchar *str;
- rsRetVal iRet = RS_RET_OK; //DEFiRet;
-
- dbgprintf("cnf:global:rule\n");
- cnfrulePrint(cnfrule);
-
- CHKiRet(rule.Construct(&pRule)); /* create "fresh" selector */
- CHKiRet(rule.SetAssRuleset(pRule, ruleset.GetCurrent(loadConf)));
- CHKiRet(rule.ConstructFinalize(pRule));
-
- switch(cnfrule->filttype) {
- case CNFFILT_NONE:
- break;
- case CNFFILT_PRI:
- str = (uchar*) cnfrule->filt.s;
- iRet = cflineProcessTradPRIFilter(&str, pRule);
- break;
- case CNFFILT_PROP:
- dbgprintf("%s\n", cnfrule->filt.s);
- str = (uchar*) cnfrule->filt.s;
- iRet = cflineProcessPropFilter(&str, pRule);
- break;
- case CNFFILT_SCRIPT:
- pRule->f_filter_type = FILTER_EXPR;
- pRule->f_filterData.expr = cnfrule->filt.expr;
- break;
- }
- /* we now check if there are some global (BSD-style) filter conditions
- * and, if so, we copy them over. rgerhards, 2005-10-18
- */
- if(pDfltProgNameCmp != NULL) {
- CHKiRet(rsCStrConstructFromCStr(&(pRule->pCSProgNameComp), pDfltProgNameCmp));
- }
-
- if(eDfltHostnameCmpMode != HN_NO_COMP) {
- pRule->eHostnameCmpMode = eDfltHostnameCmpMode;
- CHKiRet(rsCStrConstructFromCStr(&(pRule->pCSHostnameComp), pDfltHostnameCmp));
- }
-
- cnfDoActlst(cnfrule->actlst, pRule);
-
- CHKiRet(ruleset.AddRule(rule.GetAssRuleset(pRule), &pRule));
-
-finalize_it:
- //TODO: do something with error states
- cnfruleDestruct(cnfrule);
+ dbgprintf("cnf:global:script\n");
+ ruleset.AddScript(ruleset.GetCurrent(loadConf), script);
}
void cnfDoCfsysline(char *ln)
@@ -545,13 +448,21 @@ void cnfDoCfsysline(char *ln)
void cnfDoBSDTag(char *ln)
{
DBGPRINTF("cnf:global:BSD tag: %s\n", ln);
- cflineProcessTagSelector((uchar**)&ln);
+ errmsg.LogError(0, RS_RET_BSD_BLOCKS_UNSUPPORTED,
+ "BSD-style blocks are no longer supported in rsyslog, "
+ "see http://www.rsyslog.com/g/BSD for details and a "
+ "solution (Block '%s')", ln);
+ free(ln);
}
void cnfDoBSDHost(char *ln)
{
DBGPRINTF("cnf:global:BSD host: %s\n", ln);
- cflineProcessHostSelector((uchar**)&ln);
+ errmsg.LogError(0, RS_RET_BSD_BLOCKS_UNSUPPORTED,
+ "BSD-style blocks are no longer supported in rsyslog, "
+ "see http://www.rsyslog.com/g/BSD for details and a "
+ "solution (Block '%s')", ln);
+ free(ln);
}
es_str_t*
@@ -961,6 +872,7 @@ setCurrRuleset(void __attribute__((unused)) *pVal, uchar *pszName)
CHKiRet(ruleset.Construct(&pRuleset));
CHKiRet(ruleset.SetName(pRuleset, pszName));
CHKiRet(ruleset.ConstructFinalize(ourConf, pRuleset));
+ rulesetSetCurrRulesetPtr(pRuleset);
} else {
ABORT_FINALIZE(localRet);
}
@@ -1162,6 +1074,7 @@ initLegacyConf(void)
ruleset.Construct(&pRuleset);
ruleset.SetName(pRuleset, UCHAR_CONSTANT("RSYSLOG_DefaultRuleset"));
ruleset.ConstructFinalize(loadConf, pRuleset);
+ rulesetSetCurrRulesetPtr(pRuleset);
/* now register config handlers */
CHKiRet(regCfSysLineHdlr((uchar *)"sleep", 0, eCmdHdlrGoneAway,
@@ -1378,6 +1291,7 @@ ourConf = loadConf; // TODO: remove, once ourConf is gone!
ABORT_FINALIZE(RS_RET_NO_ACTIONS);
}
tellLexEndParsing();
+ rulesetOptimizeAll(loadConf);
tellCoreConfigLoadDone();
tellModulesConfigLoadDone();
@@ -1436,7 +1350,6 @@ ENDobjQueryInterface(rsconf)
BEGINObjClassInit(rsconf, 1, OBJ_IS_CORE_MODULE) /* class, version */
/* request objects we use */
CHKiRet(objUse(ruleset, CORE_COMPONENT));
- CHKiRet(objUse(rule, CORE_COMPONENT));
CHKiRet(objUse(module, CORE_COMPONENT));
CHKiRet(objUse(conf, CORE_COMPONENT));
CHKiRet(objUse(errmsg, CORE_COMPONENT));
@@ -1453,7 +1366,6 @@ ENDObjClassInit(rsconf)
/* De-initialize the rsconf class.
*/
BEGINObjClassExit(rsconf, OBJ_IS_CORE_MODULE) /* class, version */
- objRelease(rule, CORE_COMPONENT);
objRelease(ruleset, CORE_COMPONENT);
objRelease(module, CORE_COMPONENT);
objRelease(conf, CORE_COMPONENT);