diff -Naur asterisk-original/apps/app_voicemail.c asterisk/apps/app_voicemail.c --- asterisk-original/apps/app_voicemail.c 2005-05-16 15:36:35.000000000 +0200 +++ asterisk/apps/app_voicemail.c 2005-05-27 09:47:45.411612459 +0200 @@ -13,6 +13,9 @@ * 12-16 - 2005 : Support for Greek added by InAccess Networks (work funded by HOL, www.hol.gr) * George Konstantoulakis * 05-10 - 2005 : Support for Swedish and Norwegian added by Daniel Nylander, http://www.danielnylander.se/ + * + * 05-17 - 2005 : Password parameter added into VoicemailMain by GFD Partners (www.gdspartners.com) + * Stojan Sljivic */ #include "asterisk/lock.h" @@ -259,7 +262,7 @@ "Enter voicemail system"; static char *descrip_vmain = -" VoiceMailMain([mailbox][@context][|options]): Enters the main voicemail system\n" +" VoiceMailMain([mailbox][:password][@context][|options]): Enters the main voicemail system\n" "for the checking of voicemail. The mailbox can be passed in,\n" "which will stop the voicemail system from prompting the user for the mailbox.\n" "If the options contain 's' then the password check will be skipped. If\n" @@ -4485,9 +4488,11 @@ int skipuser, int maxlogins, int silent) { int useadsi, valid=0, logretries=0; - char password[AST_MAX_EXTENSION]="", *passptr; + char password[AST_MAX_EXTENSION]="", pwd[AST_MAX_EXTENSION]="", *passptr; struct ast_vm_user vmus, *vmu = NULL; + ast_copy_string(pwd, res_vmu->password, sizeof(pwd)); + /* If ADSI is supported, setup login screen */ adsi_begin(chan, &useadsi); if (!skipuser && useadsi) @@ -4514,7 +4519,7 @@ return -1; } } - if (useadsi) + if (useadsi && !pwd) adsi_password(chan); if (prefix && !ast_strlen_zero(prefix)) { @@ -4525,17 +4530,23 @@ } vmu = find_user(&vmus, context, mailbox); - if (vmu && (vmu->password[0] == '\0' || (vmu->password[0] == '-' && vmu->password[1] == '\0'))) { - /* saved password is blank, so don't bother asking */ - password[0] = '\0'; + if (pwd) { + ast_copy_string(password, pwd, sizeof(password)); + if (skipuser) + logretries = maxlogins + 1; } else { - if (ast_streamfile(chan, "vm-password", chan->language)) { - ast_log(LOG_WARNING, "Unable to stream password file\n"); - return -1; - } - if (ast_readstring(chan, password, sizeof(password) - 1, 2000, 10000, "#") < 0) { - ast_log(LOG_WARNING, "Unable to read password\n"); - return -1; + if (vmu && (ast_strlen_zero(vmu->password) || (vmu->password[0] == '-' && vmu->password[1] == '\0'))) { + /* saved password is blank, so don't bother asking */ + password[0] = '\0'; + } else { + if (ast_streamfile(chan, "vm-password", chan->language)) { + ast_log(LOG_WARNING, "Unable to stream password file\n"); + return -1; + } + if (ast_readstring(chan, password, sizeof(password) - 1, 2000, 10000, "#") < 0) { + ast_log(LOG_WARNING, "Unable to read password\n"); + return -1; + } } } @@ -4601,6 +4612,7 @@ struct vm_state vms; struct ast_vm_user *vmu = NULL, vmus; char *context=NULL; + char *pwd = NULL; int silentexit = 0; char *options; @@ -4648,6 +4660,12 @@ *context = '\0'; context++; } + + pwd = strchr(ext, ':'); + if (pwd) { + *pwd = '\0'; + pwd++; + } if (prefix) strncpy(prefixstr, ext, sizeof(prefixstr) - 1); @@ -4660,6 +4678,7 @@ } if (!valid) { + ast_copy_string(vmu->password, pwd, sizeof(vmu->password)); res = vm_authenticate(chan, vms.username, sizeof(vms.username), &vmus, context, prefixstr, skipuser, maxlogins, 0); }