From 1318909d7eb16d736cbfb9f641eecccb00d4636c Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 10 Dec 2010 22:08:36 +0000 Subject: [PATCH] cardfortress backend support --- FS/FS/Conf.pm | 7 +++ FS/FS/Schema.pm | 38 +++++++++++++ FS/FS/part_export/cardfortress.pm | 64 ++++++++++++++++++++++ FS/FS/svc_acct.pm | 8 ++- httemplate/edit/process/svc_acct.cgi | 11 ++-- httemplate/view/svc_acct.cgi | 6 ++ httemplate/view/svc_acct/cardfortress.html | 27 +++++++++ 7 files changed, 154 insertions(+), 7 deletions(-) create mode 100644 FS/FS/part_export/cardfortress.pm create mode 100644 httemplate/view/svc_acct/cardfortress.html diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index ebeebb261..a05ad0358 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -4103,6 +4103,13 @@ and customer address. Include units.', ], }, + { + 'key' => 'svc_acct-cf_privatekey-message', + 'section' => '', + 'description' => 'For internal use: HTML displayed when cf_privatekey field is set.', + 'type' => 'textarea', + }, + { key => "apacheroot", section => "deprecated", description => "DEPRECATED", type => "text" }, { key => "apachemachine", section => "deprecated", description => "DEPRECATED", type => "text" }, { key => "apachemachines", section => "deprecated", description => "DEPRECATED", type => "text" }, diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 70aab4315..b48e5af8a 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1746,6 +1746,8 @@ sub tables_hashref { 'pbxsvc', 'int', 'NULL', '', '', '', 'last_login', @date_type, '', '', 'last_logout', @date_type, '', '', + #cardfortress field(s) + 'cf_privatekey', 'text', 'NULL', '', '', '', #communigate pro fields (quota = MaxAccountSize) 'cgp_aliases', 'varchar', 'NULL', 255, '', '', #settings @@ -3094,7 +3096,43 @@ sub tables_hashref { 'unique' => [], 'index' => [], #recnum }, + + 'nms_device' => { + 'columns' => [ + 'nms_devicenum', 'serial', '', '', '', '', + #'agentnum', 'int', 'NULL', '', '', '', + 'devicename', 'varchar', '', $char_d, '', '', + 'ip', 'varchar', '', 15, '', '', + 'protocol', 'varchar', '', $char_d, '', '', +# 'last', 'int', '', '', '', '', + ], + 'primary_key' => 'nms_devicenum', + 'unique' => [], + 'index' => [], + }, + 'nms_deviceport' => { + 'columns' => [ + 'portnum', 'serial', '', '', '', '', + 'nms_devicenum', 'int', '', '', '', '', + 'deviceport', 'int', '', '', '', '', + #'ip', 'varchar', 'NULL', 15, '', '', + 'svcnum', 'int', 'NULL', '', '', '', + ], + 'primary_key' => 'portnum', + 'unique' => [ [ 'nms_devicenum', 'deviceport' ] ], + 'index' => [ [ 'svcnum' ] ], + }, + + 'svc_port' => { + 'columns' => [ + 'svcnum', 'int', '', '', '', '', + ], + 'primary_key' => 'svcnum', + 'unique' => [], + 'index' => [], #recnum + }, + # name type nullability length default local diff --git a/FS/FS/part_export/cardfortress.pm b/FS/FS/part_export/cardfortress.pm new file mode 100644 index 000000000..4916a6ee0 --- /dev/null +++ b/FS/FS/part_export/cardfortress.pm @@ -0,0 +1,64 @@ +package FS::part_export::cardfortress; + +use strict; +use base 'FS::part_export'; +use vars qw( %info ); +use String::ShellQuote; + +#tie my %options, 'Tie::IxHash'; +#; + +%info = ( + 'svc' => 'svc_acct', + 'desc' => 'CardFortress', + 'options' => {}, #\%options, + 'nodomain' => 'Y', + 'notes' => '', +); + +sub rebless { shift; } + +sub _export_insert { + my($self, $svc_acct) = (shift, shift); + + eval "use Net::OpenSSH;"; + return $@ if $@; + + open my $def_in, '<', '/dev/null' or die "unable to open /dev/null"; + my $ssh = Net::OpenSSH->new( $self->machine, + default_stdin_fh => $def_in ); + + my $private_key = $ssh->capture( + { 'stdin_data' => $svc_acct->_password. "\n" }, + '/usr/local/bin/merchant_create', map $svc_acct->$_, qw( username finger ) + ); + return $ssh->error if $ssh->error; + + $svc_acct->cf_privatekey($private_key); + + $svc_acct->replace; + +} + +sub _export_replace { + my( $self, $new, $old ) = (shift, shift, shift); + + return 'username changes not yet supported' + if $old->username ne $new->username; + + return 'password changes not yet supported' + if $old->_password ne $new->_password; + + return 'Real name changes not yet supported' + if $old->finger ne $new->finger; + + ''; +} + +sub _export_delete { + #my( $self, $svc_x ) = (shift, shift); + + return 'deletion not yet supproted'; +} + +1; diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index f2b13c312..ac336b8f6 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -1207,16 +1207,19 @@ sub check { || $self->ut_enum('_password_encoding', ['',qw(plain crypt ldap)]) || $self->ut_enum('password_selfchange', [ '', 'Y' ]) || $self->ut_enum('password_recover', [ '', 'Y' ]) + #cardfortress + || $self->ut_anything('cf_privatekey') + #communigate || $self->ut_textn('cgp_accessmodes') || $self->ut_alphan('cgp_type') || $self->ut_textn('cgp_aliases' ) #well - #settings + # settings || $self->ut_alphasn('cgp_rulesallowed') || $self->ut_enum('cgp_rpopallowed', [ '', 'Y' ]) || $self->ut_enum('cgp_mailtoall', [ '', 'Y' ]) || $self->ut_enum('cgp_addmailtrailer', [ '', 'Y' ]) || $self->ut_snumbern('cgp_archiveafter') - #preferences + # preferences || $self->ut_alphasn('cgp_deletemode') || $self->ut_enum('cgp_emptytrash', $self->cgp_emptytrash_values) || $self->ut_alphan('cgp_language') @@ -1224,7 +1227,6 @@ sub check { || $self->ut_textn('cgp_skinname') || $self->ut_textn('cgp_prontoskinname') || $self->ut_alphan('cgp_sendmdnmode') - #XXX RPOP settings ; return $error if $error; diff --git a/httemplate/edit/process/svc_acct.cgi b/httemplate/edit/process/svc_acct.cgi index ba21ab4b5..52701dfc4 100755 --- a/httemplate/edit/process/svc_acct.cgi +++ b/httemplate/edit/process/svc_acct.cgi @@ -44,11 +44,14 @@ unless ( $cgi->param('cgp_accessmodes') ) { } my %hash = $svcnum ? $old->hash : (); -map { +for ( fields('svc_acct'), qw( pkgnum svcpart usergroup ) ) { $hash{$_} = scalar($cgi->param($_)); - #} qw(svcnum pkgnum svcpart username _password popnum uid gid finger dir - # shell quota slipip) - } (fields('svc_acct'), qw ( pkgnum svcpart usergroup )); +} +if ( $svcnum ) { + for ( grep $old->$_, qw( cf_privatekey ) ) { + $hash{$_} = $old->$_; + } +} my $new = new FS::svc_acct ( \%hash ); my $error = ''; diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi index 9135e67e9..4e82569fc 100755 --- a/httemplate/view/svc_acct.cgi +++ b/httemplate/view/svc_acct.cgi @@ -56,6 +56,12 @@ Service #<% $svcnum %>
+<% include( 'svc_acct/cardfortress.html', + 'svc_acct' => $svc_acct, + %gopt, + ) +%> + <% include( 'svc_acct/hosting.html', %gopt, ) diff --git a/httemplate/view/svc_acct/cardfortress.html b/httemplate/view/svc_acct/cardfortress.html new file mode 100644 index 000000000..d010fcdad --- /dev/null +++ b/httemplate/view/svc_acct/cardfortress.html @@ -0,0 +1,27 @@ +% if ( $svc_acct->cf_privatekey ) { + +
+
+
+ Card Fortress +
+ +
<% $svc_acct->cf_privatekey %>
+ + <% $conf->config('svc_acct-cf_privatekey-message') %> + +%#XXX and then there should be a remove link to get rid of it + +% } + +
+
+<%init> + +my %opt = @_; + +my $svc_acct = $opt{'svc_acct'}; + +my $conf = new FS::Conf; + + -- 2.20.1