Open e477 opened 6 months ago
Hi! Thanks for spotting that and reporting it. Here's a little patch that fixes it. add-name-to-client-syslog.patch
Technically, I also need to change libslack/msg.c
to move openlog()
and closelog()
to immediately around each call to syslog()
(just on the off chance that different syslog message destinations have different identifiers), but that doesn't affect this problem.
Please let me know if this works for you too. I can't put it in as a commit yet because I'm in the middle of a bunch of commits that aren't public yet. This will go in after they're finished (along with the change to libslack/msg.c
).
I'm using daemon with the
-o
option to redirect all output to syslog. Despite also using the-n
option to explicitly set a name all syslog entries have the ident daemon. This makes the syslog impractical when using more than one daemon.Example:
libslack/msg.c
sets the syslog ident correctly when initializing the msg object and callingopenlog
. However, the result ofopenlog
does not survive the subsequent forks. Logging still works becausesyslog
will callopenlog
implicitly when required, but then the ident is undefined and at least glibc will fall back to using the executable's name which is daemon of course.As a simple workaround I've commented out the calls to
prog_err_syslog
andprog_dbg_syslog
(line 5158f) which delays the call toopenlog
till after the fork when the regular output starts. The syslog ident is correct then.A better way would be to re-initialize syslog output after a fork, but I've not yet found out how to do this safely and thus don't have a patch ready.