[freeside-commits] branch master updated. 0c04fc78f66d17a5736686757cd8f838715c8380

Ivan ivan at 420.am
Sat Nov 9 12:03:56 PST 2013


The branch, master has been updated
       via  0c04fc78f66d17a5736686757cd8f838715c8380 (commit)
       via  9545a93c2cb4ee76c4226e0eacf9a6fb9c169adf (commit)
      from  b668e94b7ed814217c9e4a9cfec6ed4df98e023a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0c04fc78f66d17a5736686757cd8f838715c8380
Merge: 9545a93 b668e94
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat Nov 9 12:03:52 2013 -0800

    Merge branch 'master' of git.freeside.biz:/home/git/freeside


commit 9545a93c2cb4ee76c4226e0eacf9a6fb9c169adf
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat Nov 9 12:03:47 2013 -0800

    add sip_passwordmin/max, RT#25239

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index eed84fc..81669dc 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1724,6 +1724,21 @@ and customer address. Include units.',
   },
 
   {
+    'key'         => 'sip_passwordmin',
+    'section'     => 'telephony',
+    'description' => 'Minimum SIP password length (default 6)',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'sip_passwordmax',
+    'section'     => 'telephony',
+    'description' => 'Maximum SIP password length (default 8) (don\'t set this over 12 if you need to import or export crypt() passwords)',
+    'type'        => 'text',
+  },
+
+
+  {
     'key'         => 'password-noampersand',
     'section'     => 'password',
     'description' => 'Disallow ampersands in passwords',
diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm
index 77b0137..72c609c 100644
--- a/FS/FS/svc_phone.pm
+++ b/FS/FS/svc_phone.pm
@@ -2,9 +2,12 @@ package FS::svc_phone;
 
 use strict;
 use base qw( FS::svc_Domain_Mixin FS::location_Mixin FS::svc_Common );
-use vars qw( $DEBUG $me @pw_set $conf $phone_name_max );
+use vars qw( $DEBUG $me @pw_set $conf $phone_name_max
+             $passwordmin $passwordmax
+           );
 use Data::Dumper;
 use Scalar::Util qw( blessed );
+use List::Util qw( min );
 use FS::Conf;
 use FS::Record qw( qsearch qsearchs dbh );
 use FS::PagedSearch qw( psearch );
@@ -26,6 +29,8 @@ $DEBUG = 0;
 FS::UID->install_callback( sub { 
   $conf = new FS::Conf;
   $phone_name_max = $conf->config('svc_phone-phone_name-max_length');
+  $passwordmin = $conf->config('sip_passwordmin') || 0;
+  $passwordmax = $conf->config('sip_passwordmax') || 80;
 }
 );
 
@@ -534,10 +539,17 @@ sub check {
     }
   }
 
-  unless ( length($self->sip_password) ) { # option for this?
+  if ( length($self->sip_password) ) {
+
+    return "SIP password must be longer than $passwordmin characters"
+      if length($self->sip_password) < $passwordmin;
+    return "SIP password must be shorter than $passwordmax characters"
+      if length($self->sip_password) > $passwordmax;
+
+  } else { # option for this?
 
     $self->sip_password(
-      join('', map $pw_set[ int(rand $#pw_set) ], (0..16) )
+      join('', map $pw_set[ int(rand $#pw_set) ], (1..min($passwordmax,16)) )
     );
 
   }

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm      |   15 +++++++++++++++
 FS/FS/svc_phone.pm |   18 +++++++++++++++---
 2 files changed, 30 insertions(+), 3 deletions(-)




More information about the freeside-commits mailing list