[asterisk-commits] anthonyl: branch anthonyl/usersconf-vmpassword
r50442 - /team/anthonyl/usersc...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Jan 10 13:57:27 MST 2007
Author: anthonyl
Date: Wed Jan 10 14:57:26 2007
New Revision: 50442
URL: http://svn.digium.com/view/asterisk?view=rev&rev=50442
Log:
update, added support for re-writing vmpassword in users.conf
Modified:
team/anthonyl/usersconf-vmpassword/apps/app_voicemail.c
Modified: team/anthonyl/usersconf-vmpassword/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/usersconf-vmpassword/apps/app_voicemail.c?view=diff&rev=50442&r1=50441&r2=50442
==============================================================================
--- team/anthonyl/usersconf-vmpassword/apps/app_voicemail.c (original)
+++ team/anthonyl/usersconf-vmpassword/apps/app_voicemail.c Wed Jan 10 14:57:26 2007
@@ -822,22 +822,38 @@
reset_user_pw(vmu->context, vmu->mailbox, newpassword);
ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
config_text_file_save("voicemail.conf", cfg, "AppVoicemail");
- }
-
+ if (new)
+ free(new);
+ }
+ category = NULL;
/* check users.conf and update the password stored for the mailbox*/
/* if no vmpassword entry exists create one. */
if ((cfg = ast_config_load("users.conf"))) {
+ ast_log(LOG_WARNING, "we are looking for %s\n", vmu->mailbox);
while ((category = ast_category_browse(cfg, category))) {
ast_log(LOG_WARNING, "users.conf: %s\n", category);
- for (var = ast_variable_browse(cfg, category); var; var = var->next) {
- /* check the context */
- /* write the password to memory */
- /* reset_user_pw(vmu->context, vmu->mailbox, newpassword); */
- ast_log(LOG_WARNING,"\tname: %s %s\n", var->name, var->value);
- }
- }
- /* save the results */
+ if (!strcasecmp(category, vmu->mailbox)) {
+ if (!(tmp = ast_variable_retrieve(cfg, category, "vmpassword"))) {
+ ast_log(LOG_WARNING, "we need to make vmpassword!\n");
+ }
+
+ if (!(new = ast_calloc(1,strlen(newpassword)))) {
+ ast_log(LOG_WARNING, "Memory Allocation Failed.\n");
+ break;
+ }
+ sprintf(new, "%s", newpassword);
+ if (!(cat = ast_category_get(cfg, category))) {
+ ast_log(LOG_WARNING, "failed to get category!\n");
+ }
+ ast_variable_update(cat, "vmpassword", new, NULL);
+ }
+ }
+ /* save the results and clean things up */
+ reset_user_pw(vmu->context, vmu->mailbox, newpassword);
+ ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
config_text_file_save("users.conf", cfg, "AppVoicemail");
+ if (new)
+ free(new);
}
return;
}
More information about the asterisk-commits
mailing list