dnscache: preserve hostname case in localName property #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary (non-technical, complete)
Fixes test failures on systems with mixed-case hostnames (e.g.,
build32U10b32b1b199). The DNS cache was incorrectly lowercasing hostnames when they should preserve the original case from DNS resolution.References
Refs: https://github.com/rsyslog/rsyslog/issues/PLACEHOLDER (issue describing parsertest-parse1-udp.sh failure on cloud hosts)
Notes
Root cause:
runtime/dnscache.c:setLocalHostName()was usingfqdnLowerCaseinstead offqdnwhen creating thelocalNameproperty.What changed:
fqdnproperty (notfqdnLowerCase)fqdnLowerCasestill available for case-insensitive matchingBefore/After:
Impact: UDP messages without hostnames now preserve case from reverse DNS. Affects:
parsertest-parse1-udp.shparsertest-parse-nodate-udp.shMost existing deployments unaffected (hostnames typically lowercase by convention).
Quick check (optional)
<component>:).Original prompt
使用一台云主机编译rsyslog的时候,rsyslog tests 用例parsertest-parse1-udp.sh失败,日志报错信息如下,请帮助分析原因,并解决问题。 tr: write error: Broken pipe
testbench: TZ env var not set, setting it to UTC
01:55:00[0] Test: ./parsertest-parse1-udp.sh
Obtaining HOSTNAME (prerequisite, not actual test)
config rstb_607389_d1146e46d42O_.conf is:
1 module(load="../plugins/imdiag/.libs/imdiag")
2 global(inputs.timeout.shutdown="60000"
3 default.action.queue.timeoutshutdown="20000"
4 default.action.queue.timeoutEnqueue="20000")
5 # use legacy-style for the following settings so that we can override if needed
6 $MainmsgQueueTimeoutEnqueue 20000
7 $MainmsgQueueTimeoutShutdown 10000
8 $IMDiagListenPortFileName rstb_607389_d1146e46d42O.imdiag.port
9 $IMDiagServerRun 0
10 $IMDiagAbortTimeout 580
11
12 :syslogtag, contains, "rsyslogd" ./rstb_607389_d1146e46d42O.started
13 ###### end of testbench instrumentation part, test conf follows:
14 module(load="../plugins/imtcp/.libs/imtcp")
15 input(type="imtcp" port="0" listenPortFileName="rstb_607389_d1146e46d42O.tcpflood_port")
16
17 $template hostname,"%hostname%"
18 local0.* ./rstb_607389_d1146e46d42O.HOSTNAME;hostname
rsyslogd: NOTE: RSYSLOG_DEBUG_TIMEOUTS_TO_STDERR activated
main Q:Reg: worker start requested, num workers currently 0
main Q:Reg: wrkr start initiated with state 0, num workers now 1
rsyslog debug: main Q:Reg: worker 0xaaaeb2314660 started
rsyslog debug: main Q:Reg: started with state 3, num workers now 1
01:55:00[0] rstb_607389_d1146e46d42O:.pid found, pid 2477558
01:55:00[0] rsyslogd startup msg seen, pid 2477558
waiting for file rstb_607389_d1146e46d42O.imdiag.port
imdiag port: 43797
waiting for file rstb_607389_d1146e46d42O.tcpflood_port
TCPFLOOD_PORT now: 36821
starting run 1
Sending 1 messages.
00000001 messages sent
runtime: 0.000
End of tcpflood Run
Shutting down instance 1
imdiag: wait q_empty: qsize 0 nempty 1
imdiag[43797]: mainqueue empty
rsyslogd debug: info: trying to cooperatively stop input ../plugins/imdiag/.libs/imdiag, timeout 60000 ms
rsyslogd debug: info: trying to cooperatively stop input imtcp, timeout 60000 ms
rsyslog debug: main Q:Reg/w0: enter WrkrExecCleanup
rsyslog debug: 0xaaaeb23147f0: worker exiting
rsyslog debug: main Q:Reg/w0: thread joined
01:55:01[1] wait on shutdown of 2477558
HOSTNAME is: build32U10b32b1b199
mkdir: cannot create directory 'rstb_607389_d1146e46d42O.spool': File exists
config rstb_607389_d1146e46d42O_.conf is:
1 module(load="../plugins/imdiag/.libs/imdiag")
2 global(inputs.timeout.shutdown="60000"
3 default.action.queue.timeoutshutdown="20000"
4 default.action.queue.timeoutEnqueue="20000")
5 # use legacy-style for the following settings so that we can override if needed
6 $MainmsgQueueTimeoutEnqueue 20000
7 $MainmsgQueueTimeoutShutdown 10000
8 $IMDiagListenPortFileName rstb_607389_d1146e46d42O.imdiag.port
9 $IMDiagServerRun 0
10 $IMDiagAbortTimeout 580
11
12 :syslogtag, contains, "rsyslogd" ./rstb_607389_d1146e46d42O.started
13 ###### end of testbench instrumentation part, test conf follows:
14
15 module(load="../plugins/imudp/.libs/imudp")
16 input(type="imudp" port="54403" ruleset="ruleset1")
17
18 global(localHostname="localhost")
19
20 template(name="outfmt" type="string" string="%PRI%,%syslogfacility-text%,%syslogseverity-text%,%timestamp%,%hostname%,%programname%,%syslogtag%,%msg%\n")
21
22 ruleset(name="ruleset1") {
23 action(type="omfile" file=
echo $RSYSLOG_OUT_LOG24 template="outfmt")
25 }
26
rsyslogd: NOTE: RSYSLOG_DEBUG_TIMEOUTS_TO_STDERR activated
main Q:Reg: worker start requested, num workers currently 0
main Q:Reg: wrkr start initiated with state 0, num workers now 1
rsyslog debug: main Q:Reg: worker 0xaaacd7cc5540 started
rsyslog debug: main Q:Reg: started with state 3, num workers now 1
01:55:01[1] rstb_607389_d1146e46d42O:.pid found, pid 2477609
01:55:01[1] rsyslogd startup msg seen, pid 2477609
waiting for file rstb_607389_d1146e46d42O.imdiag.port
imdiag port: 40363
starting run 1
Sending 1 messages.
00000001 messages sent
runtime: 0.000
End of tcpflood Run
starting run 1
Sending 1 messages.
00000001 messages sent
runtime: 0.000
End of tcpflood Run
starting run 1
Sending 1 messages.
00000001 messages sent
runtime: 0.000
End of tcpflood Run
starting run 1
Sending 1 messages.
00000001 messages sent
runtime: 0.000
End of tcpflood Run
starting run 1
Sending 1 messages.
00000001 messages sent
runtime: 0.000
End of tcpflood Run
starting run 1
Sending 1 messages.
00000001 messages sent
runtime: 0.000
End of tcpflood Run
starting run 1
Sending 1 messages.
00000001 messages sent
runtime: 0.000
End of tcpflood ...
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.