diff options
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r-- | apps/app_voicemail.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 6644419b2..7a04c5456 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -1061,28 +1061,27 @@ static int check_password(struct ast_vm_user *vmu, char *password) * \param vmu The voicemail user to change the password for. * \param password The new value to be set to the password for this user. * - * This only works if the voicemail user has a unique id, and if there is a realtime engine configured. + * This only works if there is a realtime engine configured. * This is called from the (top level) vm_change_password. * * \return zero on success, -1 on error. */ static int change_password_realtime(struct ast_vm_user *vmu, const char *password) { - int res; - if (!ast_strlen_zero(vmu->uniqueid)) { - if (strlen(password) > 10) { - ast_realtime_require_field("voicemail", "password", RQ_CHAR, strlen(password), SENTINEL); - } - res = ast_update2_realtime("voicemail", "context", vmu->context, "mailbox", vmu->mailbox, SENTINEL, "password", password, SENTINEL); - if (res > 0) { - ast_copy_string(vmu->password, password, sizeof(vmu->password)); - res = 0; - } else if (!res) { - res = -1; - } - return res; + int res = -1; + if (!strcmp(vmu->password, password)) { + /* No change (but an update would return 0 rows updated, so we opt out here) */ + return 0; } - return -1; + + if (strlen(password) > 10) { + ast_realtime_require_field("voicemail", "password", RQ_CHAR, strlen(password), SENTINEL); + } + if (ast_update2_realtime("voicemail", "context", vmu->context, "mailbox", vmu->mailbox, SENTINEL, "password", password, SENTINEL) > 0) { + ast_copy_string(vmu->password, password, sizeof(vmu->password)); + res = 0; + } + return res; } /*! |