summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-03-03 14:42:40 -0800
committerMark Wells <mark@freeside.biz>2012-03-03 14:42:40 -0800
commit55a734433fe1625cecca50f85c6da3cecf7c8618 (patch)
tree656fd3e6cd6fff8996e96c5872d4714eac6aa363 /FS
parent712864e9372891cc3773d01e546103c23c10ff03 (diff)
option to validate MAC address in svc_hardware, #16266
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Conf.pm7
-rw-r--r--FS/FS/svc_hardware.pm8
2 files changed, 14 insertions, 1 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 4b2bc3062..ac80a55bd 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -4402,6 +4402,13 @@ and customer address. Include units.',
},
{
+ 'key' => 'svc_hardware-check_mac_addr',
+ 'section' => '', #?
+ 'description' => 'Require the "hardware address" field in hardware services to be a valid MAC address.',
+ 'type' => 'checkbox',
+ },
+
+ {
'key' => 'tax-report_groups',
'section' => '',
'description' => 'List of grouping possibilities for tax names on reports, one per line, "label op value" (op can be = or !=).',
diff --git a/FS/FS/svc_hardware.pm b/FS/FS/svc_hardware.pm
index 4970b3e92..b4eb8ccfa 100644
--- a/FS/FS/svc_hardware.pm
+++ b/FS/FS/svc_hardware.pm
@@ -154,19 +154,25 @@ and replace methods.
sub check {
my $self = shift;
+ my $conf = FS::Conf->new;
my $x = $self->setfixed;
return $x unless ref $x;
my $hw_addr = $self->getfield('hw_addr');
$hw_addr = join('', split(/\W/, $hw_addr));
+ if ( $conf->exists('svc_hardware-check_mac_addr') ) {
+ $hw_addr = uc($hw_addr);
+ $hw_addr =~ /^[0-9A-F]{12}$/
+ or return "Illegal (MAC address) ".$self->getfield('hw_addr');
+ }
$self->setfield('hw_addr', $hw_addr);
my $error =
$self->ut_numbern('svcnum')
|| $self->ut_foreign_key('typenum', 'hardware_type', 'typenum')
|| $self->ut_ip46n('ip_addr')
- || $self->ut_hexn('hw_addr')
+ || $self->ut_alphan('hw_addr')
|| $self->ut_alphan('serial')
|| $self->ut_alphan('smartcard')
|| $self->ut_foreign_keyn('statusnum', 'hardware_status', 'statusnum')