config: Fix ast_config_text_file_save2 writability check for missing files
authorGeorge Joseph <gjoseph@digium.com>
Mon, 25 Apr 2016 03:51:16 +0000 (21:51 -0600)
committerGeorge Joseph <gjoseph@digium.com>
Mon, 25 Apr 2016 23:17:28 +0000 (18:17 -0500)
commit284bb814ac09a10e3bababa2e126d69d16fd93c4
tree3bd2a372ba65c38c62274b3ca18730ff1103dd08
parent99fcf2a791c2c78ae0ffffce2ac3e8db18ca5be0
config:  Fix ast_config_text_file_save2 writability check for missing files

A patch I did back in 2014 modified ast_config_text_file_save2 to check the
writability of the main file and include files before truncating and re-writing
them.  An unintended side-effect of this was that if a file doesn't exist,
the check fails and the write is aborted.

This patch causes ast_config_text_file_save2 to check the writability of the
parent directory of missing files instead of checking the file itself.  This
allows missing files to be created again.  A unit test was also added to
test_config to test saving of config files.

The regression was discovered when app_voicemail's passwordlocation=spooldir
feature stopped working.

ASTERISK-25917 #close
Reported-by: Jonathan Rose

Change-Id: Ic4dbe58c277a47b674679e49daed5fc6de349f80
main/config.c
tests/test_config.c