[asterisk-dev] [Code Review] Add #includeif statement

Paul Belanger pabelanger at digium.com
Fri Sep 30 17:44:07 CDT 2011

On 11-09-30 06:09 PM, Paul Belanger wrote:
> On 11-09-30 04:21 PM, Olle E. Johansson wrote:
>> 30 sep 2011 kl. 21:56 skrev Paul Belanger:
>>> Talking with Leif on IRC today, he was asking for a way to include a
>>> config file, that might not exist all the time. Because #include
>>> 'foo.conf' to a non existing will fail to load a module, we decided
>>> #includeif might be better.
>>> #exec cat foo.conf is another option, however this seems to require
>>> more CPU and opens a potential security issue.
>> This is possible today by including a directory. If the file exists,
>> it will be included.
> This does not appear to be correct, asterisk complains the file /
> directory does not exist and still fails to load. Do you have an example?
> Sep 30 18:05:38] WARNING[579]: config.c:1408 config_text_file_load:
> '/home/pabelanger/svn/digium/asterisk/testing/trunk/live/etc/asterisk/manager/'
> is not a regular file, ignoring
> [Sep 30 18:05:38] ERROR[579]: config.c:1260 process_text_line: The file
> 'manager/' was listed as a #include but it does not exist.
> [Sep 30 18:05:38] NOTICE[579]: manager.c:6451 __init_manager: Unable to
> open AMI configuration manager.conf, or configuration is invalid.
> Asterisk management interface (AMI) disabled.
>> I don't think we should make it more complicated with new directives.
> I don't see it being complicated, in fact the patch is pretty simple.
Kevin and I talked more about this on IRC now, it seems 1.4 had the 
ability to do this but the logic was reworked as sometime.

So the only way ATM to do this is using:

#exec cat foo

But at the cost of using more resources and the security. While my 
current patch is simple, I didn't account of other issue with oej likely 
knows :)

Going to rework some of it and see what I can come up with.

Paul Belanger
Digium, Inc. | Software Developer
twitter: pabelanger | IRC: pabelanger (Freenode)
Check us out at: http://digium.com & http://asterisk.org

More information about the asterisk-dev mailing list