aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-11-01 02:20:30 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-11-01 02:20:30 +0000
commit36b3d6f2837bfe68df3cf2d8779a9be64d5fecbc (patch)
tree7e0b14a63b89d2a8ce552e7b5780d15ff1381426
parentfa47ab787a866e627b66e315213db41d442149eb (diff)
when going through new user setup, don't change the password if they don't
match. Also, allow 3 tries before bailing out. (issue #5495, different fix) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6922 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xapps/app_voicemail.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index e31519ffa..fab901590 100755
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -4543,6 +4543,7 @@ static int vm_newuser(struct ast_channel *chan, struct ast_vm_user *vmu, struct
{
int cmd = 0;
int duration = 0;
+ int tries = 0;
char newpassword[80] = "";
char newpassword2[80] = "";
char prefile[256]="";
@@ -4560,33 +4561,37 @@ static int vm_newuser(struct ast_channel *chan, struct ast_vm_user *vmu, struct
/* First, have the user change their password
so they won't get here again */
- newpassword[1] = '\0';
- newpassword[0] = cmd = ast_play_and_wait(chan,"vm-newpassword");
- if (cmd == '#')
- newpassword[0] = '\0';
- if (cmd < 0 || cmd == 't' || cmd == '#')
- return cmd;
- cmd = ast_readstring(chan,newpassword + strlen(newpassword),sizeof(newpassword)-1,2000,10000,"#");
- if (cmd < 0 || cmd == 't' || cmd == '#')
- return cmd;
- newpassword2[1] = '\0';
- newpassword2[0] = cmd = ast_play_and_wait(chan,"vm-reenterpassword");
- if (cmd == '#')
- newpassword2[0] = '\0';
- if (cmd < 0 || cmd == 't' || cmd == '#')
- return cmd;
- cmd = ast_readstring(chan,newpassword2 + strlen(newpassword2),sizeof(newpassword2)-1,2000,10000,"#");
- if (cmd < 0 || cmd == 't' || cmd == '#')
- return cmd;
- if (strcmp(newpassword, newpassword2)) {
+ for (;;) {
+ newpassword[1] = '\0';
+ newpassword[0] = cmd = ast_play_and_wait(chan,"vm-newpassword");
+ if (cmd == '#')
+ newpassword[0] = '\0';
+ if (cmd < 0 || cmd == 't' || cmd == '#')
+ return cmd;
+ cmd = ast_readstring(chan,newpassword + strlen(newpassword),sizeof(newpassword)-1,2000,10000,"#");
+ if (cmd < 0 || cmd == 't' || cmd == '#')
+ return cmd;
+ newpassword2[1] = '\0';
+ newpassword2[0] = cmd = ast_play_and_wait(chan,"vm-reenterpassword");
+ if (cmd == '#')
+ newpassword2[0] = '\0';
+ if (cmd < 0 || cmd == 't' || cmd == '#')
+ return cmd;
+ cmd = ast_readstring(chan,newpassword2 + strlen(newpassword2),sizeof(newpassword2)-1,2000,10000,"#");
+ if (cmd < 0 || cmd == 't' || cmd == '#')
+ return cmd;
+ if (!strcmp(newpassword, newpassword2))
+ break;
ast_log(LOG_NOTICE,"Password mismatch for user %s (%s != %s)\n", vms->username, newpassword, newpassword2);
cmd = ast_play_and_wait(chan, "vm-mismatch");
+ if (++tries == 3)
+ return -1;
}
if (ast_strlen_zero(ext_pass_cmd))
vm_change_password(vmu,newpassword);
else
vm_change_password_shell(vmu,newpassword);
- ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
+
cmd = ast_play_and_wait(chan,"vm-passchanged");
/* If forcename is set, have the user record their name */