summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-07-19 18:26:26 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-07-19 18:26:26 +0200
commit02d44ba72d450199838dfa25eafcdf8c759ee5d4 (patch)
tree84ea5c7a282e2d8ab683e87dbb74eee1102bd4e7
parent74c2e98c13daf60bf5371f77111196679dd7df55 (diff)
downloadrsyslog-02d44ba72d450199838dfa25eafcdf8c759ee5d4.tar.gz
rsyslog-02d44ba72d450199838dfa25eafcdf8c759ee5d4.tar.xz
rsyslog-02d44ba72d450199838dfa25eafcdf8c759ee5d4.zip
milestone: size syntax implemented
-rw-r--r--grammar/rainerscript.c48
-rw-r--r--runtime/glbl.c8
-rw-r--r--runtime/rsconf.c9
3 files changed, 55 insertions, 10 deletions
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c
index 92b07a5f..76e3a0a4 100644
--- a/grammar/rainerscript.c
+++ b/grammar/rainerscript.c
@@ -204,6 +204,53 @@ nvlstChkUnused(struct nvlst *lst)
static inline void
+doGetSize(struct nvlst *valnode, struct cnfparamdescr *param,
+ struct cnfparamvals *val)
+{
+ unsigned char *c;
+ es_size_t i;
+ long long n;
+ c = es_getBufAddr(valnode->val.d.estr);
+ n = 0;
+ i = 0;
+ while(i < es_strlen(valnode->val.d.estr) && isdigit(*c)) {
+ n = 10 * n + *c - '0';
+ ++i;
+ ++c;
+ }
+ if(i < es_strlen(valnode->val.d.estr)) {
+ ++i;
+ switch(*c) {
+ /* traditional binary-based definitions */
+ case 'k': n *= 1024; break;
+ case 'm': n *= 1024 * 1024; break;
+ case 'g': n *= 1024 * 1024 * 1024; break;
+ case 't': n *= (int64) 1024 * 1024 * 1024 * 1024; break; /* tera */
+ case 'p': n *= (int64) 1024 * 1024 * 1024 * 1024 * 1024; break; /* peta */
+ case 'e': n *= (int64) 1024 * 1024 * 1024 * 1024 * 1024 * 1024; break; /* exa */
+ /* and now the "new" 1000-based definitions */
+ case 'K': n *= 1000; break;
+ case 'M': n *= 1000000; break;
+ case 'G': n *= 1000000000; break;
+ /* we need to use the multiplication below because otherwise
+ * the compiler gets an error during constant parsing */
+ case 'T': n *= (int64) 1000 * 1000000000; break; /* tera */
+ case 'P': n *= (int64) 1000000 * 1000000000; break; /* peta */
+ case 'E': n *= (int64) 1000000000 * 1000000000; break; /* exa */
+ default: --i; break; /* indicates error */
+ }
+ }
+ if(i == es_strlen(valnode->val.d.estr)) {
+ val->val.datatype = 'N';
+ val->val.d.n = n;
+ } else {
+ parser_errmsg("parameter '%s' does not contain a valid size",
+ param->name);
+ }
+}
+
+
+static inline void
doGetBinary(struct nvlst *valnode, struct cnfparamdescr *param,
struct cnfparamvals *val)
{
@@ -263,6 +310,7 @@ nvlstGetParam(struct nvlst *valnode, struct cnfparamdescr *param,
case eCmdHdlrInt:
break;
case eCmdHdlrSize:
+ doGetSize(valnode, param, val);
break;
case eCmdHdlrGetChar:
break;
diff --git a/runtime/glbl.c b/runtime/glbl.c
index 6b7d487f..eeca347a 100644
--- a/runtime/glbl.c
+++ b/runtime/glbl.c
@@ -64,7 +64,7 @@ static uchar *pszWorkDir = NULL;
static int bOptimizeUniProc = 1; /* enable uniprocessor optimizations */
static int bParseHOSTNAMEandTAG = 1; /* parser modification (based on startup params!) */
static int bPreserveFQDN = 0; /* should FQDNs always be preserved? */
-static int iMaxLine = 2048; /* maximum length of a syslog message */
+static int iMaxLine = 8096; /* maximum length of a syslog message */
static int iDefPFFamily = PF_UNSPEC; /* protocol family (IPv4, IPv6 or both) */
static int bDropMalPTRMsgs = 0;/* Drop messages which have malicious PTR records during DNS lookup */
static int option_DisallowWarning = 1; /* complain if message from disallowed sender is received */
@@ -98,6 +98,7 @@ static struct cnfparamdescr cnfparamdescr[] = {
{ "defaultnetstreamdrivercafile", eCmdHdlrString, 0 },
{ "defaultnetstreamdriverkeyfile", eCmdHdlrString, 0 },
{ "defaultnetstreamdriver", eCmdHdlrString, 0 },
+ { "maxmessagesize", eCmdHdlrSize, 0 },
};
static struct cnfparamblk paramblk =
{ CNFPARAMBLK_VERSION,
@@ -423,6 +424,7 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
bDropMalPTRMsgs = 0;
bOptimizeUniProc = 1;
bPreserveFQDN = 0;
+ iMaxLine = 8192;
#ifdef USE_UNLIMITED_SELECT
iFdSetSize = howmany(FD_SETSIZE, __NFDBITS) * sizeof (fd_mask);
#endif
@@ -490,6 +492,8 @@ glblDoneLoadCnf()
} else if(!strcmp(paramblk.descr[i].name,
"dropmsgswithmaliciousdnsptrrecords")) {
bDropMalPTRMsgs = (int) cnfparamvals[i].val.d.n;
+ } else if(!strcmp(paramblk.descr[i].name, "maxmessagesize")) {
+ iMaxLine = (int) cnfparamvals[i].val.d.n;
} else {
dbgprintf("glblDoneLoadCnf: program error, non-handled "
"param '%s'\n", paramblk.descr[i].name);
@@ -517,6 +521,8 @@ BEGINAbstractObjClassInit(glbl, 1, OBJ_IS_CORE_MODULE) /* class, version */
CHKiRet(regCfSysLineHdlr((uchar *)"localhostname", 0, eCmdHdlrGetWord, NULL, &LocalHostNameOverride, NULL, eConfObjGlobal));
CHKiRet(regCfSysLineHdlr((uchar *)"optimizeforuniprocessor", 0, eCmdHdlrBinary, NULL, &bOptimizeUniProc, NULL, eConfObjGlobal));
CHKiRet(regCfSysLineHdlr((uchar *)"preservefqdn", 0, eCmdHdlrBinary, NULL, &bPreserveFQDN, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"maxmessagesize", 0, eCmdHdlrSize,
+ NULL, &iMaxLine, NULL, eConfObjGlobal));
CHKiRet(regCfSysLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, NULL, eConfObjGlobal));
INIT_ATOMIC_HELPER_MUT(mutTerminateInputs);
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
index fd42caf9..26105e88 100644
--- a/runtime/rsconf.c
+++ b/runtime/rsconf.c
@@ -805,13 +805,6 @@ static rsRetVal setActionResumeInterval(void __attribute__((unused)) *pVal, int
}
-/* 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
@@ -1083,8 +1076,6 @@ initLegacyConf(void)
setActionResumeInterval, NULL, NULL, eConfObjGlobal));
CHKiRet(regCfSysLineHdlr((uchar *)"modload", 0, eCmdHdlrCustomHandler,
conf.doModLoad, 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,