From 26a89ab3dc8951fd82fc02eae35198cb581119ff Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 20 Oct 2008 22:52:09 +0000 Subject: [PATCH] all vm to auth from the same a1-hash param used by sip git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10086 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../mod_voicemail/mod_voicemail.c | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 16bfde5601..bfb93bf972 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -1583,7 +1583,7 @@ static void voicemail_check_main(switch_core_session_t *session, const char *pro switch_xml_t x_domain = NULL, x_domain_root = NULL, x_user = NULL, x_params, x_param; switch_status_t status; char pass_buf[80] = "", *mypass = NULL, id_buf[80] = "", *myfolder = NULL; - const char *thepass = NULL, *myid = id, *actual_id = NULL; + const char *thepass = NULL, *myid = id, *actual_id = NULL, *thehash = NULL; char term = 0; uint32_t timeout, attempts = 0; int failed = 0; @@ -1972,14 +1972,16 @@ static void voicemail_check_main(switch_core_session_t *session, const char *pro x_params = switch_xml_child(x_user, "params"); - thepass = NULL; + thepass = thehash = NULL; switch_snprintf(sql, sizeof(sql), "select * from voicemail_prefs where username='%s' and domain='%s'", myid, domain_name); vm_execute_sql_callback(profile, profile->mutex, sql, prefs_callback, &cbt); for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) { const char *var = switch_xml_attr_soft(x_param, "name"); const char *val = switch_xml_attr_soft(x_param, "value"); - if (!strcasecmp(var, "password")) { + if (!strcasecmp(var, "a1-hash")) { + thehash = val; + } else if (!strcasecmp(var, "password")) { thepass = val; } else if (!strcasecmp(var, "vm-password")) { thepass = val; @@ -1999,8 +2001,20 @@ static void voicemail_check_main(switch_core_session_t *session, const char *pro auth++; } - if (!auth && (thepass && mypass && !strcmp(thepass, mypass))) { - auth++; + if (!auth && (thepass || thehash) && mypass) { + if (thehash) { + unsigned char digest[SWITCH_MD5_DIGESTSIZE] = { 0 }; + char *lpbuf = switch_mprintf("%s:%s:%s", myid, domain_name, mypass); + switch_md5(digest, (void *) lpbuf, strlen(lpbuf)); + if (!strcmp(digest, thehash)) { + auth++; + } + switch_safe_free(lpbuf); + } + + if (!auth && thepass && !strcmp(thepass, mypass)) { + auth++; + } } }