initial commit of file from CVS for e-smith-base on Thu 26 Oct 11:24:52 BST 2023
This commit is contained in:
BIN
root/etc/e-smith/web/common/banner-shim.gif
Executable file
BIN
root/etc/e-smith/web/common/banner-shim.gif
Executable file
Binary file not shown.
After Width: | Height: | Size: 882 B |
BIN
root/etc/e-smith/web/common/stop.jpg
Normal file
BIN
root/etc/e-smith/web/common/stop.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.1 KiB |
149
root/etc/e-smith/web/functions/groups
Executable file
149
root/etc/e-smith/web/functions/groups
Executable file
@@ -0,0 +1,149 @@
|
||||
#!/usr/bin/perl -wT
|
||||
|
||||
# vim: ft=xml ts=4 sw=4 et:
|
||||
#----------------------------------------------------------------------
|
||||
# heading : Collaboration
|
||||
# description : GROUPS
|
||||
# navigation : 2000 2200
|
||||
#----------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 2002-2005 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
|
||||
#
|
||||
# Technical support for this program is available from Mitel Networks
|
||||
# Please visit our web site www.mitel.com/sme/ for details.
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
use strict;
|
||||
use esmith::FormMagick::Panel::groups;
|
||||
my $f = esmith::FormMagick::Panel::groups->new();
|
||||
$f->display();
|
||||
|
||||
=head1 TESTING
|
||||
|
||||
|
||||
=begin testing
|
||||
|
||||
use esmith::FormMagick::Tester;
|
||||
use esmith::TestUtils;
|
||||
use esmith::AccountsDB;
|
||||
my $panel = 'groups';
|
||||
my $panel_path = "/etc/e-smith/web/functions/".$panel;
|
||||
my $ua = esmith::FormMagick::Tester->new();
|
||||
|
||||
|
||||
is (mode($panel_path), '4750', "Check permissions on script");
|
||||
ok ($ua->get_panel($panel), "ABOUT TO RUN L10N TESTS");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/FORM_TITLE/, "Saw untranslated form title");
|
||||
ok ($ua->set_language("en"), "Set language to English");
|
||||
ok ($ua->get_panel($panel), "Get panel");
|
||||
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
|
||||
like($ua->{content}, qr/Create, remove, or change/, "Saw translated form title");
|
||||
|
||||
# Testing changes
|
||||
|
||||
ok ($ua->get_panel($panel), "Testing panel retrieval");
|
||||
can_ok($ua, "field");
|
||||
|
||||
# Destructive testing:
|
||||
|
||||
ok ($ua->follow('Click here to create a user group'), "Followed link to create group");
|
||||
is ($ua->{status}, 200, "200 OK" );
|
||||
can_ok($ua, "field");
|
||||
ok($ua->field('groupName' => 'aaaaaeve') , "Set GroupName");
|
||||
ok($ua->field('groupDesc' => 'sample'), "Set GroupDesc");
|
||||
|
||||
if (destruction_ok()) {
|
||||
|
||||
ok ($ua->click('Create'), "Clicked create");
|
||||
is ($ua->{status}, 200, "200 OK" );
|
||||
like ($ua->{content}, qr/created user group/, "Saw create success message");
|
||||
ok ($ua->get_panel($panel), "Get panel");
|
||||
like ($ua->{content}, qr/aaaaaeve/, "Saw newly created everygroup link");
|
||||
ok ($ua->follow('Modify'), "modifying aaaaaeve");
|
||||
is ($ua->{status}, 200, "200 OK ");
|
||||
ok ($ua->field('groupDesc' => 'Everyone') , "Set group desc to 'Everyone'");
|
||||
|
||||
#putting this in a test fails. why?
|
||||
$ua->field('groupMembers' => 'admin');
|
||||
ok ($ua->click('Modify'));
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like ($ua->{content}, qr/Successfully/, "Saw modification success message");
|
||||
ok (my $acct = esmith::AccountsDB->open());
|
||||
ok (my $everg = $acct->get('aaaaaeve'), "Got an aaaaaeveg out of the db");
|
||||
ok ($everg->prop('Members') eq 'admin', "aaaaaeve has admin as its member");
|
||||
|
||||
ok ($ua->get_panel($panel), "Get panel");
|
||||
like ($ua->{content}, qr/aaaaaeve/, "Saw modified everygroup link");
|
||||
ok ($ua->follow('Remove'), "removing aaaaaeve");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
ok ($ua->click('Remove'));
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like ($ua->{content}, qr/Successfully/, "Saw removal success message");
|
||||
ok ($ua->get_panel($panel), "Get panel");
|
||||
unlike ($ua->{content}, qr/aaaaaeve/, "Saw no everygroup");
|
||||
}
|
||||
|
||||
=end testing
|
||||
|
||||
=cut
|
||||
|
||||
__DATA__
|
||||
<form title="FORM_TITLE" header="/etc/e-smith/web/common/head.tmpl" footer="/etc/e-smith/web/common/foot.tmpl">
|
||||
<page name="First" pre-event="print_status_message()">
|
||||
<subroutine src="show_initial()"/>
|
||||
</page>
|
||||
<page name="CreateGroup" pre-event="turn_off_buttons()"
|
||||
post-event="create_group()">
|
||||
<title>CREATE_GROUP</title>
|
||||
<description>GROUP_NAMING</description>
|
||||
<field type="text" id="groupName"
|
||||
validation="validate_group, validate_group_length, validate_group_naming_conflict">
|
||||
<label>GROUP_NAME</label>
|
||||
</field>
|
||||
<field type="text" id="groupDesc" validation="validate_description">
|
||||
<label>GROUP_DESC</label>
|
||||
<description>GROUP_DESC_EXPL</description>
|
||||
</field>
|
||||
<subroutine src="genUsers()"/>
|
||||
<subroutine src="print_button('ADD')" />
|
||||
</page>
|
||||
<page name="Delete" pre-event="turn_off_buttons()"
|
||||
post-event="delete_group()">
|
||||
<title>REMOVE_USER_GROUP</title>
|
||||
<subroutine src="print_group_delete_desc()"/>
|
||||
<subroutine src="print_group_members()"/>
|
||||
<subroutine src="print_ibay_list($acct)"/>
|
||||
<subroutine src="print_button('REMOVE')" />
|
||||
</page>
|
||||
<page name="Modify" pre-event="turn_off_buttons()"
|
||||
post-event="modify_group()">
|
||||
<title>MODIFY_USER_GROUP</title>
|
||||
<field type="literal" id="groupName" value="$q->param('groupName')">
|
||||
<label>GROUP_NAME</label>
|
||||
</field>
|
||||
<field type="text" id="groupDesc" value="get_description()"
|
||||
validation="validate_description">
|
||||
<label>GROUP_DESC</label>
|
||||
</field>
|
||||
<subroutine src="genUsers()"/>
|
||||
<subroutine src="print_button('SAVE')" />
|
||||
</page>
|
||||
</form>
|
151
root/etc/e-smith/web/functions/localnetworks
Executable file
151
root/etc/e-smith/web/functions/localnetworks
Executable file
@@ -0,0 +1,151 @@
|
||||
#!/usr/bin/perl -wT
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# heading : Security
|
||||
# description : Local networks
|
||||
# navigation : 5000 5300
|
||||
#----------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 2002 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
|
||||
#
|
||||
# Technical support for this program is available from Mitel Networks
|
||||
# Please visit our web site www.mitel.com/sme/ for details.
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use esmith::FormMagick::Panel::localnetworks;
|
||||
|
||||
my $fm = esmith::FormMagick::Panel::localnetworks->new();
|
||||
$fm->display();
|
||||
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
localnetworks -- add/remove local networks
|
||||
|
||||
=head2 DESCRIPTION
|
||||
|
||||
This screen allows the administrator to add or delete local networks.
|
||||
|
||||
=begin testing
|
||||
|
||||
use esmith::FormMagick::Tester;
|
||||
use esmith::TestUtils;
|
||||
use esmith::TestUtils;
|
||||
use esmith::ConfigDB;
|
||||
use esmith::AccountsDB;
|
||||
|
||||
my $panel = $Original_File;
|
||||
my $ua = esmith::FormMagick::Tester->new();
|
||||
|
||||
my $c = esmith::ConfigDB->open();
|
||||
my $a = esmith::AccountsDB->open();
|
||||
|
||||
is (mode($panel), '4750', "Check permissions on script");
|
||||
ok ($ua->get_panel($panel), "ABOUT TO RUN L10N TESTS");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
ok ($ua->set_language("en-us"), "Set language to U.S. English");
|
||||
ok ($ua->get_panel($panel), "Get panel");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/Local networks/, "Saw translated form title");
|
||||
|
||||
|
||||
#
|
||||
# Testing creating local networks
|
||||
#
|
||||
|
||||
ok ($ua->get_panel($panel), "ABOUT TO TEST CREATING NETWORK");
|
||||
ok ($ua->follow("Click here"), "Follow 'create network' link");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/Add a local network/, "Saw page title");
|
||||
like($ua->{content}, qr/Network address/, "Saw network address field");
|
||||
like($ua->{content}, qr/Subnet mask/, "Saw subnet mask field");
|
||||
like($ua->{content}, qr/Router/, "Saw router field");
|
||||
like($ua->{content}, qr/Add/, "Saw add button");
|
||||
|
||||
#
|
||||
# checking error handling
|
||||
#
|
||||
|
||||
$ua->field(networkAddress => '10.0.0.10000');
|
||||
$ua->field(networkMask => '10.0.0.10000');
|
||||
$ua->click("Add");
|
||||
# like($ua->{content}, qr/Invalid network address/, "Saw network address validation message");
|
||||
like($ua->{content}, qr/Invalid subnet mask/, "Saw submask validation message");
|
||||
|
||||
#
|
||||
# now let's actually add one
|
||||
#
|
||||
|
||||
SKIP: {
|
||||
|
||||
skip 10, "Unsafe!" unless destruction_ok();
|
||||
|
||||
ok ($ua->follow("Click here"), "ACTUALLY ADDING A NETWORK");
|
||||
$ua->field(networkAddress => '10.0.0.0');
|
||||
$ua->field(networkMask => '255.255.255.0');
|
||||
$ua->field(networkRouter => '10.0.0.1');
|
||||
$ua->click("Add");
|
||||
like($ua->{content}, qr/Successfully added network/, "Saw success message");
|
||||
|
||||
ok ($ua->follow("Click here"), "ADDING NETWORK WITH DEFAULT ROUTER");
|
||||
$ua->field(networkAddress => '10.0.0.0');
|
||||
$ua->field(networkMask => '255.255.255.0');
|
||||
|
||||
ok ($ua->follow("Remove"), "REMOVING NETWORK");
|
||||
like($ua->{content}, qr/Are you sure/, "Saw confirmation message");
|
||||
$ua->click("Remove");
|
||||
like($ua->{content}, qr/Successfully deleted/, "Saw success message");
|
||||
|
||||
}
|
||||
|
||||
=end testing
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
|
||||
__DATA__
|
||||
<form title="Local networks" header="/etc/e-smith/web/common/head.tmpl" footer="/etc/e-smith/web/common/foot.tmpl">
|
||||
<page name="First" pre-event="print_status_message()">
|
||||
<description>FIRSTPAGE_DESC</description>
|
||||
<subroutine src="print_network_table()" />
|
||||
</page>
|
||||
<page name="Add" pre-event="turn_off_buttons()" post-event="add_network()">
|
||||
<title>ADD_TITLE</title>
|
||||
<description>ADD_DESC</description>
|
||||
<field type="text" id="networkAddress" validation="ip_number">
|
||||
<label>NETWORK_ADDRESS</label>
|
||||
</field>
|
||||
<field type="text" id="networkMask" validation="subnet_mask">
|
||||
<label>SUBNET_MASK</label>
|
||||
</field>
|
||||
<field type="text" id="networkRouter" validation="ip_number">
|
||||
<label>ROUTER</label>
|
||||
</field>
|
||||
<subroutine src="print_button('ADD')" />
|
||||
</page>
|
||||
<page name="Remove" post-event="remove_network()">
|
||||
<title>REMOVE_TITLE</title>
|
||||
<description>REMOVE_DESC</description>
|
||||
<subroutine src="show_remove_network_summary()" />
|
||||
</page>
|
||||
|
||||
</form>
|
77
root/etc/e-smith/web/functions/online-manual
Normal file
77
root/etc/e-smith/web/functions/online-manual
Normal file
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/perl -wT
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# heading : Miscellaneous
|
||||
# description : Online manual
|
||||
# navigation : 7000 7900
|
||||
#----------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 2002 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
|
||||
#
|
||||
# Technical support for this program is available from Mitel Networks
|
||||
# Please visit our web site www.mitel.com/sme/ for details.
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
use strict;
|
||||
# We don't need any custom anything, since this panel has no code.
|
||||
# so we just use esmith::FormMagick, rather than creating an empty placeholder
|
||||
use esmith::FormMagick;
|
||||
my $f = esmith::FormMagick->new();
|
||||
$f->display();
|
||||
|
||||
|
||||
|
||||
|
||||
=head1 TESTING
|
||||
|
||||
|
||||
=begin testing
|
||||
|
||||
use esmith::FormMagick::Tester;
|
||||
use esmith::TestUtils;
|
||||
|
||||
my $panel = 'online-manual';
|
||||
my $panel_path = "/etc/e-smith/web/functions/".$panel;
|
||||
my $ua = esmith::FormMagick::Tester->new();
|
||||
|
||||
|
||||
is (mode($panel_path), '4750', "Check permissions on script");
|
||||
my @stat = stat($panel_path);
|
||||
is (getpwuid($stat[4]), 'root', "File is owned by root");
|
||||
is (getgrgid($stat[5]), 'admin', "File is owned by group admin");
|
||||
ok ($ua->get_panel($panel), "ABOUT TO RUN L10N TESTS");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/FORM_TITLE/, "Saw untranslated form title");
|
||||
ok ($ua->set_language("en-us"), "Set language to U.S. English");
|
||||
ok ($ua->get_panel($panel), "Get panel");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/Online manual/, "Saw translated form title");
|
||||
like($ua->{content}, qr{e-smith.org/docs/manual}, "Saw URL");
|
||||
|
||||
=end testing
|
||||
|
||||
=cut
|
||||
|
||||
__DATA__
|
||||
<form title="FORM_TITLE" header="/etc/e-smith/web/common/head.tmpl" footer="/etc/e-smith/web/common/foot.tmpl">
|
||||
<page name="First" pre-event="turn_off_buttons()">
|
||||
<description>DESCRIPTION</description>
|
||||
</page>
|
||||
|
||||
</form>
|
110
root/etc/e-smith/web/functions/reboot
Executable file
110
root/etc/e-smith/web/functions/reboot
Executable file
@@ -0,0 +1,110 @@
|
||||
#!/usr/bin/perl -wT
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# heading : Administration
|
||||
# description : Reboot or shutdown
|
||||
# navigation : 4000 4700
|
||||
#----------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 2002-2005 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
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use esmith::FormMagick::Panel::reboot;
|
||||
my $f = esmith::FormMagick::Panel::reboot->new();
|
||||
$f->display();
|
||||
|
||||
=head1 TESTING
|
||||
|
||||
|
||||
=begin testing
|
||||
|
||||
use esmith::FormMagick::Tester;
|
||||
use esmith::TestUtils;
|
||||
use esmith::ConfigDB;
|
||||
my $panel = 'reboot';
|
||||
my $panel_path = "/etc/e-smith/web/functions/".$panel;
|
||||
my $ua = esmith::FormMagick::Tester->new();
|
||||
|
||||
|
||||
|
||||
is (mode($panel_path), '4750', "Check permissions on script");
|
||||
ok ($ua->get_panel($panel), "ABOUT TO RUN L10N TESTS");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/FORM_TITLE/, "Saw untranslated form title");
|
||||
ok ($ua->set_language("en-us"), "Set language to U.S. English");
|
||||
ok ($ua->get_panel($panel), "Get panel");
|
||||
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
|
||||
like($ua->{content}, qr/Shutdown or Reboot/, "Saw translated form title");
|
||||
|
||||
# Testing changes
|
||||
|
||||
ok ($ua->get_panel($panel), "Testing reboot");
|
||||
can_ok($ua, "field");
|
||||
ok ($ua->{form}->find_input('function'), "Finding form field");
|
||||
#$ua->field("function" => 'reboot');
|
||||
#$ua->field("debug" => '1');
|
||||
#ok ($ua->click("Save"), "Click Save");
|
||||
#is ($ua->{status}, 200, "200 OK");
|
||||
#like($ua->{content}, qr/will begin the reboot/, "Saw validation messages");
|
||||
|
||||
|
||||
|
||||
#ok ($ua->get_panel($panel), "Testing shutdown");
|
||||
#can_ok($ua, "field");
|
||||
#ok ($ua->{form}->find_input('function'), "Finding form field");
|
||||
#$ua->field("function" => 'reboot');
|
||||
#$ua->field("debug" => '1');
|
||||
|
||||
#ok ($ua->click("Save"), "Click Save");
|
||||
#is ($ua->{status}, 200, "200 OK");
|
||||
#like($ua->{content}, qr/will begin the shutdown/, "Saw validation messages");
|
||||
|
||||
=end testing
|
||||
|
||||
=cut
|
||||
|
||||
__DATA__
|
||||
<form title="FORM_TITLE" header="/etc/e-smith/web/common/head.tmpl"
|
||||
footer="/etc/e-smith/web/common/foot.tmpl">
|
||||
<page name="First" post-event="change_settings()" pre-event="turn_off_buttons()">
|
||||
<description>DESCRIPTION</description>
|
||||
|
||||
<field type="select"
|
||||
id="function"
|
||||
options="'shutdown' => 'SHUTDOWN',
|
||||
'reboot'=> 'REBOOT',
|
||||
'reconfigure'=> 'RECONFIGURE'"
|
||||
value="reboot">
|
||||
<label>LABEL_REBOOT</label>
|
||||
</field>
|
||||
|
||||
<subroutine src="print_button('PERFORM')" />
|
||||
</page>
|
||||
<page name="Reboot" pre-event="turn_off_buttons">
|
||||
<description>DESC_REBOOT</description>
|
||||
</page>
|
||||
<page name="Shutdown" pre-event="turn_off_buttons">
|
||||
<description>DESC_SHUTDOWN</description>
|
||||
</page>
|
||||
<page name="Reconfigure" pre-event="turn_off_buttons">
|
||||
<description>DESC_RECONFIGURE</description>
|
||||
</page>
|
||||
|
||||
</form>
|
177
root/etc/e-smith/web/functions/remoteaccess
Executable file
177
root/etc/e-smith/web/functions/remoteaccess
Executable file
@@ -0,0 +1,177 @@
|
||||
#!/usr/bin/perl -wT
|
||||
|
||||
# vim: ft=xml ts=8 sw=4 noet:
|
||||
#----------------------------------------------------------------------
|
||||
# heading : Security
|
||||
# description : Remote access
|
||||
# navigation : 5000 5200
|
||||
#----------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 2002 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
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use esmith::FormMagick::Panel::remoteaccess;
|
||||
my $f = esmith::FormMagick::Panel::remoteaccess->new();
|
||||
$f->display();
|
||||
|
||||
=head1 TESTING
|
||||
|
||||
|
||||
=begin testing
|
||||
|
||||
use esmith::FormMagick::Tester;
|
||||
use esmith::TestUtils;
|
||||
use esmith::ConfigDB;
|
||||
my $panel = 'remoteaccess';
|
||||
my $panel_path = "/etc/e-smith/web/functions/".$panel;
|
||||
my $ua = esmith::FormMagick::Tester->new();
|
||||
|
||||
is (mode($panel_path), '4750', "Check permissions on script");
|
||||
ok ($ua->get_panel($panel), "ABOUT TO RUN L10N TESTS");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/FORM_TITLE/, "Saw untranslated form title");
|
||||
ok ($ua->set_language("en-us"), "Set language to U.S. English");
|
||||
ok ($ua->get_panel($panel), "Get panel");
|
||||
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
|
||||
like($ua->{content}, qr/remote access settings/, "Saw translated form title");
|
||||
|
||||
# Testing changes
|
||||
|
||||
ok ($ua->get_panel($panel), "Testing panel retrieval");
|
||||
can_ok($ua, "field");
|
||||
ok ($ua->{form}->find_input('FTPAccess'), 'Finding the FTPAccess field');
|
||||
ok ($ua->{form}->find_input('sshAccess'), 'Finding the sshAccess field');
|
||||
ok ($ua->{form}->find_input('sshPermitRootLogin'), 'Finding the sshPermitRootLogin field');
|
||||
ok ($ua->{form}->find_input('sshTCPPort'), 'Finding the sshTCPPort field');
|
||||
ok ($ua->{form}->find_input('vpnSessions'), 'Finding the vpnSessions field');
|
||||
ok ($ua->{form}->find_input('sshPasswordAuthentication'), 'Finding the sshPasswordAuthentication field');
|
||||
ok ($ua->{form}->find_input('FTPLimits'), 'Finding the FTPLimits field');
|
||||
ok ($ua->{form}->find_input('TelnetAccess'), 'Finding the TelnetAccess field');
|
||||
|
||||
if (destruction_ok()) {
|
||||
$ua->field('FTPAccess' => 'private');
|
||||
$ua->field('sshAccess' => 'public');
|
||||
$ua->field('sshPermitRootLogin' => 'yes');
|
||||
$ua->field('sshTCPPort' => '22');
|
||||
$ua->field('vpnSessions' => '10');
|
||||
$ua->field('sshPasswordAuthentication' => 'yes');
|
||||
$ua->field('FTPLimits' => 'normal');
|
||||
$ua->field('TelnetAccess' => 'private');
|
||||
}
|
||||
|
||||
ok ($ua->click("Save"), "Click Save");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
|
||||
like($ua->{content}, qr/settings have been saved/, "Saw validation messages");
|
||||
|
||||
# Gotta open this later, so we don't cache stale data
|
||||
my $db = esmith::ConfigDB->open;
|
||||
|
||||
SKIP:
|
||||
{
|
||||
skip 9, "Unsafe!" unless destruction_ok();
|
||||
|
||||
is($db->get('sshd')->prop('access'), 'public', "We have public ssh");
|
||||
is($db->get('sshd')->prop('PasswordAuthentication'), 'yes', "We have password auth");
|
||||
is($db->get('sshd')->prop('PermitRootLogin'), 'yes', "We have root login");
|
||||
is($db->get('sshd')->prop('TCPPort'), '22', "Got the right tcp port for ssh');
|
||||
is($db->get('sshd')->prop('status'), 'enabled', "ssh is enabled");
|
||||
|
||||
is ($db->get('ftp')->prop('access'), 'private', "ftp access is private");
|
||||
is ($db->get('ftp')->prop('accessLimits'), 'normal', "ftp access limits are normal");
|
||||
is ($db->get('vpn')->prop('sessions') ,'10', "Got the right session count for vpn");
|
||||
is ($db->get('vpn')->prop('status') ,'enabled', "vpn is enabled");
|
||||
is ($db->get('telnet')->prop('access'), 'private', "Private telnet turned on");
|
||||
}
|
||||
|
||||
=end testing
|
||||
|
||||
=cut
|
||||
|
||||
__DATA__
|
||||
<form title="FORM_TITLE" header="/etc/e-smith/web/common/head.tmpl"
|
||||
footer="/etc/e-smith/web/common/foot.tmpl">
|
||||
<page name="First" post-event="change_settings()"
|
||||
pre-event="print_status_message()">
|
||||
|
||||
<field type="text" id="vpnSessions" size="3" validation="zero_or_positive(), vpn_and_dhcp_range()"
|
||||
value="get_vpn_sessions()">
|
||||
<label>LABEL_PPTP</label>
|
||||
<description>DESC_VPN</description>
|
||||
</field>
|
||||
|
||||
<subroutine src="show_ipsecrw_section()"/>
|
||||
|
||||
<subroutine src="show_valid_from_list()"/>
|
||||
<field type="text" id="validFromNetwork" size="15"
|
||||
value="" validation="ip_number_or_blank">
|
||||
<description>DESC_VALID_FROM_ENTRIES</description>
|
||||
<label>NETWORK</label>
|
||||
</field>
|
||||
<field type="text" id="validFromMask" size="15"
|
||||
value="" validation="subnet_mask_or_blank, validate_network_and_mask">
|
||||
<label>SUBNET_MASK</label>
|
||||
</field>
|
||||
|
||||
<field type="select"
|
||||
id="sshAccess"
|
||||
options=" 'off' => 'NO_ACCESS', 'private' => 'NETWORKS_ALLOW_LOCAL', 'public' => 'NETWORKS_ALLOW_PUBLIC'"
|
||||
value="get_ssh_access()">
|
||||
<label>LABEL_SSH</label>
|
||||
<description>DESC_SSH</description>
|
||||
</field>
|
||||
<field type="select"
|
||||
id="sshPermitRootLogin"
|
||||
options=" 'no'=>'NO', 'yes'=>'YES'"
|
||||
value="get_ssh_permit_root_login()">
|
||||
<label>LABEL_SSH_ADMIN</label>
|
||||
</field>
|
||||
<field type="select"
|
||||
id="sshPasswordAuthentication"
|
||||
options=" 'no'=>'NO', 'yes'=>'YES'"
|
||||
value="get_ssh_password_auth()">
|
||||
<label>LABEL_SSH_PASSWORD_ACCESS</label>
|
||||
</field>
|
||||
<field type="text" id="sshTCPPort" size="5"
|
||||
validation="zero_or_positive"
|
||||
value="get_ssh_port()">
|
||||
<label>LABEL_SSH_PORT</label>
|
||||
</field>
|
||||
|
||||
<subroutine src="show_ftp_section()"/>
|
||||
|
||||
<subroutine src="show_telnet_section()"/>
|
||||
|
||||
<!-- field type="select"
|
||||
id="serialConsole"
|
||||
options="
|
||||
'disabled' => 'DISABLED' ,
|
||||
'ttyS0' => 'PORT1_ENABLED' ,
|
||||
'ttyS1' => 'PORT2_ENABLED'
|
||||
"
|
||||
value="get_serial_console()">
|
||||
|
||||
<label>LABEL_SERIAL_CONSOLE_ACCESS</label>
|
||||
<description>DESC_SERIAL_CONSOLE_ACCESS</description>
|
||||
</field -->
|
||||
|
||||
<subroutine src="print_button('SAVE')" />
|
||||
</page>
|
||||
</form>
|
77
root/etc/e-smith/web/functions/review
Executable file
77
root/etc/e-smith/web/functions/review
Executable file
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/perl -wT
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# heading : Configuration
|
||||
# description : Review configuration
|
||||
# navigation : 6000 6800
|
||||
#----------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 2002 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
|
||||
#
|
||||
# Technical support for this program is available from Mitel Networks
|
||||
# Please visit our web site www.mitel.com/sme/ for details.
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
use strict;
|
||||
use esmith::FormMagick::Panel::review;
|
||||
my $f = esmith::FormMagick::Panel::review->new();
|
||||
$f->display();
|
||||
|
||||
|
||||
|
||||
|
||||
=head1 TESTING
|
||||
|
||||
|
||||
=begin testing
|
||||
|
||||
use esmith::FormMagick::Tester;
|
||||
use esmith::TestUtils;
|
||||
use esmith::ConfigDB;
|
||||
|
||||
my $panel = 'review';
|
||||
my $panel_path = "/etc/e-smith/web/functions/".$panel;
|
||||
my $ua = esmith::FormMagick::Tester->new();
|
||||
|
||||
|
||||
is (mode($panel_path), '4750', "Check permissions on script");
|
||||
my @stat = stat($panel_path);
|
||||
is (getpwuid($stat[4]), 'root', "File is owned by root");
|
||||
is (getgrgid($stat[5]), 'admin', "File is owned by group admin");
|
||||
ok ($ua->get_panel($panel), "ABOUT TO RUN L10N TESTS");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
ok ($ua->set_language("en"), "Set language to English");
|
||||
ok ($ua->get_panel($panel), "Get panel");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/Review configuration/, "Saw translated form title");
|
||||
like($ua->{content}, qr/Email Addresses/, "Saw email addresses");
|
||||
|
||||
=end testing
|
||||
|
||||
=cut
|
||||
|
||||
__DATA__
|
||||
<form title="Review configuration" header="/etc/e-smith/web/common/head.tmpl" footer="/etc/e-smith/web/common/foot.tmpl">
|
||||
<page name="First" post-event="change_settings()" pre-event="turn_off_buttons()">
|
||||
<description>DESCRIPTION</description>
|
||||
|
||||
<subroutine src="print_page()"/>
|
||||
</page>
|
||||
|
||||
</form>
|
291
root/etc/e-smith/web/functions/useraccounts
Executable file
291
root/etc/e-smith/web/functions/useraccounts
Executable file
@@ -0,0 +1,291 @@
|
||||
#!/usr/bin/perl -wT
|
||||
|
||||
# vim: ft=xml ts=4 sw=4 et:
|
||||
#----------------------------------------------------------------------
|
||||
# heading : Collaboration
|
||||
# description : Users
|
||||
# navigation : 2000 2100
|
||||
#----------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 2002 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
|
||||
#
|
||||
# Technical support for this program is available from Mitel Networks
|
||||
# Please visit our web site www.mitel.com/sme/ for details.
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use esmith::TestUtils;
|
||||
use esmith::FormMagick::Panel::useraccounts;
|
||||
|
||||
my $fm = esmith::FormMagick::Panel::useraccounts->new();
|
||||
|
||||
# XXX: need to print custom http headers, so bypass FormMagick
|
||||
use CGI;
|
||||
my $q = new CGI;
|
||||
if ($q->param('action') && $q->param('action') eq 'getCert')
|
||||
{
|
||||
$q->delete('action');
|
||||
$fm->get_ipsec_client_cert($q);
|
||||
}
|
||||
else
|
||||
{
|
||||
$fm->display();
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
useraccounts -- create/modify/delete user accounts
|
||||
|
||||
=head2 DESCRIPTION
|
||||
|
||||
This screen allows the administrator to create, modify or delete user
|
||||
accounts on the system.
|
||||
|
||||
=begin testing
|
||||
|
||||
use esmith::FormMagick::Tester;
|
||||
use esmith::TestUtils;
|
||||
use esmith::ConfigDB;
|
||||
use esmith::AccountsDB;
|
||||
|
||||
my $panel = $Original_File;
|
||||
my $ua = esmith::FormMagick::Tester->new();
|
||||
|
||||
my $c = esmith::ConfigDB->open();
|
||||
my $a = esmith::AccountsDB->open();
|
||||
|
||||
is (mode($panel), '4755', "Check permissions on script");
|
||||
ok ($ua->get_panel($panel), "ABOUT TO RUN L10N TESTS");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/FORM_TITLE/, "Saw untranslated form title");
|
||||
ok ($ua->set_language("en-us"), "Set language to U.S. English");
|
||||
ok ($ua->get_panel($panel), "Get panel");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/User accounts/, "Saw translated form title");
|
||||
|
||||
|
||||
#
|
||||
# Testing creating users
|
||||
#
|
||||
|
||||
ok ($ua->get_panel($panel), "ABOUT TO TEST CREATING USER");
|
||||
ok ($ua->follow("Click here"), "Follow 'create user' link");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/Account name/, "Saw form fields");
|
||||
|
||||
#
|
||||
# Check that address details are picked up from LDAP
|
||||
#
|
||||
|
||||
my $ldap_record = $c->get('ldap');
|
||||
my $city = $ldap_record->prop('DefaultCity');
|
||||
|
||||
like($ua->{content}, qr/$city/, "Pick up address from LDAP");
|
||||
|
||||
#
|
||||
# Creating a new user
|
||||
#
|
||||
|
||||
my $new_username = new_random_username();
|
||||
|
||||
can_ok($ua, "field");
|
||||
ok ($ua->{form}->find_input('acctName'),
|
||||
"Find acctName field to fill in");
|
||||
$ua->field("acctName" => $new_username);
|
||||
ok ($ua->click("Save"), "Click Save");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/must not be left blank/, "Saw validation messages");
|
||||
|
||||
$ua->field("FirstName" => "Fred");
|
||||
$ua->field("LastName" => "Foonly");
|
||||
|
||||
ok ($ua->click("Save"), "Click Save");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
|
||||
#
|
||||
# Testing modify user
|
||||
#
|
||||
|
||||
ok ($ua->get_panel($panel), "ABOUT TO TEST MODIFYING A USER");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
ok ($ua->follow('Modify'), "Follow modify link");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/value="Save"/, "Saw 'Save' on the button");
|
||||
|
||||
#
|
||||
# Testing removal of a user
|
||||
#
|
||||
|
||||
ok ($ua->get_panel($panel), "ABOUT TO TEST USER REMOVAL");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
ok ($ua->follow('Remove'), "Follow remove link");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/Remove/, "Saw 'Remove'");
|
||||
like($ua->{content}, qr/value="Remove"/, "Saw 'Remove' on the button");
|
||||
|
||||
#
|
||||
# Testing password reset
|
||||
#
|
||||
|
||||
ok ($ua->get_panel($panel), "ABOUT TO TEST PASSWORD RESET");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
ok ($ua->follow('Reset password'), "Follow reset password link");
|
||||
like($ua->{content}, qr/Reset password/,"Saw 'Reset password'");
|
||||
|
||||
SKIP:
|
||||
{
|
||||
skip 3, "Unsafe!" unless destruction_ok();
|
||||
$ua->field(password1 => "test");
|
||||
$ua->field(password2 => "test");
|
||||
ok($ua->click('Save'), "Set password to 'test', click Save");
|
||||
is($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/Click here/, "Returned to first page");
|
||||
}
|
||||
|
||||
=end testing
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
__DATA__
|
||||
<form title="FORM_TITLE" header="/etc/e-smith/web/common/head.tmpl" footer="/etc/e-smith/web/common/foot.tmpl">
|
||||
<page name="First" pre-event="print_status_message()">
|
||||
<description>FIRSTPAGE_DESC</description>
|
||||
<subroutine src="print_user_table()" />
|
||||
</page>
|
||||
<page name="CreateModify" pre-event="turn_off_buttons()" post-event="handle_user_accounts()">
|
||||
<title>P2_TITLE</title>
|
||||
<description>CREATE_MODIFY_DESC</description>
|
||||
<subroutine src="print_acctName_field()" />
|
||||
<field type="text" id="FirstName" validation="nonblank, pseudonym_clash">
|
||||
<label>FIRSTNAME</label>
|
||||
</field>
|
||||
<field type="text" id="LastName" validation="nonblank">
|
||||
<label>LASTNAME</label>
|
||||
</field>
|
||||
<field type="text" id="Dept"
|
||||
value="get_ldap_value('Dept')">
|
||||
<label>DEPARTMENT</label>
|
||||
</field>
|
||||
<field type="text" id="Company"
|
||||
value="get_ldap_value('Company')">
|
||||
<label>COMPANY</label>
|
||||
</field>
|
||||
<field type="text" id="Street"
|
||||
value="get_ldap_value('Street')">
|
||||
<label>STREET_ADDRESS</label>
|
||||
</field>
|
||||
<field type="text" id="City"
|
||||
value="get_ldap_value('City')">
|
||||
<label>CITY</label>
|
||||
</field>
|
||||
<field type="text" id="Phone"
|
||||
value="get_ldap_value('Phone')">
|
||||
<label>PHONE_NUMBER</label>
|
||||
</field>
|
||||
<field type="select" id="EmailForward" options="'local' =>
|
||||
'DELIVER_EMAIL_LOCALLY', 'forward' => 'FORWARD_EMAIL',
|
||||
'both' => 'DELIVER_AND_FORWARD'" validation="nonblank" value='local'
|
||||
display="display_email_forwarding()"
|
||||
>
|
||||
<label>EMAIL_DELIVERY</label>
|
||||
</field>
|
||||
<field type="text" id="ForwardAddress" validation="emailforward()"
|
||||
display="display_email_forwarding()"
|
||||
>
|
||||
<label>FORWARDING_ADDRESS</label>
|
||||
</field>
|
||||
<field type="select" id="VPNClientAccess" options="'yes' => 'YES',
|
||||
'no' => 'NO'" validation="nonblank" value="get_vpn_value()">
|
||||
<label>VPN_CLIENT_ACCESS</label>
|
||||
</field>
|
||||
<subroutine src="print_ipsec_client_section()" />
|
||||
<subroutine src="print_groupMemberships_field()" />
|
||||
<subroutine src="print_save_or_add_button()" />
|
||||
</page>
|
||||
<page name="ModifyAdmin" pre-event="turn_off_buttons()" post-event="modify_admin()">
|
||||
<title>MODIFY_ADMIN_TITLE</title>
|
||||
<subroutine src="print_acctName_field()" />
|
||||
<field type="text" id="FirstName" validation="nonblank, pseudonym_clash">
|
||||
<label>FIRSTNAME</label>
|
||||
</field>
|
||||
<field type="text" id="LastName" validation="nonblank">
|
||||
<label>LASTNAME</label>
|
||||
</field>
|
||||
<field type="select" id="EmailForward" options="'local' =>
|
||||
'DELIVER_EMAIL_LOCALLY', 'forward' => 'FORWARD_EMAIL',
|
||||
'both' => 'DELIVER_AND_FORWARD'" validation="nonblank" value='local'
|
||||
display="display_email_forwarding()"
|
||||
>
|
||||
<label>EMAIL_DELIVERY</label>
|
||||
</field>
|
||||
<field type="text" id="ForwardAddress" validation="emailforward()"
|
||||
display="display_email_forwarding()"
|
||||
>
|
||||
<label>FORWARDING_ADDRESS</label>
|
||||
</field>
|
||||
<field type="select" id="VPNClientAccess" options="'yes' => 'YES',
|
||||
'no' => 'NO'" validation="nonblank" value="get_vpn_value()">
|
||||
<label>VPN_CLIENT_ACCESS</label>
|
||||
</field>
|
||||
<subroutine src="print_ipsec_client_section()" />
|
||||
<subroutine src="print_button('SAVE')" />
|
||||
</page>
|
||||
<page name="ResetPasswordDummy">
|
||||
</page>
|
||||
<page name="ResetPassword" pre-event="turn_off_buttons()" post-event="reset_password()">
|
||||
<title>RESET_PASSWORD_TITLE</title>
|
||||
<subroutine src="print_page_description('reset')" />
|
||||
<field type="password" id="password1" validation="nonblank, check_password">
|
||||
<label>PASSWORD_NEW</label>
|
||||
</field>
|
||||
<field type="password" id="password2" validation="verifyPasswords">
|
||||
<label>PASSWORD_VERIFY_NEW</label>
|
||||
</field>
|
||||
<subroutine src="print_button('SAVE')" />
|
||||
</page>
|
||||
<page name="LockAccount" pre-event="turn_off_buttons()" post-event="lock_account()">
|
||||
<title>LOCK_ACCOUNT_TITLE</title>
|
||||
<subroutine src="print_page_description('lock')" />
|
||||
<subroutine src="print_button('LOCK')" />
|
||||
</page>
|
||||
<page name="RemoveAccount" pre-event="turn_off_buttons()" post-event="remove_account()">
|
||||
<title>REMOVE_ACCOUNT_TITLE</title>
|
||||
<subroutine src="print_page_description('remove')" />
|
||||
<subroutine src="print_button('REMOVE')" />
|
||||
</page>
|
||||
|
||||
<page name="SystemPasswordDummy">
|
||||
</page>
|
||||
<page name="SystemPassword" pre-event="turn_off_buttons()"
|
||||
post-event="system_change_password" >
|
||||
<description>SYSTEM_PASSWORD_DESCRIPTION</description>
|
||||
|
||||
<field type="password" id="curpass" validation="nonblank, system_authenticate_password">
|
||||
<label>CURRENT_SYSTEM_PASSWORD</label>
|
||||
</field>
|
||||
<field type="password" id="pass" validation="nonblank, system_check_password">
|
||||
<label>NEW_SYSTEM_PASSWORD</label>
|
||||
</field>
|
||||
<field type="password" id="passVerify" validation="system_password_compare">
|
||||
<label>NEW_SYSTEM_PASSWORD_VERIFY</label>
|
||||
</field>
|
||||
<subroutine src="print_button('SAVE')" />
|
||||
</page>
|
||||
</form>
|
151
root/etc/e-smith/web/functions/userpassword
Normal file
151
root/etc/e-smith/web/functions/userpassword
Normal file
@@ -0,0 +1,151 @@
|
||||
#!/usr/bin/perl -wT
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# e-smith manager functions: userpassword
|
||||
# copyright (C) 1999, 2000, 2001 e-smith, inc.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# Technical support for this program is available from e-smith, inc.
|
||||
# Please visit our web site www.e-smith.com for details.
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use esmith::FormMagick;
|
||||
use esmith::util;
|
||||
use esmith::ConfigDB;
|
||||
|
||||
our $configdb = esmith::ConfigDB->open();
|
||||
my $fm = new esmith::FormMagick;
|
||||
$fm->display();
|
||||
|
||||
sub change_password {
|
||||
my ($fm) = @_;
|
||||
|
||||
my $q = $fm->{cgi};
|
||||
|
||||
$q->param( -name => 'wherenext', -value => 'Done' );
|
||||
|
||||
my $oldPass = $q->param('oldPass');
|
||||
my $pass = $q->param('pass');
|
||||
my $acctName = $q->param('account');
|
||||
|
||||
unless (($oldPass) = ($oldPass =~ /^(\S+)$/ ))
|
||||
{
|
||||
$q->param(-name => 'status_message', -value => 'TAINTED_OLDPASS');
|
||||
return;
|
||||
}
|
||||
|
||||
unless (($pass) = ($pass =~ /^([ -~]+)$/ ))
|
||||
{
|
||||
$q->param(-name => 'status_message', -value => 'TAINTED_PASS');
|
||||
return;
|
||||
}
|
||||
|
||||
unless (($acctName) = ($acctName =~ /^([a-z][\-\_\.a-z0-9]*)$/ ))
|
||||
{
|
||||
$q->param(-name => 'status_message', -value => 'TAINTED_ACCOUNT');
|
||||
return;
|
||||
}
|
||||
|
||||
use esmith::AccountsDB;
|
||||
my $accountdb = esmith::AccountsDB->open();
|
||||
|
||||
my $acct;
|
||||
unless ($acct = $accountdb->get($acctName))
|
||||
{
|
||||
$q->param(-name => 'status_message', -value => 'YOUR_ACCOUNT_INVALID');
|
||||
return;
|
||||
}
|
||||
|
||||
unless ($acct->prop('type') eq 'user')
|
||||
{
|
||||
$q->param(-name=>'status_message', -value=>"YOUR_ACCOUNT_INVALID");
|
||||
return;
|
||||
}
|
||||
|
||||
unless (esmith::util::setUserPasswordRequirePrevious(
|
||||
$acctName,
|
||||
$oldPass,
|
||||
$pass))
|
||||
{
|
||||
$q->param(-name => 'status_message',
|
||||
-value => 'ERROR_PASSWORD_CHANGE');
|
||||
return;
|
||||
}
|
||||
$acct->set_prop("PasswordSet", "yes");
|
||||
undef $accountdb;
|
||||
|
||||
system("/sbin/e-smith/signal-event", "password-modify", $acctName) == 0
|
||||
or die ("Error occurred while modifying password for $acctName.\n");
|
||||
$accountdb = esmith::AccountsDB->open();
|
||||
|
||||
$q->param(-name => 'status_message', -value => 'PASSWORD_CHANGE_SUCCESS');
|
||||
return;
|
||||
}
|
||||
|
||||
sub password_compare {
|
||||
my $fm = shift;
|
||||
my $pass2 = shift;
|
||||
|
||||
my $pass1 = $fm->{cgi}->param('pass');
|
||||
unless ($pass1 eq $pass2) {
|
||||
$fm->{cgi}->param( -name => 'wherenext', -value => 'Password' );
|
||||
return "PASSWORD_VERIFY_ERROR";
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=head2 check_password
|
||||
|
||||
Validates the password using the desired strength
|
||||
|
||||
=cut
|
||||
|
||||
sub check_password {
|
||||
my $fm = shift;
|
||||
my $pass1 = shift;
|
||||
|
||||
my $check_type;
|
||||
my $rec = $configdb->get('passwordstrength');
|
||||
$check_type = ($rec ? ($rec->prop('Users') || 'none') : 'none');
|
||||
|
||||
return $fm->validate_password($check_type,$pass1);
|
||||
}
|
||||
|
||||
__DATA__
|
||||
<form title="ACCOUNT_PASSWORD_CHANGE" header="/etc/e-smith/web/common/userpassword_head.tmpl" footer="/etc/e-smith/web/common/foot.tmpl">
|
||||
<page name="Password" post-event="change_password" pre-event="turn_off_buttons()" header="/etc/e-smith/web/common/head.tmpl" footer="/etc/e-smith/web/common/foot.tmpl">
|
||||
<description>DESCRIPTION</description>
|
||||
|
||||
<field type="text" id="account" validation="nonblank" value="">
|
||||
<label>YOUR_ACCOUNT</label>
|
||||
</field>
|
||||
<field type="password" id="oldPass" validation="nonblank" value="">
|
||||
<label>PASSWORD_OLD</label>
|
||||
</field>
|
||||
<field type="password" id="pass" validation="nonblank, check_password" value="">
|
||||
<label>PASSWORD_NEW</label>
|
||||
</field>
|
||||
<field type="password" id="passVerify" validation="password_compare" value="">
|
||||
<label>PASSWORD_VERIFY_NEW</label>
|
||||
</field>
|
||||
<subroutine src="print_button('PASSWORD_CHANGE')" />
|
||||
</page>
|
||||
<page name="Done" pre-event="print_status_message()">
|
||||
</page>
|
||||
</form>
|
Reference in New Issue
Block a user