| 1 |
/* The rsconf object. It models a complete rsyslog configuration. |
| 2 |
* |
| 3 |
* Copyright 2011-2026 Rainer Gerhards and Adiscon GmbH. |
| 4 |
* |
| 5 |
* This file is part of the rsyslog runtime library. |
| 6 |
* |
| 7 |
* The rsyslog runtime library is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU Lesser General Public License as published by |
| 9 |
* the Free Software Foundation, either version 3 of the License, or |
| 10 |
* (at your option) any later version. |
| 11 |
* |
| 12 |
* The rsyslog runtime library is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU Lesser General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU Lesser General Public License |
| 18 |
* along with the rsyslog runtime library. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
* |
| 20 |
* A copy of the GPL can be found in the file "COPYING" in this distribution. |
| 21 |
* A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution. |
| 22 |
*/ |
| 23 |
#ifndef INCLUDED_RSCONF_H |
| 24 |
#define INCLUDED_RSCONF_H |
| 25 |
|
| 26 |
#include "linkedlist.h" |
| 27 |
#include "queue.h" |
| 28 |
#include "lookup.h" |
| 29 |
#include "dynstats.h" |
| 30 |
#include "perctile_stats.h" |
| 31 |
#include "timezones.h" |
| 32 |
#include "ratelimit.h" |
| 33 |
|
| 34 |
/* --- configuration objects (the plan is to have ALL upper layers in this file) --- */ |
| 35 |
|
| 36 |
#define REPORT_CHILD_PROCESS_EXITS_NONE 0 |
| 37 |
#define REPORT_CHILD_PROCESS_EXITS_ERRORS 1 |
| 38 |
#define REPORT_CHILD_PROCESS_EXITS_ALL 2 |
| 39 |
|
| 40 |
#ifndef DFLT_INT_MSGS_SEV_FILTER |
| 41 |
#define DFLT_INT_MSGS_SEV_FILTER 6 /* Warning level and more important */ |
| 42 |
#endif |
| 43 |
|
| 44 |
struct queuecnf_s { |
| 45 |
int iMainMsgQueueSize; /* size of the main message queue above */ |
| 46 |
int iMainMsgQHighWtrMark; /* high water mark for disk-assisted queues */ |
| 47 |
int iMainMsgQLowWtrMark; /* low water mark for disk-assisted queues */ |
| 48 |
int iMainMsgQDiscardMark; /* begin to discard messages */ |
| 49 |
int iMainMsgQDiscardSeverity; /* by default, discard nothing to prevent unintentional loss */ |
| 50 |
int iMainMsgQueueNumWorkers; /* number of worker threads for the mm queue above */ |
| 51 |
queueType_t MainMsgQueType; /* type of the main message queue above */ |
| 52 |
uchar *pszMainMsgQFName; /* prefix for the main message queue file */ |
| 53 |
int64 iMainMsgQueMaxFileSize; |
| 54 |
int iMainMsgQPersistUpdCnt; /* persist queue info every n updates */ |
| 55 |
int bMainMsgQSyncQeueFiles; /* sync queue files on every write? */ |
| 56 |
int iMainMsgQtoQShutdown; /* queue shutdown (ms) */ |
| 57 |
int iMainMsgQtoActShutdown; /* action shutdown (in phase 2) */ |
| 58 |
int iMainMsgQtoEnq; /* timeout for queue enque */ |
| 59 |
int iMainMsgQtoWrkShutdown; /* timeout for worker thread shutdown */ |
| 60 |
int iMainMsgQWrkMinMsgs; /* minimum messages per worker needed to start a new one */ |
| 61 |
int iMainMsgQDeqSlowdown; /* dequeue slowdown (simple rate limiting) */ |
| 62 |
int64 iMainMsgQueMaxDiskSpace; /* max disk space allocated 0 ==> unlimited */ |
| 63 |
int64 iMainMsgQueDeqBatchSize; /* dequeue batch size */ |
| 64 |
int bMainMsgQSaveOnShutdown; /* save queue on shutdown (when DA enabled)? */ |
| 65 |
int iMainMsgQueueDeqtWinFromHr; /* hour begin of time frame when queue is to be dequeued */ |
| 66 |
int iMainMsgQueueDeqtWinToHr; /* hour begin of time frame when queue is to be dequeued */ |
| 67 |
}; |
| 68 |
|
| 69 |
/* parser config parameters */ |
| 70 |
struct parsercnf_s { |
| 71 |
uchar cCCEscapeChar; /* character to be used to start an escape sequence for control chars */ |
| 72 |
int bDropTrailingLF; /* drop trailing LF's on reception? */ |
| 73 |
int bEscapeCCOnRcv; /* escape control characters on reception: 0 - no, 1 - yes */ |
| 74 |
int bSpaceLFOnRcv; /* replace newlines with spaces on reception: 0 - no, 1 - yes */ |
| 75 |
int bEscape8BitChars; /* escape characters > 127 on reception: 0 - no, 1 - yes */ |
| 76 |
int bEscapeTab; /* escape tab control character when doing CC escapes: 0 - no, 1 - yes */ |
| 77 |
int bParserEscapeCCCStyle; /* escape control characters in c style: 0 - no, 1 - yes */ |
| 78 |
int bPermitSlashInProgramname; |
| 79 |
int bParseHOSTNAMEandTAG; /* parser modification (based on startup params!) */ |
| 80 |
}; |
| 81 |
|
| 82 |
/* globals are data items that are really global, and can be set only |
| 83 |
* once (at least in theory, because the legacy system permits them to |
| 84 |
* be re-set as often as the user likes). |
| 85 |
*/ |
| 86 |
struct globals_s { |
| 87 |
#ifdef ENABLE_LIBCAPNG |
| 88 |
int bAbortOnFailedLibcapngSetup; |
| 89 |
int bCapabilityDropEnabled; |
| 90 |
#endif |
| 91 |
int bDebugPrintTemplateList; |
| 92 |
int bDebugPrintModuleList; |
| 93 |
int bDebugPrintCfSysLineHandlerList; |
| 94 |
int bLogStatusMsgs; /* log rsyslog start/stop/HUP messages? */ |
| 95 |
int bAllMsgToStderr; /* print all internal messages to stderr */ |
| 96 |
int bErrMsgToStderr; /* print error messages to stderr |
| 97 |
(in addition to everything else)? */ |
| 98 |
int maxErrMsgToStderr; /* how many messages to forward at most to stderr? */ |
| 99 |
int bAbortOnUncleanConfig; /* abort run (rather than starting with partial |
| 100 |
config) if there was any issue in conf */ |
| 101 |
int bAbortOnFailedQueueStartup; /* similar to bAbortOnUncleanConfig, but abort if a queue |
| 102 |
startup fails. This is not exactly an unclan config. */ |
| 103 |
int uidDropPriv; /* user-id to which priveleges should be dropped to */ |
| 104 |
int gidDropPriv; /* group-id to which priveleges should be dropped to */ |
| 105 |
int gidDropPrivKeepSupplemental; /* keep supplemental groups when dropping? */ |
| 106 |
int abortOnIDResolutionFail; |
| 107 |
int umask; /* umask to use */ |
| 108 |
uchar *pszConfDAGFile; /* name of config DAG file, non-NULL means generate one */ |
| 109 |
uchar *pszWorkDir; |
| 110 |
int bDropMalPTRMsgs; /* Drop messages which have malicious PTR records during DNS lookup */ |
| 111 |
uchar *operatingStateFile; |
| 112 |
int debugOnShutdown; /* start debug log when we are shut down */ |
| 113 |
int iGnuTLSLoglevel; /* Sets GNUTLS Debug Level */ |
| 114 |
uchar *pszDfltNetstrmDrvrCAF; /* default CA file for the netstrm driver */ |
| 115 |
uchar *pszDfltNetstrmDrvrCRLF; /* default CRL file for the netstrm driver */ |
| 116 |
uchar *pszDfltNetstrmDrvrCertFile; /* default cert file for the netstrm driver (server) */ |
| 117 |
uchar *pszDfltNetstrmDrvrKeyFile; /* default key file for the netstrm driver (server) */ |
| 118 |
uchar *pszDfltNetstrmDrvr; /* module name of default netstream driver */ |
| 119 |
uchar *pszNetstrmDrvrCAExtraFiles; /* CA extra file for the netstrm driver */ |
| 120 |
uchar *pszDfltOpensslEngine; /* custom openssl engine */ |
| 121 |
uchar *oversizeMsgErrorFile; /* File where oversize messages are written to */ |
| 122 |
int reportOversizeMsg; /* shall error messages be generated for oversize messages? */ |
| 123 |
int oversizeMsgInputMode; /* Mode which oversize messages will be forwarded */ |
| 124 |
int reportChildProcessExits; |
| 125 |
int bActionReportSuspension; |
| 126 |
int bActionReportSuspensionCont; |
| 127 |
short janitorInterval; /* interval (in minutes) at which the janitor runs */ |
| 128 |
int reportNewSenders; |
| 129 |
int reportGoneAwaySenders; |
| 130 |
int senderStatsTimeout; |
| 131 |
int senderKeepTrack; /* keep track of known senders? */ |
| 132 |
int inputTimeoutShutdown; /* input shutdown timeout in ms */ |
| 133 |
int iDefPFFamily; /* protocol family (IPv4, IPv6 or both) */ |
| 134 |
int ACLAddHostnameOnFail; /* add hostname to acl when DNS resolving has failed */ |
| 135 |
int ACLDontResolve; /* add hostname to acl instead of resolving it to IP(s) */ |
| 136 |
int bDisableDNS; /* don't look up IP addresses of remote messages */ |
| 137 |
int bProcessInternalMessages; /* Should rsyslog itself process internal messages? |
| 138 |
* 1 - yes |
| 139 |
* 0 - send them to libstdlog (e.g. to push to journal) or syslog() |
| 140 |
*/ |
| 141 |
uint64_t glblDevOptions; /* to be used by developers only */ |
| 142 |
int intMsgRateLimitItv; |
| 143 |
int intMsgRateLimitBurst; |
| 144 |
int intMsgsSeverityFilter; /* filter for logging internal messages by syslog sev. */ |
| 145 |
int permitCtlC; |
| 146 |
|
| 147 |
int actq_dflt_toQShutdown; /* queue shutdown */ |
| 148 |
int actq_dflt_toActShutdown; /* action shutdown (in phase 2) */ |
| 149 |
int actq_dflt_toEnq; /* timeout for queue enque */ |
| 150 |
int actq_dflt_toWrkShutdown; /* timeout for worker thread shutdown */ |
| 151 |
|
| 152 |
int ruleset_dflt_toQShutdown; /* queue shutdown */ |
| 153 |
int ruleset_dflt_toActShutdown; /* action shutdown (in phase 2) */ |
| 154 |
int ruleset_dflt_toEnq; /* timeout for queue enque */ |
| 155 |
int ruleset_dflt_toWrkShutdown; /* timeout for worker thread shutdown */ |
| 156 |
|
| 157 |
unsigned dnscacheDefaultTTL; /* 24 hrs default TTL */ |
| 158 |
int dnscacheEnableTTL; /* expire entries or not (0) ? */ |
| 159 |
int shutdownQueueDoubleSize; |
| 160 |
int optionDisallowWarning; /* complain if message from disallowed sender is received */ |
| 161 |
int bSupportCompressionExtension; |
| 162 |
#ifdef ENABLE_LIBLOGGING_STDLOG |
| 163 |
stdlog_channel_t stdlog_hdl; /* handle to be used for stdlog */ |
| 164 |
uchar *stdlog_chanspec; |
| 165 |
#endif |
| 166 |
int iMaxLine; /* maximum length of a syslog message */ |
| 167 |
|
| 168 |
// TODO are the following ones defaults? |
| 169 |
int bReduceRepeatMsgs; /* reduce repeated message - 0 - no, 1 - yes */ |
| 170 |
|
| 171 |
// TODO: other representation for main queue? Or just load it differently? |
| 172 |
queuecnf_t mainQ; /* main queue parameters */ |
| 173 |
parsercnf_t parser; /* parser parameters */ |
| 174 |
}; |
| 175 |
|
| 176 |
/* (global) defaults are global in the sense that they are accessible |
| 177 |
* to all code, but they can change value and other objects (like |
| 178 |
* actions) actually copy the value a global had at the time the action |
| 179 |
* was defined. In that sense, a global default is just that, a default, |
| 180 |
* wich can (and will) be changed in the course of config file |
| 181 |
* processing. Once the config file has been processed, defaults |
| 182 |
* can be dropped. The current code does not do this for simplicity. |
| 183 |
* That is not a problem, because the defaults do not take up much memory. |
| 184 |
* At a later stage, we may think about dropping them. -- rgerhards, 2011-04-19 |
| 185 |
*/ |
| 186 |
struct defaults_s { |
| 187 |
int remove_me_when_first_real_member_is_added; |
| 188 |
}; |
| 189 |
|
| 190 |
|
| 191 |
/* list of modules loaded in this configuration (config specific module list) */ |
| 192 |
struct cfgmodules_etry_s { |
| 193 |
cfgmodules_etry_t *next; |
| 194 |
modInfo_t *pMod; |
| 195 |
void *modCnf; /* pointer to the input module conf */ |
| 196 |
/* the following data is input module specific */ |
| 197 |
sbool canActivate; /* OK to activate this config? */ |
| 198 |
sbool canRun; /* OK to run this config? */ |
| 199 |
}; |
| 200 |
|
| 201 |
struct cfgmodules_s { |
| 202 |
cfgmodules_etry_t *root; |
| 203 |
}; |
| 204 |
|
| 205 |
/* outchannel-specific data */ |
| 206 |
struct outchannels_s { |
| 207 |
struct outchannel *ochRoot; /* the root of the outchannel list */ |
| 208 |
struct outchannel *ochLast; /* points to the last element of the outchannel list */ |
| 209 |
}; |
| 210 |
|
| 211 |
struct templates_s { |
| 212 |
struct template *root; /* the root of the template list */ |
| 213 |
struct template *last; /* points to the last element of the template list */ |
| 214 |
struct template *lastStatic; /* last static element of the template list */ |
| 215 |
}; |
| 216 |
|
| 217 |
struct parsers_s { |
| 218 |
/* This is the list of all parsers known to us. |
| 219 |
* This is also used to unload all modules on shutdown. |
| 220 |
*/ |
| 221 |
parserList_t *pParsLstRoot; |
| 222 |
|
| 223 |
/* this is the list of the default parsers, to be used if no others |
| 224 |
* are specified. |
| 225 |
*/ |
| 226 |
parserList_t *pDfltParsLst; |
| 227 |
}; |
| 228 |
|
| 229 |
struct actions_s { |
| 230 |
/* number of active actions */ |
| 231 |
unsigned nbrActions; |
| 232 |
/* number of actions created. It is used to obtain unique IDs for the action. They |
| 233 |
* should not be relied on for any long-term activity (e.g. disk queue names!), but they are nice |
| 234 |
* to have during one instance of an rsyslogd run. For example, I use them to name actions when there |
| 235 |
* is no better name available. |
| 236 |
*/ |
| 237 |
int iActionNbr; |
| 238 |
}; |
| 239 |
|
| 240 |
|
| 241 |
struct rulesets_s { |
| 242 |
linkedList_t llRulesets; /* this is NOT a pointer - no typo here ;) */ |
| 243 |
|
| 244 |
/* support for legacy rsyslog.conf format */ |
| 245 |
ruleset_t *pCurr; /* currently "active" ruleset */ |
| 246 |
ruleset_t *pDflt; /* current default ruleset, e.g. for binding to actions which have no other */ |
| 247 |
}; |
| 248 |
|
| 249 |
|
| 250 |
/* --- end configuration objects --- */ |
| 251 |
|
| 252 |
/* the rsconf object */ |
| 253 |
struct rsconf_s { |
| 254 |
BEGINobjInstance |
| 255 |
; /* Data to implement generic object - MUST be the first data element! */ |
| 256 |
cfgmodules_t modules; |
| 257 |
globals_t globals; |
| 258 |
defaults_t defaults; |
| 259 |
templates_t templates; |
| 260 |
parsers_t parsers; |
| 261 |
lookup_tables_t lu_tabs; |
| 262 |
dynstats_buckets_t dynstats_buckets; |
| 263 |
perctile_buckets_t perctile_buckets; |
| 264 |
outchannels_t och; |
| 265 |
actions_t actions; |
| 266 |
rulesets_t rulesets; |
| 267 |
/* note: rulesets include the complete output part: |
| 268 |
* - rules |
| 269 |
* - filter (as part of the action) |
| 270 |
* - actions |
| 271 |
* Of course, we need to debate if we shall change that some time... |
| 272 |
*/ |
| 273 |
timezones_t timezones; |
| 274 |
qqueue_t *pMsgQueue; /* the main message queue */ |
| 275 |
ratelimit_cfgs_t ratelimit_cfgs; |
| 276 |
}; |
| 277 |
|
| 278 |
|
| 279 |
/* interfaces */ |
| 280 |
BEGINinterface(rsconf) /* name must also be changed in ENDinterface macro! */ |
| 281 |
INTERFACEObjDebugPrint(rsconf); |
| 282 |
rsRetVal (*Destruct)(rsconf_t **ppThis); |
| 283 |
rsRetVal (*Load)(rsconf_t **ppThis, uchar *confFile); |
| 284 |
rsRetVal (*Activate)(rsconf_t *ppThis); |
| 285 |
ENDinterface(rsconf) |
| 286 |
// TODO: switch version to 1 for first "complete" version!!!! 2011-04-20 |
| 287 |
#define rsconfCURR_IF_VERSION 0 /* increment whenever you change the interface above! */ |
| 288 |
|
| 289 |
|
| 290 |
/* prototypes */ |
| 291 |
PROTOTYPEObjFull(rsconf); |
| 292 |
/* globally-visible external data */ |
| 293 |
extern rsconf_t *runConf; /* the currently running config */ |
| 294 |
extern rsconf_t *loadConf; /* the config currently being loaded (no concurrent config load supported!) */ |
| 295 |
|
| 296 |
|
| 297 |
int rsconfNeedDropPriv(rsconf_t *const cnf); |
| 298 |
|
| 299 |
/* some defaults (to be removed?) */ |
| 300 |
#define DFLT_bLogStatusMsgs 1 |
| 301 |
|
| 302 |
#endif /* #ifndef INCLUDED_RSCONF_H */ |