|
|
@ -110,6 +110,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
#define VM_ATTACH (1 << 11)
|
|
|
|
#define VM_ATTACH (1 << 11)
|
|
|
|
#define VM_DELETE (1 << 12)
|
|
|
|
#define VM_DELETE (1 << 12)
|
|
|
|
#define VM_ALLOCED (1 << 13)
|
|
|
|
#define VM_ALLOCED (1 << 13)
|
|
|
|
|
|
|
|
#define VM_SEARCH (1 << 14)
|
|
|
|
|
|
|
|
|
|
|
|
#define ERROR_LOCK_PATH -100
|
|
|
|
#define ERROR_LOCK_PATH -100
|
|
|
|
|
|
|
|
|
|
|
@ -534,12 +535,11 @@ static struct ast_vm_user *find_user_realtime(struct ast_vm_user *ivm, const cha
|
|
|
|
ast_set_flag(retval, VM_ALLOCED);
|
|
|
|
ast_set_flag(retval, VM_ALLOCED);
|
|
|
|
if (mailbox)
|
|
|
|
if (mailbox)
|
|
|
|
ast_copy_string(retval->mailbox, mailbox, sizeof(retval->mailbox));
|
|
|
|
ast_copy_string(retval->mailbox, mailbox, sizeof(retval->mailbox));
|
|
|
|
if (context)
|
|
|
|
|
|
|
|
ast_copy_string(retval->context, context, sizeof(retval->context));
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
strcpy(retval->context, "default");
|
|
|
|
|
|
|
|
populate_defaults(retval);
|
|
|
|
populate_defaults(retval);
|
|
|
|
var = ast_load_realtime("voicemail", "mailbox", mailbox, "context", retval->context, NULL);
|
|
|
|
if (ast_test_flag((&globalflags), VM_SEARCH))
|
|
|
|
|
|
|
|
var = ast_load_realtime("voicemail", "mailbox", mailbox, NULL);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
var = ast_load_realtime("voicemail", "mailbox", mailbox, "context", retval->context, NULL);
|
|
|
|
if (var) {
|
|
|
|
if (var) {
|
|
|
|
tmp = var;
|
|
|
|
tmp = var;
|
|
|
|
while(tmp) {
|
|
|
|
while(tmp) {
|
|
|
@ -554,6 +554,8 @@ static struct ast_vm_user *find_user_realtime(struct ast_vm_user *ivm, const cha
|
|
|
|
ast_copy_string(retval->email, tmp->value, sizeof(retval->email));
|
|
|
|
ast_copy_string(retval->email, tmp->value, sizeof(retval->email));
|
|
|
|
} else if (!strcasecmp(tmp->name, "fullname")) {
|
|
|
|
} else if (!strcasecmp(tmp->name, "fullname")) {
|
|
|
|
ast_copy_string(retval->fullname, tmp->value, sizeof(retval->fullname));
|
|
|
|
ast_copy_string(retval->fullname, tmp->value, sizeof(retval->fullname));
|
|
|
|
|
|
|
|
} else if (!strcasecmp(tmp->name, "context")) {
|
|
|
|
|
|
|
|
ast_copy_string(retval->context, tmp->value, sizeof(retval->context));
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
apply_option(retval, tmp->name, tmp->value);
|
|
|
|
apply_option(retval, tmp->name, tmp->value);
|
|
|
|
tmp = tmp->next;
|
|
|
|
tmp = tmp->next;
|
|
|
@ -574,13 +576,14 @@ static struct ast_vm_user *find_user(struct ast_vm_user *ivm, const char *contex
|
|
|
|
ast_mutex_lock(&vmlock);
|
|
|
|
ast_mutex_lock(&vmlock);
|
|
|
|
cur = users;
|
|
|
|
cur = users;
|
|
|
|
|
|
|
|
|
|
|
|
if (!context)
|
|
|
|
if (!context && !ast_test_flag((&globalflags), VM_SEARCH))
|
|
|
|
context = "default";
|
|
|
|
context = "default";
|
|
|
|
|
|
|
|
|
|
|
|
while (cur) {
|
|
|
|
while (cur) {
|
|
|
|
if ((!strcasecmp(context, cur->context)) &&
|
|
|
|
if (ast_test_flag((&globalflags), VM_SEARCH) && !strcasecmp(mailbox, cur->mailbox))
|
|
|
|
(!strcasecmp(mailbox, cur->mailbox)))
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
if ((!strcasecmp(context, cur->context)) && (!strcasecmp(mailbox, cur->mailbox)))
|
|
|
|
|
|
|
|
break;
|
|
|
|
cur=cur->next;
|
|
|
|
cur=cur->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cur) {
|
|
|
|
if (cur) {
|
|
|
@ -660,91 +663,89 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while (!feof(configin)) {
|
|
|
|
while (!feof(configin)) {
|
|
|
|
|
|
|
|
char *user = NULL, *pass = NULL, *rest = NULL, *comment = NULL, *tmpctx = NULL, *tmpctxend = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* Read in the line */
|
|
|
|
/* Read in the line */
|
|
|
|
fgets(inbuf, sizeof(inbuf), configin);
|
|
|
|
fgets(inbuf, sizeof(inbuf), configin);
|
|
|
|
linenum++;
|
|
|
|
linenum++;
|
|
|
|
if (!feof(configin)) {
|
|
|
|
|
|
|
|
char *user = NULL, *pass = NULL, *rest = NULL,
|
|
|
|
|
|
|
|
*comment = NULL, *tmpctx = NULL, *tmpctxend = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ast_strlen_zero(inbuf)) {
|
|
|
|
if (ast_strlen_zero(inbuf)) {
|
|
|
|
fprintf(configout, "\n");
|
|
|
|
fprintf(configout, "\n");
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Make a backup of it */
|
|
|
|
/* Make a backup of it */
|
|
|
|
ast_copy_string(orig, inbuf, sizeof(orig));
|
|
|
|
ast_copy_string(orig, inbuf, sizeof(orig));
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
Read the file line by line, split each line into a comment and command section
|
|
|
|
Read the file line by line, split each line into a comment and command section
|
|
|
|
only parse the command portion of the line
|
|
|
|
only parse the command portion of the line
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (inbuf[strlen(inbuf) - 1] == '\n')
|
|
|
|
if (inbuf[strlen(inbuf) - 1] == '\n')
|
|
|
|
inbuf[strlen(inbuf) - 1] = '\0';
|
|
|
|
inbuf[strlen(inbuf) - 1] = '\0';
|
|
|
|
|
|
|
|
|
|
|
|
if ((comment = strchr(inbuf, ';')))
|
|
|
|
if ((comment = strchr(inbuf, ';')))
|
|
|
|
*comment++ = '\0'; /* Now inbuf is terminated just before the comment */
|
|
|
|
*comment++ = '\0'; /* Now inbuf is terminated just before the comment */
|
|
|
|
|
|
|
|
|
|
|
|
if (ast_strlen_zero(inbuf)) {
|
|
|
|
if (ast_strlen_zero(inbuf)) {
|
|
|
|
|
|
|
|
fprintf(configout, "%s", orig);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Check for a context, first '[' to first ']' */
|
|
|
|
|
|
|
|
if ((tmpctx = strchr(inbuf, '['))) {
|
|
|
|
|
|
|
|
tmpctxend = strchr(tmpctx, ']');
|
|
|
|
|
|
|
|
if (tmpctxend) {
|
|
|
|
|
|
|
|
/* Valid context */
|
|
|
|
|
|
|
|
ast_copy_string(currcontext, tmpctx + 1, tmpctxend - tmpctx);
|
|
|
|
fprintf(configout, "%s", orig);
|
|
|
|
fprintf(configout, "%s", orig);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Check for a context, first '[' to first ']' */
|
|
|
|
/* This isn't a context line, check for MBX => PSWD... */
|
|
|
|
if ((tmpctx = strchr(inbuf, '['))) {
|
|
|
|
user = inbuf;
|
|
|
|
tmpctxend = strchr(tmpctx, ']');
|
|
|
|
if ((pass = strchr(user, '='))) {
|
|
|
|
if (tmpctxend) {
|
|
|
|
/* We have a line in the form of aaaaa=aaaaaa */
|
|
|
|
/* Valid context */
|
|
|
|
*pass++ = '\0';
|
|
|
|
ast_copy_string(currcontext, tmpctx + 1, tmpctxend - tmpctx);
|
|
|
|
|
|
|
|
fprintf(configout, "%s", orig);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* This isn't a context line, check for MBX => PSWD... */
|
|
|
|
user = ast_strip(user);
|
|
|
|
user = inbuf;
|
|
|
|
|
|
|
|
if ((pass = strchr(user, '='))) {
|
|
|
|
|
|
|
|
/* We have a line in the form of aaaaa=aaaaaa */
|
|
|
|
|
|
|
|
*pass++ = '\0';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user = ast_strip(user);
|
|
|
|
if (*pass == '>')
|
|
|
|
|
|
|
|
*pass++ = '\0';
|
|
|
|
|
|
|
|
|
|
|
|
if (*pass == '>')
|
|
|
|
pass = ast_skip_blanks(pass);
|
|
|
|
*pass++ = '\0';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pass = ast_skip_blanks(pass);
|
|
|
|
/*
|
|
|
|
|
|
|
|
Since no whitespace allowed in fields, or more correctly white space
|
|
|
|
|
|
|
|
inside the fields is there for a purpose, we can just terminate pass
|
|
|
|
|
|
|
|
at the comma or EOL whichever comes first.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((rest = strchr(pass, ',')))
|
|
|
|
|
|
|
|
*rest++ = '\0';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
user = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/* Compare user, pass AND context */
|
|
|
|
Since no whitespace allowed in fields, or more correctly white space
|
|
|
|
if (!ast_strlen_zero(user) && !strcmp(user, vmu->mailbox) &&
|
|
|
|
inside the fields is there for a purpose, we can just terminate pass
|
|
|
|
!ast_strlen_zero(pass) && !strcmp(pass, vmu->password) &&
|
|
|
|
at the comma or EOL whichever comes first.
|
|
|
|
!strcasecmp(currcontext, vmu->context)) {
|
|
|
|
*/
|
|
|
|
/* This is the line */
|
|
|
|
if ((rest = strchr(pass, ',')))
|
|
|
|
if (rest) {
|
|
|
|
*rest++ = '\0';
|
|
|
|
fprintf(configout, "%s => %s,%s", user, newpassword, rest);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
user = NULL;
|
|
|
|
fprintf(configout, "%s => %s", user, newpassword);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If there was a comment on the line print it out */
|
|
|
|
/* Compare user, pass AND context */
|
|
|
|
if (comment) {
|
|
|
|
if (!ast_strlen_zero(user) && !strcmp(user, vmu->mailbox) &&
|
|
|
|
fprintf(configout, ";%s\n", comment);
|
|
|
|
!ast_strlen_zero(pass) && !strcmp(pass, vmu->password) &&
|
|
|
|
|
|
|
|
!strcasecmp(currcontext, vmu->context)) {
|
|
|
|
|
|
|
|
/* This is the line */
|
|
|
|
|
|
|
|
if (rest) {
|
|
|
|
|
|
|
|
fprintf(configout, "%s => %s,%s", user, newpassword, rest);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
fprintf(configout, "%s => %s", user, newpassword);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If there was a comment on the line print it out */
|
|
|
|
|
|
|
|
if (comment) {
|
|
|
|
|
|
|
|
fprintf(configout, ";%s\n", comment);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
fprintf(configout, "\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
/* Put it back like it was */
|
|
|
|
fprintf(configout, "\n");
|
|
|
|
fprintf(configout, "%s", orig);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* Put it back like it was */
|
|
|
|
|
|
|
|
fprintf(configout, "%s", orig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(configin);
|
|
|
|
fclose(configin);
|
|
|
@ -5812,6 +5813,7 @@ static int load_config(void)
|
|
|
|
struct ast_variable *var;
|
|
|
|
struct ast_variable *var;
|
|
|
|
char *notifystr = NULL;
|
|
|
|
char *notifystr = NULL;
|
|
|
|
char *astattach;
|
|
|
|
char *astattach;
|
|
|
|
|
|
|
|
char *astsearch;
|
|
|
|
char *astsaycid;
|
|
|
|
char *astsaycid;
|
|
|
|
char *send_voicemail;
|
|
|
|
char *send_voicemail;
|
|
|
|
char *astcallop;
|
|
|
|
char *astcallop;
|
|
|
@ -5865,6 +5867,10 @@ static int load_config(void)
|
|
|
|
astattach = "yes";
|
|
|
|
astattach = "yes";
|
|
|
|
ast_set2_flag((&globalflags), ast_true(astattach), VM_ATTACH);
|
|
|
|
ast_set2_flag((&globalflags), ast_true(astattach), VM_ATTACH);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!(astsearch = ast_variable_retrieve(cfg, "general", "searchcontexts")))
|
|
|
|
|
|
|
|
astsearch = "no";
|
|
|
|
|
|
|
|
ast_set2_flag((&globalflags), ast_true(astsearch), VM_SEARCH);
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef USE_ODBC_STORAGE
|
|
|
|
#ifdef USE_ODBC_STORAGE
|
|
|
|
strcpy(odbc_database, "asterisk");
|
|
|
|
strcpy(odbc_database, "asterisk");
|
|
|
|
if ((thresholdstr = ast_variable_retrieve(cfg, "general", "odbcstorage"))) {
|
|
|
|
if ((thresholdstr = ast_variable_retrieve(cfg, "general", "odbcstorage"))) {
|
|
|
|