Index: channels/chan_jingle.c =================================================================== --- channels/chan_jingle.c (revision 131480) +++ channels/chan_jingle.c (working copy) @@ -1736,8 +1736,9 @@ struct ast_flags config_flags = { 0 }; cfg = ast_config_load(JINGLE_CONFIG, config_flags); - if (!cfg) + if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) { return 0; + } /* Copy the default jb config over global_jbconf */ memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); Index: channels/chan_usbradio.c =================================================================== --- channels/chan_usbradio.c (revision 131480) +++ channels/chan_usbradio.c (working copy) @@ -1,4 +1,3 @@ -#define NEW_ASTERISK /* * Asterisk -- An open source telephony toolkit. * @@ -149,16 +148,6 @@ #include "asterisk/musiconhold.h" #include "asterisk/dsp.h" -#ifndef NEW_ASTERISK - -/* ringtones we use */ -#include "busy.h" -#include "ringtone.h" -#include "ring10.h" -#include "answer.h" - -#endif - #define C108_VENDOR_ID 0x0d8c #define C108_PRODUCT_ID 0x000c #define C108_HID_INTERFACE 3 @@ -394,19 +383,6 @@ int repeat; }; -#ifndef NEW_ASTERISK - -static struct sound sounds[] = { - { AST_CONTROL_RINGING, "RINGING", ringtone, sizeof(ringtone)/2, 16000, 32000, 1 }, - { AST_CONTROL_BUSY, "BUSY", busy, sizeof(busy)/2, 4000, 4000, 1 }, - { AST_CONTROL_CONGESTION, "CONGESTION", busy, sizeof(busy)/2, 2000, 2000, 1 }, - { AST_CONTROL_RING, "RING10", ring10, sizeof(ring10)/2, 16000, 32000, 1 }, - { AST_CONTROL_ANSWER, "ANSWER", answer, sizeof(answer)/2, 2200, 0, 0 }, - { -1, NULL, 0, 0, 0, 0 }, /* end marker */ -}; - -#endif - /* * descriptor for one of our channels. * There is one used for 'default' values (from the [general] entry in @@ -418,19 +394,6 @@ struct chan_usbradio_pvt *next; char *name; -#ifndef NEW_ASTERISK - /* - * cursound indicates which in struct sound we play. -1 means nothing, - * any other value is a valid sound, in which case sampsent indicates - * the next sample to send in [0..samplen + silencelen] - * nosound is set to disable the audio data from the channel - * (so we can play the tones etc.). - */ - int sndcmd[2]; /* Sound command pipe */ - int cursound; /* index of sound to send */ - int sampsent; /* # of sound samples sent */ - int nosound; /* set to block audio from the PBX */ -#endif int pttkick[2]; int total_blocks; /* total blocks in the output device */ @@ -464,9 +427,6 @@ int spkrmax; int micmax; -#ifndef NEW_ASTERISK - pthread_t sthread; -#endif pthread_t hidthread; int stophid; @@ -626,9 +586,6 @@ // maw add additional defaults !!! static struct chan_usbradio_pvt usbradio_default = { -#ifndef NEW_ASTERISK - .cursound = -1, -#endif .sounddev = -1, .duplex = M_UNSET, /* XXX check this */ .autoanswer = 1, @@ -1379,137 +1336,7 @@ return write(o->sounddev, ((void *) data), FRAME_SIZE * 2 * 12); } -#ifndef NEW_ASTERISK - /* - * Handler for 'sound writable' events from the sound thread. - * Builds a frame from the high level description of the sounds, - * and passes it to the audio device. - * The actual sound is made of 1 or more sequences of sound samples - * (s->datalen, repeated to make s->samplen samples) followed by - * s->silencelen samples of silence. The position in the sequence is stored - * in o->sampsent, which goes between 0 .. s->samplen+s->silencelen. - * In case we fail to write a frame, don't update o->sampsent. - */ -static void send_sound(struct chan_usbradio_pvt *o) -{ - short myframe[FRAME_SIZE]; - int ofs, l, start; - int l_sampsent = o->sampsent; - struct sound *s; - - if (o->cursound < 0) /* no sound to send */ - return; - - s = &sounds[o->cursound]; - - for (ofs = 0; ofs < FRAME_SIZE; ofs += l) { - l = s->samplen - l_sampsent; /* # of available samples */ - if (l > 0) { - start = l_sampsent % s->datalen; /* source offset */ - if (l > FRAME_SIZE - ofs) /* don't overflow the frame */ - l = FRAME_SIZE - ofs; - if (l > s->datalen - start) /* don't overflow the source */ - l = s->datalen - start; - bcopy(s->data + start, myframe + ofs, l * 2); - if (0) - ast_log(LOG_WARNING, "send_sound sound %d/%d of %d into %d\n", l_sampsent, l, s->samplen, ofs); - l_sampsent += l; - } else { /* end of samples, maybe some silence */ - static const short silence[FRAME_SIZE] = { 0, }; - - l += s->silencelen; - if (l > 0) { - if (l > FRAME_SIZE - ofs) - l = FRAME_SIZE - ofs; - bcopy(silence, myframe + ofs, l * 2); - l_sampsent += l; - } else { /* silence is over, restart sound if loop */ - if (s->repeat == 0) { /* last block */ - o->cursound = -1; - o->nosound = 0; /* allow audio data */ - if (ofs < FRAME_SIZE) /* pad with silence */ - bcopy(silence, myframe + ofs, (FRAME_SIZE - ofs) * 2); - } - l_sampsent = 0; - } - } - } - l = soundcard_writeframe(o, myframe); - if (l > 0) - o->sampsent = l_sampsent; /* update status */ -} - -static void *sound_thread(void *arg) -{ - char ign[4096]; - struct chan_usbradio_pvt *o = (struct chan_usbradio_pvt *) arg; - - /* - * Just in case, kick the driver by trying to read from it. - * Ignore errors - this read is almost guaranteed to fail. - */ - read(o->sounddev, ign, sizeof(ign)); - for (;;) { - fd_set rfds, wfds; - int maxfd, res; - - FD_ZERO(&rfds); - FD_ZERO(&wfds); - FD_SET(o->sndcmd[0], &rfds); - maxfd = o->sndcmd[0]; /* pipe from the main process */ - if (o->cursound > -1 && o->sounddev < 0) - setformat(o, O_RDWR); /* need the channel, try to reopen */ - else if (o->cursound == -1 && o->owner == NULL) - { - setformat(o, O_CLOSE); /* can close */ - } - if (o->sounddev > -1) { - if (!o->owner) { /* no one owns the audio, so we must drain it */ - FD_SET(o->sounddev, &rfds); - maxfd = MAX(o->sounddev, maxfd); - } - if (o->cursound > -1) { - FD_SET(o->sounddev, &wfds); - maxfd = MAX(o->sounddev, maxfd); - } - } - /* ast_select emulates linux behaviour in terms of timeout handling */ - res = ast_select(maxfd + 1, &rfds, &wfds, NULL, NULL); - if (res < 1) { - ast_log(LOG_WARNING, "select failed: %s\n", strerror(errno)); - sleep(1); - continue; - } - if (FD_ISSET(o->sndcmd[0], &rfds)) { - /* read which sound to play from the pipe */ - int i, what = -1; - - read(o->sndcmd[0], &what, sizeof(what)); - for (i = 0; sounds[i].ind != -1; i++) { - if (sounds[i].ind == what) { - o->cursound = i; - o->sampsent = 0; - o->nosound = 1; /* block audio from pbx */ - break; - } - } - if (sounds[i].ind == -1) - ast_log(LOG_WARNING, "invalid sound index: %d\n", what); - } - if (o->sounddev > -1) { - if (FD_ISSET(o->sounddev, &rfds)) /* read and ignore errors */ - read(o->sounddev, ign, sizeof(ign)); - if (FD_ISSET(o->sounddev, &wfds)) - send_sound(o); - } - } - return NULL; /* Never reached */ -} - -#endif - -/* * reset and close the device if opened, * then open and initialize it in the desired mode, * trigger reads and writes so we can start using it. @@ -1685,9 +1512,6 @@ /* Play ringtone 'x' on device 'o' */ static void ring(struct chan_usbradio_pvt *o, int x) { -#ifndef NEW_ASTERISK - write(o->sndcmd[1], &x, sizeof(x)); -#endif } /* @@ -1709,15 +1533,7 @@ */ static int usbradio_answer(struct ast_channel *c) { -#ifndef NEW_ASTERISK - struct chan_usbradio_pvt *o = c->tech_pvt; -#endif - ast_setstate(c, AST_STATE_UP); -#ifndef NEW_ASTERISK - o->cursound = -1; - o->nosound = 0; -#endif return 0; } @@ -1726,10 +1542,6 @@ struct chan_usbradio_pvt *o = c->tech_pvt; //ast_log(LOG_NOTICE, "usbradio_hangup()\n"); -#ifndef NEW_ASTERISK - o->cursound = -1; - o->nosound = 0; -#endif c->tech_pvt = NULL; o->owner = NULL; ast_module_unref(ast_module_info->self); @@ -1756,13 +1568,6 @@ traceusb2(("usbradio_write() o->nosound= %i\n",o->nosound)); -#ifndef NEW_ASTERISK - /* Immediately return if no sound is enabled */ - if (o->nosound) - return 0; - /* Stop any currently playing sound */ - o->cursound = -1; -#endif /* * we could receive a block which is not a multiple of our * FRAME_SIZE, so buffer it locally and write to the device @@ -2125,10 +1930,6 @@ break; case -1: -#ifndef NEW_ASTERISK - o->cursound = -1; - o->nosound = 0; /* when cursound is -1 nosound must be 0 */ -#endif return 0; case AST_CONTROL_VIDUPDATE: @@ -2642,40 +2443,6 @@ " load (tuning settings from EEPROM)\n" "\n All [newsetting]'s are values 0-999\n\n"; -#ifndef NEW_ASTERISK - -static struct ast_cli_entry cli_usbradio[] = { - { { "radio", "key", NULL }, - console_key, "Simulate Rx Signal Present", - key_usage, NULL, NULL}, - - { { "radio", "unkey", NULL }, - console_unkey, "Simulate Rx Signal Lusb", - unkey_usage, NULL, NULL }, - - { { "radio", "tune", NULL }, - radio_tune, "Radio Tune", - radio_tune_usage, NULL, NULL }, - - { { "radio", "set", "debug", NULL }, - radio_set_debug, "Radio Debug", - radio_tune_usage, NULL, NULL }, - - { { "radio", "set", "debug", "off", NULL }, - radio_set_debug_off, "Radio Debug", - radio_tune_usage, NULL, NULL }, - - { { "radio", "active", NULL }, - radio_active, "Change commanded device", - active_usage, NULL, NULL }, - - { { "radio", "set", "xdebug", NULL }, - radio_set_xpmr_debug, "Radio set xpmr debug level", - active_usage, NULL, NULL }, - -}; -#endif - /* * store the callerid components */ @@ -3402,9 +3169,7 @@ struct ast_config *cfg1; int i; char fname[200]; -#ifdef NEW_ASTERISK struct ast_flags zeroflag = {0}; -#endif if (ctg == NULL) { traceusb1((" store_config() ctg == NULL\n")); o = &usbradio_default; @@ -3497,11 +3262,7 @@ return NULL; snprintf(fname,sizeof(fname) - 1,config1,o->name); -#ifdef NEW_ASTERISK cfg1 = ast_config_load(fname,zeroflag); -#else - cfg1 = ast_config_load(fname); -#endif o->rxmixerset = 500; o->txmixaset = 500; o->txmixbset = 500; @@ -3572,13 +3333,8 @@ o->dsp = ast_dsp_new(); if (o->dsp) { -#ifdef NEW_ASTERISK ast_dsp_set_features(o->dsp,DSP_FEATURE_DIGIT_DETECT); ast_dsp_set_digitmode(o->dsp,DSP_DIGITMODE_DTMF | DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_RELAXDTMF); -#else - ast_dsp_set_features(o->dsp,DSP_FEATURE_DTMF_DETECT); - ast_dsp_digitmode(o->dsp,DSP_DIGITMODE_DTMF | DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_RELAXDTMF); -#endif } if(o->pmrChan==NULL) @@ -3688,15 +3444,6 @@ TRACEO(1,("store_config() 200\n")); -#ifndef NEW_ASTERISK - if (pipe(o->sndcmd) != 0) { - ast_log(LOG_ERROR, "Unable to create pipe\n"); - goto error; - } - - ast_pthread_create_background(&o->sthread, NULL, sound_thread, o); -#endif - /* link into list of devices */ if (o != &usbradio_default) { o->next = usbradio_default.next; @@ -3786,8 +3533,6 @@ } #endif -#ifdef NEW_ASTERISK - static char *res2cli(int r) { @@ -3911,8 +3656,6 @@ AST_CLI_DEFINE(handle_set_xdebug,"Radio set xpmr debug level") }; -#endif - #include "./xpmr/xpmr.c" #ifdef HAVE_XPMRX #include "./xpmrx/xpmrx.c" @@ -3924,9 +3667,7 @@ { struct ast_config *cfg = NULL; char *ctg = NULL; -#ifdef NEW_ASTERISK struct ast_flags zeroflag = {0}; -#endif if (hid_device_mklist()) { ast_log(LOG_NOTICE, "Unable to make hid list\n"); @@ -3941,13 +3682,12 @@ memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); /* load config file */ -#ifdef NEW_ASTERISK if (!(cfg = ast_config_load(config,zeroflag))) { -#else - if (!(cfg = ast_config_load(config))) { -#endif ast_log(LOG_NOTICE, "Unable to load config %s\n", config); return AST_MODULE_LOAD_DECLINE; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config); + return AST_MODULE_LOAD_DECLINE; } do { @@ -3998,12 +3738,6 @@ #endif close(o->sounddev); -#ifndef NEW_ASTERISK - if (o->sndcmd[0] > 0) { - close(o->sndcmd[0]); - close(o->sndcmd[1]); - } -#endif if (o->dsp) ast_dsp_free(o->dsp); if (o->owner) ast_softhangup(o->owner, AST_SOFTHANGUP_APPUNLOAD); Index: channels/chan_phone.c =================================================================== --- channels/chan_phone.c (revision 131480) +++ channels/chan_phone.c (working copy) @@ -1346,7 +1346,10 @@ int txgain = DEFAULT_GAIN, rxgain = DEFAULT_GAIN; /* default gain 1.0 */ struct ast_flags config_flags = { 0 }; - cfg = ast_config_load(config, config_flags); + if ((cfg = ast_config_load(config, config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config); + return AST_MODULE_LOAD_DECLINE; + } /* We *must* have a config file otherwise stop immediately */ if (!cfg) { Index: channels/chan_dahdi.c =================================================================== --- channels/chan_dahdi.c (revision 131480) +++ channels/chan_dahdi.c (working copy) @@ -14592,13 +14592,28 @@ return 0; } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { ucfg = ast_config_load("users.conf", config_flags); - if (ucfg == CONFIG_STATUS_FILEUNCHANGED) + if (ucfg == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } else if (ucfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "File users.conf cannot be parsed. Aborting.\n"); + return 0; + } ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - cfg = ast_config_load(config, config_flags); + if ((cfg = ast_config_load(config, config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "File %s cannot be parsed. Aborting.\n", config); + ast_config_destroy(ucfg); + return 0; + } + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "File %s cannot be parsed. Aborting.\n", config); + return 0; } else { ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - ucfg = ast_config_load("users.conf", config_flags); + if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "File users.conf cannot be parsed. Aborting.\n"); + ast_config_destroy(cfg); + return 0; + } } /* It's a little silly to lock it, but we mind as well just to be sure */ Index: channels/chan_h323.c =================================================================== --- channels/chan_h323.c (revision 131480) +++ channels/chan_h323.c (working copy) @@ -2816,13 +2816,28 @@ return 1; } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { ucfg = ast_config_load("users.conf", config_flags); - if (ucfg == CONFIG_STATUS_FILEUNCHANGED) + if (ucfg == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } else if (ucfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Aborting.\n"); + return 0; + } ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - cfg = ast_config_load(config, config_flags); + if ((cfg = ast_config_load(config, config_flags))) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config); + ast_config_destroy(ucfg); + return 0; + } + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config); + return 0; } else { ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - ucfg = ast_config_load("users.conf", config_flags); + if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Aborting.\n"); + ast_config_destroy(cfg); + return 0; + } } if (is_reload) { Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 131480) +++ channels/chan_sip.c (working copy) @@ -20779,14 +20779,29 @@ return -1; } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { ucfg = ast_config_load("users.conf", config_flags); - if (ucfg == CONFIG_STATUS_FILEUNCHANGED) + if (ucfg == CONFIG_STATUS_FILEUNCHANGED) { return 1; + } else if (ucfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Contents of users.conf are invalid and cannot be parsed\n"); + return 1; + } /* Must reread both files, because one changed */ ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - cfg = ast_config_load(config, config_flags); + if ((cfg = ast_config_load(config, config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Contents of %s are invalid and cannot be parsed\n", config); + ast_config_destroy(ucfg); + return 1; + } + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Contents of %s are invalid and cannot be parsed\n", config); + return 1; } else { ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - ucfg = ast_config_load("users.conf", config_flags); + if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Contents of users.conf are invalid and cannot be parsed\n"); + ast_config_destroy(cfg); + return 1; + } } /* Initialize tcp sockets */ @@ -21543,7 +21558,10 @@ /* Load the list of manual NOTIFY types to support */ if (notify_types) ast_config_destroy(notify_types); - notify_types = ast_config_load(notify_config, config_flags); + if ((notify_types = ast_config_load(notify_config, config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Contents of %s are invalid and cannot be parsed.\n", notify_config); + notify_types = NULL; + } /* Done, tell the manager */ manager_event(EVENT_FLAG_SYSTEM, "ChannelReload", "ChannelType: SIP\r\nReloadReason: %s\r\nRegistry_Count: %d\r\nPeer_Count: %d\r\n", channelreloadreason2txt(reason), registry_count, peer_count); Index: channels/chan_agent.c =================================================================== --- channels/chan_agent.c (revision 131480) +++ channels/chan_agent.c (working copy) @@ -1110,8 +1110,21 @@ if (!cfg) { ast_log(LOG_NOTICE, "No agent configuration found -- agent support disabled\n"); return 0; - } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { return -1; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "%s contains a parsing error. Aborting\n", config); + return 0; + } + if ((ucfg = ast_config_load("users.conf", config_flags))) { + if (ucfg == CONFIG_STATUS_FILEUNCHANGED) { + ucfg = NULL; + } else if (ucfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "users.conf contains a parsing error. Aborting\n"); + return 0; + } + } + AST_LIST_LOCK(&agents); AST_LIST_TRAVERSE(&agents, p, list) { p->dead = 1; @@ -1201,7 +1214,7 @@ } v = v->next; } - if ((ucfg = ast_config_load("users.conf", config_flags)) && ucfg != CONFIG_STATUS_FILEUNCHANGED) { + if (ucfg) { genhasagent = ast_true(ast_variable_retrieve(ucfg, "general", "hasagent")); catname = ast_category_browse(ucfg, NULL); while(catname) { Index: channels/chan_console.c =================================================================== --- channels/chan_console.c (revision 131480) +++ channels/chan_console.c (working copy) @@ -1400,6 +1400,9 @@ if (!(cfg = ast_config_load(config_file, config_flags))) { ast_log(LOG_NOTICE, "Unable to open configuration file %s!\n", config_file); return -1; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_NOTICE, "Config file %s has an invalid format\n", config_file); + return -1; } ao2_callback(pvts, 0, pvt_mark_destroy_cb, NULL); Index: channels/chan_iax2.c =================================================================== --- channels/chan_iax2.c (revision 131480) +++ channels/chan_iax2.c (working copy) @@ -10921,10 +10921,21 @@ return 0; /* Otherwise we need to reread both files */ ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - cfg = ast_config_load(config_file, config_flags); + if ((cfg = ast_config_load(config_file, config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config_file); + ast_config_destroy(ucfg); + return 0; + } + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config_file); + return 0; } else { /* iax.conf changed, gotta reread users.conf, too */ ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - ucfg = ast_config_load("users.conf", config_flags); + if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Aborting.\n"); + ast_config_destroy(cfg); + return 0; + } } if (reload) { Index: channels/chan_oss.c =================================================================== --- channels/chan_oss.c (revision 131480) +++ channels/chan_oss.c (working copy) @@ -1434,6 +1434,9 @@ if (!(cfg = ast_config_load(config, config_flags))) { ast_log(LOG_NOTICE, "Unable to load config %s\n", config); return AST_MODULE_LOAD_DECLINE; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config); + return AST_MODULE_LOAD_DECLINE; } do { Index: channels/chan_skinny.c =================================================================== --- channels/chan_skinny.c (revision 131480) +++ channels/chan_skinny.c (working copy) @@ -6151,7 +6151,10 @@ ast_log(LOG_WARNING, "Unable to get hostname, Skinny disabled\n"); return 0; } - cfg = ast_config_load(config, config_flags); + if ((cfg = ast_config_load(config, config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config); + return 0; + } /* We *must* have a config file otherwise stop immediately */ if (!cfg) { Index: channels/chan_alsa.c =================================================================== --- channels/chan_alsa.c (revision 131480) +++ channels/chan_alsa.c (working copy) @@ -857,8 +857,12 @@ strcpy(mohinterpret, "default"); - if (!(cfg = ast_config_load(config, config_flags))) + if (!(cfg = ast_config_load(config, config_flags))) { return AST_MODULE_LOAD_DECLINE; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "%s is in an invalid format. Aborting.\n", config); + return AST_MODULE_LOAD_DECLINE; + } v = ast_variable_browse(cfg, "general"); for (; v; v = v->next) { Index: channels/chan_mgcp.c =================================================================== --- channels/chan_mgcp.c (revision 131480) +++ channels/chan_mgcp.c (working copy) @@ -4122,8 +4122,12 @@ if (!cfg) { ast_log(LOG_NOTICE, "Unable to load config %s, MGCP disabled\n", config); return 0; - } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config); + return 0; + } memset(&bindaddr, 0, sizeof(bindaddr)); dtmfmode = 0; Index: channels/chan_unistim.c =================================================================== --- channels/chan_unistim.c (revision 131480) +++ channels/chan_unistim.c (working copy) @@ -5300,6 +5300,9 @@ if (!cfg) { ast_log(LOG_ERROR, "Unable to load config %s\n", config); return -1; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config); + return -1; } /* Copy the default jb config over global_jbconf */ Index: channels/chan_gtalk.c =================================================================== --- channels/chan_gtalk.c (revision 131480) +++ channels/chan_gtalk.c (working copy) @@ -1868,8 +1868,12 @@ struct ast_flags config_flags = { 0 }; cfg = ast_config_load(GOOGLE_CONFIG, config_flags); - if (!cfg) + if (!cfg) { return 0; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", GOOGLE_CONFIG); + return 0; + } /* Copy the default jb config over global_jbconf */ memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); Index: apps/app_festival.c =================================================================== --- apps/app_festival.c (revision 131480) +++ apps/app_festival.c (working copy) @@ -300,7 +300,11 @@ if (!cfg) { ast_log(LOG_WARNING, "No such configuration file %s\n", FESTIVAL_CONFIG); return -1; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file " FESTIVAL_CONFIG " is in an invalid format. Aborting.\n"); + return -1; } + if (!(host = ast_variable_retrieve(cfg, "general", "host"))) { host = "localhost"; } @@ -517,6 +521,9 @@ if (!cfg) { ast_log(LOG_WARNING, "No such configuration file %s\n", FESTIVAL_CONFIG); return AST_MODULE_LOAD_DECLINE; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file " FESTIVAL_CONFIG " is in an invalid format. Aborting.\n"); + return AST_MODULE_LOAD_DECLINE; } ast_config_destroy(cfg); return ast_register_application(app, festival_exec, synopsis, descrip); Index: apps/app_alarmreceiver.c =================================================================== --- apps/app_alarmreceiver.c (revision 131480) +++ apps/app_alarmreceiver.c (working copy) @@ -639,6 +639,9 @@ if (!cfg) { ast_verb(4, "AlarmReceiver: No config file\n"); return 0; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", ALMRCV_CONFIG); + return 0; } else { p = ast_variable_retrieve(cfg, "general", "eventcmd"); if (p) { Index: apps/app_rpt.c =================================================================== --- apps/app_rpt.c (revision 131480) +++ apps/app_rpt.c (working copy) @@ -2008,7 +2008,7 @@ ourcfg = ast_config_load(myrpt->p.extnodefile); #endif /* if file not there, just bail */ - if (!ourcfg) + if (!ourcfg && ourcfg == CONFIG_STATUS_FILEINVALID) { ast_mutex_unlock(&nodelookuplock); return(NULL); @@ -2235,7 +2235,7 @@ #else cfg = ast_config_load("rpt.conf"); #endif - if (!cfg) { + if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) { ast_mutex_unlock(&rpt_vars[n].lock); ast_log(LOG_NOTICE, "Unable to open radio repeater configuration rpt.conf. Radio Repeater disabled.\n"); pthread_exit(NULL); @@ -12924,7 +12924,7 @@ rpt_vars[n].cfg = ast_config_load("rpt.conf"); #endif cfg = rpt_vars[n].cfg; - if (!cfg) { + if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_NOTICE, "Unable to open radio repeater configuration rpt.conf. Radio Repeater disabled.\n"); pthread_exit(NULL); } Index: apps/app_meetme.c =================================================================== --- apps/app_meetme.c (revision 131480) +++ apps/app_meetme.c (working copy) @@ -2896,6 +2896,9 @@ if (!cfg) { ast_log(LOG_WARNING, "No %s file :(\n", CONFIG_FILE_NAME); return NULL; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file " CONFIG_FILE_NAME " is in an invalid format. Aborting.\n"); + return NULL; } for (var = ast_variable_browse(cfg, "rooms"); var; var = var->next) { if (strcasecmp(var->name, "conf")) @@ -3058,7 +3061,7 @@ /* We only need to load the config file for static and empty_no_pin (otherwise we don't care) */ if ((empty_no_pin) || (!dynamic)) { cfg = ast_config_load(CONFIG_FILE_NAME, config_flags); - if (cfg) { + if (cfg && cfg != CONFIG_STATUS_FILEINVALID) { var = ast_variable_browse(cfg, "rooms"); while (var) { if (!strcasecmp(var->name, "conf")) { @@ -3704,8 +3707,12 @@ struct ast_flags config_flags = { 0 }; const char *val; - if (!(cfg = ast_config_load(CONFIG_FILE_NAME, config_flags))) + if (!(cfg = ast_config_load(CONFIG_FILE_NAME, config_flags))) { return; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file " CONFIG_FILE_NAME " is in an invalid format. Aborting.\n"); + return; + } audio_buffers = DEFAULT_AUDIO_BUFFERS; @@ -5532,10 +5539,14 @@ ast_cond_init(&sla.cond, NULL); } - if (!(cfg = ast_config_load(SLA_CONFIG_FILE, config_flags))) + if (!(cfg = ast_config_load(SLA_CONFIG_FILE, config_flags))) { return 0; /* Treat no config as normal */ - else if (cfg == CONFIG_STATUS_FILEUNCHANGED) + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file " SLA_CONFIG_FILE " is in an invalid format. Aborting.\n"); + return 0; + } if ((val = ast_variable_retrieve(cfg, "general", "attemptcallerid"))) sla.attempt_callerid = ast_true(val); Index: apps/app_minivm.c =================================================================== --- apps/app_minivm.c (revision 131480) +++ apps/app_minivm.c (working copy) @@ -2364,8 +2364,12 @@ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags); - if (cfg == CONFIG_STATUS_FILEUNCHANGED) + if (cfg == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file " VOICEMAIL_CONFIG " is in an invalid format. Aborting.\n"); + return 0; + } ast_mutex_lock(&minivmlock); Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 131480) +++ apps/app_voicemail.c (working copy) @@ -1158,7 +1158,7 @@ return; /* check voicemail.conf */ - if ((cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags))) { + if ((cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) { while ((category = ast_category_browse(cfg, category))) { if (!strcasecmp(category, vmu->context)) { if (!(tmp = ast_variable_retrieve(cfg, category, vmu->mailbox))) { @@ -1188,7 +1188,7 @@ var = NULL; /* check users.conf and update the password stored for the mailbox*/ /* if no vmsecret entry exists create one. */ - if ((cfg = ast_config_load("users.conf", config_flags))) { + if ((cfg = ast_config_load("users.conf", config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) { ast_debug(4, "we are looking for %s\n", vmu->mailbox); while ((category = ast_category_browse(cfg, category))) { ast_debug(4, "users.conf: %s\n", category); @@ -1853,7 +1853,7 @@ res = -1; break; } - if (cfg) { + if (cfg && cfg != CONFIG_STATUS_FILEINVALID) { if (!(idata.context = ast_variable_retrieve(cfg, "message", "context"))) { idata.context = ""; } @@ -4888,7 +4888,7 @@ strncat(textfile, ".txt", sizeof(textfile) - strlen(textfile) - 1); strncat(backup, "-bak", sizeof(backup) - strlen(backup) - 1); - if ((msg_cfg = ast_config_load(textfile, config_flags)) && (duration_str = ast_variable_retrieve(msg_cfg, "message", "duration"))) { + if ((msg_cfg = ast_config_load(textfile, config_flags)) && msg_cfg != CONFIG_STATUS_FILEINVALID && (duration_str = ast_variable_retrieve(msg_cfg, "message", "duration"))) { *duration = atoi(duration_str); } else { *duration = 0; @@ -5813,7 +5813,7 @@ snprintf(filename, sizeof(filename), "%s.txt", vms->fn); RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context); msg_cfg = ast_config_load(filename, config_flags); - if (!msg_cfg) { + if (!msg_cfg || msg_cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_WARNING, "No message attribute file?!! (%s)\n", filename); return 0; } @@ -5863,7 +5863,7 @@ RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context); msg_cfg = ast_config_load(filename, config_flags); - if (!msg_cfg) { + if (!msg_cfg || msg_cfg == CONFIG_STATUS_FILEINVALID) { ast_log(AST_LOG_WARNING, "No message attribute file?!! (%s)\n", filename); return 0; } @@ -9438,13 +9438,27 @@ ast_unload_realtime("voicemail_data"); if ((cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags)) == CONFIG_STATUS_FILEUNCHANGED) { - if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) + if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } else if (ucfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Avoiding.\n"); + ucfg = NULL; + } ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags); + if ((cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_config_destroy(ucfg); + ast_log(LOG_ERROR, "Config file " VOICEMAIL_CONFIG " is in an invalid format. Aborting.\n"); + return 0; + } + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file " VOICEMAIL_CONFIG " is in an invalid format. Aborting.\n"); + return 0; } else { ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - ucfg = ast_config_load("users.conf", config_flags); + if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Avoiding.\n"); + ucfg = NULL; + } } /* set audio control prompts */ @@ -10297,7 +10311,7 @@ RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context); msg_cfg = ast_config_load(filename, config_flags); DISPOSE(vms->curdir, vms->curmsg); - if (!msg_cfg) { + if (!msg_cfg || msg_cfg == CONFIG_STATUS_FILEINVALID) { ast_log(AST_LOG_WARNING, "No message attribute file?!! (%s)\n", filename); return 0; } Index: apps/app_playback.c =================================================================== --- apps/app_playback.c (revision 131480) +++ apps/app_playback.c (working copy) @@ -461,8 +461,12 @@ struct ast_flags config_flags = { CONFIG_FLAG_FILEUNCHANGED }; struct ast_config *newcfg; - if ((newcfg = ast_config_load("say.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) + if ((newcfg = ast_config_load("say.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } else if (newcfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file say.conf is in an invalid format. Aborting.\n"); + return 0; + } if (say_cfg) { ast_config_destroy(say_cfg); @@ -506,7 +510,7 @@ struct ast_flags config_flags = { 0 }; say_cfg = ast_config_load("say.conf", config_flags); - if (say_cfg) { + if (say_cfg && say_cfg != CONFIG_STATUS_FILEINVALID) { for (v = ast_variable_browse(say_cfg, "general"); v ; v = v->next) { if (ast_extension_match(v->name, "mode")) { say_init_mode(v->value); Index: apps/app_osplookup.c =================================================================== --- apps/app_osplookup.c (revision 131480) +++ apps/app_osplookup.c (working copy) @@ -1776,8 +1776,12 @@ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; int error = OSPC_ERR_NO_ERROR; - if ((cfg = ast_config_load(OSP_CONFIG_FILE, config_flags)) == CONFIG_STATUS_FILEUNCHANGED) + if ((cfg = ast_config_load(OSP_CONFIG_FILE, config_flags)) == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file " OSP_CONFIG_FILE " is in an invalid format. Aborting.\n"); + return 0; + } if (cfg) { if (reload) Index: apps/app_amd.c =================================================================== --- apps/app_amd.c (revision 131480) +++ apps/app_amd.c (working copy) @@ -376,8 +376,12 @@ if (!(cfg = ast_config_load("amd.conf", config_flags))) { ast_log(LOG_ERROR, "Configuration file amd.conf missing.\n"); return -1; - } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file amd.conf is in an invalid format. Aborting.\n"); + return -1; + } cat = ast_category_browse(cfg, NULL); Index: apps/app_directory.c =================================================================== --- apps/app_directory.c (revision 131480) +++ apps/app_directory.c (working copy) @@ -362,6 +362,9 @@ /* Loading config failed. */ ast_log(LOG_WARNING, "Loading config failed.\n"); return NULL; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", VOICEMAIL_CONFIG); + return NULL; } /* Get realtime entries, categorized by their mailbox number @@ -670,7 +673,10 @@ return -1; } - ucfg = ast_config_load("users.conf", config_flags); + if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Aborting.\n"); + ucfg = NULL; + } dirintro = ast_variable_retrieve(cfg, args.vmcontext, "directoryintro"); if (ast_strlen_zero(dirintro)) Index: apps/app_queue.c =================================================================== --- apps/app_queue.c (revision 131480) +++ apps/app_queue.c (working copy) @@ -5191,6 +5191,9 @@ } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { ast_log(LOG_NOTICE, "queuerules.conf has not changed since it was last loaded. Not taking any action.\n"); return AST_MODULE_LOAD_SUCCESS; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file queuerules.conf is in an invalid format. Aborting.\n"); + return AST_MODULE_LOAD_SUCCESS; } else { AST_LIST_LOCK(&rule_lists); while ((rl_iter = AST_LIST_REMOVE_HEAD(&rule_lists, list))) { @@ -5252,8 +5255,12 @@ if (!(cfg = ast_config_load("queues.conf", config_flags))) { ast_log(LOG_NOTICE, "No call queueing config file (queues.conf), so no call queues\n"); return 0; - } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file queues.conf is in an invalid format. Aborting.\n"); + return 0; + } ao2_lock(queues); use_weight=0; /* Mark all queues as dead for the moment */ Index: apps/app_followme.c =================================================================== --- apps/app_followme.c (revision 131480) +++ apps/app_followme.c (working copy) @@ -292,8 +292,12 @@ if (!(cfg = ast_config_load("followme.conf", config_flags))) { ast_log(LOG_WARNING, "No follow me config file (followme.conf), so no follow me\n"); return 0; - } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file followme.conf is in an invalid format. Aborting.\n"); + return 0; + } AST_RWLIST_WRLOCK(&followmes); Index: funcs/func_config.c =================================================================== --- funcs/func_config.c (revision 131480) +++ funcs/func_config.c (working copy) @@ -82,7 +82,7 @@ return -1; } - if (!(cfg = ast_config_load(args.filename, cfg_flags))) { + if (!(cfg = ast_config_load(args.filename, cfg_flags)) || cfg == CONFIG_STATUS_FILEINVALID) { return -1; } @@ -107,7 +107,7 @@ strcpy(cur->filename, args.filename); ast_clear_flag(&cfg_flags, CONFIG_FLAG_FILEUNCHANGED); - if (!(cfg = ast_config_load(args.filename, cfg_flags))) { + if (!(cfg = ast_config_load(args.filename, cfg_flags)) || cfg == CONFIG_STATUS_FILEINVALID) { ast_free(cur); AST_RWLIST_UNLOCK(&configs); return -1; Index: funcs/func_odbc.c =================================================================== --- funcs/func_odbc.c (revision 131480) +++ funcs/func_odbc.c (working copy) @@ -789,7 +789,7 @@ AST_LIST_LOCK(&queries); cfg = ast_config_load(config, config_flags); - if (!cfg) { + if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_NOTICE, "Unable to load config for func_odbc: %s\n", config); AST_LIST_UNLOCK(&queries); return AST_MODULE_LOAD_DECLINE; @@ -855,7 +855,7 @@ struct ast_flags config_flags = { CONFIG_FLAG_FILEUNCHANGED }; cfg = ast_config_load(config, config_flags); - if (cfg == CONFIG_STATUS_FILEUNCHANGED) + if (cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) return 0; AST_LIST_LOCK(&queries); Index: include/asterisk/config.h =================================================================== --- include/asterisk/config.h (revision 131480) +++ include/asterisk/config.h (working copy) @@ -45,7 +45,9 @@ CONFIG_FLAG_NOCACHE = (1 << 2), }; +#define CONFIG_STATUS_FILEMISSING (void *)0 #define CONFIG_STATUS_FILEUNCHANGED (void *)-1 +#define CONFIG_STATUS_FILEINVALID (void *)-2 /*! * \brief Types used in ast_realtime_require_field Index: main/config.c =================================================================== --- main/config.c (revision 131480) +++ main/config.c (working copy) @@ -1011,13 +1011,17 @@ cur++; c = cur; - while (*c && (*c > 32)) c++; + while (*c && (*c > 32)) { + c++; + } + if (*c) { *c = '\0'; /* Find real argument */ c = ast_skip_blanks(c + 1); - if (!(*c)) + if (!(*c)) { c = NULL; + } } else c = NULL; if (!strcasecmp(cur, "include")) { @@ -1041,45 +1045,50 @@ return 0; /* XXX is this correct ? or we should return -1 ? */ } - /* Strip off leading and trailing "'s and <>'s */ - while ((*c == '<') || (*c == '>') || (*c == '\"')) c++; - /* Get rid of leading mess */ - cur = c; - cur2 = cur; - while (!ast_strlen_zero(cur)) { - c = cur + strlen(cur) - 1; - if ((*c == '>') || (*c == '<') || (*c == '\"')) - *c = '\0'; - else - break; - } - /* #exec - We create a tmp file, then we #include it, then we delete it. */ - if (!do_include) { - struct timeval tv = ast_tvnow(); - if (!ast_test_flag(&flags, CONFIG_FLAG_NOCACHE)) - config_cache_attribute(configfile, ATTRIBUTE_EXEC, NULL, who_asked); - snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d%d.%ld", (int)tv.tv_sec, (int)tv.tv_usec, (long)pthread_self()); - snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file); - ast_safe_system(cmd); - cur = exec_file; - } else { - if (!ast_test_flag(&flags, CONFIG_FLAG_NOCACHE)) - config_cache_attribute(configfile, ATTRIBUTE_INCLUDE, cur, who_asked); - exec_file[0] = '\0'; - } - /* A #include */ - /* record this inclusion */ - inclu = ast_include_new(cfg, configfile, cur, !do_include, cur2, lineno, real_inclusion_name, sizeof(real_inclusion_name)); + /* Strip off leading and trailing "'s and <>'s */ + while ((*c == '<') || (*c == '>') || (*c == '\"')) { + c++; + } + /* Get rid of leading mess */ + cur = c; + cur2 = cur; + while (!ast_strlen_zero(cur)) { + c = cur + strlen(cur) - 1; + if ((*c == '>') || (*c == '<') || (*c == '\"')) { + *c = '\0'; + } else { + break; + } + } + /* #exec + We create a tmp file, then we #include it, then we delete it. */ + if (!do_include) { + struct timeval tv = ast_tvnow(); + if (!ast_test_flag(&flags, CONFIG_FLAG_NOCACHE)) { + config_cache_attribute(configfile, ATTRIBUTE_EXEC, NULL, who_asked); + } + snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d%d.%ld", (int)tv.tv_sec, (int)tv.tv_usec, (long)pthread_self()); + snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file); + ast_safe_system(cmd); + cur = exec_file; + } else { + if (!ast_test_flag(&flags, CONFIG_FLAG_NOCACHE)) { + config_cache_attribute(configfile, ATTRIBUTE_INCLUDE, cur, who_asked); + } + exec_file[0] = '\0'; + } + /* A #include */ + /* record this inclusion */ + inclu = ast_include_new(cfg, configfile, cur, !do_include, cur2, lineno, real_inclusion_name, sizeof(real_inclusion_name)); - do_include = ast_config_internal_load(cur, cfg, flags, real_inclusion_name, who_asked) ? 1 : 0; - if (!ast_strlen_zero(exec_file)) - unlink(exec_file); - if (!do_include) { - ast_log(LOG_ERROR, "The file '%s' was listed as a #include but it does not exist.\n", cur); - return -1; - } - /* XXX otherwise what ? the default return is 0 anyways */ + do_include = ast_config_internal_load(cur, cfg, flags, real_inclusion_name, who_asked) ? 1 : 0; + if (!ast_strlen_zero(exec_file)) { + unlink(exec_file); + } + if (!do_include) { + ast_log(LOG_ERROR, "The file '%s' was listed as a #include but it does not exist.\n", cur); + return -1; + } } else { /* Just a line (variable = value) */ @@ -1358,7 +1367,7 @@ char *buf = ast_strip(process_buf); if (!ast_strlen_zero(buf)) { if (process_text_line(cfg, &cat, buf, lineno, fn, flags, comment_buffer, lline_buffer, suggested_include_file, &last_cat, &last_var, who_asked)) { - cfg = NULL; + cfg = CONFIG_STATUS_FILEINVALID; break; } } @@ -1396,15 +1405,16 @@ ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment - 1]); } #ifdef AST_INCLUDE_GLOB - if (cfg == NULL || cfg == CONFIG_STATUS_FILEUNCHANGED) + if (cfg == NULL || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) { break; + } } globfree(&globbuf); } } #endif - if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg->include_level == 1 && ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) { + if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg != CONFIG_STATUS_FILEINVALID && cfg->include_level == 1 && ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) { if (comment_buffer) ast_free(comment_buffer); if (lline_buffer) @@ -2023,7 +2033,7 @@ return NULL; result = ast_config_internal_load(filename, cfg, flags, "", who_asked); - if (!result || result == CONFIG_STATUS_FILEUNCHANGED) + if (!result || result == CONFIG_STATUS_FILEUNCHANGED || result == CONFIG_STATUS_FILEINVALID) ast_config_destroy(cfg); return result; Index: main/loader.c =================================================================== --- main/loader.c (revision 131480) +++ main/loader.c (working copy) @@ -809,7 +809,8 @@ embedded_module_list.first = NULL; } - if (!(cfg = ast_config_load2(AST_MODULE_CONFIG, "" /* core, can't reload */, config_flags))) { + cfg = ast_config_load2(AST_MODULE_CONFIG, "" /* core, can't reload */, config_flags); + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG); goto done; } Index: main/cdr.c =================================================================== --- main/cdr.c (revision 131480) +++ main/cdr.c (working copy) @@ -1387,6 +1387,9 @@ if ((config = ast_config_load2("cdr.conf", "cdr", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) return 0; + if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEUNCHANGED || config == CONFIG_STATUS_FILEINVALID) { + return 0; + } ast_mutex_lock(&cdr_batch_lock); Index: main/manager.c =================================================================== --- main/manager.c (revision 131480) +++ main/manager.c (working copy) @@ -1123,7 +1123,8 @@ astman_send_error(s, m, "Filename not specified"); return 0; } - if (!(cfg = ast_config_load2(fn, "manager", config_flags))) { + cfg = ast_config_load2(fn, "manager", config_flags); + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) { astman_send_error(s, m, "Config file not found"); return 0; } Index: main/features.c =================================================================== --- main/features.c (revision 131480) +++ main/features.c (working copy) @@ -2997,7 +2997,7 @@ atxfercallbackretries = DEFAULT_ATXFER_CALLBACK_RETRIES; cfg = ast_config_load2("features.conf", "features", config_flags); - if (!cfg) { + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_WARNING,"Could not load features.conf\n"); return 0; } Index: main/http.c =================================================================== --- main/http.c (revision 131480) +++ main/http.c (working copy) @@ -822,7 +822,8 @@ struct http_uri_redirect *redirect; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; - if ((cfg = ast_config_load2("http.conf", "http", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) { + cfg = ast_config_load2("http.conf", "http", config_flags); + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) { return 0; } Index: main/rtp.c =================================================================== --- main/rtp.c (revision 131480) +++ main/rtp.c (working copy) @@ -4689,8 +4689,10 @@ const char *s; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; - if ((cfg = ast_config_load2("rtp.conf", "rtp", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) + cfg = ast_config_load2("rtp.conf", "rtp", config_flags); + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) { return 0; + } rtpstart = 5000; rtpend = 31000; Index: main/asterisk.c =================================================================== --- main/asterisk.c (revision 131480) +++ main/asterisk.c (working copy) @@ -2604,7 +2604,7 @@ if (ast_opt_override_config) { cfg = ast_config_load2(ast_config_AST_CONFIG_FILE, "" /* core, can't reload */, config_flags); - if (!cfg) + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) ast_log(LOG_WARNING, "Unable to open specified master config file '%s', using built-in defaults\n", ast_config_AST_CONFIG_FILE); } else cfg = ast_config_load2(config, "" /* core, can't reload */, config_flags); @@ -2627,7 +2627,7 @@ ast_set_default_eid(&g_eid); /* no asterisk.conf? no problem, use buildtime config! */ - if (!cfg) { + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) { return; } @@ -2879,6 +2879,9 @@ if (!(cfg = ast_config_load2("cli.conf", "" /* core, can't reload */, cfg_flags))) return; + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) { + return; + } fd = open("/dev/null", O_RDWR); if (fd < 0) { Index: main/dsp.c =================================================================== --- main/dsp.c (revision 131480) +++ main/dsp.c (working copy) @@ -1614,6 +1614,9 @@ struct ast_config *cfg; cfg = ast_config_load2(CONFIG_FILE_NAME, "dsp", config_flags); + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) { + return 0; + } if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED) { const char *value; Index: main/udptl.c =================================================================== --- main/udptl.c (revision 131480) +++ main/udptl.c (working copy) @@ -1223,8 +1223,10 @@ const char *s; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; - if ((cfg = ast_config_load2("udptl.conf", "udptl", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) + cfg = ast_config_load2("udptl.conf", "udptl", config_flags); + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) { return; + } udptlstart = 4500; udptlend = 4999; Index: main/enum.c =================================================================== --- main/enum.c (revision 131480) +++ main/enum.c (working copy) @@ -959,6 +959,9 @@ if ((cfg = ast_config_load2("enum.conf", "enum", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) return 0; + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) { + return 0; + } /* Destroy existing list */ ast_mutex_lock(&enumlock); Index: main/dnsmgr.c =================================================================== --- main/dnsmgr.c (revision 131480) +++ main/dnsmgr.c (working copy) @@ -372,8 +372,10 @@ int was_enabled; int res = -1; - if ((config = ast_config_load2("dnsmgr.conf", "dnsmgr", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) + config = ast_config_load2("dnsmgr.conf", "dnsmgr", config_flags); + if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEUNCHANGED || config == CONFIG_STATUS_FILEINVALID) { return 0; + } /* ensure that no refresh cycles run while the reload is in progress */ ast_mutex_lock(&refresh_lock); Index: res/res_config_sqlite.c =================================================================== --- res/res_config_sqlite.c (revision 131480) +++ res/res_config_sqlite.c (working copy) @@ -618,7 +618,7 @@ config = ast_config_load(RES_CONFIG_SQLITE_CONF_FILE, config_flags); - if (!config) { + if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_ERROR, "Unable to load " RES_CONFIG_SQLITE_CONF_FILE "\n"); return 1; } Index: res/res_config_ldap.c =================================================================== --- res/res_config_ldap.c (revision 131480) +++ res/res_config_ldap.c (working copy) @@ -1391,8 +1391,7 @@ char *category_name = NULL; config = ast_config_load(RES_CONFIG_LDAP_CONF, config_flags); - - if (!config) { + if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_WARNING, "Cannot load configuration %s\n", RES_CONFIG_LDAP_CONF); return -1; } Index: res/res_odbc.c =================================================================== --- res/res_odbc.c (revision 131480) +++ res/res_odbc.c (working copy) @@ -417,7 +417,7 @@ struct odbc_class *new; config = ast_config_load(cfg, config_flags); - if (!config) { + if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_WARNING, "Unable to load config file res_odbc.conf\n"); return -1; } Index: res/res_snmp.c =================================================================== --- res/res_snmp.c (revision 131480) +++ res/res_snmp.c (working copy) @@ -52,7 +52,7 @@ res_snmp_enabled = 0; res_snmp_agentx_subagent = 1; cfg = ast_config_load("res_snmp.conf", config_flags); - if (!cfg) { + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_WARNING, "Could not load res_snmp.conf\n"); return 0; } Index: res/res_jabber.c =================================================================== --- res/res_jabber.c (revision 131480) +++ res/res_jabber.c (working copy) @@ -2870,7 +2870,7 @@ /* Reset flags to default value */ ast_set_flag(&globalflags, AJI_AUTOPRUNE | AJI_AUTOREGISTER); - if (!cfg) { + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_WARNING, "No such configuration file %s\n", JABBER_CONFIG); return 0; } Index: res/res_smdi.c =================================================================== --- res/res_smdi.c (revision 131480) +++ res/res_smdi.c (working copy) @@ -848,7 +848,7 @@ int msdstrip = 0; /* strip zero digits */ long msg_expiry = SMDI_MSG_EXPIRY_TIME; - if (!(conf = ast_config_load(config_file, config_flags))) { + if (!(conf = ast_config_load(config_file, config_flags)) || conf == CONFIG_STATUS_FILEINVALID) { if (reload) ast_log(LOG_NOTICE, "Unable to reload config %s: SMDI untouched\n", config_file); else Index: res/res_indications.c =================================================================== --- res/res_indications.c (revision 131480) +++ res/res_indications.c (working copy) @@ -263,10 +263,11 @@ /* that the following cast is needed, is yuk! */ /* yup, checked it out. It is NOT written to. */ cfg = ast_config_load((char *)config, config_flags); - if (!cfg) + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) { return -1; - else if (cfg == CONFIG_STATUS_FILEUNCHANGED) + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } if (reload) ast_unregister_indication_country(NULL); Index: res/res_config_pgsql.c =================================================================== --- res/res_config_pgsql.c (revision 131480) +++ res/res_config_pgsql.c (working copy) @@ -1125,10 +1125,12 @@ const char *s; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; - if ((config = ast_config_load(RES_CONFIG_PGSQL_CONF, config_flags)) == CONFIG_STATUS_FILEUNCHANGED) + config = ast_config_load(RES_CONFIG_PGSQL_CONF, config_flags); + if (config == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } - if (!config) { + if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_WARNING, "Unable to load config %s\n", RES_CONFIG_PGSQL_CONF); return 0; } Index: res/res_phoneprov.c =================================================================== --- res/res_phoneprov.c (revision 131480) +++ res/res_phoneprov.c (working copy) @@ -903,12 +903,12 @@ /* Try to grab the port from sip.conf. If we don't get it here, we'll set it * to whatever is set in phoneprov.conf or default to 5060 */ - if ((cfg = ast_config_load("sip.conf", config_flags))) { + if ((cfg = ast_config_load("sip.conf", config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) { ast_copy_string(global_serverport, S_OR(ast_variable_retrieve(cfg, "general", "bindport"), "5060"), sizeof(global_serverport)); ast_config_destroy(cfg); } - if (!(cfg = ast_config_load("users.conf", config_flags))) { + if (!(cfg = ast_config_load("users.conf", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_WARNING, "Unable to load users.cfg\n"); return 0; } @@ -930,7 +930,7 @@ } } - if (!(phoneprov_cfg = ast_config_load("phoneprov.conf", config_flags))) { + if (!(phoneprov_cfg = ast_config_load("phoneprov.conf", config_flags)) || phoneprov_cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_ERROR, "Unable to load config phoneprov.conf\n"); return -1; } Index: res/res_adsi.c =================================================================== --- res/res_adsi.c (revision 131480) +++ res/res_adsi.c (working copy) @@ -1021,10 +1021,10 @@ char *name, *sname; init_state(); - if (!(conf = ast_config_load("adsi.conf", config_flags))) + conf = ast_config_load("adsi.conf", config_flags); + if (conf == CONFIG_STATUS_FILEMISSING || conf == CONFIG_STATUS_FILEUNCHANGED || conf == CONFIG_STATUS_FILEINVALID) { return; - else if (conf == CONFIG_STATUS_FILEUNCHANGED) - return; + } for (v = ast_variable_browse(conf, "intro"); v; v = v->next) { if (!strcasecmp(v->name, "alignment")) alignment = str2align(v->value); Index: res/res_http_post.c =================================================================== --- res/res_http_post.c (revision 131480) +++ res/res_http_post.c (working copy) @@ -264,7 +264,8 @@ struct ast_variable *v; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; - if ((cfg = ast_config_load2("http.conf", "http", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) { + cfg = ast_config_load2("http.conf", "http", config_flags); + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) { return 0; } Index: res/res_musiconhold.c =================================================================== --- res/res_musiconhold.c (revision 131480) +++ res/res_musiconhold.c (working copy) @@ -1337,8 +1337,9 @@ cfg = ast_config_load("musiconhold.conf", config_flags); - if (cfg == NULL || cfg == CONFIG_STATUS_FILEUNCHANGED) + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) { return 0; + } if (reload) { AST_RWLIST_WRLOCK(&mohclasses); Index: codecs/codec_lpc10.c =================================================================== --- codecs/codec_lpc10.c (revision 131480) +++ codecs/codec_lpc10.c (working copy) @@ -255,10 +255,8 @@ struct ast_variable *var; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; struct ast_config *cfg = ast_config_load("codecs.conf", config_flags); - if (cfg == NULL) + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) return 0; - if (cfg == CONFIG_STATUS_FILEUNCHANGED) - return 0; for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { if (!strcasecmp(var->name, "genericplc")) { lpc10tolin.useplc = ast_true(var->value) ? 1 : 0; Index: codecs/codec_g722.c =================================================================== --- codecs/codec_g722.c (revision 131480) +++ codecs/codec_g722.c (working copy) @@ -244,10 +244,8 @@ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; struct ast_config *cfg = ast_config_load("codecs.conf", config_flags); - if (cfg == NULL) + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) return 0; - if (cfg == CONFIG_STATUS_FILEUNCHANGED) - return 0; for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { if (!strcasecmp(var->name, "genericplc")) { g722tolin.useplc = ast_true(var->value) ? 1 : 0; Index: codecs/codec_speex.c =================================================================== --- codecs/codec_speex.c (revision 131480) +++ codecs/codec_speex.c (working copy) @@ -375,10 +375,8 @@ int res; float res_f; - if (cfg == NULL) + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) return 0; - if (cfg == CONFIG_STATUS_FILEUNCHANGED) - return 0; for (var = ast_variable_browse(cfg, "speex"); var; var = var->next) { if (!strcasecmp(var->name, "quality")) { Index: codecs/codec_alaw.c =================================================================== --- codecs/codec_alaw.c (revision 131480) +++ codecs/codec_alaw.c (working copy) @@ -128,10 +128,8 @@ struct ast_variable *var; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; struct ast_config *cfg = ast_config_load("codecs.conf", config_flags); - if (cfg == NULL) + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) return 0; - if (cfg == CONFIG_STATUS_FILEUNCHANGED) - return 0; for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { if (!strcasecmp(var->name, "genericplc")) { alawtolin.useplc = ast_true(var->value) ? 1 : 0; Index: codecs/codec_g726.c =================================================================== --- codecs/codec_g726.c (revision 131480) +++ codecs/codec_g726.c (working copy) @@ -890,10 +890,8 @@ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; struct ast_config *cfg = ast_config_load("codecs.conf", config_flags); - if (cfg == NULL) + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) return 0; - if (cfg == CONFIG_STATUS_FILEUNCHANGED) - return 0; for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { if (!strcasecmp(var->name, "genericplc")) { g726tolin.useplc = ast_true(var->value) ? 1 : 0; Index: codecs/codec_ulaw.c =================================================================== --- codecs/codec_ulaw.c (revision 131480) +++ codecs/codec_ulaw.c (working copy) @@ -141,10 +141,8 @@ struct ast_variable *var; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; struct ast_config *cfg = ast_config_load("codecs.conf", config_flags); - if (cfg == NULL) + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) return 0; - if (cfg == CONFIG_STATUS_FILEUNCHANGED) - return 0; for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { if (!strcasecmp(var->name, "genericplc")) { ulawtolin.useplc = ast_true(var->value) ? 1 : 0; Index: codecs/codec_dahdi.c =================================================================== --- codecs/codec_dahdi.c (revision 131480) +++ codecs/codec_dahdi.c (working copy) @@ -378,10 +378,8 @@ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; struct ast_config *cfg = ast_config_load("codecs.conf", config_flags); - if (cfg == NULL) + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) return 0; - if (cfg == CONFIG_STATUS_FILEUNCHANGED) - return 0; for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { if (!strcasecmp(var->name, "genericplc")) { Index: codecs/codec_adpcm.c =================================================================== --- codecs/codec_adpcm.c (revision 131480) +++ codecs/codec_adpcm.c (working copy) @@ -345,10 +345,8 @@ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; struct ast_config *cfg = ast_config_load("codecs.conf", config_flags); struct ast_variable *var; - if (cfg == NULL) + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) return 0; - if (cfg == CONFIG_STATUS_FILEUNCHANGED) - return 0; for (var = ast_variable_browse(cfg, "plc"); var ; var = var->next) { if (!strcasecmp(var->name, "genericplc")) { adpcmtolin.useplc = ast_true(var->value) ? 1 : 0; Index: codecs/codec_gsm.c =================================================================== --- codecs/codec_gsm.c (revision 131480) +++ codecs/codec_gsm.c (working copy) @@ -229,10 +229,8 @@ struct ast_variable *var; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; struct ast_config *cfg = ast_config_load("codecs.conf", config_flags); - if (cfg == NULL) + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) return 0; - if (cfg == CONFIG_STATUS_FILEUNCHANGED) - return 0; for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { if (!strcasecmp(var->name, "genericplc")) { gsmtolin.useplc = ast_true(var->value) ? 1 : 0;