| 1 |
/* Definition of globally-accessible data items. |
| 2 |
* |
| 3 |
* This module provides access methods to items of global scope. Most often, |
| 4 |
* these globals serve as defaults to initialize local settings. Currently, |
| 5 |
* many of them are either constants or global variable references. However, |
| 6 |
* this module provides the necessary hooks to change that at any time. |
| 7 |
* |
| 8 |
* Please note that there currently is no glbl.c file as we do not yet |
| 9 |
* have any implementations. |
| 10 |
* |
| 11 |
* Copyright 2008-2024 Rainer Gerhards and Adiscon GmbH. |
| 12 |
* |
| 13 |
* This file is part of the rsyslog runtime library. |
| 14 |
* |
| 15 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 16 |
* you may not use this file except in compliance with the License. |
| 17 |
* You may obtain a copy of the License at |
| 18 |
* |
| 19 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 20 |
* -or- |
| 21 |
* see COPYING.ASL20 in the source distribution |
| 22 |
* |
| 23 |
* Unless required by applicable law or agreed to in writing, software |
| 24 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 25 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 26 |
* See the License for the specific language governing permissions and |
| 27 |
* limitations under the License. |
| 28 |
*/ |
| 29 |
|
| 30 |
#ifndef GLBL_H_INCLUDED |
| 31 |
#define GLBL_H_INCLUDED |
| 32 |
|
| 33 |
#include <sys/types.h> |
| 34 |
#ifdef ENABLE_LIBLOGGING_STDLOG |
| 35 |
#include <liblogging/stdlog.h> |
| 36 |
#endif |
| 37 |
#include "rainerscript.h" |
| 38 |
#include "prop.h" |
| 39 |
|
| 40 |
#define glblGetIOBufSize() 4096 /* size of the IO buffer, e.g. for strm class */ |
| 41 |
#define glblOversizeMsgInputMode_Truncate 0 |
| 42 |
#define glblOversizeMsgInputMode_Split 1 |
| 43 |
#define glblOversizeMsgInputMode_Accept 2 |
| 44 |
|
| 45 |
extern pid_t glbl_ourpid; |
| 46 |
|
| 47 |
/* interfaces */ |
| 48 |
BEGINinterface(glbl) /* name must also be changed in ENDinterface macro! */ |
| 49 |
uchar *(*GetWorkDir)(rsconf_t *cnf); |
| 50 |
int (*GetMaxLine)(rsconf_t *cnf); |
| 51 |
#define SIMP_PROP(name, dataType) \ |
| 52 |
dataType (*Get##name)(void); \ |
| 53 |
rsRetVal (*Set##name)(dataType) |
| 54 |
SIMP_PROP(OptimizeUniProc, int); |
| 55 |
SIMP_PROP(PreserveFQDN, int); |
| 56 |
SIMP_PROP(LocalFQDNName, uchar *); |
| 57 |
SIMP_PROP(mainqCnfObj, struct cnfobj *); |
| 58 |
SIMP_PROP(LocalHostName, uchar *); |
| 59 |
SIMP_PROP(LocalDomain, uchar *); |
| 60 |
/* added v3, 2009-06-30 */ |
| 61 |
rsRetVal (*GenerateLocalHostNameProperty)(void); |
| 62 |
prop_t *(*GetLocalHostNameProp)(void); |
| 63 |
/* added v4, 2009-07-20 */ |
| 64 |
int (*GetGlobalInputTermState)(void); |
| 65 |
void (*SetGlobalInputTermination)(void); |
| 66 |
/* added v5, 2009-11-03 */ |
| 67 |
/* note: v4, v5 are already used by more recent versions, so we need to skip them! */ |
| 68 |
/* added v6, 2009-11-16 as part of varmojfekoj's "unlimited select()" patch |
| 69 |
* Note that it must be always present, otherwise the interface would have different |
| 70 |
* versions depending on compile settings, what is not acceptable. |
| 71 |
* Use this property with care, it is only truly available if UNLIMITED_SELECT is enabled |
| 72 |
* (I did not yet further investigate the details, because that code hopefully can be removed |
| 73 |
* at some later stage). |
| 74 |
*/ |
| 75 |
SIMP_PROP(FdSetSize, int); |
| 76 |
/* v7: was neeeded to mean v5+v6 - do NOT add anything else for that version! */ |
| 77 |
/* next change is v9! */ |
| 78 |
/* v8 - 2012-03-21 */ |
| 79 |
prop_t *(*GetLocalHostIP)(void); |
| 80 |
uchar *(*GetSourceIPofLocalClient)(void); /* [ar] */ |
| 81 |
rsRetVal (*SetSourceIPofLocalClient)(uchar *); /* [ar] */ |
| 82 |
/* v9 - 2015-01-12 SetMaxLine method removed */ |
| 83 |
/* v10 - global variables should be moved to the rsconf_t data structure, so |
| 84 |
* dynamic configuration reload can be introduced. This is why each getter needs additional |
| 85 |
* parameter specifying a configuration it belongs to(either loadConf or runConf) |
| 86 |
*/ |
| 87 |
#undef SIMP_PROP |
| 88 |
#define SIMP_PROP(name, dataType) \ |
| 89 |
dataType (*Get##name)(rsconf_t * cnf); \ |
| 90 |
rsRetVal (*Set##name)(dataType) |
| 91 |
|
| 92 |
SIMP_PROP(DropMalPTRMsgs, int); |
| 93 |
SIMP_PROP(DfltNetstrmDrvrCAF, uchar *); |
| 94 |
SIMP_PROP(DfltNetstrmDrvrCRLF, uchar *); |
| 95 |
SIMP_PROP(DfltNetstrmDrvrCertFile, uchar *); |
| 96 |
SIMP_PROP(DfltNetstrmDrvrKeyFile, uchar *); |
| 97 |
SIMP_PROP(DfltNetstrmDrvr, uchar *); |
| 98 |
SIMP_PROP(DfltOpensslEngine, uchar *); |
| 99 |
SIMP_PROP(DefPFFamily, int); |
| 100 |
SIMP_PROP(DisableDNS, int); |
| 101 |
SIMP_PROP(NetstrmDrvrCAExtraFiles, uchar *); |
| 102 |
SIMP_PROP(ParserControlCharacterEscapePrefix, uchar); |
| 103 |
SIMP_PROP(ParserDropTrailingLFOnReception, int); |
| 104 |
SIMP_PROP(ParserEscapeControlCharactersOnReceive, int); |
| 105 |
SIMP_PROP(ParserSpaceLFOnReceive, int); |
| 106 |
SIMP_PROP(ParserEscape8BitCharactersOnReceive, int); |
| 107 |
SIMP_PROP(ParserEscapeControlCharacterTab, int); |
| 108 |
SIMP_PROP(ParserEscapeControlCharactersCStyle, int); |
| 109 |
SIMP_PROP(ParseHOSTNAMEandTAG, int); |
| 110 |
SIMP_PROP(OptionDisallowWarning, int); |
| 111 |
|
| 112 |
#undef SIMP_PROP |
| 113 |
ENDinterface(glbl) |
| 114 |
#define glblCURR_IF_VERSION 10 /* increment whenever you change the interface structure! */ |
| 115 |
/* version 2 had PreserveFQDN added - rgerhards, 2008-12-08 */ |
| 116 |
|
| 117 |
/* the remaining prototypes */ |
| 118 |
PROTOTYPEObj(glbl); |
| 119 |
|
| 120 |
extern int glblJsonFormatOpt; |
| 121 |
extern int glblUnloadModules; |
| 122 |
extern short janitorInterval; |
| 123 |
extern char **glblDbgFiles; |
| 124 |
extern size_t glblDbgFilesNum; |
| 125 |
extern int glblDbgWhitelist; |
| 126 |
extern int glblPermitCtlC; |
| 127 |
extern int glblAbortOnProgramError; |
| 128 |
extern int bTerminateInputs; |
| 129 |
#ifndef HAVE_ATOMIC_BUILTINS |
| 130 |
extern DEF_ATOMIC_HELPER_MUT(mutTerminateInputs); |
| 131 |
#endif |
| 132 |
|
| 133 |
/* Developer options enable some strange things for developer-only testing. |
| 134 |
* These should never be enabled in a user build, except if explicitly told |
| 135 |
* by a developer. The options are acutally flags, so they should be powers |
| 136 |
* of two. Flag assignment may change between versions, **backward |
| 137 |
* compatibility is NOT necessary**. |
| 138 |
* rgerhards, 2018-04-28 |
| 139 |
*/ |
| 140 |
#define DEV_OPTION_KEEP_RUNNING_ON_HARD_CONF_ERROR 1 |
| 141 |
#define DEV_OPTION_8_1905_HANG_TEST 2 // TODO: remove - temporary for bughunt |
| 142 |
|
| 143 |
#define glblGetOurPid() glbl_ourpid |
| 144 |
#define glblSetOurPid(pid) \ |
| 145 |
{ glbl_ourpid = (pid); } |
| 146 |
|
| 147 |
void glblPrepCnf(void); |
| 148 |
void glblProcessCnf(struct cnfobj *o); |
| 149 |
void glblProcessMainQCnf(struct cnfobj *o); |
| 150 |
void glblDestructMainqCnfObj(void); |
| 151 |
rsRetVal glblDoneLoadCnf(void); |
| 152 |
const uchar *glblGetWorkDirRaw(rsconf_t *cnf); |
| 153 |
int GetGnuTLSLoglevel(rsconf_t *cnf); |
| 154 |
int glblGetMaxLine(rsconf_t *cnf); |
| 155 |
int bs_arrcmp_glblDbgFiles(const void *s1, const void *s2); |
| 156 |
uchar *glblGetOversizeMsgErrorFile(rsconf_t *cnf); |
| 157 |
const uchar *glblGetOperatingStateFile(rsconf_t *cnf); |
| 158 |
int glblGetOversizeMsgInputMode(rsconf_t *cnf); |
| 159 |
int glblReportOversizeMessage(rsconf_t *cnf); |
| 160 |
void glblReportChildProcessExit(rsconf_t *cnf, const uchar *name, pid_t pid, int status); |
| 161 |
uchar *glblGetLocalHostName(void); |
| 162 |
|
| 163 |
#endif /* #ifndef GLBL_H_INCLUDED */ |