[svn-commits] murf: branch group/newcdr r115936 - in /team/group/newcdr: ./ apps/ cdr/ cel/...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue May 13 14:28:13 CDT 2008


Author: murf
Date: Tue May 13 14:28:12 2008
New Revision: 115936

URL: http://svn.digium.com/view/asterisk?view=rev&rev=115936
Log:
Merged revisions 115546,115548,115552,115555,115558,115562,115566,115569,115580,115582,115584,115586,115588,115591,115593-115596,115598,115600,115669,115705,115737,115784,115813,115847,115850 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r115546 | russell | 2008-05-08 08:41:12 -0600 (Thu, 08 May 2008) | 12 lines

Merged revisions 115545 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r115545 | russell | 2008-05-08 09:40:53 -0500 (Thu, 08 May 2008) | 4 lines

Use the same method for executing Asterisk as the rest of the script.
(closes issue #12611)
Reported by: b_plessis

........

................
r115548 | mattf | 2008-05-08 09:04:45 -0600 (Thu, 08 May 2008) | 1 line

Remove unused code as well as demote an error message to a debug message
................
r115552 | russell | 2008-05-08 09:26:49 -0600 (Thu, 08 May 2008) | 12 lines

Merged revisions 115551 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r115551 | russell | 2008-05-08 10:24:54 -0500 (Thu, 08 May 2008) | 4 lines

Don't use a channel before checking for channel allocation failure.
(closes issue #12609)
Reported by: edantie

........

................
r115555 | russell | 2008-05-08 09:32:48 -0600 (Thu, 08 May 2008) | 11 lines

Merged revisions 115554 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r115554 | russell | 2008-05-08 10:32:08 -0500 (Thu, 08 May 2008) | 3 lines

Don't exit the script if Asterisk is not running.
(closes issue #12611)

........

................
r115558 | russell | 2008-05-08 09:38:27 -0600 (Thu, 08 May 2008) | 11 lines

Merged revisions 115557 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r115557 | russell | 2008-05-08 10:37:49 -0500 (Thu, 08 May 2008) | 3 lines

remove postgres_cdr.sql, as the CDR schema is in realtime_pgsql.sql, as well
(closes issue #9676)

........

................
r115562 | russell | 2008-05-08 10:14:08 -0600 (Thu, 08 May 2008) | 11 lines

Merged revisions 115561 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r115561 | russell | 2008-05-08 11:11:33 -0500 (Thu, 08 May 2008) | 3 lines

Don't give up on attempting an outbound registration if we receive a 408 Timeout.
(closes issue #12323)

........

................
r115566 | russell | 2008-05-08 13:17:04 -0600 (Thu, 08 May 2008) | 41 lines

Merged revisions 115565 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r115565 | russell | 2008-05-08 14:15:25 -0500 (Thu, 08 May 2008) | 33 lines

Merged revisions 115564 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r115564 | russell | 2008-05-08 14:14:04 -0500 (Thu, 08 May 2008) | 25 lines

Fix a race condition that bbryant just found while doing some IAX2 testing.
He was running Asterisk trunk running IAX2 calls through a few Asterisk boxes,
however, the audio was extremely choppy.  We looked at a packet trace and saw
a storm of INVAL and VNAK frames being sent from one box to another.

It turned out that what had happened was that one box tried to send a CONTROL
frame before the 3 way handshake had completed.  So, that frame did not include
the destination call number, because it didn't have it yet.  Part of our recent
work for security issues included an additional check to ensure that frames that
are supposed to include the destination call number have the correct one.  This
caused the frame to be rejected with an INVAL.  The frame would get retransmitted
for forever, rejected every time ...

This race condition exists in all versions that got the security changes,
in theory.  However, it is really only likely that this would cause a problem in
Asterisk trunk.  There was a control frame being sent (SRCUPDATE) at the _very_
beginning of the call, which does not exist in 1.2 or 1.4.  However, I am fixing
all versions that could potentially be affected by the introduced race condition.

These changes are what bbryant and I came up with to fix the issue.  Instead of
simply dropping control frames that get sent before the handshake is complete,
the code attempts to wait a little while, since in most cases, the handshake
will complete very quickly.  If it doesn't complete after yielding for a little
while, then the frame gets dropped.

........

................

................
r115569 | russell | 2008-05-08 13:20:35 -0600 (Thu, 08 May 2008) | 10 lines

Merged revisions 115568 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r115568 | russell | 2008-05-08 14:19:50 -0500 (Thu, 08 May 2008) | 2 lines

Remove debug output.

........

................
r115580 | file | 2008-05-09 10:36:58 -0600 (Fri, 09 May 2008) | 10 lines

Merged revisions 115579 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r115579 | file | 2008-05-09 13:34:08 -0300 (Fri, 09 May 2008) | 2 lines

Improve res_ninit and res_ndestroy autoconf logic on the Darwin platform.

........

................
r115582 | tilghman | 2008-05-09 11:28:06 -0600 (Fri, 09 May 2008) | 7 lines

Allow a password change to be validated by an external script.
(closes issue #12090)
 Reported by: jaroth
 Patches: 
       vm-check-newpassword.diff.txt uploaded by mvanbaak (license 7)
       20080509__bug12090.diff.txt uploaded by Corydon76 (license 14)

................
r115584 | bbryant | 2008-05-09 13:54:45 -0600 (Fri, 09 May 2008) | 15 lines

The following patch adds new options and alters the default behavior of the ENUM* functions. The TXCIDNAME lookup function has also gotten a 
new paramater. The new options for ENUM* functions include 'u', 's', 'i', and 'd' which return the full uri, trigger isn specific rewriting, look 
for branches into an infrastructure enum tree, or do a direct dns lookup of a number respectively. The new paramater for TXCIDNAME adds a 
zone-suffix argument for looking up caller id's in DNS that aren't e164.arpa.

This patch is based on the original code from otmar, modified by snuffy, and tested by jtodd, me, and others.

(closes issue #8089)
Reported by: otmar
Patches:
      20080508_bug8089-1.diff 
	- original code by otmar (license 480), 
	- revised by snuffy (license 35)
Tested by: oej, otmar, jtodd, Corydon76, snuffy, alexnikolov, bbryant

................
r115586 | bbryant | 2008-05-09 14:05:50 -0600 (Fri, 09 May 2008) | 2 lines

Update CHANGES file for previous commit of ENUM and TXCIDNAME changes.

................
r115588 | mmichelson | 2008-05-09 15:22:42 -0600 (Fri, 09 May 2008) | 19 lines

Adding support for "urgent" voicemail messages. Messages which are
marked "urgent" are considered to be higher priority than other messages
and so they will be played before any other messages in a user's mailbox.

There are two ways to leave an urgent message. 
1. send the 'U' option to VoiceMail().
2. Set review=yes in voicemail.conf. This will give instructions for 
   a caller to mark a message as urgent after the message has been recorded.

I have tested that this works correctly with file and ODBC storage, and James
Rothenberger (who wrote initial support for this feature) has tested its use
with IMAP storage.

(closes issue #11817)
Reported by: jaroth
	Based on branch http://svn.digium.com/svn/asterisk/team/jrothenberger/asterisk-urgent
Tested by: putnopvut, jaroth


................
r115591 | mmichelson | 2008-05-09 16:36:50 -0600 (Fri, 09 May 2008) | 3 lines

Remove a debug line


................
r115593 | junky | 2008-05-09 21:04:25 -0600 (Fri, 09 May 2008) | 2 lines

since we unregister, that has not been properly registered, i standardized this.

................
r115594 | junky | 2008-05-09 21:28:50 -0600 (Fri, 09 May 2008) | 3 lines

ameliorate load and unload to dont use DECLINED or FAILED, when theres no .conf involved.


................
r115595 | junky | 2008-05-09 21:30:59 -0600 (Fri, 09 May 2008) | 3 lines

fix a sample since we now required , and not | for the arguments separator


................
r115596 | tilghman | 2008-05-10 08:19:41 -0600 (Sat, 10 May 2008) | 2 lines

Ensure that "calldate" is acceptable for a column name.

................
r115598 | mattf | 2008-05-10 20:19:21 -0600 (Sat, 10 May 2008) | 1 line

Open up audio channel when we get ACM on SS7 event
................
r115600 | mattf | 2008-05-10 21:23:05 -0600 (Sat, 10 May 2008) | 1 line

Add Zap MTP2 support to chan_zap
................
r115669 | bbryant | 2008-05-12 09:17:32 -0600 (Mon, 12 May 2008) | 3 lines

A small change to fix iax2 native bridging.


................
r115705 | qwell | 2008-05-12 10:35:50 -0600 (Mon, 12 May 2008) | 1 line

Correctly document state interface for AddQueueMember.  Discovered while looking at issue #12626.
................
r115737 | mmichelson | 2008-05-12 11:55:08 -0600 (Mon, 12 May 2008) | 15 lines

Merged revisions 115735 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r115735 | mmichelson | 2008-05-12 12:51:14 -0500 (Mon, 12 May 2008) | 7 lines

If a thread holds no locks, do not print any information on the thread when issuing
a core show locks command. This will help to de-clutter output somewhat.

Russell said it would be fine to place this improvement in the 1.4 branch, so that's
why it's going here too.


........

................
r115784 | oej | 2008-05-12 12:39:09 -0600 (Mon, 12 May 2008) | 4 lines

Add support for playing an audio file for caller and callee at start and stop of monitoring (one-touch monitor).
Keep messages short, since the other party is waiting while one party hear the message...


................
r115813 | tilghman | 2008-05-12 14:34:38 -0600 (Mon, 12 May 2008) | 8 lines

Add a script which installs every package needed for a Debian install of
Asterisk, and includes possible support (to be contributed) for various other
distributions.
(closes issue #10523)
 Reported by: tzafrir
 Patches: 
       install_prereq_2 uploaded by tzafrir (license 46)

................
r115847 | russell | 2008-05-13 11:14:22 -0600 (Tue, 13 May 2008) | 2 lines

Initialize the start time in smdi_msg_wait.  Somehow this code got lost in trunk.

................
r115850 | russell | 2008-05-13 11:42:17 -0600 (Tue, 13 May 2008) | 2 lines

Re-introduce proper error handling that was removed in recent commits.

................

Added:
    team/group/newcdr/contrib/scripts/install_prereq
      - copied unchanged from r115850, trunk/contrib/scripts/install_prereq
Removed:
    team/group/newcdr/contrib/scripts/postgres_cdr.sql
Modified:
    team/group/newcdr/   (props changed)
    team/group/newcdr/CHANGES
    team/group/newcdr/UPGRADE.txt
    team/group/newcdr/apps/app_jack.c
    team/group/newcdr/apps/app_queue.c
    team/group/newcdr/apps/app_skel.c
    team/group/newcdr/apps/app_voicemail.c
    team/group/newcdr/cdr/cdr_pgsql.c
    team/group/newcdr/cel/cel_custom.c
    team/group/newcdr/channels/chan_iax2.c
    team/group/newcdr/channels/chan_sip.c
    team/group/newcdr/channels/chan_skinny.c
    team/group/newcdr/channels/chan_unistim.c
    team/group/newcdr/channels/chan_zap.c
    team/group/newcdr/configs/queues.conf.sample
    team/group/newcdr/configs/voicemail.conf.sample
    team/group/newcdr/configure
    team/group/newcdr/configure.ac
    team/group/newcdr/contrib/init.d/rc.debian.asterisk
    team/group/newcdr/doc/tex/channelvariables.tex
    team/group/newcdr/funcs/func_enum.c
    team/group/newcdr/funcs/func_speex.c
    team/group/newcdr/include/asterisk/app.h
    team/group/newcdr/include/asterisk/autoconfig.h.in
    team/group/newcdr/include/asterisk/enum.h
    team/group/newcdr/main/app.c
    team/group/newcdr/main/asterisk.c
    team/group/newcdr/main/cel.c
    team/group/newcdr/main/enum.c
    team/group/newcdr/main/features.c
    team/group/newcdr/main/manager.c
    team/group/newcdr/main/pbx.c
    team/group/newcdr/main/utils.c
    team/group/newcdr/res/res_smdi.c

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue May 13 14:28:12 2008
@@ -1,1 +1,1 @@
-/trunk:1-115539
+/trunk:1-115885

Modified: team/group/newcdr/CHANGES
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/CHANGES?view=diff&rev=115936&r1=115935&r2=115936
==============================================================================
--- team/group/newcdr/CHANGES (original)
+++ team/group/newcdr/CHANGES Tue May 13 14:28:12 2008
@@ -42,6 +42,11 @@
    quite helpful.
  * Voicemail now permits a mailbox setting to wrap around from first to last
    messages, if the "messagewrap" option is set to a true value.
+ * Voicemail now permits an external script to be run, for password validation.
+   The script should output "VALID" or "INVALID" on stdout, depending upon the
+   wish to validate or invalidate the password given.  Arguments are:
+   "mailbox" "context" "oldpass" "newpass".  See the sample voicemail.conf for
+   more details
  * Dial has a new option: F(context^extension^pri), which permits a callee to
    continue in the dialplan, at the specified label, if the caller hangs up.
  * ChanSpy and ExtenSpy have a new option, 's' which suppresses speaking the
@@ -96,6 +101,12 @@
 Dialplan function changes
 -------------------------
  * TIMEOUT() has been modified to be accurate down to the millisecond.
+ * ENUM*() functions now include the following new options:
+     - 'u' returns the full URI and does not strip off the URI-scheme.
+	 - 's' triggers ISN specific rewriting
+	 - 'i' looks for branches into an Infrastructure ENUM tree
+	 - 'd' for a direct DNS lookup without any flipping of digits.
+ * TXCIDNAME() has a new zone-suffix parameter (which defaults to 'e164.arpa')
 
 AMI - The manager (TCP/TLS/HTTP)
 --------------------------------
@@ -406,6 +417,12 @@
      voicemail boxes.  The SMDI interface can also poll for MWI changes when some
      outside entity is modifying the state of the mailbox (such as IMAP storage or
      a web interface of some kind).
+  * Added the support for marking messages as "urgent." There are two methods to accomplish
+     this. One is to pass the 'U' option to VoiceMail(). Another way to mark a message as urgent
+	 is to specify "review=yes" in voicemail.conf. Doing this will cause allow the user to mark
+	 the message as urgent after he has recorded a voicemail by following the voice instructions.
+	When listening to voicemails using VoiceMailMain urgent messages will be presented before other
+	 messages
 
 Queue changes
 -------------

Modified: team/group/newcdr/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/UPGRADE.txt?view=diff&rev=115936&r1=115935&r2=115936
==============================================================================
--- team/group/newcdr/UPGRADE.txt (original)
+++ team/group/newcdr/UPGRADE.txt Tue May 13 14:28:12 2008
@@ -74,6 +74,8 @@
   checking mailboxes for changes so that they can send MWI information to users.
   Examples of situations that would require this option are web interfaces to
   voicemail or an email client in the case of using IMAP storage.
+* The externnotify script should accept an additional (last) parameter
+  containing the string "URGENT" if there are new urgent messages in the INBOX.
 
 Applications:
 

Modified: team/group/newcdr/apps/app_jack.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/apps/app_jack.c?view=diff&rev=115936&r1=115935&r2=115936
==============================================================================
--- team/group/newcdr/apps/app_jack.c (original)
+++ team/group/newcdr/apps/app_jack.c Tue May 13 14:28:12 2008
@@ -977,8 +977,9 @@
 
 static int load_module(void)
 {
-	if (ast_register_application(jack_app, jack_exec, jack_synopsis, jack_desc))
+	if (ast_register_application(jack_app, jack_exec, jack_synopsis, jack_desc)) {
 		return AST_MODULE_LOAD_DECLINE;
+	}
 
 	if (ast_custom_function_register(&jack_hook_function)) {
 		ast_unregister_application(jack_app);

Modified: team/group/newcdr/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/apps/app_queue.c?view=diff&rev=115936&r1=115935&r2=115936
==============================================================================
--- team/group/newcdr/apps/app_queue.c (original)
+++ team/group/newcdr/apps/app_queue.c Tue May 13 14:28:12 2008
@@ -199,7 +199,7 @@
 static char *app_aqm = "AddQueueMember" ;
 static char *app_aqm_synopsis = "Dynamically adds queue members" ;
 static char *app_aqm_descrip =
-"   AddQueueMember(queuename[,interface[,penalty[,options[,membername]]]]):\n"
+"   AddQueueMember(queuename[,interface[,penalty[,options[,membername[,stateinterface]]]]]):\n"
 "Dynamically adds interface to an existing queue.\n"
 "If the interface is already in the queue it will return an error.\n"
 "  This application sets the following channel variable upon completion:\n"
@@ -4239,7 +4239,7 @@
 	int penalty = 0;
 
 	if (ast_strlen_zero(data)) {
-		ast_log(LOG_WARNING, "AddQueueMember requires an argument (queuename[,[interface],[penalty][,options][,membername]])\n");
+		ast_log(LOG_WARNING, "AddQueueMember requires an argument (queuename[,interface[,penalty[,options[,membername[,stateinterface]]]]])\n");
 		return -1;
 	}
 

Modified: team/group/newcdr/apps/app_skel.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/apps/app_skel.c?view=diff&rev=115936&r1=115935&r2=115936
==============================================================================
--- team/group/newcdr/apps/app_skel.c (original)
+++ team/group/newcdr/apps/app_skel.c Tue May 13 14:28:12 2008
@@ -109,17 +109,13 @@
 
 static int unload_module(void)
 {
-	int res;
-	res = ast_unregister_application(app);
-	return res;	
+	return ast_unregister_application(app);
 }
 
 static int load_module(void)
 {
-	if (ast_register_application(app, app_exec, synopsis, descrip))
-		return AST_MODULE_LOAD_DECLINE;
-
-	return AST_MODULE_LOAD_SUCCESS;
+	return ast_register_application(app, app_exec, synopsis, descrip) ? 
+		AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Skeleton (sample) Application");

Modified: team/group/newcdr/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/apps/app_voicemail.c?view=diff&rev=115936&r1=115935&r2=115936
==============================================================================
--- team/group/newcdr/apps/app_voicemail.c (original)
+++ team/group/newcdr/apps/app_voicemail.c Tue May 13 14:28:12 2008
@@ -155,11 +155,11 @@
 static void get_mailbox_delimiter(MAILSTREAM *stream);
 static void mm_parsequota (MAILSTREAM *stream, unsigned char *msg, QUOTALIST *pquota);
 static void imap_mailbox_name(char *spec, size_t len, struct vm_state *vms, int box, int target);
-static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, int msgnum, struct ast_channel *chan, struct ast_vm_user *vmu, char *fmt, int duration, struct vm_state *vms, char *introfile);
+static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, int msgnum, struct ast_channel *chan, struct ast_vm_user *vmu, char *fmt, int duration, struct vm_state *vms, char *introfile, const char *flag);
 static void update_messages_by_imapuser(const char *user, unsigned long number);
 
 static int imap_remove_file (char *dir, int msgnum);
-static int imap_retrieve_file (char *dir, int msgnum, const char *mailbox, char *context);
+static int imap_retrieve_file (char *dir, int msgnum, const char *mailbox, const char *context);
 static int imap_delete_old_greeting (char *dir, struct vm_state *vms);
 static void check_quota(struct vm_state *vms, char *mailbox);
 static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu, int box);
@@ -201,6 +201,8 @@
 
 #define MAXMSG 100
 #define MAXMSGLIMIT 9999
+
+#define MINPASSWORD 0 /*!< Default minimum mailbox password length */
 
 #define BASELINELEN 72
 #define BASEMAXINLINE 256
@@ -228,7 +230,6 @@
 #define VM_MOVEHEARD     (1 << 16)  /*!< Move a "heard" message to Old after listening to it */
 #define VM_MESSAGEWRAP   (1 << 17)  /*!< Wrap around from the last message to the first, and vice-versa */
 #define ERROR_LOCK_PATH  -100
-#define ERROR_MAILBOX_FULL	-200
 
 
 enum {
@@ -248,6 +249,8 @@
 	OPT_PREPEND_MAILBOX =  (1 << 4),
 	OPT_AUTOPLAY =         (1 << 6),
 	OPT_DTMFEXIT =         (1 << 7),
+	OPT_MESSAGE_Urgent =   (1 << 8),
+	OPT_MESSAGE_PRIORITY = (1 << 9)
 } vm_option_flags;
 
 enum {
@@ -266,6 +269,8 @@
 	AST_APP_OPTION_ARG('d', OPT_DTMFEXIT, OPT_ARG_DTMFEXIT),
 	AST_APP_OPTION('p', OPT_PREPEND_MAILBOX),
 	AST_APP_OPTION_ARG('a', OPT_AUTOPLAY, OPT_ARG_PLAYFOLDER),
+	AST_APP_OPTION('U', OPT_MESSAGE_Urgent),
+	AST_APP_OPTION('P', OPT_MESSAGE_PRIORITY)
 });
 
 static int load_config(int reload);
@@ -422,6 +427,7 @@
 	int lastmsg;
 	int newmessages;
 	int oldmessages;
+	int urgentmessages;
 	int starting;
 	int repeats;
 #ifdef IMAP_STORAGE
@@ -443,7 +449,7 @@
 static char odbc_table[80];
 #define RETRIEVE(a,b,c,d) retrieve_file(a,b)
 #define DISPOSE(a,b) remove_file(a,b)
-#define STORE(a,b,c,d,e,f,g,h,i,j) store_file(a,b,c,d)
+#define STORE(a,b,c,d,e,f,g,h,i,j,k) store_file(a,b,c,d)
 #define EXISTS(a,b,c,d) (message_exists(a,b))
 #define RENAME(a,b,c,d,e,f,g,h) (rename_file(a,b,c,d,e,f))
 #define COPY(a,b,c,d,e,f,g,h) (copy_file(a,b,c,d,e,f))
@@ -452,8 +458,8 @@
 #ifdef IMAP_STORAGE
 #define RETRIEVE(a,b,c,d) (imap_retrieve_file(a,b,c,d ))
 #define DISPOSE(a,b) (imap_remove_file(a,b))
-#define STORE(a,b,c,d,e,f,g,h,i,j) (imap_store_file(a,b,c,d,e,f,g,h,i,j))
-#define EXISTS(a,b,c,d) (ast_fileexists(c, NULL, d) > 0)
+#define STORE(a,b,c,d,e,f,g,h,i,j,k) (imap_store_file(a,b,c,d,e,f,g,h,i,j,k))
+#define EXISTS(a,b,c,d) (ast_fileexists(c,NULL,d) > 0)
 #define RENAME(a,b,c,d,e,f,g,h) (rename_file(g,h));
 #define COPY(a,b,c,d,e,f,g,h) (copy_file(g,h));
 #define IMAP_DELETE(a,b,c,d) (vm_imap_delete(b,d))
@@ -461,10 +467,10 @@
 #else
 #define RETRIEVE(a,b,c,d)
 #define DISPOSE(a,b)
-#define STORE(a,b,c,d,e,f,g,h,i,j)
-#define EXISTS(a,b,c,d) (ast_fileexists(c, NULL, d) > 0)
+#define STORE(a,b,c,d,e,f,g,h,i,j,k)
+#define EXISTS(a,b,c,d) (ast_fileexists(c,NULL,d) > 0)
 #define RENAME(a,b,c,d,e,f,g,h) (rename_file(g,h));
-#define COPY(a,b,c,d,e,f,g,h) (copy_plain_file(g,h));
+#define COPY(a,b,c,d,e,f,g,h) (copy_plain_file(g,h)); 
 #define DELETE(a,b,c) (vm_delete(c))
 #endif
 #endif
@@ -472,6 +478,7 @@
 static char VM_SPOOL_DIR[PATH_MAX];
 
 static char ext_pass_cmd[128];
+static char ext_pass_check_cmd[128];
 
 int my_umask;
 
@@ -510,14 +517,16 @@
 	"               application. The possible values are:\n"
 	"               SUCCESS | USEREXIT | FAILED\n\n"
 	"  Options:\n"
-	"    b      - Play the 'busy' greeting to the calling party.\n"
+	"    b    - Play the 'busy' greeting to the calling party.\n"
 	"    d([c]) - Accept digits for a new extension in context c, if played during\n"
 	"             the greeting.  Context defaults to the current context.\n"
-	"    g(#)   - Use the specified amount of gain when recording the voicemail\n"
-	"             message. The units are whole-number decibels (dB).\n"
-	"    s      - Skip the playback of instructions for leaving a message to the\n"
-	"             calling party.\n"
-	"    u      - Play the 'unavailable' greeting.\n";
+	"    g(#) - Use the specified amount of gain when recording the voicemail\n"
+	"           message. The units are whole-number decibels (dB).\n"
+	"    s    - Skip the playback of instructions for leaving a message to the\n"
+	"           calling party.\n"
+	"    u    - Play the 'unavailable' greeting.\n"
+	"    U    - Mark message as Urgent.\n"
+	"    P    - Mark message as PRIORITY.\n";
 
 static char *synopsis_vmain = "Check Voicemail messages";
 
@@ -587,6 +596,7 @@
 static int maxgreet;
 static int skipms;
 static int maxlogins;
+static int minpassword;
 
 /*! Poll mailboxes for changes since there is something external to
  *  app_voicemail that may change them. */
@@ -616,6 +626,7 @@
  */
 struct mwi_sub {
 	AST_RWLIST_ENTRY(mwi_sub) entry;
+	int old_urgent;
 	int old_new;
 	int old_old;
 	uint32_t uniqueid;
@@ -645,6 +656,7 @@
 static char vm_passchanged[80] = "vm-passchanged";
 static char vm_reenterpassword[80] = "vm-reenterpassword";
 static char vm_mismatch[80] = "vm-mismatch";
+static char vm_invalid_password[80] = "vm-invalid-password";
 
 static struct ast_flags globalflags = {0};
 
@@ -676,11 +688,11 @@
 static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context);
 static int play_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime,
 			char *fmt, int outsidecaller, struct ast_vm_user *vmu, int *duration, const char *unlockdir,
-			signed char record_gain, struct vm_state *vms);
+			signed char record_gain, struct vm_state *vms, char *flag);
 static int vm_tempgreeting(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain);
 static int vm_play_folder_name(struct ast_channel *chan, char *mbox);
-static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msgnum, long duration, char *fmt, char *cidnum, char *cidname);
-static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, char *attach, char *attach2, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category, int imap);
+static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msgnum, long duration, char *fmt, char *cidnum, char *cidname, const char *flag);
+static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, char *attach, char *attach2, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category, int imap, const char *flag);
 static void apply_options(struct ast_vm_user *vmu, const char *options);
 static int add_email_attachment(FILE *p, struct ast_vm_user *vmu, char *format, char *attach, char *greeting_attachment, char *mailbox, char *bound, char *filename, int last, int msgnum);
 static int is_valid_dtmf(const char *key);
@@ -748,33 +760,33 @@
 #endif
 	} else if (!strcasecmp(var, "delete") || !strcasecmp(var, "deletevoicemail")) {
 		ast_set2_flag(vmu, ast_true(value), VM_DELETE);	
-	} else if (!strcasecmp(var, "saycid")) {
+	} else if (!strcasecmp(var, "saycid")){
 		ast_set2_flag(vmu, ast_true(value), VM_SAYCID);	
-	} else if (!strcasecmp(var, "sendvoicemail")) {
+	} else if (!strcasecmp(var,"sendvoicemail")){
 		ast_set2_flag(vmu, ast_true(value), VM_SVMAIL);	
-	} else if (!strcasecmp(var, "review")) {
+	} else if (!strcasecmp(var, "review")){
 		ast_set2_flag(vmu, ast_true(value), VM_REVIEW);
-	} else if (!strcasecmp(var, "tempgreetwarn")) {
+	} else if (!strcasecmp(var, "tempgreetwarn")){
 		ast_set2_flag(vmu, ast_true(value), VM_TEMPGREETWARN);	
 	} else if (!strcasecmp(var, "messagewrap")){
 		ast_set2_flag(vmu, ast_true(value), VM_MESSAGEWRAP);	
 	} else if (!strcasecmp(var, "operator")) {
 		ast_set2_flag(vmu, ast_true(value), VM_OPERATOR);	
-	} else if (!strcasecmp(var, "envelope")) {
+	} else if (!strcasecmp(var, "envelope")){
 		ast_set2_flag(vmu, ast_true(value), VM_ENVELOPE);	
-	} else if (!strcasecmp(var, "moveheard")) {
+	} else if (!strcasecmp(var, "moveheard")){
 		ast_set2_flag(vmu, ast_true(value), VM_MOVEHEARD);
-	} else if (!strcasecmp(var, "sayduration")) {
+	} else if (!strcasecmp(var, "sayduration")){
 		ast_set2_flag(vmu, ast_true(value), VM_SAYDURATION);	
-	} else if (!strcasecmp(var, "saydurationm")) {
+	} else if (!strcasecmp(var, "saydurationm")){
 		if (sscanf(value, "%d", &x) == 1) {
 			vmu->saydurationm = x;
 		} else {
 			ast_log(AST_LOG_WARNING, "Invalid min duration for say duration\n");
 		}
-	} else if (!strcasecmp(var, "forcename")) {
+	} else if (!strcasecmp(var, "forcename")){
 		ast_set2_flag(vmu, ast_true(value), VM_FORCENAME);	
-	} else if (!strcasecmp(var, "forcegreetings")) {
+	} else if (!strcasecmp(var, "forcegreetings")){
 		ast_set2_flag(vmu, ast_true(value), VM_FORCEGREET);	
 	} else if (!strcasecmp(var, "callback")) {
 		ast_copy_string(vmu->callback, value, sizeof(vmu->callback));
@@ -820,6 +832,85 @@
 	} else if (!strcasecmp(var, "options")) {
 		apply_options(vmu, value);
 	}
+}
+
+static char *vm_check_password_shell(char *command, char *buf, size_t len) 
+{
+	int fds[2], pid = 0;
+
+	memset(buf, 0, len);
+
+	if (pipe(fds)) {
+		snprintf(buf, len, "FAILURE: Pipe failed: %s", strerror(errno));
+	} else {
+		/* good to go*/
+		pid = ast_safe_fork(0);
+
+		if (pid < 0) {
+			/* ok maybe not */
+			close(fds[0]);
+			close(fds[1]);
+			snprintf(buf, len, "FAILURE: Fork failed");
+		} else if (pid) {
+			/* parent */
+			close(fds[1]);
+			read(fds[0], buf, len);
+			close(fds[0]);
+		} else {
+			/*  child */
+			AST_DECLARE_APP_ARGS(arg,
+				AST_APP_ARG(v)[20];
+			);
+			char *mycmd = ast_strdupa(command);
+
+			close(fds[0]);
+			dup2(fds[1], STDOUT_FILENO);
+			close(fds[1]);
+			ast_close_fds_above_n(STDOUT_FILENO);
+
+			AST_NONSTANDARD_APP_ARGS(arg, mycmd, ' ');
+
+			execv(arg.v[0], arg.v); 
+			printf("FAILURE: %s", strerror(errno));
+			_exit(0);
+		}
+	}
+	return buf;
+}
+
+/*!
+ * \brief Check that password meets minimum required length
+ * \param vmu The voicemail user to change the password for.
+ * \param password The password string to check
+ *
+ * \return zero on ok, 1 on not ok.
+ */
+static int check_password(struct ast_vm_user *vmu, char *password)
+{
+	/* check minimum length */
+	if (strlen(password) < minpassword)
+		return 1;
+	if (!ast_strlen_zero(ext_pass_check_cmd)) {
+		char cmd[255], buf[255];
+
+		ast_log(LOG_DEBUG, "Verify password policies for %s\n", password);
+
+		snprintf(cmd, sizeof(cmd), "%s %s %s %s %s", ext_pass_check_cmd, vmu->mailbox, vmu->context, vmu->password, password);
+		if (vm_check_password_shell(cmd, buf, sizeof(buf))) {
+			ast_debug(5, "Result: %s\n", buf);
+			if (!strncasecmp(buf, "VALID", 5)) {
+				ast_debug(3, "Passed password check: '%s'\n", buf);
+				return 0;
+			} else if (!strncasecmp(buf, "FAILURE", 7)) {
+				ast_log(LOG_WARNING, "Unable to execute password validation script: '%s'.\n", buf);
+				return 0;
+			} else {
+				ast_log(LOG_NOTICE, "Password doesn't match policies for user %s %s\n", vmu->mailbox, password);
+				return 1;
+			}
+		}
+	}
+	return 0;
 }
 
 /*! 
@@ -974,7 +1065,7 @@
 static struct ast_vm_user *find_user(struct ast_vm_user *ivm, const char *context, const char *mailbox)
 {
 	/* This function could be made to generate one from a database, too */
