]> git.ipfire.org Git - thirdparty/asterisk.git/commit
logger: Prevent duplicate dynamic channels from being added. 03/1303/2
authorMark Michelson <mmichelson@digium.com>
Wed, 23 Sep 2015 19:02:15 +0000 (14:02 -0500)
committerMark Michelson <mmichelson@digium.com>
Thu, 24 Sep 2015 20:03:18 +0000 (15:03 -0500)
commitf050fa76eb8535a2b8a3b047527a42ea369d8792
tree737c60a43832b992b109be32d766d8b10854e5f6
parent3502c0431db52d00eb16dc1cc2462be7a509ba5e
logger: Prevent duplicate dynamic channels from being added.

There was a problem observed where the "logger add channel" CLI command
would allow for a channel with the same name to be added multiple times.
This would result in each message being written out to the same file
multiple times.

The problem was due to the difference in how logger channel filenames
are stored versus the format they are allowed to be presented when they
are added. For instance, if adding the logger channel "foo" through the
CLI, the result would be a logger channel with the file name
/var/log/asterisk/foo being stored. So when trying to add another "foo"
channel, "foo" would not match "/var/log/asterisk/foo" so we'd happily
add the duplicate channel.

The fix presented here is to introduce two new methods in the logger
code:
 * make_filename(): given a logger channel name, this creates the
   filename for that logger channel.
 * find_logchannel(): given a logger channel name, this calls
   make_filename() and then traverses the list of logchannels in order
   to find a match.

This change has made use of make_filename() and find_logchannel()
throughout to more consistently behave.

ASTERISK-25305 #close
Reported by Mark Michelson

Change-Id: I892d52954d6007d8bc453c3cbdd9235dec9c4a36
main/logger.c