summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-07-20 17:37:44 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-07-20 17:37:44 +0200
commit5820c5f3e8dc69bdee969d6487d084e884595069 (patch)
treec44cda2313dd8ae3d1f415e864500a747ac4b23c
parent686540cebee2920341911860c0019e687174daa8 (diff)
downloadrsyslog-5820c5f3e8dc69bdee969d6487d084e884595069.tar.gz
rsyslog-5820c5f3e8dc69bdee969d6487d084e884595069.tar.xz
rsyslog-5820c5f3e8dc69bdee969d6487d084e884595069.zip
milestone: done plumbing to call plugin create action instance entry point
-rw-r--r--action.c100
-rw-r--r--action.h1
-rw-r--r--configure.ac2
-rw-r--r--grammar/rainerscript.c5
-rw-r--r--runtime/conf.c40
-rw-r--r--runtime/modules.c22
-rw-r--r--runtime/modules.h3
-rw-r--r--runtime/rsconf.c6
-rw-r--r--runtime/rsyslog.h2
9 files changed, 135 insertions, 46 deletions
diff --git a/action.c b/action.c
index 0fb660bb..f24fee06 100644
--- a/action.c
+++ b/action.c
@@ -178,6 +178,51 @@ configSettings_t cs_save; /* our saved (scope!) config settings */
*/
static int iActionNbr = 0;
+/* tables for interfacing with the v6 config system */
+static struct cnfparamdescr cnfparamdescr[] = {
+ { "name", eCmdHdlrGetWord, 0 }, /* legacy: actionname */
+ { "type", eCmdHdlrString, CNFPARAM_REQUIRED }, /* legacy: actionname */
+ { "action.writeallmarkmessages", eCmdHdlrBinary, 0 }, /* legacy: actionwriteallmarkmessages */
+ { "action.execonlyeverynthtime", eCmdHdlrInt, 0 }, /* legacy: actionexeconlyeverynthtime */
+ { "action.execonlyeverynthtimetimeout", eCmdHdlrInt, 0 }, /* legacy: actionexeconlyeverynthtimetimeout */
+ { "action.execonlyonceeveryinterval", eCmdHdlrInt, 0 }, /* legacy: actionexeconlyonceeveryinterval */
+ { "action.execonlywhenpreviousissuspended", eCmdHdlrInt, 0 }, /* legacy: actionexeconlywhenpreviousissuspended */
+ { "action.repeatedmsgcontainsoriginalmsg", eCmdHdlrBinary, 0 }, /* legacy: repeatedmsgcontainsoriginalmsg */
+ { "action.resumeretrycount ", eCmdHdlrGetWord, 0 } /* legacy: actionresumeretrycount */
+ //{ "", eCmdHdlrGetWord, 0 }, /* legacy: */
+};
+static struct cnfparamblk paramblk =
+ { CNFPARAMBLK_VERSION,
+ sizeof(cnfparamdescr)/sizeof(struct cnfparamdescr),
+ cnfparamdescr
+ };
+
+/* Still TODO: */
+#if 0
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuefilename", 0, eCmdHdlrGetWord, NULL, &cs.pszActionQFName, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuesize", 0, eCmdHdlrInt, NULL, &cs.iActionQueueSize, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuedequeuebatchsize", 0, eCmdHdlrInt, NULL, &cs.iActionQueueDeqBatchSize, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuemaxdiskspace", 0, eCmdHdlrSize, NULL, &cs.iActionQueMaxDiskSpace, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuehighwatermark", 0, eCmdHdlrInt, NULL, &cs.iActionQHighWtrMark, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuelowwatermark", 0, eCmdHdlrInt, NULL, &cs.iActionQLowWtrMark, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuediscardmark", 0, eCmdHdlrInt, NULL, &cs.iActionQDiscardMark, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuediscardseverity", 0, eCmdHdlrInt, NULL, &cs.iActionQDiscardSeverity, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuecheckpointinterval", 0, eCmdHdlrInt, NULL, &cs.iActionQPersistUpdCnt, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuesyncqueuefiles", 0, eCmdHdlrBinary, NULL, &cs.bActionQSyncQeueFiles, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuetype", 0, eCmdHdlrGetWord, setActionQueType, NULL, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueueworkerthreads", 0, eCmdHdlrInt, NULL, &cs.iActionQueueNumWorkers, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuetimeoutshutdown", 0, eCmdHdlrInt, NULL, &cs.iActionQtoQShutdown, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuetimeoutactioncompletion", 0, eCmdHdlrInt, NULL, &cs.iActionQtoActShutdown, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuetimeoutenqueue", 0, eCmdHdlrInt, NULL, &cs.iActionQtoEnq, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueueworkertimeoutthreadshutdown", 0, eCmdHdlrInt, NULL, &cs.iActionQtoWrkShutdown, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueueworkerthreadminimummessages", 0, eCmdHdlrInt, NULL, &cs.iActionQWrkMinMsgs, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuemaxfilesize", 0, eCmdHdlrSize, NULL, &cs.iActionQueMaxFileSize, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuesaveonshutdown", 0, eCmdHdlrBinary, NULL, &cs.bActionQSaveOnShutdown, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuedequeueslowdown", 0, eCmdHdlrInt, NULL, &cs.iActionQueueDeqSlowdown, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuedequeuetimebegin", 0, eCmdHdlrInt, NULL, &cs.iActionQueueDeqtWinFromHr, NULL, eConfObjAction));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuedequeuetimeend", 0, eCmdHdlrInt, NULL, &cs.iActionQueueDeqtWinToHr, NULL, eConfObjAction));
+#endif
+
/* ------------------------------ methods ------------------------------ */
/* This function returns the "current" time for this action. Current time
@@ -1889,6 +1934,61 @@ actionRestoreScope(void)
+rsRetVal
+actionNewInst(struct nvlst *lst, action_t **ppAction)
+{
+ struct cnfparamvals *paramvals;
+ modInfo_t *pMod;
+ uchar *cnfModName = NULL;
+ DEFiRet;
+
+ paramvals = nvlstGetParams(lst, &paramblk, NULL);
+ if(paramvals == NULL) {
+ iRet = RS_RET_ERR;
+ goto finalize_it;
+ }
+ dbgprintf("action param blk after actionNewInst:\n");
+ cnfparamsPrint(&paramblk, paramvals);
+ if(paramvals[cnfparamGetIdx(&paramblk, "type")].bUsed == 0) {
+ ABORT_FINALIZE(RS_RET_CONF_RQRD_PARAM_MISSING); // TODO: move this into rainerscript handlers
+ }
+ cnfModName = (uchar*)es_str2cstr(paramvals[cnfparamGetIdx(&paramblk, ("type"))].val.d.estr, NULL);
+ if((pMod = module.FindWithCnfName(loadConf, cnfModName, eMOD_OUT)) == NULL) {
+ errmsg.LogError(0, RS_RET_MOD_UNKNOWN, "module name '%s' is unknown", cnfModName);
+ ABORT_FINALIZE(RS_RET_MOD_UNKNOWN);
+ }
+dbgprintf("XXXX:actionNewInst for module '%s'/%p\n", cnfModName, pMod);
+finalize_it:
+ free(cnfModName);
+ RETiRet;
+}
+
+
+/* Process a rsyslog v6 action config object (the now-primary config method).
+ * rgerhards, 2011-07-19
+ */
+rsRetVal
+actionProcessCnf(struct cnfobj *o)
+{
+ DEFiRet;
+#if 0 /* we need to check if we actually need this functionality -- later! */
+ struct cnfparamvals *paramvals;
+
+ paramvals = nvlstGetParams(o->nvlst, &paramblk, NULL);
+ if(paramvals == NULL) {
+ iRet = RS_RET_ERR;
+ goto finalize_it;
+ }
+ DBGPRINTF("action param blk after actionProcessCnf:\n");
+ cnfparamsPrint(&paramblk, paramvals);
+
+ /* now find module to activate */
+finalize_it:
+#endif
+ RETiRet;
+}
+
+
/* TODO: we are not yet a real object, the ClassInit here just looks like it is..
*/
rsRetVal actionClassInit(void)
diff --git a/action.h b/action.h
index 253514df..4d56106b 100644
--- a/action.h
+++ b/action.h
@@ -107,5 +107,6 @@ rsRetVal addAction(action_t **ppAction, modInfo_t *pMod, void *pModData, omodStr
rsRetVal actionNewScope(void);
rsRetVal actionRestoreScope(void);
rsRetVal activateActions(void);
+rsRetVal actionNewInst(struct nvlst *lst, action_t **ppAction);
#endif /* #ifndef ACTION_H_INCLUDED */
diff --git a/configure.ac b/configure.ac
index 0093d860..48e6a94e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,7 +38,7 @@ AC_CANONICAL_HOST
PKG_PROG_PKG_CONFIG
# modules we require
-PKG_CHECK_MODULES(LIBESTR, libestr >= 0.1.1)
+PKG_CHECK_MODULES(LIBESTR, libestr >= 0.1.2)
PKG_CHECK_MODULES(LIBEE, libee >= 0.3.1)
case "${host}" in
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c
index 76e3a0a4..c953c840 100644
--- a/grammar/rainerscript.c
+++ b/grammar/rainerscript.c
@@ -146,14 +146,15 @@ nvlstFindName(struct nvlst *lst, es_str_t *name)
}
-/* find a name starting at node lst. SAme as nvlstFindName, but
+/* find a name starting at node lst. Same as nvlstFindName, but
* for classical C strings. This is useful because the config system
* uses C string constants.
*/
static inline struct nvlst*
nvlstFindNameCStr(struct nvlst *lst, char *name)
{
- while(lst != NULL && es_strbufcmp(lst->name, (uchar*)name, strlen(name)))
+ es_size_t lenName = strlen(name);
+ while(lst != NULL && es_strcasebufcmp(lst->name, (uchar*)name, lenName))
lst = lst->next;
return lst;
}
diff --git a/runtime/conf.c b/runtime/conf.c
index 1757c944..6136262e 100644
--- a/runtime/conf.c
+++ b/runtime/conf.c
@@ -708,46 +708,6 @@ finalize_it:
}
-#if 0
-/* read the filter part of a configuration line and store the filter
- * in the supplied rule_t
- * rgerhards, 2007-08-01
- */
-static rsRetVal cflineDoFilter(uchar **pp, rule_t *f)
-{
- DEFiRet;
-
- ASSERT(pp != NULL);
- ISOBJ_TYPE_assert(f, rule);
-
- /* check which filter we need to pull... */
- switch(**pp) {
- case ':':
- CHKiRet(cflineProcessPropFilter(pp, f));
- break;
- default:
- CHKiRet(cflineProcessTradPRIFilter(pp, f));
- 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(&(f->pCSProgNameComp), pDfltProgNameCmp));
- }
-
- if(eDfltHostnameCmpMode != HN_NO_COMP) {
- f->eHostnameCmpMode = eDfltHostnameCmpMode;
- CHKiRet(rsCStrConstructFromCStr(&(f->pCSHostnameComp), pDfltHostnameCmp));
- }
-
-finalize_it:
- RETiRet;
-}
-#endif
-
-
/* process the action part of a selector line
* rgerhards, 2007-08-01
*/
diff --git a/runtime/modules.c b/runtime/modules.c
index d09ba770..59eaec34 100644
--- a/runtime/modules.c
+++ b/runtime/modules.c
@@ -427,7 +427,7 @@ static cfgmodules_etry_t
if(rqtdType != eMOD_ANY) { /* if any, we already have the right one! */
while(node != NULL && node->pMod->eType != rqtdType) {
- node = node->next; /* warning: do ... while() */
+ node = node->next;
}
}
@@ -435,6 +435,25 @@ static cfgmodules_etry_t
}
+/* Find a module with the given conf name and type. Returns NULL if none
+ * can be found, otherwise module found.
+ */
+static modInfo_t *
+FindWithCnfName(rsconf_t *cnf, uchar *name, eModType_t rqtdType)
+{
+ cfgmodules_etry_t *node;
+
+ node = cnf->modules.root;
+ while(node != NULL && node->pMod->eType != rqtdType) {
+ if(!strcasecmp((char*)node->pMod->cnfName, (char*)name))
+ break;
+ node = node->next;
+ }
+
+ return node == NULL ? NULL : node->pMod;
+}
+
+
/* Prepare a module for unloading.
* This is currently a dummy, to be filled when we have a plug-in
* interface - rgerhards, 2007-08-09
@@ -1179,6 +1198,7 @@ CODESTARTobjQueryInterface(module)
pIf->GetName = modGetName;
pIf->GetStateName = modGetStateName;
pIf->PrintList = modPrintList;
+ pIf->FindWithCnfName = FindWithCnfName;
pIf->UnloadAndDestructAll = modUnloadAndDestructAll;
pIf->doModInit = doModInit;
pIf->SetModDir = SetModDir;
diff --git a/runtime/modules.h b/runtime/modules.h
index 1579fb86..ebde1219 100644
--- a/runtime/modules.h
+++ b/runtime/modules.h
@@ -174,8 +174,9 @@ BEGINinterface(module) /* name must also be changed in ENDinterface macro! */
rsRetVal (*doModInit)(rsRetVal (*modInit)(), uchar *name, void *pModHdlr, modInfo_t **pNew);
rsRetVal (*Load)(uchar *name, sbool bConfLoad);
rsRetVal (*SetModDir)(uchar *name);
+ modInfo_t *(*FindWithCnfName)(rsconf_t *cnf, uchar *name, eModType_t rqtdType); /* added v3, 2011-07-19 */
ENDinterface(module)
-#define moduleCURR_IF_VERSION 2 /* increment whenever you change the interface structure! */
+#define moduleCURR_IF_VERSION 3 /* increment whenever you change the interface structure! */
/* Changes:
* v2
* - added param bCondLoad to Load call - 2011-04-27
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
index 26105e88..4fe17534 100644
--- a/runtime/rsconf.c
+++ b/runtime/rsconf.c
@@ -230,7 +230,8 @@ cnfDoActlst(struct cnfactlst *actlst, rule_t *pRule)
while(actlst != NULL) {
dbgprintf("aclst %p: ", actlst);
if(actlst->actType == CNFACT_V2) {
- dbgprintf("V2 action type not yet handled\n");
+ dbgprintf("v6+ action object\n");
+ actionNewInst(actlst->data.lst, &pAction);
} else {
dbgprintf("legacy action line:%s\n", actlst->data.legActLine);
str = (uchar*) actlst->data.legActLine;
@@ -360,6 +361,9 @@ void cnfDoObj(struct cnfobj *o)
case CNFOBJ_GLOBAL:
glblProcessCnf(o);
break;
+ case CNFOBJ_ACTION:
+ actionProcessCnf(o);
+ break;
}
nvlstChkUnused(o->nvlst);
cnfobjDestruct(o);
diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h
index 39f00ebc..dc2f15be 100644
--- a/runtime/rsyslog.h
+++ b/runtime/rsyslog.h
@@ -361,6 +361,8 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth
RS_RET_ERR_SCHED_PARAMS = -2205,/**< there is a problem with configured thread scheduling params */
RS_RET_SOCKNAME_MISSING = -2206,/**< no socket name configured where one is required */
RS_RET_CONF_PARSE_ERROR = -2207,/**< (fatal) error parsing config file */
+ RS_RET_CONF_RQRD_PARAM_MISSING = -2208,/**< required parameter in config object is missing */
+ RS_RET_MOD_UNKNOWN = -2209,/**< module (config name) is unknown */
/* RainerScript error messages (range 1000.. 1999) */
RS_RET_SYSVAR_NOT_FOUND = 1001, /**< system variable could not be found (maybe misspelled) */