-	struct ast_vm_user *vmu = NULL, *cur;
+	struct ast_vm_user *vmu=NULL, *cur;
 	AST_LIST_LOCK(&users);
 
 	if (!context && !ast_test_flag((&globalflags), VM_SEARCH))
@@ -1037,11 +1128,11 @@
  */
 static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword)
 {
-	struct ast_config *cfg = NULL;
-	struct ast_variable *var = NULL;
-	struct ast_category *cat = NULL;
-	char *category = NULL, *value = NULL, *new = NULL;
-	const char *tmp = NULL;
+	struct ast_config   *cfg=NULL;
+	struct ast_variable *var=NULL;
+	struct ast_category *cat=NULL;
+	char *category=NULL, *value=NULL, *new=NULL;
+	const char *tmp=NULL;
 	struct ast_flags config_flags = { CONFIG_FLAG_WITHCOMMENTS };
 	if (!change_password_realtime(vmu, newpassword))
 		return;
@@ -1054,13 +1145,13 @@
 					ast_log(AST_LOG_WARNING, "We could not find the mailbox.\n");
 					break;
 				}
-				value = strstr(tmp, ",");
+				value = strstr(tmp,",");
 				if (!value) {
 					ast_log(AST_LOG_WARNING, "variable has bad format.\n");
 					break;
 				}
