Project

General

Profile

Actions

Bug #13356

closed

syslog(3c) should not open syslog_door without LOG_CONS

Added by Marcel Telka 5 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
lib - userland libraries
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

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

test.c (176 Bytes) test.c Marcel Telka, 2020-12-08 10:52 AM
Actions #1

Updated by Marcel Telka 5 months 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
Actions #3

Updated by Marcel Telka 4 months ago

  • Status changed from In Progress to Pending RTI
Actions #4

Updated by Electric Monk 4 months 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

Also available in: Atom PDF