diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2012-04-12 14:10:09 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-04-12 14:10:09 +0200 |
commit | e4d87aac957ea639935f56fb8b03f3c03d037491 (patch) | |
tree | b479a4ebfda4228355801dea625346e7a7e0798f /runtime/glbl.c | |
parent | bd8d972a975ce794dd71c1c8db724991dd4744a0 (diff) | |
parent | d749dadcc30e35448894a152fb0ddf77d60b8300 (diff) | |
download | rsyslog-e4d87aac957ea639935f56fb8b03f3c03d037491.tar.gz rsyslog-e4d87aac957ea639935f56fb8b03f3c03d037491.tar.xz rsyslog-e4d87aac957ea639935f56fb8b03f3c03d037491.zip |
Merge branch 'v5-stable' into v5-stable-newstats
Conflicts:
plugins/imuxsock/imuxsock.c
runtime/glbl.c
Diffstat (limited to 'runtime/glbl.c')
-rw-r--r-- | runtime/glbl.c | 88 |
1 files changed, 58 insertions, 30 deletions
diff --git a/runtime/glbl.c b/runtime/glbl.c index 4f2ee377..ff4358c4 100644 --- a/runtime/glbl.c +++ b/runtime/glbl.c @@ -70,10 +70,10 @@ static int option_DisallowWarning = 1; /* complain if message from disallowed se static int bDisableDNS = 0; /* don't look up IP addresses of remote messages */ static prop_t *propLocalIPIF = NULL;/* IP address to report for the local host (default is 127.0.0.1) */ static prop_t *propLocalHostName = NULL;/* our hostname as FQDN - read-only after startup */ -static uchar *LocalHostName = NULL;/* our hostname - read-only after startup */ +static uchar *LocalHostName = NULL;/* our hostname - read-only after startup, except HUP */ static uchar *LocalHostNameOverride = NULL;/* user-overridden hostname - read-only after startup */ -static uchar *LocalFQDNName = NULL;/* our hostname as FQDN - read-only after startup */ -static uchar *LocalDomain; /* our local domain name - read-only after startup */ +static uchar *LocalFQDNName = NULL;/* our hostname as FQDN - read-only after startup, except HUP */ +static uchar *LocalDomain = NULL;/* our local domain name - read-only after startup, except HUP */ static char **StripDomains = NULL;/* these domains may be stripped before writing logs - r/o after s.u., never touched by init */ static char **LocalHosts = NULL;/* these hosts are logged with their hostname - read-only after startup, never touched by init */ static uchar *pszDfltNetstrmDrvr = NULL; /* module name of default netstream driver */ @@ -116,15 +116,12 @@ SIMP_PROP(DefPFFamily, iDefPFFamily, int) /* note that in the future we may chec SIMP_PROP(DropMalPTRMsgs, bDropMalPTRMsgs, int) SIMP_PROP(Option_DisallowWarning, option_DisallowWarning, int) SIMP_PROP(DisableDNS, bDisableDNS, int) -SIMP_PROP(LocalDomain, LocalDomain, uchar*) SIMP_PROP(StripDomains, StripDomains, char**) SIMP_PROP(LocalHosts, LocalHosts, char**) #ifdef USE_UNLIMITED_SELECT SIMP_PROP(FdSetSize, iFdSetSize, int) #endif -SIMP_PROP_SET(LocalFQDNName, LocalFQDNName, uchar*) -SIMP_PROP_SET(LocalHostName, LocalHostName, uchar*) SIMP_PROP_SET(DfltNetstrmDrvr, pszDfltNetstrmDrvr, uchar*) /* TODO: use custom function which frees existing value */ SIMP_PROP_SET(DfltNetstrmDrvrCAF, pszDfltNetstrmDrvrCAF, uchar*) /* TODO: use custom function which frees existing value */ SIMP_PROP_SET(DfltNetstrmDrvrKeyFile, pszDfltNetstrmDrvrKeyFile, uchar*) /* TODO: use custom function which frees existing value */ @@ -273,6 +270,20 @@ GetLocalHostIP(void) return(propLocalIPIF); } + +/* set our local hostname. Free previous hostname, if it was already set. + * Note that we do now do this in a thread + * "once in a lifetime" action which can not be undone. -- gerhards, 2009-07-20 + */ +static rsRetVal +SetLocalHostName(uchar *newname) +{ + free(LocalHostName); + LocalHostName = newname; + return RS_RET_OK; +} + + /* return our local hostname. if it is not set, "[localhost]" is returned */ static uchar* @@ -298,6 +309,26 @@ done: } +/* set our local domain name. Free previous domain, if it was already set. + */ +static rsRetVal +SetLocalDomain(uchar *newname) +{ + free(LocalDomain); + LocalDomain = newname; + return RS_RET_OK; +} + + +/* return our local hostname. if it is not set, "[localhost]" is returned + */ +static uchar* +GetLocalDomain(void) +{ + return LocalDomain; +} + + /* generate the local hostname property. This must be done after the hostname info * has been set as well as PreserveFQDN. * rgerhards, 2009-06-30 @@ -342,6 +373,14 @@ GetLocalHostNameProp(void) } +static rsRetVal +SetLocalFQDNName(uchar *newname) +{ + free(LocalFQDNName); + LocalFQDNName = newname; + return RS_RET_OK; +} + /* return the current localhost name as FQDN (requires FQDN to be set) * TODO: we should set the FQDN ourselfs in here! */ @@ -445,30 +484,18 @@ ENDobjQueryInterface(glbl) */ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal) { - if(pszDfltNetstrmDrvr != NULL) { - free(pszDfltNetstrmDrvr); - pszDfltNetstrmDrvr = NULL; - } - if(pszDfltNetstrmDrvrCAF != NULL) { - free(pszDfltNetstrmDrvrCAF); - pszDfltNetstrmDrvrCAF = NULL; - } - if(pszDfltNetstrmDrvrKeyFile != NULL) { - free(pszDfltNetstrmDrvrKeyFile); - pszDfltNetstrmDrvrKeyFile = NULL; - } - if(pszDfltNetstrmDrvrCertFile != NULL) { - free(pszDfltNetstrmDrvrCertFile); - pszDfltNetstrmDrvrCertFile = NULL; - } - if(LocalHostNameOverride != NULL) { - free(LocalHostNameOverride); - LocalHostNameOverride = NULL; - } - if(pszWorkDir != NULL) { - free(pszWorkDir); - pszWorkDir = NULL; - } + free(pszDfltNetstrmDrvr); + pszDfltNetstrmDrvr = NULL; + free(pszDfltNetstrmDrvrCAF); + pszDfltNetstrmDrvrCAF = NULL; + free(pszDfltNetstrmDrvrKeyFile); + pszDfltNetstrmDrvrKeyFile = NULL; + free(pszDfltNetstrmDrvrCertFile); + pszDfltNetstrmDrvrCertFile = NULL; + free(LocalHostNameOverride); + LocalHostNameOverride = NULL; + free(pszWorkDir); + pszWorkDir = NULL; bDropMalPTRMsgs = 0; bOptimizeUniProc = 1; bPreserveFQDN = 0; @@ -515,6 +542,7 @@ BEGINObjClassExit(glbl, OBJ_IS_CORE_MODULE) /* class, version */ free(pszDfltNetstrmDrvrKeyFile); free(pszDfltNetstrmDrvrCertFile); free(pszWorkDir); + free(LocalDomain); free(LocalHostName); free(LocalHostNameOverride); free(LocalFQDNName); |