Actions
Bug #13356
closedsyslog(3c) should not open syslog_door without LOG_CONS
Start date:
Due date:
% Done:
100%
Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:
Description
On success, the syslog(3c)
always tries to open /var/run/syslog_door
(via syslogd_ok()
), even this is not needed in a case the LOG_CONS
flag is not set:
340 /* output the message to the local logger */ 341 if ((putmsg(LogFile, &ctl, &dat, 0) >= 0) && syslogd_ok()) 342 return; 343 if (!(LogStat & LOG_CONS)) 344 return; 345 346 /* 347 * Output the message to the console directly. To reduce visual 348 * clutter, we strip out the message ID. 349 */ ...
We can safely skip the syslogd_ok()
call in such a case.
Files
Updated by Marcel Telka over 2 years ago
Testing¶
Compile the attached test.c
:
gcc -o test test.c
Without the fix¶
root@t2# dtrace -q -n 'pid$target::open:entry{print((userland string)arg0)}' -c ./test string "/proc/889/psinfo" string "/dev/conslog" string "/var/run/tzsync" string "/usr/share/lib/zoneinfo/Europe/Prague" string "/var/run/syslog_door" string "/var/run/syslog_door" root@t2# tail -n2 /var/adm/messages Dec 8 11:27:20 t2 test[889]: [ID 889693 daemon.notice] test no-cons Dec 8 11:27:20 t2 CONS: [ID 639743 daemon.notice] test cons root@t2# rm /var/run/syslog_door root@t2# dtrace -q -n 'pid$target::open:entry{print((userland string)arg0)}' -c ./test string "/proc/893/psinfo" string "/dev/conslog" string "/var/run/tzsync" string "/usr/share/lib/zoneinfo/Europe/Prague" string "/var/run/syslog_door" string "/var/run/syslog_door" root@t2# tail -n2 /var/adm/messages Dec 8 11:27:38 t2 test[893]: [ID 889693 daemon.notice] test no-cons Dec 8 11:27:38 t2 CONS: [ID 639743 daemon.notice] test cons root@t2#
... and this appeared at the console:
Dec 8 11:27:38 CONS: test cons
With the fix¶
root@t1# dtrace -q -n 'pid$target::open:entry{print((userland string)arg0)}' -c ./test string "/proc/103000/psinfo" string "/dev/conslog" string "/var/run/tzsync" string "/usr/share/lib/zoneinfo/Europe/Prague" string "/var/run/syslog_door" root@t1# tail -n2 /var/adm/messages Dec 8 11:21:40 t1 test[103000]: [ID 889693 daemon.notice] test no-cons Dec 8 11:21:40 t1 CONS: [ID 639743 daemon.notice] test cons root@t1# rm /var/run/syslog_door root@t1# dtrace -q -n 'pid$target::open:entry{print((userland string)arg0)}' -c ./test string "/proc/103004/psinfo" string "/dev/conslog" string "/var/run/tzsync" string "/usr/share/lib/zoneinfo/Europe/Prague" string "/var/run/syslog_door" root@t1# tail -n2 /var/adm/messages Dec 8 11:21:56 t1 test[103004]: [ID 889693 daemon.notice] test no-cons Dec 8 11:21:56 t1 CONS: [ID 639743 daemon.notice] test cons root@t1#
... and this appeared at the console:
Dec 8 11:21:56 CONS: test cons
Updated by Marcel Telka over 2 years ago
Updated by Marcel Telka about 2 years ago
- Status changed from In Progress to Pending RTI
Updated by Electric Monk about 2 years ago
- Status changed from Pending RTI to Closed
- % Done changed from 0 to 100
git commit 986778a303c760bb2204efc52ea9eba748546342
commit 986778a303c760bb2204efc52ea9eba748546342 Author: David Hanisch <titanic@dh-werder.de> Date: 2021-01-21T14:29:31.000Z 13356 syslog(3c) should not open syslog_door without LOG_CONS Reviewed by: Marcel Telka <marcel@telka.sk> Approved by: Robert Mustacchi <rm@fingolfin.org>
Actions