summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-04-21 14:27:41 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-04-21 14:27:41 +0200
commit13ecf8a6ef5a5b69819865a2b9b524d4c561f5de (patch)
tree9de0040d5d4af84c980c19b0aa64de7551b063e8 /runtime
parent82fa17ae5621849790eb39ed046d58333ede347c (diff)
downloadrsyslog-13ecf8a6ef5a5b69819865a2b9b524d4c561f5de.tar.gz
rsyslog-13ecf8a6ef5a5b69819865a2b9b524d4c561f5de.tar.xz
rsyslog-13ecf8a6ef5a5b69819865a2b9b524d4c561f5de.zip
step: config handler setting from syslogd.c moved to rsconf.c
Diffstat (limited to 'runtime')
-rw-r--r--runtime/cfsysline.c4
-rw-r--r--runtime/conf.c6
-rw-r--r--runtime/conf.h2
-rw-r--r--runtime/modules.c9
-rw-r--r--runtime/modules.h3
-rw-r--r--runtime/rsconf.c386
-rw-r--r--runtime/rsconf.h41
-rw-r--r--runtime/typedefs.h1
8 files changed, 437 insertions, 15 deletions
diff --git a/runtime/cfsysline.c b/runtime/cfsysline.c
index 2475c270..f6581ccd 100644
--- a/runtime/cfsysline.c
+++ b/runtime/cfsysline.c
@@ -587,7 +587,9 @@ doFacility(uchar **pp, rsRetVal (*pSetHdlr)(void*, int), void *pVal)
static rsRetVal
-doGoneAway(uchar **pp, rsRetVal (*pSetHdlr)(void*, int), void *pVal)
+doGoneAway(__attribute__((unused)) uchar **pp,
+ __attribute__((unused)) rsRetVal (*pSetHdlr)(void*, int),
+ __attribute__((unused)) void *pVal)
{
errmsg.LogError(0, RS_RET_CMD_GONE_AWAY, "config directive is no longer supported -- ignored");
return RS_RET_CMD_GONE_AWAY;
diff --git a/runtime/conf.c b/runtime/conf.c
index 8e05609d..9fecc34d 100644
--- a/runtime/conf.c
+++ b/runtime/conf.c
@@ -296,7 +296,7 @@ finalize_it:
* generalized.
*/
rsRetVal
-doNameLine(rsconf_t *conf, uchar **pp, void* pVal)
+doNameLine(uchar **pp, void* pVal)
{
DEFiRet;
uchar *p;
@@ -324,7 +324,7 @@ doNameLine(rsconf_t *conf, uchar **pp, void* pVal)
switch(eDir) {
case DIR_TEMPLATE:
- tplAddLine(ourConf, szName, &p);
+ tplAddLine(loadConf, szName, &p);
break;
case DIR_OUTCHANNEL:
ochAddLine(szName, &p);
@@ -1125,7 +1125,7 @@ static rsRetVal cflineDoAction(rsconf_t *conf, uchar **p, action_t **ppAction)
if((iRet = addAction(&pAction, pMod, pModData, pOMSR, (iRet == RS_RET_SUSPENDED)? 1 : 0)) == RS_RET_OK) {
/* now check if the module is compatible with select features */
if(pMod->isCompatibleWithFeature(sFEATURERepeatedMsgReduction) == RS_RET_OK)
- pAction->f_ReduceRepeated = bReduceRepeatMsgs;
+ pAction->f_ReduceRepeated = loadConf->globals.bReduceRepeatMsgs;
else {
dbgprintf("module is incompatible with RepeatedMsgReduction - turned off\n");
pAction->f_ReduceRepeated = 0;
diff --git a/runtime/conf.h b/runtime/conf.h
index 3b3d488b..c169a9c0 100644
--- a/runtime/conf.h
+++ b/runtime/conf.h
@@ -33,7 +33,7 @@ extern int bConfStrictScoping; /* force strict scoping during config processing?
/* interfaces */
BEGINinterface(conf) /* name must also be changed in ENDinterface macro! */
- rsRetVal (*doNameLine)(rsconf_t *conf, uchar **pp, void* pVal);
+ rsRetVal (*doNameLine)(uchar **pp, void* pVal);
rsRetVal (*cfsysline)(rsconf_t *conf, uchar *p);
rsRetVal (*doModLoad)(rsconf_t *conf, uchar **pp, __attribute__((unused)) void* pVal);
rsRetVal (*doIncludeLine)(rsconf_t *conf, uchar **pp, __attribute__((unused)) void* pVal);
diff --git a/runtime/modules.c b/runtime/modules.c
index 8ede134b..7389909d 100644
--- a/runtime/modules.c
+++ b/runtime/modules.c
@@ -55,6 +55,7 @@
#endif
#include "cfsysline.h"
+#include "rsconf.h"
#include "modules.h"
#include "errmsg.h"
#include "parser.h"
@@ -80,9 +81,7 @@ static modInfo_t *pLoadedModulesLast = NULL; /* tail-pointer */
/* already dlopen()-ed libs */
static struct dlhandle_s *pHandles = NULL;
-/* config settings */
-uchar *pModDir = NULL; /* read-only after startup */
-
+static uchar *pModDir; /* directory where loadable modules are found */
/* we provide a set of dummy functions for modules that do not support the
* some interfaces.
@@ -801,7 +800,8 @@ Load(uchar *pModName)
pModInfo = GetNxt(pModInfo);
}
- pModDirCurr = (uchar *)((pModDir == NULL) ? _PATH_MODDIR : (char *)pModDir);
+ pModDirCurr = (uchar *)((pModDir == NULL) ?
+ _PATH_MODDIR : (char *)pModDir);
pModDirNext = NULL;
pModHdlr = NULL;
iLoadCnt = 0;
@@ -1013,6 +1013,7 @@ CODESTARTObjClassExit(module)
* TODO: add again: pthread_mutex_destroy(&mutLoadUnload);
*/
+ free(pModDir);
# ifdef DEBUG
modUsrPrintAll(); /* debug aid - TODO: integrate with debug.c, at least the settings! */
# endif
diff --git a/runtime/modules.h b/runtime/modules.h
index c1c38a26..08e0851c 100644
--- a/runtime/modules.h
+++ b/runtime/modules.h
@@ -175,7 +175,4 @@ ENDinterface(module)
/* prototypes */
PROTOTYPEObj(module);
-/* TODO: remove them below (means move the config init code) -- rgerhards, 2008-02-19 */
-extern uchar *pModDir; /* read-only after startup */
-
#endif /* #ifndef MODULES_H_INCLUDED */
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
index 1f7a46c3..bebe77dd 100644
--- a/runtime/rsconf.c
+++ b/runtime/rsconf.c
@@ -29,6 +29,9 @@
#include <assert.h>
#include <string.h>
#include <errno.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "rsyslog.h"
#include "obj.h"
@@ -36,9 +39,12 @@
#include "ruleset.h"
#include "modules.h"
#include "conf.h"
+#include "queue.h"
#include "rsconf.h"
#include "cfsysline.h"
#include "errmsg.h"
+#include "action.h"
+#include "glbl.h"
#include "unicode-helper.h"
/* static data */
@@ -47,6 +53,7 @@ DEFobjCurrIf(ruleset)
DEFobjCurrIf(module)
DEFobjCurrIf(conf)
DEFobjCurrIf(errmsg)
+DEFobjCurrIf(glbl)
/* exported static data */
rsconf_t *runConf = NULL;/* the currently running config */
@@ -64,7 +71,32 @@ BEGINobjConstruct(rsconf) /* be sure to specify the object type also in END macr
pThis->templates.last = NULL;
pThis->templates.lastStatic = NULL;
pThis->actions.nbrActions = 0;
- CHKiRet(llInit(&pThis->rulesets.llRulesets, rulesetDestructForLinkedList, rulesetKeyDestruct, strcasecmp));
+ CHKiRet(llInit(&pThis->rulesets.llRulesets, rulesetDestructForLinkedList,
+ rulesetKeyDestruct, strcasecmp));
+ /* queue params */
+ pThis->globals.mainQ.iMainMsgQueueSize = 10000;
+ pThis->globals.mainQ.iMainMsgQHighWtrMark = 8000;
+ pThis->globals.mainQ.iMainMsgQLowWtrMark = 2000;
+ pThis->globals.mainQ.iMainMsgQDiscardMark = 9800;
+ pThis->globals.mainQ.iMainMsgQDiscardSeverity = 8;
+ pThis->globals.mainQ.iMainMsgQueueNumWorkers = 1;
+ pThis->globals.mainQ.MainMsgQueType = QUEUETYPE_FIXED_ARRAY;
+ pThis->globals.mainQ.pszMainMsgQFName = NULL;
+ pThis->globals.mainQ.iMainMsgQueMaxFileSize = 1024*1024;
+ pThis->globals.mainQ.iMainMsgQPersistUpdCnt = 0;
+ pThis->globals.mainQ.bMainMsgQSyncQeueFiles = 0;
+ pThis->globals.mainQ.iMainMsgQtoQShutdown = 1500;
+ pThis->globals.mainQ.iMainMsgQtoActShutdown = 1000;
+ pThis->globals.mainQ.iMainMsgQtoEnq = 2000;
+ pThis->globals.mainQ.iMainMsgQtoWrkShutdown = 60000;
+ pThis->globals.mainQ.iMainMsgQWrkMinMsgs = 100;
+ pThis->globals.mainQ.iMainMsgQDeqSlowdown = 0;
+ pThis->globals.mainQ.iMainMsgQueMaxDiskSpace = 0;
+ pThis->globals.mainQ.iMainMsgQueDeqBatchSize = 32;
+ pThis->globals.mainQ.bMainMsgQSaveOnShutdown = 1;
+ pThis->globals.mainQ.iMainMsgQueueDeqtWinFromHr = 0;
+ pThis->globals.mainQ.iMainMsgQueueDeqtWinToHr = 25;
+ /* end queue params */
finalize_it:
ENDobjConstruct(rsconf)
@@ -82,6 +114,7 @@ rsRetVal rsconfConstructFinalize(rsconf_t __attribute__((unused)) *pThis)
/* destructor for the rsconf object */
BEGINobjDestruct(rsconf) /* be sure to specify the object type also in END and CODESTART macros! */
CODESTARTobjDestruct(rsconf)
+ free(pThis->globals.mainQ.pszMainMsgQFName);
llDestroy(&(pThis->rulesets.llRulesets));
ENDobjDestruct(rsconf)
@@ -108,6 +141,26 @@ BEGINobjDebugPrint(rsconf) /* be sure to specify the object type also in END and
module.PrintList();
if(pThis->globals.bDebugPrintCfSysLineHandlerList)
dbgPrintCfSysLineHandlers();
+ // TODO: The following code needs to be "streamlined", so far just moved over...
+ DBGPRINTF("Main queue size %d messages.\n", pThis->globals.mainQ.iMainMsgQueueSize);
+ DBGPRINTF("Main queue worker threads: %d, wThread shutdown: %d, Perists every %d updates.\n",
+ pThis->globals.mainQ.iMainMsgQueueNumWorkers, pThis->globals.mainQ.iMainMsgQtoWrkShutdown, pThis->globals.mainQ.iMainMsgQPersistUpdCnt);
+ DBGPRINTF("Main queue timeouts: shutdown: %d, action completion shutdown: %d, enq: %d\n",
+ pThis->globals.mainQ.iMainMsgQtoQShutdown, pThis->globals.mainQ.iMainMsgQtoActShutdown, pThis->globals.mainQ.iMainMsgQtoEnq);
+ DBGPRINTF("Main queue watermarks: high: %d, low: %d, discard: %d, discard-severity: %d\n",
+ pThis->globals.mainQ.iMainMsgQHighWtrMark, pThis->globals.mainQ.iMainMsgQLowWtrMark, pThis->globals.mainQ.iMainMsgQDiscardMark, pThis->globals.mainQ.iMainMsgQDiscardSeverity);
+ DBGPRINTF("Main queue save on shutdown %d, max disk space allowed %lld\n",
+ pThis->globals.mainQ.bMainMsgQSaveOnShutdown, pThis->globals.mainQ.iMainMsgQueMaxDiskSpace);
+ /* TODO: add
+ iActionRetryCount = 0;
+ iActionRetryInterval = 30000;
+ static int iMainMsgQtoWrkMinMsgs = 100;
+ static int iMainMsgQbSaveOnShutdown = 1;
+ iMainMsgQueMaxDiskSpace = 0;
+ setQPROP(qqueueSetiMinMsgsPerWrkr, "$MainMsgQueueWorkerThreadMinimumMessages", 100);
+ setQPROP(qqueueSetbSaveOnShutdown, "$MainMsgQueueSaveOnShutdown", 1);
+ */
+ DBGPRINTF("Work Directory: '%s'.\n", glbl.GetWorkDir());
CODESTARTobjDebugPrint(rsconf)
ENDobjDebugPrint(rsconf)
@@ -128,6 +181,215 @@ activate(rsconf_t *cnf)
}
+/* -------------------- some legacy config handlers --------------------
+ * TODO: move to conf.c?
+ */
+
+/* this method is needed to shuffle the current conf object down to the
+ * IncludeConfig handler.
+ */
+static rsRetVal
+doModLoad(void *pVal, uchar *pNewVal)
+{
+ DEFiRet;
+ iRet = conf.doModLoad(ourConf, pVal, pNewVal);
+ free(pNewVal);
+ RETiRet;
+}
+
+/* legacy config system: set the action resume interval */
+static rsRetVal setActionResumeInterval(void __attribute__((unused)) *pVal, int iNewVal)
+{
+ return actionSetGlobalResumeInterval(iNewVal);
+}
+
+
+/* this method is needed to shuffle the current conf object down to the
+ * IncludeConfig handler.
+ */
+static rsRetVal
+doIncludeLine(void *pVal, uchar *pNewVal)
+{
+ DEFiRet;
+ iRet = conf.doIncludeLine(ourConf, pVal, pNewVal);
+ free(pNewVal);
+ RETiRet;
+}
+
+
+/* set the processes umask (upon configuration request) */
+static rsRetVal
+setUmask(void __attribute__((unused)) *pVal, int iUmask)
+{
+#warning this *really* needs to be done differently!
+ umask(iUmask);
+ DBGPRINTF("umask set to 0%3.3o.\n", iUmask);
+
+ return RS_RET_OK;
+}
+
+
+/* set the maximum message size */
+static rsRetVal setMaxMsgSize(void __attribute__((unused)) *pVal, long iNewVal)
+{
+ return glbl.SetMaxLine(iNewVal);
+}
+
+
+/* Switch the default ruleset (that, what servcies bind to if nothing specific
+ * is specified).
+ * rgerhards, 2009-06-12
+ */
+static rsRetVal
+setDefaultRuleset(void __attribute__((unused)) *pVal, uchar *pszName)
+{
+ DEFiRet;
+
+ CHKiRet(ruleset.SetDefaultRuleset(ourConf, pszName));
+
+finalize_it:
+ free(pszName); /* no longer needed */
+ RETiRet;
+}
+
+
+/* Switch to either an already existing rule set or start a new one. The
+ * named rule set becomes the new "current" rule set (what means that new
+ * actions are added to it).
+ * rgerhards, 2009-06-12
+ */
+static rsRetVal
+setCurrRuleset(void __attribute__((unused)) *pVal, uchar *pszName)
+{
+ ruleset_t *pRuleset;
+ rsRetVal localRet;
+ DEFiRet;
+
+ localRet = ruleset.SetCurrRuleset(ourConf, pszName);
+
+ if(localRet == RS_RET_NOT_FOUND) {
+ DBGPRINTF("begin new current rule set '%s'\n", pszName);
+ CHKiRet(ruleset.Construct(&pRuleset));
+ CHKiRet(ruleset.SetName(ourConf, pRuleset, pszName));
+ CHKiRet(ruleset.ConstructFinalize(ourConf, pRuleset));
+ } else {
+ ABORT_FINALIZE(localRet);
+ }
+
+finalize_it:
+ free(pszName); /* no longer needed */
+ RETiRet;
+}
+
+
+/* set the main message queue mode
+ * rgerhards, 2008-01-03
+ */
+static rsRetVal setMainMsgQueType(void __attribute__((unused)) *pVal, uchar *pszType)
+{
+ DEFiRet;
+
+ if (!strcasecmp((char *) pszType, "fixedarray")) {
+ loadConf->globals.mainQ.MainMsgQueType = QUEUETYPE_FIXED_ARRAY;
+ DBGPRINTF("main message queue type set to FIXED_ARRAY\n");
+ } else if (!strcasecmp((char *) pszType, "linkedlist")) {
+ loadConf->globals.mainQ.MainMsgQueType = QUEUETYPE_LINKEDLIST;
+ DBGPRINTF("main message queue type set to LINKEDLIST\n");
+ } else if (!strcasecmp((char *) pszType, "disk")) {
+ loadConf->globals.mainQ.MainMsgQueType = QUEUETYPE_DISK;
+ DBGPRINTF("main message queue type set to DISK\n");
+ } else if (!strcasecmp((char *) pszType, "direct")) {
+ loadConf->globals.mainQ.MainMsgQueType = QUEUETYPE_DIRECT;
+ DBGPRINTF("main message queue type set to DIRECT (no queueing at all)\n");
+ } else {
+ errmsg.LogError(0, RS_RET_INVALID_PARAMS, "unknown mainmessagequeuetype parameter: %s", (char *) pszType);
+ iRet = RS_RET_INVALID_PARAMS;
+ }
+ free(pszType); /* no longer needed */
+
+ RETiRet;
+}
+
+
+/* -------------------- end legacy config handlers -------------------- */
+
+
+/* set the processes max number ob files (upon configuration request)
+ * 2009-04-14 rgerhards
+ */
+static rsRetVal setMaxFiles(void __attribute__((unused)) *pVal, int iFiles)
+{
+// TODO this must use a local var, then carry out action during activate!
+ struct rlimit maxFiles;
+ char errStr[1024];
+ DEFiRet;
+
+ maxFiles.rlim_cur = iFiles;
+ maxFiles.rlim_max = iFiles;
+
+ if(setrlimit(RLIMIT_NOFILE, &maxFiles) < 0) {
+ /* NOTE: under valgrind, we seem to be unable to extend the size! */
+ rs_strerror_r(errno, errStr, sizeof(errStr));
+ errmsg.LogError(0, RS_RET_ERR_RLIM_NOFILE, "could not set process file limit to %d: %s [kernel max %ld]",
+ iFiles, errStr, (long) maxFiles.rlim_max);
+ ABORT_FINALIZE(RS_RET_ERR_RLIM_NOFILE);
+ }
+#ifdef USE_UNLIMITED_SELECT
+ glbl.SetFdSetSize(howmany(iFiles, __NFDBITS) * sizeof (fd_mask));
+#endif
+ DBGPRINTF("Max number of files set to %d [kernel max %ld].\n", iFiles, (long) maxFiles.rlim_max);
+
+finalize_it:
+ RETiRet;
+}
+
+
+/* legac config system: reset config variables to default values. */
+static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal)
+{
+ loadConf->globals.bLogStatusMsgs = DFLT_bLogStatusMsgs;
+ loadConf->globals.bDebugPrintTemplateList = 1;
+ loadConf->globals.bDebugPrintCfSysLineHandlerList = 1;
+ loadConf->globals.bDebugPrintModuleList = 1;
+ loadConf->globals.bAbortOnUncleanConfig = 0;
+ loadConf->globals.bReduceRepeatMsgs = 0;
+ free(loadConf->globals.mainQ.pszMainMsgQFName);
+ loadConf->globals.mainQ.pszMainMsgQFName = NULL;
+ loadConf->globals.mainQ.iMainMsgQueueSize = 10000;
+ loadConf->globals.mainQ.iMainMsgQHighWtrMark = 8000;
+ loadConf->globals.mainQ.iMainMsgQLowWtrMark = 2000;
+ loadConf->globals.mainQ.iMainMsgQDiscardMark = 9800;
+ loadConf->globals.mainQ.iMainMsgQDiscardSeverity = 8;
+ loadConf->globals.mainQ.iMainMsgQueMaxFileSize = 1024 * 1024;
+ loadConf->globals.mainQ.iMainMsgQueueNumWorkers = 1;
+ loadConf->globals.mainQ.iMainMsgQPersistUpdCnt = 0;
+ loadConf->globals.mainQ.bMainMsgQSyncQeueFiles = 0;
+ loadConf->globals.mainQ.iMainMsgQtoQShutdown = 1500;
+ loadConf->globals.mainQ.iMainMsgQtoActShutdown = 1000;
+ loadConf->globals.mainQ.iMainMsgQtoEnq = 2000;
+ loadConf->globals.mainQ.iMainMsgQtoWrkShutdown = 60000;
+ loadConf->globals.mainQ.iMainMsgQWrkMinMsgs = 100;
+ loadConf->globals.mainQ.iMainMsgQDeqSlowdown = 0;
+ loadConf->globals.mainQ.bMainMsgQSaveOnShutdown = 1;
+ loadConf->globals.mainQ.MainMsgQueType = QUEUETYPE_FIXED_ARRAY;
+ loadConf->globals.mainQ.iMainMsgQueMaxDiskSpace = 0;
+ loadConf->globals.mainQ.iMainMsgQueDeqBatchSize = 32;
+
+ return RS_RET_OK;
+}
+
+
+/* legacy config system: set the action resume interval */
+static rsRetVal
+setModDir(void __attribute__((unused)) *pVal, uchar* pszNewVal)
+{
+ DEFiRet;
+ iRet = module.SetModDir(pszNewVal);
+ free(pszNewVal);
+ RETiRet;
+}
+
+
/* intialize the legacy config system */
static inline rsRetVal
initLegacyConf(void)
@@ -140,6 +402,123 @@ initLegacyConf(void)
ruleset.SetName(loadConf, pRuleset, UCHAR_CONSTANT("RSYSLOG_DefaultRuleset"));
ruleset.ConstructFinalize(loadConf, pRuleset);
+ /* now register config handlers */
+ CHKiRet(regCfSysLineHdlr((uchar *)"sleep", 0, eCmdHdlrGoneAway,
+ NULL, NULL, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"logrsyslogstatusmessages", 0, eCmdHdlrBinary,
+ NULL, &loadConf->globals.bLogStatusMsgs, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"errormessagestostderr", 0, eCmdHdlrBinary,
+ NULL, &loadConf->globals.bErrMsgToStderr, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"abortonuncleanconfig", 0, eCmdHdlrBinary,
+ NULL, &loadConf->globals.bAbortOnUncleanConfig, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"repeatedmsgreduction", 0, eCmdHdlrBinary,
+ NULL, &loadConf->globals.bReduceRepeatMsgs, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"debugprinttemplatelist", 0, eCmdHdlrBinary,
+ NULL, &(loadConf->globals.bDebugPrintTemplateList), NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"debugprintmodulelist", 0, eCmdHdlrBinary,
+ NULL, &(loadConf->globals.bDebugPrintModuleList), NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"debugprintcfsyslinehandlerlist", 0, eCmdHdlrBinary,
+ NULL, &(loadConf->globals.bDebugPrintCfSysLineHandlerList), NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"privdroptouser", 0, eCmdHdlrUID,
+ NULL, &loadConf->globals.uidDropPriv, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"privdroptouserid", 0, eCmdHdlrInt,
+ NULL, &loadConf->globals.uidDropPriv, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"privdroptogroup", 0, eCmdHdlrGID,
+ NULL, &loadConf->globals.gidDropPriv, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"privdroptogroupid", 0, eCmdHdlrGID,
+ NULL, &loadConf->globals.gidDropPriv, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"generateconfiggraph", 0, eCmdHdlrGetWord,
+ NULL, &loadConf->globals.pszConfDAGFile, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"maxopenfiles", 0, eCmdHdlrInt,
+ setMaxFiles, NULL, NULL, eConfObjGlobal));
+
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionresumeinterval", 0, eCmdHdlrInt,
+ setActionResumeInterval, NULL, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"modload", 0, eCmdHdlrCustomHandler,
+ doModLoad, NULL, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"includeconfig", 0, eCmdHdlrCustomHandler,
+ doIncludeLine, NULL, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"umask", 0, eCmdHdlrFileCreateMode,
+ setUmask, NULL, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"maxmessagesize", 0, eCmdHdlrSize,
+ setMaxMsgSize, NULL, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"defaultruleset", 0, eCmdHdlrGetWord,
+ setDefaultRuleset, NULL, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"ruleset", 0, eCmdHdlrGetWord,
+ setCurrRuleset, NULL, NULL, eConfObjGlobal));
+
+ /* handler for "larger" config statements (tie into legacy conf system) */
+ CHKiRet(regCfSysLineHdlr((uchar *)"template", 0, eCmdHdlrCustomHandler,
+ conf.doNameLine, (void*)DIR_TEMPLATE, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"outchannel", 0, eCmdHdlrCustomHandler,
+ conf.doNameLine, (void*)DIR_OUTCHANNEL, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"allowedsender", 0, eCmdHdlrCustomHandler,
+ conf.doNameLine, (void*)DIR_ALLOWEDSENDER, NULL, eConfObjGlobal));
+
+ /* the following are parameters for the main message queue. I have the
+ * strong feeling that this needs to go to a different space, but that
+ * feeling may be wrong - we'll see how things evolve.
+ * rgerhards, 2011-04-21
+ */
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuefilename", 0, eCmdHdlrGetWord,
+ NULL, &loadConf->globals.mainQ.pszMainMsgQFName, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuesize", 0, eCmdHdlrInt,
+ NULL, &loadConf->globals.mainQ.iMainMsgQueueSize, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuehighwatermark", 0, eCmdHdlrInt,
+ NULL, &loadConf->globals.mainQ.iMainMsgQHighWtrMark, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuelowwatermark", 0, eCmdHdlrInt,
+ NULL, &loadConf->globals.mainQ.iMainMsgQLowWtrMark, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuediscardmark", 0, eCmdHdlrInt,
+ NULL, &loadConf->globals.mainQ.iMainMsgQDiscardMark, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuediscardseverity", 0, eCmdHdlrSeverity,
+ NULL, &loadConf->globals.mainQ.iMainMsgQDiscardSeverity, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuecheckpointinterval", 0, eCmdHdlrInt,
+ NULL, &loadConf->globals.mainQ.iMainMsgQPersistUpdCnt, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuesyncqueuefiles", 0, eCmdHdlrBinary,
+ NULL, &loadConf->globals.mainQ.bMainMsgQSyncQeueFiles, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuetype", 0, eCmdHdlrGetWord,
+ setMainMsgQueType, NULL, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueueworkerthreads", 0, eCmdHdlrInt,
+ NULL, &loadConf->globals.mainQ.iMainMsgQueueNumWorkers, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuetimeoutshutdown", 0, eCmdHdlrInt,
+ NULL, &loadConf->globals.mainQ.iMainMsgQtoQShutdown, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuetimeoutactioncompletion", 0, eCmdHdlrInt,
+ NULL, &loadConf->globals.mainQ.iMainMsgQtoActShutdown, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuetimeoutenqueue", 0, eCmdHdlrInt,
+ NULL, &loadConf->globals.mainQ.iMainMsgQtoEnq, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueueworkertimeoutthreadshutdown", 0, eCmdHdlrInt,
+ NULL, &loadConf->globals.mainQ.iMainMsgQtoWrkShutdown, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuedequeueslowdown", 0, eCmdHdlrInt,
+ NULL, &loadConf->globals.mainQ.iMainMsgQDeqSlowdown, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueueworkerthreadminimummessages", 0, eCmdHdlrInt,
+ NULL, &loadConf->globals.mainQ.iMainMsgQWrkMinMsgs, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuemaxfilesize", 0, eCmdHdlrSize,
+ NULL, &loadConf->globals.mainQ.iMainMsgQueMaxFileSize, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuedequeuebatchsize", 0, eCmdHdlrSize,
+ NULL, &loadConf->globals.mainQ.iMainMsgQueDeqBatchSize, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuemaxdiskspace", 0, eCmdHdlrSize,
+ NULL, &loadConf->globals.mainQ.iMainMsgQueMaxDiskSpace, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuesaveonshutdown", 0, eCmdHdlrBinary,
+ NULL, &loadConf->globals.mainQ.bMainMsgQSaveOnShutdown, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuedequeuetimebegin", 0, eCmdHdlrInt,
+ NULL, &loadConf->globals.mainQ.iMainMsgQueueDeqtWinFromHr, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuedequeuetimeend", 0, eCmdHdlrInt,
+ NULL, &loadConf->globals.mainQ.iMainMsgQueueDeqtWinToHr, NULL, eConfObjGlobal));
+ /* moddir is a bit hard problem -- because it actually needs to
+ * modify a setting that is specific to module.c. The important point
+ * is that this action MUST actually be carried out during config load,
+ * because we must load modules in order to get their config extensions
+ * (no way around).
+ * TODO: think about a clean solution
+ */
+ CHKiRet(regCfSysLineHdlr((uchar *)"moddir", 0, eCmdHdlrGetWord,
+ setModDir, NULL, NULL, eConfObjGlobal));
+
+ /* finally, the reset handler */
+ CHKiRet(regCfSysLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler,
+ resetConfigVariables, NULL, NULL, eConfObjGlobal));
+
+finalize_it:
RETiRet;
}
@@ -162,6 +541,7 @@ load(rsconf_t **cnf, uchar *confFile)
CHKiRet(rsconfConstruct(&loadConf));
ourConf = loadConf; // TODO: remove, once ourConf is gone!
+dbgprintf("XXXX: loadConf is %p\n", loadConf);
CHKiRet(initLegacyConf());
@@ -216,7 +596,7 @@ dbgprintf("XXXX: 20\n");
/* all OK, pass loaded conf to caller */
*cnf = loadConf;
- loadConf = NULL;
+// TODO: enable this once all config code is moved to here! loadConf = NULL;
dbgprintf("rsyslog finished loading initial config %p\n", loadConf);
// rsconfDebugPrint(loadConf);
@@ -258,6 +638,7 @@ BEGINObjClassInit(rsconf, 1, OBJ_IS_CORE_MODULE) /* class, version */
CHKiRet(objUse(module, CORE_COMPONENT));
CHKiRet(objUse(conf, CORE_COMPONENT));
CHKiRet(objUse(errmsg, CORE_COMPONENT));
+ CHKiRet(objUse(glbl, CORE_COMPONENT));
/* now set our own handlers */
OBJSetMethodHandler(objMethod_DEBUGPRINT, rsconfDebugPrint);
@@ -272,6 +653,7 @@ BEGINObjClassExit(rsconf, OBJ_IS_CORE_MODULE) /* class, version */
objRelease(module, CORE_COMPONENT);
objRelease(conf, CORE_COMPONENT);
objRelease(errmsg, CORE_COMPONENT);
+ objRelease(glbl, CORE_COMPONENT);
ENDObjClassExit(rsconf)
/* vi:set ai:
diff --git a/runtime/rsconf.h b/runtime/rsconf.h
index 3302e990..5229b9f7 100644
--- a/runtime/rsconf.h
+++ b/runtime/rsconf.h
@@ -24,9 +24,36 @@
#define INCLUDED_RSCONF_H
#include "linkedlist.h"
+#include "queue.h"
/* --- configuration objects (the plan is to have ALL upper layers in this file) --- */
+/* queue config parameters. TODO: move to queue.c? */
+struct queuecnf_s {
+ int iMainMsgQueueSize; /* size of the main message queue above */
+ int iMainMsgQHighWtrMark; /* high water mark for disk-assisted queues */
+ int iMainMsgQLowWtrMark; /* low water mark for disk-assisted queues */
+ int iMainMsgQDiscardMark; /* begin to discard messages */
+ int iMainMsgQDiscardSeverity; /* by default, discard nothing to prevent unintentional loss */
+ int iMainMsgQueueNumWorkers; /* number of worker threads for the mm queue above */
+ queueType_t MainMsgQueType; /* type of the main message queue above */
+ uchar *pszMainMsgQFName; /* prefix for the main message queue file */
+ int64 iMainMsgQueMaxFileSize;
+ int iMainMsgQPersistUpdCnt; /* persist queue info every n updates */
+ int bMainMsgQSyncQeueFiles; /* sync queue files on every write? */
+ int iMainMsgQtoQShutdown; /* queue shutdown (ms) */
+ int iMainMsgQtoActShutdown; /* action shutdown (in phase 2) */
+ int iMainMsgQtoEnq; /* timeout for queue enque */
+ int iMainMsgQtoWrkShutdown; /* timeout for worker thread shutdown */
+ int iMainMsgQWrkMinMsgs; /* minimum messages per worker needed to start a new one */
+ int iMainMsgQDeqSlowdown; /* dequeue slowdown (simple rate limiting) */
+ int64 iMainMsgQueMaxDiskSpace; /* max disk space allocated 0 ==> unlimited */
+ int64 iMainMsgQueDeqBatchSize; /* dequeue batch size */
+ int bMainMsgQSaveOnShutdown; /* save queue on shutdown (when DA enabled)? */
+ int iMainMsgQueueDeqtWinFromHr; /* hour begin of time frame when queue is to be dequeued */
+ int iMainMsgQueueDeqtWinToHr; /* hour begin of time frame when queue is to be dequeued */
+};
+
/* globals are data items that are really global, and can be set only
* once (at least in theory, because the legacy system permits them to
* be re-set as often as the user likes).
@@ -36,7 +63,19 @@ struct globals_s {
int bDebugPrintModuleList;
int bDebugPrintCfSysLineHandlerList;
int bLogStatusMsgs; /* log rsyslog start/stop/HUP messages? */
- int bErrMsgToStderr; /* print error messages to stderr (in addition to everything else)? */
+ int bErrMsgToStderr; /* print error messages to stderr
+ (in addition to everything else)? */
+ int bAbortOnUncleanConfig; /* abort run (rather than starting with partial
+ config) if there was any issue in conf */
+ int uidDropPriv; /* user-id to which priveleges should be dropped to */
+ int gidDropPriv; /* group-id to which priveleges should be dropped to */
+ uchar *pszConfDAGFile; /* name of config DAG file, non-NULL means generate one */
+
+ // TODO are the following ones defaults?
+ int bReduceRepeatMsgs; /* reduce repeated message - 0 - no, 1 - yes */
+
+ //TODO: other representation for main queue? Or just load it differently?
+ queuecnf_t mainQ; /* main queue paramters */
};
/* (global) defaults are global in the sense that they are accessible
diff --git a/runtime/typedefs.h b/runtime/typedefs.h
index e46f509b..b7df0464 100644
--- a/runtime/typedefs.h
+++ b/runtime/typedefs.h
@@ -81,6 +81,7 @@ typedef struct strgenList_s strgenList_t;
typedef struct statsobj_s statsobj_t;
typedef struct nsd_epworkset_s nsd_epworkset_t;
typedef struct templates_s templates_t;
+typedef struct queuecnf_s queuecnf_t;
typedef struct rulesets_s rulesets_t;
typedef struct globals_s globals_t;
typedef struct defaults_s defaults_t;