+ First line is from returned from list:
+ <%= $listR %>
+
+
+
+
+ Form starts here
+
+
+
+
+
\ No newline at end of file
diff -ruN smeserver-manager-0.1.0.old/root/etc/e-smith/web/panels/manager2/cgi-bin/useraccounts smeserver-manager-0.1.0/root/etc/e-smith/web/panels/manager2/cgi-bin/useraccounts
--- smeserver-manager-0.1.0.old/root/etc/e-smith/web/panels/manager2/cgi-bin/useraccounts 1970-01-01 01:00:00.000000000 +0100
+++ smeserver-manager-0.1.0/root/etc/e-smith/web/panels/manager2/cgi-bin/useraccounts 2018-02-15 23:05:44.000000000 +0100
@@ -0,0 +1,52 @@
+#!/usr/bin/perl
+# no -d allowed when running suid from the cgi-bin dir :-(
+#-wT
+# vim: ft=xml:
+
+#----------------------------------------------------------------------
+# heading : Configuration
+# description : E-mail WBL
+# navigation : 6000 6710
+#----------------------------------------------------------------------
+
+use strict;
+use warnings;
+use Mojolicious::Lite;
+use smeserver::Panel::useraccountsNew;
+
+#use esmith::wblNew;
+
+# We can use separate template in templates/somefile.html.ep
+# plugin 'HTMLTemplateProRenderer';
+
+# Load up our wbl subroutines
+# my $f = esmith::wblNew->new();
+
+# Initial setup when called
+# get '/useraccounts' => sub {
+
+get '/' => sub {
+
+ my ($mojo) = @_;
+
+ my @useraccounts = get_user_accounts();
+
+ if ( scalar @useraccounts ) {
+
+ $mojo->stash( userlist => \@useraccounts );
+
+ # This is the template fragment to be embedded in main
+ $mojo->stash( contentVar => '_useraccounts' );
+
+ }
+
+ else {
+ $mojo->stash( contentVar => '_unavailable' );
+ }
+
+ $mojo->render( template => 'main' );
+};
+
+
+app->start;
+
diff -ruN smeserver-manager-0.1.0.old/root/etc/e-smith/web/panels/manager2/cgi-bin/wbl smeserver-manager-0.1.0/root/etc/e-smith/web/panels/manager2/cgi-bin/wbl
--- smeserver-manager-0.1.0.old/root/etc/e-smith/web/panels/manager2/cgi-bin/wbl 1970-01-01 01:00:00.000000000 +0100
+++ smeserver-manager-0.1.0/root/etc/e-smith/web/panels/manager2/cgi-bin/wbl 2018-02-15 23:05:44.000000000 +0100
@@ -0,0 +1,165 @@
+#!/usr/bin/perl
+# no -d allowed when running suid from the cgi-bin dir :-(
+#-wT
+# vim: ft=xml:
+
+#----------------------------------------------------------------------
+# heading : Configuration
+# description : E-mail WBL
+# navigation : 6000 6710
+#----------------------------------------------------------------------
+
+use strict;
+use warnings;
+use Mojolicious::Lite;
+use smeserver::Panel::wblNew;
+
+
+# We can use separate template in templates/somefile.html.ep
+# plugin 'HTMLTemplateProRenderer';
+
+# Load up our wbl subroutines
+# my $f = esmith::wblNew->new();
+
+# Initial setup when called
+get '/' => sub {
+
+ my ($mojo) = @_;
+
+ # Setup our 3 - test
+ # $mojo->stash( RBL => 'RBL List', Black => 'Black List', White => 'White List' );
+
+ # Or use a dropdown list
+ my @wblList = ( 'RBL List', 'Black List', 'White List' );
+ $mojo->stash( list => \@wblList );
+
+ # This is the template fragment to be embedded in main
+ $mojo->stash( contentVar => '_choice' );
+
+ # And now we render main
+ $mojo->render( template => 'main' );
+
+};
+
+#get 'test1' => sub {
+#};
+
+#get 'test2' => sub {
+#};
+
+# called via post
+post '/' => sub {
+
+ # push the returned array to the $mojo array
+ my $mojo = shift;
+
+ my $button = $mojo->param('button');
+
+ # This is the name used in the select_files e.g. 'list'
+ my $list = $mojo->param('list');
+
+ # We should put the vars below into these SWITCH statements
+ # We can then check the call in the $list var.
+ # If it is a straightforward POST call we return a template
+ # If it is like wbl.cgi?get_dnsbl or wbl.cgi?get_rblSettings or similar
+ # we could return some JSON instead
+ # Just needs some logic to figure the call style and output relevant data
+
+ # Hmm some of this comes back as a carriage return separated array
+ # For now removed the \n and join in the wbl.pm file
+ # eg joe@domain.com\nfred@domain.com
+ #
+
+ SWITCH: {
+
+ if ( $list =~ /^RBL List/ ) {
+
+ # Set the template we require
+ # You could do some logic to either call a template to output the data,
+ # or alternatively answer a query with some JSON instead
+ $mojo->stash( contentVar => '_rbl' );
+
+ # Set the retrieved list name to display it for testing
+ $mojo->stash( listR => $list );
+
+ # For RBL List
+ # dnsbl - returns 'enabled/disabled
+ my $dnsbl = get_dnsbl();
+ $mojo->stash( dnsbl => $dnsbl );
+
+ # rhsbl - returns 'enabled/disabled
+ my $rhsbl = get_rhsbl();
+ $mojo->stash( rhsbl => $rhsbl );
+
+ # uribl - returns 'enabled/disabled
+ my $uribl = get_uribl();
+ $mojo->stash( uribl => $uribl );
+
+ # For SBLList List
+ my @sbllist = get_sbllist();
+ $mojo->stash( sbllist => \@sbllist );
+
+ # For RBLList List
+ my @rbllist = get_rbllist();
+ $mojo->stash( rbllist => \@rbllist );
+
+ # For URLList List
+ my @ubllist = get_ubllist();
+ $mojo->stash( ubllist => \@ubllist );
+
+ }
+ if ( $list =~ /^Black List/ ) {
+
+ # Set the template we require
+ # You could do some logic to either call a template to output the data,
+ # or alternatively answer a query with some JSON instead
+ $mojo->stash( contentVar => '_black' );
+
+ # Set the retrieved list name to display it for testing
+ $mojo->stash( listR => $list );
+
+ # For Black List
+ my @badhelo = get_badhelo();
+ $mojo->stash( badhelo => \@badhelo );
+
+ my @badmailfrom = get_badmailfrom();
+ $mojo->stash( badmailfrom => \@badmailfrom );
+
+ }
+ if ( $list =~ /^White List/ ) {
+
+ # Set the template we require
+ # You could do some logic to either call a template to output the data,
+ # or alternatively answer a query with some JSON instead
+ $mojo->stash( contentVar => '_white' );
+
+ # Set the retrieved list name to display it for testing
+ $mojo->stash( listR => $list );
+
+ # For WBL List
+ my @whitelistsenders = get_whitelistsenders();
+ $mojo->stash( whitesenders => \@whitelistsenders );
+
+ my @whitelisthelo = get_whitelisthelo();
+ $mojo->stash( whitehelo => \@whitelisthelo );
+
+ my @whitelisthosts = get_whitelisthosts();
+ $mojo->stash( whitehosts => \@whitelisthosts );
+
+ my @whitelistfrom = get_whitelistfrom();
+ $mojo->stash( whitefrom => \@whitelistfrom );
+
+ }
+
+ # Fall through back to choice list
+ # Not sure how do do an 'else' though !
+ # my @wblList = ( 'RBL List', 'Black List', 'White List' );
+ # $mojo->stash( list => \@wblList );
+ # $mojo->stash( contentVar => '_choice' );
+ }
+
+ $mojo->render( template => 'main' );
+};
+
+app->start;
+
diff -ruN smeserver-manager-0.1.0.old/root/usr/share/perl5/vendor_perl/smeserver/Panel/useraccountsNew.pm smeserver-manager-0.1.0/root/usr/share/perl5/vendor_perl/smeserver/Panel/useraccountsNew.pm
--- smeserver-manager-0.1.0.old/root/usr/share/perl5/vendor_perl/smeserver/Panel/useraccountsNew.pm 1970-01-01 01:00:00.000000000 +0100
+++ smeserver-manager-0.1.0/root/usr/share/perl5/vendor_perl/smeserver/Panel/useraccountsNew.pm 2018-02-16 00:21:52.000000000 +0100
@@ -0,0 +1,1310 @@
+#!/usr/bin/perl -w
+
+#----------------------------------------------------------------------
+# $Id: useraccounts.pm,v 1.108 2004/11/11 20:05:56 charlieb Exp $
+#----------------------------------------------------------------------
+# copyright (C) 1999-2006 Mitel Networks Corporation
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#----------------------------------------------------------------------
+package smeserver::Panel::useraccountsNew;
+
+use strict;
+
+# Get shot of FormMagick and cgi
+
+
+use esmith::AccountsDB;
+use esmith::ConfigDB;
+#use esmith::FormMagick;
+#use esmith::cgi;
+use esmith::util;
+use File::Basename;
+use Exporter;
+use Carp qw(verbose);
+
+# This will have to go - where do we need it ?
+our @ISA = qw( Exporter);
+
+# Anything with print is a non starter and should be renamed
+our @EXPORT = qw(
+ get_user_accounts
+ print_user_table
+ print_acctName_field
+ print_groupMemberships_field
+ print_page_description
+ get_ldap_value
+ username_clash
+ pseudonym_clash
+ handle_user_accounts
+ modify_admin
+ emailforward
+ verifyPasswords
+ lock_account
+ remove_account
+ reset_password
+ check_password
+ print_save_or_add_button
+ get_pptp_value
+ print_ipsec_client_section
+ get_prop
+
+ system_password_compare
+ system_valid_password
+ system_change_password
+ system_check_password
+ system_authenticate_password
+);
+
+our $VERSION = sprintf '%d.%03d', q$Revision: 1.108 $ =~ /: (\d+).(\d+)/;
+
+our $accountdb = esmith::AccountsDB->open();
+our $configdb = esmith::ConfigDB->open();
+
+=pod
+
+=head1 NAME
+
+esmith::FormMagick::Panels::useraccounts - useful panel functions
+
+=head1 SYNOPSIS
+
+use esmith::FormMagick::Panels::useraccount;
+
+my $panel = esmith::FormMagick::Panel::useraccount->new();
+$panel->display();
+
+=head1 DESCRIPTION
+
+
+=head2 new();
+
+Exactly as for esmith::FormMagick
+
+=begin testing
+
+$ENV{ESMITH_ACCOUNT_DB} = "10e-smith-base/accounts.conf";
+$ENV{ESMITH_CONFIG_DB} = "10e-smith-base/configuration.conf";
+
+open DATA, "echo ''|";
+use_ok('esmith::FormMagick::Panel::useraccounts');
+use vars qw($panel);
+ok($panel = esmith::FormMagick::Panel::useraccounts->new(),
+"Create panel object");
+close DATA;
+isa_ok($panel, 'esmith::FormMagick::Panel::useraccounts');
+$panel->{cgi} = CGI->new();
+$panel->parse_xml();
+
+{ package esmith::FormMagick::Panel::useraccounts;
+our $accountdb;
+::isa_ok($accountdb, 'esmith::AccountsDB');
+}
+
+=end testing
+
+=cut
+
+# Errrr ? No FormMagick now.
+sub new {
+ shift;
+ my $self = esmith::FormMagick->new();
+ $self->{calling_package} = (caller)[0];
+ bless $self;
+ return $self;
+}
+
+=head1 HTML GENERATION ROUTINES
+
+Routines for generating chunks of HTML needed by the panel.
+
+=head2 print_user_table
+
+Prints out the user table on the front page.
+
+=for testing
+$panel->print_user_table;
+like($_STDOUT_, qr/bart/, "Found usernames in user table output");
+like($_STDOUT_, qr/ff0000/, "Found red 'reset password' output");
+
+=cut
+
+# The whole print_user_table routine can go - we just need get_users here
+
+sub get_user_accounts {
+ #my $self = shift;
+ #my $q = $self->{cgi};
+ #my $account = $self->localise('ACCOUNT');
+ #my $acctName = $self->localise('USER_NAME');
+ #
+ #my $modify = $self->localise('MODIFY');
+ #my $resetpw = $self->localise('PASSWORD_RESET');
+ #my $lock = $self->localise('LOCK_ACCOUNT');
+ #my $account_locked = $self->localise('ACCOUNT_LOCKED');
+ #my $remove = $self->localise('REMOVE');
+
+ my @users = $accountdb->get('admin');
+ push @users, $accountdb->users();
+
+ unless ( scalar @users )
+ {
+ return "No user accounts available";
+ }
+ return @users;
+}
+
+# Not required
+
+sub print_user_table {
+ my $self = shift;
+ my $q = $self->{cgi};
+ my $account = $self->localise('ACCOUNT');
+ my $acctName = $self->localise('USER_NAME');
+
+ my $modify = $self->localise('MODIFY');
+ my $resetpw = $self->localise('PASSWORD_RESET');
+ my $lock = $self->localise('LOCK_ACCOUNT');
+ my $account_locked = $self->localise('ACCOUNT_LOCKED');
+ my $remove = $self->localise('REMOVE');
+
+ my @users = $accountdb->get('admin');
+ push @users, $accountdb->users();
+
+ unless ( scalar @users )
+ {
+ print $q->Tr($q->td($self->localise('NO_USER_ACCOUNTS')));
+ return "";
+ }
+ print "
\n);
+
+ return "";
+}
+
+=head2 print_acctName_field
+
+This subroutine is used to generate the Account name field on the form in
+the case of "create user", or to make it a plain uneditable string in the case
+of "modify user".
+
+=begin testing
+
+my $self = esmith::FormMagick::Panel::useraccounts->new();
+$self->{cgi} = CGI->new("");
+print_acctName_field($self);
+like($_STDOUT_, qr/text.*acctName/, "print text field if acctName not set");
+like($_STDOUT_, qr/create/, "action=create if acctName not set");
+$self->{cgi}->param(-name => 'acctName', -value => 'foo');
+$self->{cgi}->param(-name => 'action', -value => 'modify');
+print_acctName_field($self);
+like($_STDOUT_, qr/hidden.*acctName/, "print hidden field if acctName is set");
+like($_STDOUT_, qr/modify/, "action=modify if acctName already set");
+
+=end testing
+
+=cut
+
+sub print_acctName_field {
+ my $self = shift;
+ my $cgi = $self->{cgi};
+ my $an = $cgi->param('acctName') || '';
+ print qq(
) . $self->localise('ACCOUNT_NAME') . qq(
\n);
+ my $action = $cgi->param('action') || '';
+ if ( $action eq 'modify') {
+ print qq(
+
$an
+
+
+
+ );
+ # if there's no CGI data, fill in the fields with the account db
+ # data for this user
+ my $rec = $accountdb->get($an);
+ my $fn = $cgi->param('FirstName') ?
+ $cgi->param('FirstName') :
+ ($rec ? ($rec->prop('FirstName')) : '');
+ my $ln = $cgi->param('LastName') ?
+ $cgi->param('LastName') :
+ ($rec ? ($rec->prop('LastName')) : '');
+ my $dept = $cgi->param('Dept') ?
+ $cgi->param('Dept') :
+ ($rec ? ($rec->prop('Dept')) : '');
+ my $company = $cgi->param('Company') ?
+ $cgi->param('Company') :
+ ($rec ? ($rec->prop('Company')) : '');
+ my $street = $cgi->param('Street') ?
+ $cgi->param('Street') :
+ ($rec ? ($rec->prop('Street')) : '');
+ my $city = $cgi->param('City') ?
+ $cgi->param('City') :
+ ($rec ? ($rec->prop('City')) : '');
+ my $phone = $cgi->param('Phone') ?
+ $cgi->param('Phone') :
+ ($rec ? ($rec->prop('Phone')) : '');
+ my $emf = $cgi->param('EmailForward') ?
+ $cgi->param('EmailForward') :
+ ($rec ? ($rec->prop('EmailForward')) : 'local');
+ my $fwd = $cgi->param('ForwardAddress') ?
+ $cgi->param('ForwardAddress') :
+ ($rec ? ($rec->prop('ForwardAddress')) : '');
+ my $pptp = $cgi->param('VPNClientAccess') ?
+ $cgi->param('VPNClientAccess') :
+ ($rec ? ($rec->prop('VPNClientAccess')) : 'no');
+ # now that we're down with the 411, let's set the values
+ $cgi->param(-name=>'FirstName', -value=>$fn);
+ $cgi->param(-name=>'LastName', -value=>$ln);
+ $cgi->param(-name=>'Dept', -value=>$dept);
+ $cgi->param(-name=>'Company', -value=>$company);
+ $cgi->param(-name=>'Street', -value=>$street);
+ $cgi->param(-name=>'City', -value=>$city);
+ $cgi->param(-name=>'Phone', -value=>$phone);
+ $cgi->param(-name=>'EmailForward', -value=>$emf);
+ $cgi->param(-name=>'ForwardAddress', -value=>$fwd);
+ $cgi->param(-name=>'VPNClientAccess', -value=>$pptp);
+ } else {
+ print qq(
+
+
+
+ );
+ }
+
+ print qq(
\n);
+ return undef;
+
+}
+
+=head2 print_groupMemberships_field()
+
+Builds a list of groups for the create/modify user screen.
+
+=begin testing
+
+my $self = esmith::FormMagick::Panel::useraccounts->new();
+$self->{cgi} = CGI->new("");
+$self->print_groupMemberships_field();
+like($_STDOUT_, qr/simpsons/, "Found simpsons in group list");
+like($_STDOUT_, qr/flanders/, "Found flanders in group list");
+$self->{cgi}->param(-name => 'acctName', -value => 'rod');
+$self->print_groupMemberships_field();
+like($_STDOUT_, qr/checked value="flanders"/, "Checked flanders group for user rod");
+
+=end testing
+
+=cut
+
+sub print_groupMemberships_field {
+ my ($self) = @_;
+ my $q = $self->{cgi};
+ my $user = $q->param('acctName');
+
+ if (my @groups = $accountdb->groups()) {
+
+ print "