diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-02-24 17:11:23 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-02-24 17:11:23 +0000 |
commit | 6b2df182e423d2b5ea2a61736fc23bc32174d11b (patch) | |
tree | b04bd0f2d0e878a50d7cd5a2ad688cee3c731b0f /apps/app_voicemail.c | |
parent | 4a8a0996428b71ae973cb0738137636e57776a9c (diff) |
Handle change password properly with multiple VM contexts (bug #1069)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2227 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_voicemail.c')
-rwxr-xr-x | apps/app_voicemail.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 89c52d91f..f42df964a 100755 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -450,11 +450,14 @@ static void vm_change_password(struct ast_vm_user *vmu, char *newpassword) FILE *configin; FILE *configout; + int linenum=0; char inbuf[256]; char orig[256]; + char currcontext[256] =""; char tmpin[AST_CONFIG_MAX_PATH]; char tmpout[AST_CONFIG_MAX_PATH]; - char *user, *pass, *rest, *trim; + char *user, *pass, *rest, *trim, *tempcontext; + tempcontext = NULL; 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"); @@ -477,6 +480,7 @@ static void vm_change_password(struct ast_vm_user *vmu, char *newpassword) while (!feof(configin)) { /* Read in the line */ fgets(inbuf, sizeof(inbuf), configin); + linenum++; if (!feof(configin)) { /* Make a backup of it */ memcpy(orig, inbuf, sizeof(orig)); @@ -488,6 +492,18 @@ static void vm_change_password(struct ast_vm_user *vmu, char *newpassword) user=inbuf; while(*user < 33) user++; + /* check for '[' (opening of context name ) */ + tempcontext = strchr(user, '['); + if (tempcontext) { + strncpy(currcontext, tempcontext +1, + sizeof(currcontext) - 1); + /* now check for ']' */ + tempcontext = strchr(currcontext, ']'); + if (tempcontext) + *tempcontext = '\0'; + else + currcontext[0] = '\0'; + } pass = strchr(user, '='); if (pass > user) { trim = pass - 1; @@ -512,7 +528,11 @@ static void vm_change_password(struct ast_vm_user *vmu, char *newpassword) } } else rest = NULL; - if (user && pass && *user && *pass && !strcmp(user, vmu->mailbox) && !strcmp(pass, vmu->password)) { + + /* Compare user, pass AND context */ + if (user && *user && !strcmp(user, vmu->mailbox) && + pass && *pass && !strcmp(pass, vmu->password) && + currcontext && *currcontext && !strcmp(currcontext, vmu->context)) { /* This is the line */ if (rest) { fprintf(configout, "%s => %s,%s\n", vmu->mailbox,newpassword,rest); |