summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--grammar/rainerscript.c2
-rw-r--r--grammar/rainerscript.h1
-rw-r--r--runtime/glbl.c54
-rw-r--r--runtime/glbl.h4
-rw-r--r--runtime/rsconf.c19
5 files changed, 77 insertions, 3 deletions
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c
index 502deece..92b07a5f 100644
--- a/grammar/rainerscript.c
+++ b/grammar/rainerscript.c
@@ -158,6 +158,7 @@ nvlstFindNameCStr(struct nvlst *lst, char *name)
return lst;
}
+
/* check if there are duplicate names inside a nvlst and emit
* an error message, if so.
*/
@@ -247,6 +248,7 @@ nvlstGetParam(struct nvlst *valnode, struct cnfparamdescr *param,
{
dbgprintf("XXXX: in nvlstGetParam, name '%s', type %d\n",
param->name, (int) param->type);
+ valnode->bUsed = 1;
val->bUsed = 1;
switch(param->type) {
case eCmdHdlrUID:
diff --git a/grammar/rainerscript.h b/grammar/rainerscript.h
index 03e59895..f7454ef5 100644
--- a/grammar/rainerscript.h
+++ b/grammar/rainerscript.h
@@ -217,6 +217,7 @@ void readConfFile(FILE *fp, es_str_t **str);
struct nvlst* nvlstNew(es_str_t *name, es_str_t *value);
void nvlstDestruct(struct nvlst *lst);
void nvlstPrint(struct nvlst *lst);
+void nvlstChkUnused(struct nvlst *lst);
struct nvlst* nvlstFindName(struct nvlst *lst, es_str_t *name);
struct cnfobj* cnfobjNew(enum cnfobjType objType, struct nvlst *lst);
void cnfobjDestruct(struct cnfobj *o);
diff --git a/runtime/glbl.c b/runtime/glbl.c
index 4ca99303..6b7d487f 100644
--- a/runtime/glbl.c
+++ b/runtime/glbl.c
@@ -430,6 +430,15 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
}
+/* Prepare for new config
+ */
+void
+glblPrepCnf(void)
+{
+ free(cnfparamvals);
+ cnfparamvals = NULL;
+}
+
/* handle a global config object. Note that multiple global config statements
* are permitted (because of plugin support), so once we got a param block,
* we need to hold to it.
@@ -443,6 +452,51 @@ glblProcessCnf(struct cnfobj *o)
cnfparamsPrint(&paramblk, cnfparamvals);
}
+rsRetVal
+glblCheckCnf()
+{
+}
+
+void
+glblDoneLoadCnf()
+{
+ int i;
+ unsigned char *cstr;
+
+ for(i = 0 ; i < paramblk.nParams ; ++i) {
+ if(!cnfparamvals[i].bUsed)
+ continue;
+ if(!strcmp(paramblk.descr[i].name, "workdirectory")) {
+ cstr = (uchar*) es_str2cstr(cnfparamvals[i].val.d.estr, NULL);
+ setWorkDir(NULL, cstr);
+ } else if(!strcmp(paramblk.descr[i].name, "localhostname")) {
+ free(LocalHostNameOverride);
+ LocalHostNameOverride = (uchar*)
+ es_str2cstr(cnfparamvals[i].val.d.estr, NULL);
+ } else if(!strcmp(paramblk.descr[i].name, "defaultnetstreamdriverkeyfile")) {
+ free(pszDfltNetstrmDrvrKeyFile);
+ pszDfltNetstrmDrvrKeyFile = (uchar*)
+ es_str2cstr(cnfparamvals[i].val.d.estr, NULL);
+ } else if(!strcmp(paramblk.descr[i].name, "defaultnetstreamdrivercafile")) {
+ free(pszDfltNetstrmDrvrCAF);
+ pszDfltNetstrmDrvrCAF = (uchar*)
+ es_str2cstr(cnfparamvals[i].val.d.estr, NULL);
+ } else if(!strcmp(paramblk.descr[i].name, "defaultnetstreamdriver")) {
+ free(pszDfltNetstrmDrvr);
+ pszDfltNetstrmDrvr = (uchar*)
+ es_str2cstr(cnfparamvals[i].val.d.estr, NULL);
+ } else if(!strcmp(paramblk.descr[i].name, "preservefqdn")) {
+ bPreserveFQDN = (int) cnfparamvals[i].val.d.n;
+ } else if(!strcmp(paramblk.descr[i].name,
+ "dropmsgswithmaliciousdnsptrrecords")) {
+ bDropMalPTRMsgs = (int) cnfparamvals[i].val.d.n;
+ } else {
+ dbgprintf("glblDoneLoadCnf: program error, non-handled "
+ "param '%s'\n", paramblk.descr[i].name);
+ }
+ }
+}
+
/* Initialize the glbl class. Must be called as the very first method
* before anything else is called inside this class.
diff --git a/runtime/glbl.h b/runtime/glbl.h
index 82bd1a7a..94eec23d 100644
--- a/runtime/glbl.h
+++ b/runtime/glbl.h
@@ -32,6 +32,7 @@
#ifndef GLBL_H_INCLUDED
#define GLBL_H_INCLUDED
+#include "rainerscript.h"
#include "prop.h"
#define glblGetIOBufSize() 4096 /* size of the IO buffer, e.g. for strm class */
@@ -85,4 +86,7 @@ ENDinterface(glbl)
/* the remaining prototypes */
PROTOTYPEObj(glbl);
+void glblPrepCnf(void);
+void glblProcessCnf(struct cnfobj *o);
+
#endif /* #ifndef GLBL_H_INCLUDED */
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
index aa7a3e3b..fd42caf9 100644
--- a/runtime/rsconf.c
+++ b/runtime/rsconf.c
@@ -361,6 +361,7 @@ void cnfDoObj(struct cnfobj *o)
glblProcessCnf(o);
break;
}
+ nvlstChkUnused(o->nvlst);
cnfobjDestruct(o);
}
@@ -542,6 +543,16 @@ dropPrivileges(rsconf_t *cnf)
}
+/* tell the rsysog core (including ourselfs) that the config load is done and
+ * we need to prepare to move over to activate mode.
+ */
+static inline void
+tellCoreConfigLoadDone(void)
+{
+ glblDoneLoadCnf();
+}
+
+
/* Tell input modules that the config parsing stage is over. */
static rsRetVal
tellModulesConfigLoadDone(void)
@@ -755,9 +766,7 @@ activate(rsconf_t *cnf)
if(ourConf->globals.pszConfDAGFile != NULL)
generateConfigDAG(ourConf->globals.pszConfDAGFile);
# endif
- tellModulesConfigLoadDone();
setUmask(cnf->globals.umask);
- tellModulesCheckConfig();
/* the output part and the queue is now ready to run. So it is a good time
* to initialize the inputs. Please note that the net code above should be
@@ -911,7 +920,7 @@ finalize_it:
}
-/* legac config system: reset config variables to default values. */
+/* legacy config system: reset config variables to default values. */
static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal)
{
loadConf->globals.bLogStatusMsgs = DFLT_bLogStatusMsgs;
@@ -1251,6 +1260,10 @@ ourConf = loadConf; // TODO: remove, once ourConf is gone!
ABORT_FINALIZE(RS_RET_NO_ACTIONS);
}
+ tellCoreConfigLoadDone();
+ tellModulesConfigLoadDone();
+
+ tellModulesCheckConfig();
CHKiRet(validateConf());
/* we are done checking the config - now validate if we should actually run or not.