Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:FrontRunner
rsyslog.35890
0001-core-bugfix-rsyslog-messages-may-not-alway...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-core-bugfix-rsyslog-messages-may-not-always-have-FQD.patch of Package rsyslog.35890
From 280978f59af3d1111cdc230d4cde167b0b9769f6 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards <rgerhards@adiscon.com> Date: Wed, 6 Dec 2023 17:11:20 +0100 Subject: [PATCH] core bugfix: rsyslog messages may not always have FQDN Even if hostname FQDN is configured, rsyslog internal messages generated after rsyslog startup and before the first HUP will not necessarily have FQDN but instead only the shortname of the local host. This commit fixes the situation. Special thanks to github user eciii for doing a great bug analysis and helping us considerably to fix the issue. closes https://github.com/rsyslog/rsyslog/issues/5218 (cherry picked from commit f886d1f1b2fcda9d9b72efdc15b387d3fc9b1f55) --- runtime/glbl.c | 4 ++-- runtime/net.c | 4 ++-- runtime/net.h | 2 +- runtime/rsconf.h | 2 +- runtime/rsyslog.h | 4 ++-- tools/rsyslogd.c | 9 ++++++--- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/runtime/glbl.c b/runtime/glbl.c index 178ea330a..680538836 100644 --- a/runtime/glbl.c +++ b/runtime/glbl.c @@ -7,7 +7,7 @@ * * Module begun 2008-04-16 by Rainer Gerhards * - * Copyright 2008-2022 Rainer Gerhards and Adiscon GmbH. + * Copyright 2008-2023 Rainer Gerhards and Adiscon GmbH. * * This file is part of the rsyslog runtime library. * @@ -1412,7 +1412,7 @@ finalize_it: * hostname. These messages are currently in iminternal queue. Once they * are taken from that queue, the hostname will be adapted. */ - queryLocalHostname(); + queryLocalHostname(loadConf); RETiRet; } diff --git a/runtime/net.c b/runtime/net.c index 861112586..ff46cbcab 100644 --- a/runtime/net.c +++ b/runtime/net.c @@ -1160,7 +1160,7 @@ cvthname(struct sockaddr_storage *f, prop_t **localName, prop_t **fqdn, prop_t * */ #define EMPTY_HOSTNAME_REPLACEMENT "localhost-empty-hostname" static rsRetVal -getLocalHostname(uchar **ppName) +getLocalHostname(rsconf_t *const pConf, uchar **ppName) { DEFiRet; char hnbuf[8192]; @@ -1183,7 +1183,7 @@ getLocalHostname(uchar **ppName) char *dot = strstr(hnbuf, "."); struct addrinfo *res = NULL; - if(!empty_hostname && dot == NULL && runConf != NULL && !glbl.GetDisableDNS(runConf)) { + if(!empty_hostname && dot == NULL && pConf != NULL && !glbl.GetDisableDNS(pConf)) { /* we need to (try) to find the real name via resolver */ struct addrinfo flags; memset(&flags, 0, sizeof(flags)); diff --git a/runtime/net.h b/runtime/net.h index c2847f65f..88d2df5f1 100644 --- a/runtime/net.h +++ b/runtime/net.h @@ -152,7 +152,7 @@ BEGINinterface(net) /* name must also be changed in ENDinterface macro! */ int ipfreebind, char *device); void (*closeUDPListenSockets)(int *finet); int (*isAllowedSender)(uchar *pszType, struct sockaddr *pFrom, const char *pszFromHost); /* deprecated! */ - rsRetVal (*getLocalHostname)(uchar**); + rsRetVal (*getLocalHostname)(rsconf_t *const, uchar**); int (*should_use_so_bsdcompat)(void); /* permitted peer handling should be replaced by something better (see comments above) */ rsRetVal (*AddPermittedPeer)(permittedPeers_t **ppRootPeer, uchar *pszID); diff --git a/runtime/rsconf.h b/runtime/rsconf.h index 4725f916f..2ea34eac4 100644 --- a/runtime/rsconf.h +++ b/runtime/rsconf.h @@ -1,6 +1,6 @@ /* The rsconf object. It models a complete rsyslog configuration. * - * Copyright 2011-2022 Rainer Gerhards and Adiscon GmbH. + * Copyright 2011-2023 Rainer Gerhards and Adiscon GmbH. * * This file is part of the rsyslog runtime library. * diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h index 01616d8f7..da9006949 100644 --- a/runtime/rsyslog.h +++ b/runtime/rsyslog.h @@ -3,7 +3,7 @@ * * Begun 2005-09-15 RGerhards * - * Copyright (C) 2005-2019 by Rainer Gerhards and Adiscon GmbH + * Copyright (C) 2005-2023 by Rainer Gerhards and Adiscon GmbH * * This file is part of the rsyslog runtime library. * @@ -779,7 +779,7 @@ rsRetVal rsrtExit(void); int rsrtIsInit(void); void rsrtSetErrLogger(void (*errLogger)(const int, const int, const uchar*)); void dfltErrLogger(const int, const int, const uchar *errMsg); -rsRetVal queryLocalHostname(void); +rsRetVal queryLocalHostname(rsconf_t *const); /* this define below is (later) intended to be used to implement empty diff --git a/tools/rsyslogd.c b/tools/rsyslogd.c index 3b4de5f43..55eb37e1b 100644 --- a/tools/rsyslogd.c +++ b/tools/rsyslogd.c @@ -233,15 +233,18 @@ setsid(void) #endif +/* we need a pointer to the conf, because in early startup stage we + * need to use loadConf, later on runConf. + */ rsRetVal -queryLocalHostname(void) +queryLocalHostname(rsconf_t *const pConf) { uchar *LocalHostName = NULL; uchar *LocalDomain = NULL; uchar *LocalFQDNName; DEFiRet; - CHKiRet(net.getLocalHostname(&LocalFQDNName)); + CHKiRet(net.getLocalHostname(pConf, &LocalFQDNName)); uchar *dot = (uchar*) strstr((char*)LocalFQDNName, "."); if(dot == NULL) { CHKmalloc(LocalHostName = (uchar*) strdup((char*)LocalFQDNName)); @@ -1839,7 +1842,7 @@ doHUP(void) logmsgInternal(NO_ERRCODE, LOG_SYSLOG|LOG_INFO, (uchar*)buf, 0); } - queryLocalHostname(); /* re-read our name */ + queryLocalHostname(runConf); /* re-read our name */ ruleset.IterateAllActions(ourConf, doHUPActions, NULL); modDoHUP(); lookupDoHUP(); -- 2.46.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor