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-2019 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 extern int bProcessInternalMessages; 47 extern int bPermitSlashInProgramname; 48 #ifdef ENABLE_LIBLOGGING_STDLOG 49 extern stdlog_channel_t stdlog_hdl; 50 #endif 51 52 /* interfaces */ 53 BEGINinterface(glbl) /* name must also be changed in ENDinterface macro! */ 54 uchar* (*GetWorkDir)(void); 55 int (*GetMaxLine)(void); 56 #define SIMP_PROP(name, dataType) \ 57 dataType (*Get##name)(void); \ 58 rsRetVal (*Set##name)(dataType); 59 SIMP_PROP(OptimizeUniProc, int) 60 SIMP_PROP(PreserveFQDN, int) 61 SIMP_PROP(DefPFFamily, int) 62 SIMP_PROP(DropMalPTRMsgs, int) 63 SIMP_PROP(Option_DisallowWarning, int) 64 SIMP_PROP(DisableDNS, int) 65 SIMP_PROP(LocalFQDNName, uchar*) 66 SIMP_PROP(mainqCnfObj, struct cnfobj*) 67 SIMP_PROP(LocalHostName, uchar*) 68 SIMP_PROP(LocalDomain, uchar*) 69 SIMP_PROP(StripDomains, char**) 70 SIMP_PROP(LocalHosts, char**) 71 SIMP_PROP(DfltNetstrmDrvr, uchar*) 72 SIMP_PROP(DfltNetstrmDrvrCAF, uchar*) 73 SIMP_PROP(DfltNetstrmDrvrKeyFile, uchar*) 74 SIMP_PROP(DfltNetstrmDrvrCertFile, uchar*) 75 SIMP_PROP(ParserControlCharacterEscapePrefix, uchar) 76 SIMP_PROP(ParserDropTrailingLFOnReception, int) 77 SIMP_PROP(ParserEscapeControlCharactersOnReceive, int) 78 SIMP_PROP(ParserSpaceLFOnReceive, int) 79 SIMP_PROP(ParserEscape8BitCharactersOnReceive, int) 80 SIMP_PROP(ParserEscapeControlCharacterTab, int) 81 SIMP_PROP(ParserEscapeControlCharactersCStyle, int) 82 /* added v3, 2009-06-30 */ 83 rsRetVal (*GenerateLocalHostNameProperty)(void); 84 prop_t* (*GetLocalHostNameProp)(void); 85 /* added v4, 2009-07-20 */ 86 int (*GetGlobalInputTermState)(void); 87 void (*SetGlobalInputTermination)(void); 88 /* added v5, 2009-11-03 */ 89 SIMP_PROP(ParseHOSTNAMEandTAG, int) 90 /* note: v4, v5 are already used by more recent versions, so we need to skip them! */ 91 /* added v6, 2009-11-16 as part of varmojfekoj's "unlimited select()" patch 92 * Note that it must be always present, otherwise the interface would have different 93 * versions depending on compile settings, what is not acceptable. 94 * Use this property with care, it is only truly available if UNLIMITED_SELECT is enabled 95 * (I did not yet further investigate the details, because that code hopefully can be removed 96 * at some later stage). 97 */ 98 SIMP_PROP(FdSetSize, int) 99 /* v7: was neeeded to mean v5+v6 - do NOT add anything else for that version! */ 100 /* next change is v9! */ 101 /* v8 - 2012-03-21 */ 102 prop_t* (*GetLocalHostIP)(void); 103 uchar* (*GetSourceIPofLocalClient)(void); /* [ar] */ 104 rsRetVal (*SetSourceIPofLocalClient)(uchar*); /* [ar] */ 105 /* v9 - 2015-01-12 SetMaxLine method removed */ 106 #undef SIMP_PROP 107 ENDinterface(glbl) 108 #define glblCURR_IF_VERSION 9 /* increment whenever you change the interface structure! */ 109 /* version 2 had PreserveFQDN added - rgerhards, 2008-12-08 */ 110 111 /* the remaining prototypes */ 112 PROTOTYPEObj(glbl); 113 114 extern int glblDebugOnShutdown; /* start debug log when we are shut down */ 115 extern int glblReportNewSenders; 116 extern int glblReportGoneAwaySenders; 117 extern int glblSenderStatsTimeout; 118 extern int glblSenderKeepTrack; 119 extern int glblUnloadModules; 120 extern short janitorInterval; 121 extern int glblIntMsgRateLimitItv; 122 extern int glblIntMsgRateLimitBurst; 123 extern char** glblDbgFiles; 124 extern size_t glblDbgFilesNum; 125 extern int glblDbgWhitelist; 126 extern int glblPermitCtlC; 127 extern int glblInputTimeoutShutdown; 128 extern int glblIntMsgsSeverityFilter; 129 extern int bTerminateInputs; 130 extern int glblShutdownQueueDoubleSize; 131 #ifndef HAVE_ATOMIC_BUILTINS 132 extern DEF_ATOMIC_HELPER_MUT(mutTerminateInputs); 133 #endif 134 135 /* Developer options enable some strange things for developer-only testing. 136 * These should never be enabled in a user build, except if explicitly told 137 * by a developer. The options are acutally flags, so they should be powers 138 * of two. Flag assignment may change between versions, **backward 139 * compatibility is NOT necessary**. 140 * rgerhards, 2018-04-28 141 */ 142 #define DEV_OPTION_KEEP_RUNNING_ON_HARD_CONF_ERROR 1 143 #define DEV_OPTION_8_1905_HANG_TEST 2 // TODO: remove - temporary for bughunt 144 extern uint64_t glblDevOptions; 145 146 #define glblGetOurPid() glbl_ourpid 147 #define glblSetOurPid(pid) { glbl_ourpid = (pid); } 148 149 void glblPrepCnf(void); 150 void glblProcessCnf(struct cnfobj *o); 151 void glblProcessTimezone(struct cnfobj *o); 152 void glblProcessMainQCnf(struct cnfobj *o); 153 void glblDestructMainqCnfObj(void); 154 rsRetVal glblDoneLoadCnf(void); 155 const uchar * glblGetWorkDirRaw(void); 156 tzinfo_t* glblFindTimezoneInfo(char *id); 157 int GetGnuTLSLoglevel(void); 158 int glblGetMaxLine(void); 159 int bs_arrcmp_glblDbgFiles(const void *s1, const void *s2); 160 uchar* glblGetOversizeMsgErrorFile(void); 161 const uchar* glblGetOperatingStateFile(void); 162 int glblGetOversizeMsgInputMode(void); 163 int glblReportOversizeMessage(void); 164 void glblReportChildProcessExit(const uchar *name, pid_t pid, int status); 165 166 #endif /* #ifndef GLBL_H_INCLUDED */ 167