diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-09-25 13:18:03 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-09-25 13:18:03 +0000 |
commit | b83c18b9ca0c8a8ce7a4ecb6eada01fd01cc9ff8 (patch) | |
tree | 842c7b30b46a0f21e1356de8fde227c4ec798b93 | |
parent | 3a3cab946e1355c2e17d35ee74466e495e35c4b7 (diff) |
Keep voicemail from segging on a permissions problem (bug #245)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1543 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-x | apps/app_voicemail2.c | 22 | ||||
-rwxr-xr-x | channels/chan_sip.c | 24 |
2 files changed, 32 insertions, 14 deletions
diff --git a/apps/app_voicemail2.c b/apps/app_voicemail2.c index 6ff1a016d..a2fbca42f 100755 --- a/apps/app_voicemail2.c +++ b/apps/app_voicemail2.c @@ -375,10 +375,24 @@ static void vm_change_password(struct ast_vm_user *vmu, char *newpassword) char tmpin[AST_CONFIG_MAX_PATH]; char tmpout[AST_CONFIG_MAX_PATH]; char *user, *pass, *rest, *trim; - snprintf((char *)tmpin, sizeof(tmpin)-1, "%s/voicemail.conf",(char *)ast_config_AST_CONFIG_DIR); - snprintf((char *)tmpout, sizeof(tmpout)-1, "%s/voicemail.conf.new",(char *)ast_config_AST_CONFIG_DIR); + snprintf((char *)tmpin, sizeof(tmpin)-1, "%s/voicemail.conf",(char *)ast_config_AST_CONFIG_DIR); + snprintf((char *)tmpout, sizeof(tmpout)-1, "%s/voicemail.conf.new",(char *)ast_config_AST_CONFIG_DIR); configin = fopen((char *)tmpin,"r"); - configout = fopen((char *)tmpout,"w+"); + if (configin) + configout = fopen((char *)tmpout,"w+"); + else + configout = NULL; + if(!configin || !configout) { + if (configin) + fclose(configin); + else + ast_log(LOG_WARNING, "Warning: Unable to open '%s' for reading: %s\n", tmpin, strerror(errno)); + if (configout) + fclose(configout); + else + ast_log(LOG_WARNING, "Warning: Unable to open '%s' for writing: %s\n", tmpout, strerror(errno)); + return; + } while (!feof(configin)) { /* Read in the line */ @@ -1955,7 +1969,7 @@ static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *v /* Can't think of how other diffs might be helpful, but I'm sure somebody will think of something. */ #endif if (the_zone) - res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, the_zone->msg_format, &(the_zone->timezone)); + res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, the_zone->msg_format, the_zone->timezone); else res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q 'digits/at' IMp", NULL); #if 0 diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 936fea3e1..1c2f52376 100755 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -187,6 +187,7 @@ static struct sip_pvt { int alreadygone; /* Whether or not we've already been destroyed by or peer */ int needdestroy; /* if we need to be destroyed */ int capability; /* Special capability */ + int jointcapability; /* Supported capability at both ends */ int noncodeccapability; int outgoing; /* Outgoing or incoming call? */ int authtries; /* Times we've tried to authenticate */ @@ -1224,9 +1225,11 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, char *title) if (tmp) { /* Select our native format based on codec preference until we receive something from another device to the contrary. */ - if (i->capability) + if (i->jointcapability) + tmp->nativeformats = sip_codec_choose(i->jointcapability); + else if (i->capability) tmp->nativeformats = sip_codec_choose(i->capability); - else + else tmp->nativeformats = sip_codec_choose(capability); fmt = ast_best_codec(tmp->nativeformats); if (title) @@ -1847,24 +1850,24 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req) if (p->vrtp) ast_rtp_get_current_formats(p->vrtp, &vpeercapability, &vpeernoncodeccapability); - p->capability = capability & (peercapability | vpeercapability); + p->jointcapability = p->capability & (peercapability | vpeercapability); p->noncodeccapability = noncodeccapability & (peernoncodeccapability | vpeernoncodeccapability); if (sipdebug) { ast_verbose("Capabilities: us - %d, them - %d/%d, combined - %d\n", - capability, peercapability, vpeercapability, p->capability); + p->capability, peercapability, vpeercapability, p->jointcapability); ast_verbose("Non-codec capabilities: us - %d, them - %d, combined - %d\n", noncodeccapability, peernoncodeccapability, p->noncodeccapability); } - if (!p->capability) { + if (!p->jointcapability) { ast_log(LOG_WARNING, "No compatible codecs!\n"); return -1; } if (p->owner) { - if (!(p->owner->nativeformats & p->capability)) { - ast_log(LOG_DEBUG, "Oooh, we need to change our formats since our peer supports only %d and not %d\n", p->capability, p->owner->nativeformats); - p->owner->nativeformats = sip_codec_choose(p->capability); + if (!(p->owner->nativeformats & p->jointcapability)) { + ast_log(LOG_DEBUG, "Oooh, we need to change our formats since our peer supports only %d and not %d\n", p->jointcapability, p->owner->nativeformats); + p->owner->nativeformats = sip_codec_choose(p->jointcapability); ast_set_read_format(p->owner, p->owner->readformat); ast_set_write_format(p->owner, p->owner->writeformat); } @@ -4128,8 +4131,9 @@ static int sip_show_channel(int fd, int argc, char *argv[]) while(cur) { if (!strcasecmp(cur->callid, argv[3])) { ast_cli(fd, "Call-ID: %s\n", cur->callid); - ast_cli(fd, "Codec Capability: %d\n", cur->capability); + ast_cli(fd, "Our Codec Capability: %d\n", cur->capability); ast_cli(fd, "Non-Codec Capability: %d\n", cur->noncodeccapability); + ast_cli(fd, "Joint Codec Capability: %d\n", cur->jointcapability); ast_cli(fd, "Theoretical Address: %s:%d\n", inet_ntoa(cur->sa.sin_addr), ntohs(cur->sa.sin_port)); ast_cli(fd, "Received Address: %s:%d\n", inet_ntoa(cur->recv.sin_addr), ntohs(cur->recv.sin_port)); ast_cli(fd, "NAT Support: %s\n", cur->nat ? "Yes" : "No"); @@ -4831,7 +4835,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc if (process_sdp(p, req)) return -1; } else { - p->capability = capability; + p->jointcapability = p->capability; ast_log(LOG_DEBUG, "Hm.... No sdp for the moemnt\n"); } /* Queue NULL frame to prod ast_rtp_bridge if appropriate */ |