-				new = alloca(strlen(value) + strlen(newpassword) + 1);
-				sprintf(new, "%s%s", newpassword, value);
+				new = alloca((strlen(value)+strlen(newpassword)+1));
+				sprintf(new,"%s%s", newpassword, value);
 				if (!(cat = ast_category_get(cfg, category))) {
 					ast_log(AST_LOG_WARNING, "Failed to get category structure.\n");
 					break;
@@ -1086,7 +1177,7 @@
 					ast_debug(3, "looks like we need to make vmsecret!\n");
 					var = ast_variable_new("vmsecret", newpassword, "");
 				} 
-				new = alloca(strlen(newpassword) + 1);
+				new = alloca(strlen(newpassword)+1);
 				sprintf(new, "%s", newpassword);
 				if (!(cat = ast_category_get(cfg, category))) {
 					ast_debug(4, "failed to get category!\n");
@@ -1108,7 +1199,7 @@
 static void vm_change_password_shell(struct ast_vm_user *vmu, char *newpassword)
 {
 	char buf[255];
-	snprintf(buf, sizeof(buf), "%s %s %s %s", ext_pass_cmd, vmu->context, vmu->mailbox, newpassword);
+	snprintf(buf,255,"%s %s %s %s",ext_pass_cmd,vmu->context,vmu->mailbox,newpassword);
 	if (!ast_safe_system(buf)) {
 		ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
 		/* Reset the password in memory, too */
@@ -1155,10 +1246,10 @@
 		ast_log(AST_LOG_WARNING, "msgnum %d, mailbox message %lu is zero.\n", msgnum, messageNum);
 		return;
 	}
-	ast_debug(3, "deleting msgnum %d, which is mailbox message %lu\n", msgnum, messageNum);
+	ast_debug(3, "deleting msgnum %d, which is mailbox message %lu\n",msgnum,messageNum);
 	/* delete message */
-	snprintf(arg, sizeof(arg), "%lu", messageNum);
-	mail_setflag(vms->mailstream, arg, "\\DELETED");
+	snprintf (arg, sizeof(arg), "%lu",messageNum);
+	mail_setflag (vms->mailstream,arg,"\\DELETED");
 }
 
 #endif
@@ -1251,13 +1342,13 @@
 {
 	int x = 0;
 	int res;
-	int fd = -1;
+	int fd=-1;
 	size_t fdlen = 0;
 	void *fdm = MAP_FAILED;
-	SQLSMALLINT colcount = 0;
+	SQLSMALLINT colcount=0;
 	SQLHSTMT stmt;
 	char sql[PATH_MAX];
-	char fmt[80] = "";
+	char fmt[80]="";
 	char *c;
 	char coltitle[256];
 	SQLSMALLINT collen;
@@ -1266,7 +1357,7 @@
 	SQLSMALLINT nullable;
 	SQLULEN colsize;
 	SQLLEN colsize2;
-	FILE *f = NULL;
+	FILE *f=NULL;
 	char rowdata[80];
 	char fn[PATH_MAX];
 	char full_fn[PATH_MAX];
@@ -1283,8 +1374,7 @@
 			*c = '\0';
 		if (!strcasecmp(fmt, "wav49"))
 			strcpy(fmt, "WAV");
-
-		snprintf(msgnums, sizeof(msgnums), "%d", msgnum);
+		snprintf(msgnums, sizeof(msgnums),"%d", msgnum);
 		if (msgnum > -1)
 			make_file(fn, sizeof(fn), dir, msgnum);
 		else
@@ -1299,7 +1389,7 @@
 		}
 		
 		snprintf(full_fn, sizeof(full_fn), "%s.%s", fn, fmt);
-		snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE dir=? AND msgnum=?", odbc_table);
+		snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE dir=? AND msgnum=?",odbc_table);
 		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
 		if (!stmt) {
 			ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
@@ -1333,7 +1423,7 @@
 		}
 		if (f) 
 			fprintf(f, "[message]\n");
-		for (x = 0; x < colcount; x++) {
+		for (x=0;x<colcount;x++) {
 			rowdata[0] = '\0';
 			collen = sizeof(coltitle);
 			res = SQLDescribeCol(stmt, x + 1, (unsigned char *)coltitle, sizeof(coltitle), &collen, 
@@ -1349,7 +1439,7 @@
 				res = SQLGetData(stmt, x + 1, SQL_BINARY, rowdata, 0, &colsize2);
 				fdlen = colsize2;
 				if (fd > -1) {
-					char tmp[1] = "";
+					char tmp[1]="";
 					lseek(fd, fdlen - 1, SEEK_SET);
 					if (write(fd, tmp, 1) != 1) {
 						close(fd);
@@ -1380,7 +1470,7 @@
 			} else {
 				res = SQLGetData(stmt, x + 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);
 				if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
-					ast_log(AST_LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
+					ast_log(AST_LOG_WARNING, "SQL Get Data error! coltitle=%s\n[%s]\n\n", coltitle, sql);
 					SQLFreeHandle (SQL_HANDLE_STMT, stmt);
 					ast_odbc_release_obj(obj);
 					goto yuck;
@@ -1455,7 +1545,7 @@
 	struct odbc_obj *obj;
 	obj = ast_odbc_request_obj(odbc_database, 0);
 	if (obj) {
-		snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir=?", odbc_table);
+		snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir=?",odbc_table);
 		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
 		if (!stmt) {
 			ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
@@ -1510,7 +1600,7 @@
 	obj = ast_odbc_request_obj(odbc_database, 0);
 	if (obj) {
 		snprintf(msgnums, sizeof(msgnums), "%d", msgnum);
-		snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir=? AND msgnum=?", odbc_table);
+		snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir=? AND msgnum=?",odbc_table);
 		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
 		if (!stmt) {
 			ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
@@ -1580,7 +1670,7 @@
 	obj = ast_odbc_request_obj(odbc_database, 0);
 	if (obj) {
 		snprintf(msgnums, sizeof(msgnums), "%d", smsg);
-		snprintf(sql, sizeof(sql), "DELETE FROM %s WHERE dir=? AND msgnum=?", odbc_table);
+		snprintf(sql, sizeof(sql), "DELETE FROM %s WHERE dir=? AND msgnum=?",odbc_table);
 		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
 		if (!stmt)
 			ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
@@ -1618,7 +1708,7 @@
 	if (obj) {
 		snprintf(msgnums, sizeof(msgnums), "%d", smsg);
 		snprintf(msgnumd, sizeof(msgnumd), "%d", dmsg);
-		snprintf(sql, sizeof(sql), "INSERT INTO %s (dir, msgnum, context, macrocontext, callerid, origtime, duration, recording, mailboxuser, mailboxcontext) SELECT ?,?,context,macrocontext,callerid,origtime,duration,recording,?,? FROM %s WHERE dir=? AND msgnum=?", odbc_table, odbc_table);
+		snprintf(sql, sizeof(sql), "INSERT INTO %s (dir, msgnum, context, macrocontext, callerid, origtime, duration, recording, mailboxuser, mailboxcontext, flag) SELECT ?,?,context,macrocontext,callerid,origtime,duration,recording,flag,?,? FROM %s WHERE dir=? AND msgnum=?",odbc_table,odbc_table);
 		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
 		if (!stmt)
 			ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s] (You probably don't have MySQL 4.1 or later installed)\n\n", sql);
@@ -1644,6 +1734,7 @@
 	char *mailboxuser;
 	char *mailboxcontext;
 	const char *category;
+	const char *flag;
 };
 
 static SQLHSTMT insert_data_cb(struct odbc_obj *obj, void *vdata)
@@ -1670,8 +1761,9 @@
 	SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->duration), 0, (void *)data->duration, 0, NULL);
 	SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxuser), 0, (void *)data->mailboxuser, 0, NULL);
 	SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxcontext), 0, (void *)data->mailboxcontext, 0, NULL);
+	SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->flag), 0, (void *)data->flag, 0, NULL);
 	if (!ast_strlen_zero(data->category)) {
-		SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->category), 0, (void *)data->category, 0, NULL);
+		SQLBindParameter(stmt, 12, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->category), 0, (void *)data->category, 0, NULL);
 	}
 	res = SQLExecDirect(stmt, (unsigned char *)data->sql, SQL_NTS);
 	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
@@ -1707,9 +1799,9 @@
 	char msgnums[20];
 	char fn[PATH_MAX];
 	char full_fn[PATH_MAX];
-	char fmt[80] = "";
+	char fmt[80]="";
 	char *c;
-	struct ast_config *cfg = NULL;
+	struct ast_config *cfg=NULL;
 	struct odbc_obj *obj;
 	struct insert_data idata = { .sql = sql, .msgnums = msgnums, .dir = dir, .mailboxuser = mailboxuser, .mailboxcontext = mailboxcontext };

[... 6818 lines stripped ...]



More information about the svn-commits mailing list