initial commit of file from CVS for e-smith-hosts on Wed 12 Jul 08:56:08 BST 2023
This commit is contained in:
parent
58e6e39b6f
commit
b45f3382c7
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*.rpm
|
||||
*.log
|
||||
*spec-20*
|
||||
*.tar.xz
|
21
Makefile
Normal file
21
Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
# Makefile for source rpm: e-smith-hosts
|
||||
# $Id: Makefile,v 1.1 2016/02/05 22:56:04 stephdl Exp $
|
||||
NAME := e-smith-hosts
|
||||
SPECFILE = $(firstword $(wildcard *.spec))
|
||||
|
||||
define find-makefile-common
|
||||
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
|
||||
endef
|
||||
|
||||
MAKEFILE_COMMON := $(shell $(find-makefile-common))
|
||||
|
||||
ifeq ($(MAKEFILE_COMMON),)
|
||||
# attept a checkout
|
||||
define checkout-makefile-common
|
||||
test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
|
||||
endef
|
||||
|
||||
MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
|
||||
endif
|
||||
|
||||
include $(MAKEFILE_COMMON)
|
16
README.md
16
README.md
@ -1,3 +1,17 @@
|
||||
# e-smith-hosts
|
||||
# <img src="https://www.koozali.org/images/koozali/Logo/Png/Koozali_logo_2016.png" width="25%" vertical="auto" style="vertical-align:bottom"> e-smith-hosts
|
||||
|
||||
SMEServer Koozali developed git repo for e-smith-hosts smeserver
|
||||
|
||||
## Wiki
|
||||
<br />https://wiki.koozali.org/
|
||||
|
||||
## Bugzilla
|
||||
Show list of outstanding bugs: [here](https://bugs.koozali.org/buglist.cgi?component=e-smith-hosts&product=SME%20Server%2010.X&query_format=advanced&limit=0&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=CONFIRMED)
|
||||
|
||||
## Description
|
||||
|
||||
<br />*This description has been generated by an LLM AI system and cannot be relied on to be fully correct.*
|
||||
*Once it has been checked, then this comment will be deleted*
|
||||
<br />
|
||||
|
||||
e-smith-hosts is a software used to manage the local and remote addresses of a network. It is a powerful tool for network administrators that allows them to maintain secure and efficient networks. It can be used to add and remove IP addresses and hostnames of local and remote computers, and it also allows users to define DNS records for each host. It also lets administrators maintain an efficient firewall configuration, which is essential in preventing malicious attacks and data breaches. e-smith-hosts is a powerful and versatile tool that can help administrators maintain a secure and efficient network.
|
||||
|
340
additional/COPYING
Normal file
340
additional/COPYING
Normal file
@ -0,0 +1,340 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
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
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
1
contriborbase
Normal file
1
contriborbase
Normal file
@ -0,0 +1 @@
|
||||
sme10
|
69
createlinks
Normal file
69
createlinks
Normal file
@ -0,0 +1,69 @@
|
||||
#!/usr/bin/perl -w
|
||||
# This script creates the symlinks needed by this RPM
|
||||
# Specific support exists to create symlinks within e-smith web "panels"
|
||||
# and for links from named "events" directories into the "actions" directory
|
||||
|
||||
use strict;
|
||||
use esmith::Build::CreateLinks qw(:all);
|
||||
|
||||
#--------------------------------------------------
|
||||
# functions for manager panel
|
||||
#--------------------------------------------------
|
||||
my $panel = "manager";
|
||||
|
||||
panel_link("hostentries", $panel);
|
||||
|
||||
#--------------------------------------------------
|
||||
# link in the appropriate actions
|
||||
#--------------------------------------------------
|
||||
my $event;
|
||||
|
||||
foreach $event ( qw(host-create host-delete host-modify) )
|
||||
{
|
||||
safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/dhcpd");
|
||||
safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/tinydns");
|
||||
safe_symlink("sigterm", "root/etc/e-smith/events/$event/services2adjust/dnscache");
|
||||
}
|
||||
|
||||
#--------------------------------------------------
|
||||
# actions for bootstrap-console-save event
|
||||
#--------------------------------------------------
|
||||
$event = "bootstrap-console-save";
|
||||
|
||||
event_link("conf-hostsdb", $event , "03");
|
||||
event_link("purge-domain", $event, "04");
|
||||
|
||||
#--------------------------------------------------
|
||||
# actions for console-save event
|
||||
#--------------------------------------------------
|
||||
$event = "console-save";
|
||||
|
||||
event_link("conf-hostsdb", $event , "04");
|
||||
|
||||
#--------------------------------------------------
|
||||
# actions for domain-create event
|
||||
#--------------------------------------------------
|
||||
$event = "domain-create";
|
||||
|
||||
event_link("create-default-hosts", $event, "04");
|
||||
|
||||
#--------------------------------------------------
|
||||
# actions for domain-delete event
|
||||
#--------------------------------------------------
|
||||
$event = "domain-delete";
|
||||
|
||||
event_link("purge-domain", $event, "04");
|
||||
|
||||
#--------------------------------------------------
|
||||
# e-smith-hosts-update event
|
||||
#--------------------------------------------------
|
||||
$event="e-smith-hosts-update";
|
||||
|
||||
safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/dhcpd");
|
||||
safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/tinydns");
|
||||
safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/dnscache");
|
||||
event_link("conf-hostsdb", $event , "03");
|
||||
event_link("purge-domain", $event, "04");
|
||||
# systemd-specific action mandatory for this package-update event
|
||||
event_link("systemd-reload", $event, "89");
|
||||
event_link("systemd-default", $event, "88");
|
1099
e-smith-hosts.spec
Normal file
1099
e-smith-hosts.spec
Normal file
File diff suppressed because it is too large
Load Diff
38
root/etc/e-smith/db/hosts/migrate/10reformat
Normal file
38
root/etc/e-smith/db/hosts/migrate/10reformat
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
foreach my $host ($DB->get_all)
|
||||
{
|
||||
next if defined $host->prop('HostType');
|
||||
|
||||
my %properties;
|
||||
$properties{'InternalIP'} = $host->prop('InternalIP') || '';
|
||||
$properties{'ExternalIP'} = $host->prop('ExternalIP') || '';
|
||||
$properties{'MACAddress'} = $host->prop('MACAddress') || '';
|
||||
|
||||
# If defined as host 'self', change to new format
|
||||
if (($properties{'InternalIP'} eq 'self') &&
|
||||
($properties{'ExternalIP'} eq 'self'))
|
||||
{
|
||||
$properties{'HostType'} = 'Self';
|
||||
$properties{'InternalIP'} = '';
|
||||
$properties{'ExternalIP'} = '';
|
||||
$properties{'MACAddress'} = '';
|
||||
}
|
||||
# defined as 'local' entry in new format
|
||||
elsif( $properties{InternalIP} ne 'self' )
|
||||
{
|
||||
$properties{'HostType'} = 'Local';
|
||||
$properties{ExternalIP} = '';
|
||||
}
|
||||
elsif( $properties{ExternalIP} ne 'self' )
|
||||
{
|
||||
$properties{'HostType'} = 'Remote';
|
||||
$properties{InternalIP} = '';
|
||||
}
|
||||
else {
|
||||
warn "$host has no InternalIP or ExternalIP!\n";
|
||||
}
|
||||
|
||||
$host->delete_prop('Visibility');
|
||||
$host->merge_props(%properties);
|
||||
}
|
||||
}
|
22
root/etc/e-smith/db/hosts/migrate/10sanitise-db
Normal file
22
root/etc/e-smith/db/hosts/migrate/10sanitise-db
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
foreach my $host ($DB->get_all)
|
||||
{
|
||||
my $lc_key = lc($host->key);
|
||||
|
||||
next if ( $lc_key eq $host->key );
|
||||
|
||||
my $rec = $DB->get($lc_key);
|
||||
|
||||
if ($rec)
|
||||
{
|
||||
warn "HostsDB: " . $host->key .
|
||||
" NOT migrated as $lc_key exists\n";
|
||||
next;
|
||||
}
|
||||
|
||||
$rec = $DB->new_record($lc_key);
|
||||
$rec->merge_props($host->props);
|
||||
|
||||
$host->delete;
|
||||
}
|
||||
}
|
20
root/etc/e-smith/db/hosts/migrate/20eachdomain
Normal file
20
root/etc/e-smith/db/hosts/migrate/20eachdomain
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
use esmith::DomainsDB;
|
||||
my $ddb = esmith::DomainsDB->open_ro;
|
||||
# If there's no domains db, there's nothing to do
|
||||
return unless $ddb;
|
||||
|
||||
# For any bare hostname, create a qualified host record
|
||||
# for each domain, then delete the bare host record
|
||||
foreach my $host (grep { $_->key !~ /\./ } $DB->get_all)
|
||||
{
|
||||
my $key = $host->key;
|
||||
foreach my $d ($ddb->domains)
|
||||
{
|
||||
$d = $d->key;
|
||||
next if $DB->get("$key.$d");
|
||||
$DB->new_record("$key.$d", { $host->props });
|
||||
}
|
||||
$host->delete;
|
||||
}
|
||||
}
|
10
root/etc/e-smith/db/hosts/migrate/30sanitise_host_comment
Normal file
10
root/etc/e-smith/db/hosts/migrate/30sanitise_host_comment
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
# Purge quoting chars in comments to fix bug 8723 & bug 8806
|
||||
foreach my $host ($DB->get_all)
|
||||
{
|
||||
my $comment = $host->prop('Comment');
|
||||
next unless $comment;
|
||||
$comment =~ s/[^a-zA-Z0-9\ \_\-\,\.]+//g;
|
||||
$host->merge_props(Comment => $comment);
|
||||
}
|
||||
}
|
28
root/etc/e-smith/events/actions/conf-hostsdb
Normal file
28
root/etc/e-smith/events/actions/conf-hostsdb
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 1999-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
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Create the default hosts for the primary domain in
|
||||
# bootstrap-console-save
|
||||
#------------------------------------------------------------
|
||||
|
||||
exec /etc/e-smith/events/actions/create-default-hosts domain-create \
|
||||
$(/sbin/e-smith/config get DomainName)
|
272
root/etc/e-smith/events/actions/conf-migrate-hosts
Normal file
272
root/etc/e-smith/events/actions/conf-migrate-hosts
Normal file
@ -0,0 +1,272 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# 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
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#--------------------------------------------------
|
||||
# Names in the hosts database can be:
|
||||
# - Internal name only (name for host on local LAN)
|
||||
# hp4500=host|InternalIP|192.168.16.201|MacAddress|aa:bb:cc:dd:ee:ff
|
||||
#
|
||||
# - Hosted by e-smith server (internal/external on e-smith server)
|
||||
# mail=host|ExternalIP|self|InternalIP|self
|
||||
#
|
||||
# - Externally hosted
|
||||
# www=host|ExternalIP|a.b.c.d
|
||||
#
|
||||
# - Internal machine behind port-forwarding firewall
|
||||
# secure=host|ExternalIP|d.e.f.g|InternalIP|w.x.y.z
|
||||
#
|
||||
# Unqualified names in the key apply to all domains
|
||||
# FQDNs apply to specific domains and override the wildcard shortnames
|
||||
#--------------------------------------------------
|
||||
package esmith;
|
||||
|
||||
use strict;
|
||||
use Errno;
|
||||
use esmith::HostsDB;
|
||||
my $hdb = esmith::HostsDB->open();
|
||||
|
||||
=begin testing
|
||||
|
||||
use esmith::TestUtils qw(scratch_copy);
|
||||
|
||||
my $h_tmp = '50-hosts/hosts.conf.4.1.2';
|
||||
my $c_scratch = scratch_copy('50-hosts/configuration.conf');
|
||||
$ENV{ESMITH_HOSTS_DB} = $h_tmp;
|
||||
$ENV{ESMITH_CONFIG_DB} = $c_scratch;
|
||||
|
||||
# 4.1.2 Hosts DB which caused bug 2495
|
||||
open(TMP, ">$h_tmp") || die $!;
|
||||
print TMP <<'OUT';
|
||||
archie=host|ExternalIP|209.28.139.23|InternalIP|self
|
||||
e-smith=host|ExternalIP|self|InternalIP|self
|
||||
e-smith-manager=host|ExternalIP|self|InternalIP|self
|
||||
ftp=host|ExternalIP|self|InternalIP|self
|
||||
mail=host|ExternalIP|self|InternalIP|self
|
||||
proxy=host|ExternalIP|self|InternalIP|self
|
||||
server=host|ExternalIP|self|InternalIP|self
|
||||
www=host|ExternalIP|self|InternalIP|202.49.164.27
|
||||
OUT
|
||||
close TMP;
|
||||
|
||||
END { unlink $h_tmp }
|
||||
|
||||
system($^X, $Original_File);
|
||||
|
||||
use esmith::ConfigDB;
|
||||
use esmith::HostsDB;
|
||||
my $migrated = esmith::HostsDB->open;
|
||||
my $config = esmith::ConfigDB->open;
|
||||
my $domain = $config->get('DomainName')->value;
|
||||
|
||||
my $www = $migrated->get("www.$domain");
|
||||
isa_ok( $www, 'esmith::DB::Record' );
|
||||
is( $www->prop('InternalIP'), '202.49.164.27' );
|
||||
is( $www->prop('ExternalIP'), '' );
|
||||
is( $www->prop('HostType'), 'Local' );
|
||||
|
||||
my $archie = $migrated->get("archie.$domain");
|
||||
isa_ok( $archie, 'esmith::DB::Record' );
|
||||
is( $archie->prop('InternalIP'), '', 'InternalIP');
|
||||
is( $archie->prop('ExternalIP'), '209.28.139.23', 'ExternalIP' );
|
||||
is( $archie->prop('HostType'), 'Remote', 'HostType' );
|
||||
|
||||
|
||||
my @migrated = grep { $_->key !~ /^(archie|www)/ }
|
||||
$migrated->get_all_by_prop(type => 'host');
|
||||
is_deeply( [ sort map { $_->key } @migrated ],
|
||||
[ sort map { "$_.$domain" }
|
||||
qw( e-smith e-smith-manager ftp mail proxy server )],
|
||||
'domain names fully qualified'
|
||||
);
|
||||
|
||||
foreach my $host (@migrated) {
|
||||
my $dn = $host->key;
|
||||
is( $host->prop('HostType'), 'Self', "$dn - HostType");
|
||||
is( $host->prop('ExternalIP'), '' , " ExternalIP" );
|
||||
is( $host->prop('InternalIP'), '' , " InternalIP" );
|
||||
}
|
||||
|
||||
=end testing
|
||||
|
||||
=cut
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Populate the hosts database with default entries if they
|
||||
# they don't already exist
|
||||
#------------------------------------------------------------
|
||||
my $event = $ARGV [0];
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Migrate existing hosts to new format for primary domain, and
|
||||
# for any existing virtual domains
|
||||
#
|
||||
# eg. www=host|... -> www.{$DomainName}=host|...
|
||||
#------------------------------------------------------------
|
||||
|
||||
my @FQDNHostList = ();
|
||||
my @ShortHostList = ();
|
||||
|
||||
foreach my $host ($hdb->hosts)
|
||||
{
|
||||
if ($host->key =~ /\./)
|
||||
{
|
||||
# keep track of fully qualified domain name hosts
|
||||
push @FQDNHostList, $host->key;
|
||||
}
|
||||
else
|
||||
{
|
||||
# keep track of single word hosts
|
||||
push @ShortHostList, $host->key;
|
||||
}
|
||||
}
|
||||
|
||||
# Get the list of local domain names
|
||||
use esmith::DomainsDB;
|
||||
my $ddb = esmith::DomainsDB->open_ro();
|
||||
|
||||
my @domainsList = map { $_-> key } $ddb->domains;
|
||||
|
||||
eval "require esmith::NetworkServicesDB";
|
||||
|
||||
unless ($@)
|
||||
{
|
||||
my $nsdb = esmith::NetworkServicesDB->open();
|
||||
|
||||
if ($nsdb)
|
||||
{
|
||||
my $service_domain = $nsdb->service_domain();
|
||||
|
||||
push @domainsList, $service_domain if $service_domain;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
# Iterate over each domain to propagate the single host
|
||||
# entries for each virtual domain
|
||||
#-------------------------------------------------------
|
||||
|
||||
foreach my $domain ( @domainsList )
|
||||
{
|
||||
# default visibility property is 'Local' as this never existed before
|
||||
|
||||
my %properties = (
|
||||
Visibility => 'Local'
|
||||
);
|
||||
|
||||
foreach my $host ( @ShortHostList )
|
||||
{
|
||||
$properties{'InternalIP'} =
|
||||
$hdb->get_prop ($host, 'InternalIP') || '';
|
||||
|
||||
$properties{'ExternalIP'} =
|
||||
$hdb->get_prop ($host, 'ExternalIP') || '';
|
||||
|
||||
$properties{'MACAddress'} =
|
||||
$hdb->get_prop ($host, 'MACAddress') || '';
|
||||
|
||||
my $FQDN = "$host.$domain";
|
||||
|
||||
next if (defined $hdb->get ($FQDN));
|
||||
|
||||
# If defined as host 'self', change to new format
|
||||
if (($properties{'InternalIP'} eq 'self') &&
|
||||
($properties{'ExternalIP'} eq 'self'))
|
||||
{
|
||||
$properties{'HostType'} = 'Self';
|
||||
$properties{'InternalIP'} = '';
|
||||
$properties{'ExternalIP'} = '';
|
||||
$properties{'MACAddress'} = '';
|
||||
}
|
||||
# defined as 'local' entry in new format
|
||||
elsif( $properties{InternalIP} ne 'self' )
|
||||
{
|
||||
$properties{'HostType'} = 'Local';
|
||||
$properties{ExternalIP} = '';
|
||||
}
|
||||
elsif( $properties{ExternalIP} ne 'self' )
|
||||
{
|
||||
$properties{'HostType'} = 'Remote';
|
||||
$properties{InternalIP} = '';
|
||||
}
|
||||
else {
|
||||
warn "$host has no InternalIP or ExternalIP!\n";
|
||||
}
|
||||
|
||||
$properties{'type'} = 'host';
|
||||
$hdb->new_record($FQDN, \%properties);
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
# Iterate over all of the fully qualified domain names,
|
||||
# setting valid ones (from @domainsList) with appropriate
|
||||
# values and flagging other non-expected ones with errors
|
||||
#-------------------------------------------------------
|
||||
|
||||
foreach my $key ( @FQDNHostList )
|
||||
{
|
||||
# Skip the hosts if already in the new format
|
||||
next if (defined $hdb->get_prop ($key, 'HostType'));
|
||||
|
||||
my %properties = (
|
||||
Visibility => 'Local'
|
||||
);
|
||||
|
||||
my ($tempHost, $tempDomain) = split /\./, $key, 2;
|
||||
|
||||
my @matches = grep(/$tempDomain/, @domainsList);
|
||||
|
||||
unless (@matches)
|
||||
{
|
||||
# doesn't match an existing domain, set error flag
|
||||
$properties{'error'} = 'Host has no matching domain in system';
|
||||
}
|
||||
|
||||
$properties{'InternalIP'} = $hdb->get_prop ($key, 'InternalIP') || '';
|
||||
$properties{'ExternalIP'} = $hdb->get_prop ($key, 'ExternalIP') || '';
|
||||
$properties{'MACAddress'} = $hdb->get_prop ($key, 'MACAddress') || '';
|
||||
|
||||
# If defined as host 'self', change to new format
|
||||
if ($properties{'InternalIP'} eq 'self')
|
||||
{
|
||||
$properties{'HostType'} = 'Self';
|
||||
$properties{'InternalIP'} = '';
|
||||
$properties{'ExternalIP'} = '';
|
||||
$properties{'MACAddress'} = '';
|
||||
}
|
||||
else # defined as 'local' entry in new format
|
||||
{
|
||||
$properties{'HostType'} = 'Local';
|
||||
$properties{'ExternalIP'} = '';
|
||||
}
|
||||
|
||||
$properties{'type'} = 'host';
|
||||
$hdb->new_record($key, \%properties);
|
||||
}
|
||||
|
||||
|
||||
# Remove the old single host entries
|
||||
foreach my $host ( @ShortHostList )
|
||||
{
|
||||
$hdb->get($host)->delete;
|
||||
}
|
||||
|
||||
exit (0);
|
69
root/etc/e-smith/events/actions/create-default-hosts
Normal file
69
root/etc/e-smith/events/actions/create-default-hosts
Normal file
@ -0,0 +1,69 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 1999-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
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
package esmith;
|
||||
|
||||
use strict;
|
||||
use Errno;
|
||||
use esmith::ConfigDB;
|
||||
use esmith::HostsDB;
|
||||
|
||||
my $db = esmith::ConfigDB->open_ro();
|
||||
|
||||
my $hdb = esmith::HostsDB->open();
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Populate the hosts database with default entries for a given
|
||||
# domain if they don't already exist
|
||||
#------------------------------------------------------------
|
||||
my $event = $ARGV [0] or die "Must provide event name arg";
|
||||
my $domain = $ARGV [1] or die "Must provide domain name arg";
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Create a default host for the SystemName which includes
|
||||
# a property static=yes (meaning not editable from the interface)
|
||||
#
|
||||
# Also create a set of default host records of type "Self".
|
||||
#------------------------------------------------------------
|
||||
|
||||
my $systemName = $db->get('SystemName')->value;
|
||||
|
||||
foreach my $host (qw(ftp mail www proxy wpad), $systemName)
|
||||
{
|
||||
my $FQDN = join ".", $host, $domain;
|
||||
next if (defined $hdb->get($FQDN));
|
||||
|
||||
my %properties = (
|
||||
type => 'host',
|
||||
HostType => 'Self',
|
||||
InternalIP => '',
|
||||
ExternalIP => '',
|
||||
MACAddress => ''
|
||||
);
|
||||
if ($host eq $systemName)
|
||||
{
|
||||
$properties{static} = "yes";
|
||||
}
|
||||
|
||||
$hdb->new_record($FQDN, \%properties);
|
||||
}
|
||||
|
||||
exit (0);
|
67
root/etc/e-smith/events/actions/purge-domain
Normal file
67
root/etc/e-smith/events/actions/purge-domain
Normal file
@ -0,0 +1,67 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 1999-2005 Mitel Networks Corporation
|
||||
# Copyright (C) 2005 Gordon Rowell <gordonr@gormand.com.au>
|
||||
#
|
||||
# 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 esmith;
|
||||
|
||||
use strict;
|
||||
use esmith::util;
|
||||
use esmith::DomainsDB;
|
||||
use esmith::HostsDB;
|
||||
use esmith::AccountsDB;
|
||||
|
||||
my $domainsdb = esmith::DomainsDB->open_ro;
|
||||
my $hostsdb = esmith::HostsDB->open;
|
||||
my $accountsdb = esmith::AccountsDB->open;
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Remove all hosts for the domain being deleted
|
||||
#------------------------------------------------------------
|
||||
|
||||
my $event = $ARGV [0];
|
||||
# my $domain = $ARGV[1]; # Unused
|
||||
|
||||
# Look for invalid hosts in the hostsdb.
|
||||
my %domain_names = map { $_->{key} => 1 } $domainsdb->domains;
|
||||
|
||||
# We want to check each host and see if it belongs to a domain that we are
|
||||
# currently managing. If not, delete it.
|
||||
foreach my $host ($hostsdb->hosts)
|
||||
{
|
||||
my ($hostpart, $domainpart) = split (/\./, $host->{key}, 2);
|
||||
|
||||
next if exists $domain_names{$domainpart};
|
||||
|
||||
$host->delete;
|
||||
}
|
||||
|
||||
# Ditto for pseudonyms
|
||||
for my $nym ($accountsdb->pseudonyms)
|
||||
{
|
||||
my ($host, $domain) = split (/\@/, $nym->{key}, 2);
|
||||
|
||||
next unless $domain;
|
||||
|
||||
next if exists $domain_names{$domain};
|
||||
|
||||
$nym->delete;
|
||||
}
|
||||
|
||||
exit 0;
|
288
root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/hostentries
Executable file
288
root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/hostentries
Executable file
@ -0,0 +1,288 @@
|
||||
<lexicon lang="en-us" params="lexicon_params()">
|
||||
<!-- vim: ft=xml
|
||||
-->
|
||||
<entry>
|
||||
<base>Hostnames and addresses</base>
|
||||
<trans>
|
||||
Hostnames and addresses
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>UNABLE_TO_OPEN_CONFIGDB</base>
|
||||
<trans>Unable to open configuration database</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>DNS_FORWARDER_ENABLED</base>
|
||||
<trans>
|
||||
A DNS forwarder has been configured. This means that all DNS
|
||||
lookups will be handled by the DNS forwarder. Hostnames
|
||||
and addresses cannot be modified on this server while
|
||||
a DNS forwarder is configured.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>ADD_HOSTNAME</base>
|
||||
<trans>
|
||||
<![CDATA[
|
||||
<a class="button-like" href="hostentries?page=0&page_stack=&Next=Next&wherenext=CreateModify">Add hostname</a>
|
||||
]]>
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>HOSTNAME</base>
|
||||
<trans>
|
||||
Hostname
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>HOSTTYPE</base>
|
||||
<trans>
|
||||
Location
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>LOCAL_IP</base>
|
||||
<trans>
|
||||
Local IP
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>ETHERNET_ADDRESS</base>
|
||||
<trans>
|
||||
Ethernet address
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>CURRENT_HOSTNAMES_FOR_DOMAIN</base>
|
||||
<trans>
|
||||
Current list of hostnames for {$domain}.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>NO_HOSTNAMES_FOR_SERVICENAME</base>
|
||||
<trans>
|
||||
There are no hostnames in the system for {$serviceName}.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>CURRENT_HOSTNAMES_FOR_LOCAL_DOMAIN</base>
|
||||
<trans>
|
||||
Current list of hostnames for {$localDomainName}
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>NO_HOSTNAMES_FOR_LOCAL_DOMAIN</base>
|
||||
<trans>
|
||||
There are no hostnames in the system for {$localDomainName}.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>STATIC_HOST_MESSAGE</base>
|
||||
<trans>
|
||||
- This host represents your system name and cannot be modified
|
||||
or removed.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>CREATE_LOCAL_HOST_TITLE</base>
|
||||
<trans>
|
||||
Create a new hostname for this server</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>HOSTNAME_VALIDATION_ERROR</base>
|
||||
<trans>
|
||||
Error: unexpected characters in host name:
|
||||
"{$HostName}". The host name should contain only
|
||||
letters, numbers, and hyphens and must start
|
||||
with a letter or a number.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>HOSTNAME_LENGTH_ERROR</base>
|
||||
<trans>
|
||||
Error: account name {$HostName} is too long. The
|
||||
maximum is 32 characters.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>DOMAIN_VALIDATION_ERROR</base>
|
||||
<trans>
|
||||
Error: unexpected or missing characters in domain name
|
||||
{$DomainName}. The domain name should contain one or more
|
||||
letters, numbers, periods and minus signs. Did not create new
|
||||
domain.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>HOSTNAME_EXISTS_ERROR</base>
|
||||
<trans>
|
||||
Error: account {$fullHostName} is an existing {$type} hostname.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>SUCCESSFULLY_CREATED</base>
|
||||
<trans>
|
||||
Successfully created hostname.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>HOSTNAME_DESCRIPTION</base>
|
||||
<trans>
|
||||
The hostname must contain only letters, numbers, and hyphens,
|
||||
and must start with a letter or number.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>LOCAL_IP_DESCRIPTION</base>
|
||||
<trans>
|
||||
The Local IP address is the IP address of another machine on
|
||||
the local network. Please enter a valid IP address in the
|
||||
format "aaa.bbb.ccc.ddd".
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>ETHERNET_ADDRESS_DESCRIPTION</base>
|
||||
<trans>
|
||||
The ethernet address is optional and causes the DHCP server to
|
||||
statically bind the local IP address to the computer with this
|
||||
ethernet address. If specified, it must be of the form
|
||||
"AA:BB:CC:DD:EE:FF" and must contain only the numbers 0-9 and
|
||||
the letters A-F.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>CREATE_LOCAL_HOST_TITLE</base>
|
||||
<trans>
|
||||
Create a new hostname referring to a local host.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>DIDNT_ENTER_LOCAL_IP</base>
|
||||
<trans>
|
||||
Error: You did not specify a Local IP address. IP
|
||||
addresses must contain only numbers and periods and
|
||||
be in the form "aaa.bbb.ccc.ddd". Did not create hostname.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>IP_VALIDATION_ERROR</base>
|
||||
<trans>
|
||||
Error: IP Address {$InternalIP} is
|
||||
invalid. IP Addresses must contain only numbers and periods and be in the form "aaa.bbb.ccc.ddd". Did not create hostname.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>MAC_ADDRESS_VALIDATION_ERROR</base>
|
||||
<trans>
|
||||
Error: Ethernet address {$MACAddress}
|
||||
is invalid. Ethernet addresses must be in the
|
||||
form "AA:BB:CC:DD:EE:FF" and only contain the
|
||||
numbers 0-9 and the letters A-F. Did not create
|
||||
hostname.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>CREATE_REMOTE_HOST_TITLE</base>
|
||||
<trans>
|
||||
Create a new hostname referring to a remote host
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>CREATE_TITLE</base>
|
||||
<trans>
|
||||
Create or modify hostname
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>LOCAL_PAGE_DESCRIPTION</base>
|
||||
<trans>
|
||||
Please enter the following additional details for a local
|
||||
host:
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>REMOTE_PAGE_DESCRIPTION</base>
|
||||
<trans>
|
||||
Please enter the following additional details for a remote
|
||||
host:
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>SUCCESSFULLY_DELETED</base>
|
||||
<trans>
|
||||
Successfully deleted host.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>SUCCESSFULLY_MODIFIED</base>
|
||||
<trans>
|
||||
Successfully modified host.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>REMOVE_PAGE_DESCRIPTION</base>
|
||||
<trans>
|
||||
<![CDATA[
|
||||
You are about to remove the hostname "{$hostname}.{$domain}".
|
||||
</p>
|
||||
<p>
|
||||
<b>Are you sure you wish to remove this hostname?</b>
|
||||
]]>
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>CONFIRM_DESCRIPTION</base>
|
||||
<trans>
|
||||
Please confirm the following details.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>NO_HOSTS_FOR_THIS_DOMAIN</base>
|
||||
<trans>
|
||||
There are no hosts for this domain.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>ADDR_IN_DHCP_RANGE</base>
|
||||
<trans>Address is inside the DHCP assigned dynamic range</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>ERROR_WHILE_CREATING_HOST</base>
|
||||
<trans>Error occurred while creating hostname.</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>ERROR_WHILE_MODIFYING_HOST</base>
|
||||
<trans>Error occurred while modifying hostname.</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>ERROR_WHILE_DELETING_HOST</base>
|
||||
<trans>Error occurred while deleting hostname.</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>ERR_IP_IS_LOCAL_OR_GATEWAY</base>
|
||||
<trans>Error: IP cannot be server IP or Gateway IP.</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>ERR_IP_NOT_LOCAL</base>
|
||||
<trans>Error: This IP address is not on any of our local
|
||||
networks.</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>MUST_BE_VALID_HOSTNAME_OR_IP</base>
|
||||
<trans>Must be a valid hostname or IP number</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>HOSTNAME_COMMENT_ERROR</base>
|
||||
<trans>
|
||||
Error: unexpected characters in the comment of "{$hostname}.{$domain}".
|
||||
The comment must contain only letters, spaces, numbers, dots, commas, undescores, hyphens and must start with a letter or number.
|
||||
</trans>
|
||||
</entry>
|
||||
<entry>
|
||||
<base>HOSTNAME_VALIDATOR_ERROR</base>
|
||||
<trans>
|
||||
Error: unexpected characters in host name: "{$hostname}.{$domain}". The host name should contain only
|
||||
letters, numbers, and hyphens and must start with a letter or a number.
|
||||
</trans>
|
||||
</entry>
|
||||
</lexicon>
|
27
root/etc/e-smith/templates/etc/dhcpd.conf/60StaticEntries
Normal file
27
root/etc/e-smith/templates/etc/dhcpd.conf/60StaticEntries
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
#------------------------------------------------------------
|
||||
# Static dhcp Entries
|
||||
#------------------------------------------------------------
|
||||
use esmith::HostsDB;
|
||||
my $hdb = esmith::HostsDB->open_ro();
|
||||
|
||||
foreach $host ($hdb->hosts)
|
||||
{
|
||||
my $InternalIP = $host->prop('InternalIP');
|
||||
next unless (defined($InternalIP) && ($InternalIP ne ''));
|
||||
|
||||
my $MACAddress = $host->prop('MACAddress');
|
||||
next unless ( defined($MACAddress) && ($MACAddress ne ''));
|
||||
|
||||
my $Filename = $host->prop('Filename');
|
||||
|
||||
$OUT .= "\n";
|
||||
$OUT .= "host " . $host->key . " \{\n";
|
||||
defined($Filename) and $OUT .= " filename \"$Filename\";\n";
|
||||
$OUT .= " hardware ethernet $MACAddress;\n";
|
||||
$OUT .= " fixed-address $InternalIP;\n";
|
||||
$OUT .= "\}";
|
||||
$OUT .= "\n";
|
||||
}
|
||||
undef; # We need a return value
|
||||
}
|
0
root/etc/e-smith/tests/50-hosts/.dummy
Normal file
0
root/etc/e-smith/tests/50-hosts/.dummy
Normal file
104
root/etc/e-smith/tests/50-hosts/configuration.conf
Normal file
104
root/etc/e-smith/tests/50-hosts/configuration.conf
Normal file
@ -0,0 +1,104 @@
|
||||
# DO NOT MODIFY THIS FILE.
|
||||
# This file is automatically maintained by the Mitel Networks SME Server
|
||||
# configuration software. Manually editing this file may put your
|
||||
# system in an unknown state.
|
||||
#
|
||||
# updated: Tue Apr 16 08:41:42 2002
|
||||
AccessType=dedicated
|
||||
ActiveAccounts=0
|
||||
AdminEmail=
|
||||
ConsoleMode=auto
|
||||
ContactEmail=
|
||||
ContactName=
|
||||
ContactOrg=
|
||||
DNSPrimaryIP=
|
||||
DNSSecondaryIP=
|
||||
DialupConnOffice=long
|
||||
DialupConnOutside=long
|
||||
DialupConnWeekend=long
|
||||
DialupFreqOffice=every15min
|
||||
DialupFreqOutside=everyhour
|
||||
DialupFreqWeekend=everyhour
|
||||
DialupModemDevice=/dev/ttyS1
|
||||
DialupPhoneNumber=
|
||||
DialupUserAccount=useraccount
|
||||
DialupUserPassword=userpassword
|
||||
DomainName=nssg.mitel.com
|
||||
EmailUnknownUser=return
|
||||
EthernetDriver1=pcnet32
|
||||
EthernetDriver2=unknown
|
||||
ExternalDHCP=off
|
||||
ExternalNetmask=255.255.255.0
|
||||
GatewayIP=10.33.15.1
|
||||
LocalIP=10.33.15.127
|
||||
LocalNetmask=255.255.255.0
|
||||
MinUid=5000
|
||||
NOCType=undefined
|
||||
PasswordSet=yes
|
||||
PreviousConfiguration=/home/e-smith/db/configuration.previous
|
||||
SMTPSmartHost=
|
||||
SambaDomainMaster=no
|
||||
SambaServerName=mitel-networks-server
|
||||
SambaWorkgroup=mitel-networks
|
||||
ServiceAccountId=
|
||||
ServiceDomainName=
|
||||
ServiceTargetIP=
|
||||
SquidParent=
|
||||
SquidParentPort=
|
||||
StatusReports=off
|
||||
SystemMode=serveronly
|
||||
SystemName=chocky
|
||||
TimeZone=US/Eastern
|
||||
UnsavedChanges=no
|
||||
atalk=service|InitscriptOrder|91|status|enabled
|
||||
auth=service|access|public|status|enabled
|
||||
blades=service|Host|service.e-smith.com|status|enabled
|
||||
bootstrap-console=service|InitscriptOrder|35|Run|no|status|enabled
|
||||
branding=service|modified|000000000000|status|enabled
|
||||
broker=service|DbHost|localhost|DbPass|nocpassword|DbPort|3306|DbUser|nocuser
|
||||
crond=service|InitscriptOrder|40|status|enabled
|
||||
ctrlaltdel=service|status|enabled
|
||||
dhcpd=service|InitscriptOrder|65|end|10.33.15.250|start|10.33.15.65|status|disabled
|
||||
diald=service|InitscriptOrder|57|status|disabled
|
||||
fetchmail=service|FreqOffice|every5min|FreqOutside|every30min|FreqWeekend|never|Method|standard|SecondaryMailAccount|popaccount|SecondaryMailPassword|poppassword|SecondaryMailServer|mail.myisp.xxx|status|disabled
|
||||
flexbackup=backupservice|erase_rewind_only|true
|
||||
ftp=service|access|private|accessLimits|off|status|enabled
|
||||
hdparm=service|InitscriptOrder|40|status|disabled
|
||||
horde=service|status|disabled
|
||||
httpd-admin=service|InitscriptOrder|86|status|enabled
|
||||
httpd-e-smith=service|InitscriptOrder|85|access|private|status|enabled
|
||||
imap=service|access|private|status|enabled
|
||||
imp=service|status|disabled
|
||||
ippp=service|InitscriptOrder|55|status|enabled
|
||||
ipsec=service|InitscriptOrder|90|PubKey|0sAQNRVkVir0fuYdTrXFJlWdQuBB3Z67JqdqjPJzIdxCec/ci4PgJ6nA6zsTe+VqVYzFwCz2MudYlEN0pzwMaNcXdFXhPXhb969klS90UhgB2OdImwqGtt++si/WJ9DT3NdGRFYIw1hPibd5NzjFi3fNVS4lW8oU4I4ic0q7vYVpXu2Q==|status|disabled
|
||||
isdn=service|Protocol|2|UseSyncPPP|yes|status|disabled
|
||||
keytable=service|InitscriptOrder|25|status|enabled
|
||||
ldap=service|InitscriptOrder|80|access|private|defaultCity|Ottawa|defaultCompany|XYZ Corporation|defaultDepartment|Main|defaultPhoneNumber|555-5555|defaultStreet|123 Main Street|status|enabled
|
||||
lilo=service|AddressMode|linear
|
||||
local=service|InitscriptOrder|99|status|enabled
|
||||
lpd=service|InitscriptOrder|60|status|enabled
|
||||
mariadb=service|InitscriptOrder|90|status|enabled
|
||||
masq=service|InitscriptOrder|06|Logging|none|Stealth|no|status|disabled
|
||||
modSSL=service|status|enabled
|
||||
mysql.init=service|InitscriptOrder|99|status|enabled
|
||||
named=service|chroot|yes|status|enabled
|
||||
network=service|InitscriptOrder|10|status|enabled
|
||||
ntpd=service|InitscriptOrder|55|status|disabled
|
||||
php=service|status|enabled
|
||||
popd=service|access|private|status|enabled
|
||||
pppoe=service|DemandIdleTime|no|InitscriptOrder|57|SynchronousPPP|no|status|disabled
|
||||
pptpd=service|sessions|10|status|disabled
|
||||
qmail=service|InitscriptOrder|80|status|enabled
|
||||
random=service|InitscriptOrder|20|status|enabled
|
||||
rsyslog=service|InitscriptOrder|05|status|enabled
|
||||
scanner=service|ScannerFns|iscan|UpdateTime|24:17|scanMail|yes|status|enabled
|
||||
smb=service|DomainMaster|no|InitscriptOrder|91|RoamingProfiles|no|ServerName|chocky|Workgroup|mitel-networks|status|enabled
|
||||
smtpfwdd=service|InitscriptOrder|81|status|enabled
|
||||
squid=service|InitscriptOrder|90|status|enabled
|
||||
sshd=service|InitscriptOrder|85|PasswordAuthentication|yes|PermitRootLogin|yes|access|private|status|enabled
|
||||
sync=service|Host|service.e-smith.com|LastId|0|SuccessId|0|SyncFrequency|1|SyncMinute|36|status|disabled
|
||||
telnet=service|access|private|status|disabled
|
||||
testing=service|destruction|0
|
||||
tinydns=service|InitscriptOrder|81|NOCServer|service.e-smith.com|Nameservers|ns1.e-smith.com,ns2.e-smith.com,ns3.e-smith.com,ns4.e-smith.com|PublishDomain|e-smith.net|SOA_Expiry|1048576|SOA_Minimum|2560|SOA_Refresh|16384|SOA_Retry|2048|status|enabled
|
||||
twig=service|status|disabled
|
||||
xinetd=service|InitscriptOrder|50|status|enabled
|
10
root/etc/e-smith/tests/50-hosts/hosts.conf
Normal file
10
root/etc/e-smith/tests/50-hosts/hosts.conf
Normal file
@ -0,0 +1,10 @@
|
||||
# DO NOT MODIFY THIS FILE.
|
||||
# This file is automatically maintained by the Mitel Networks SME Server
|
||||
# configuration software. Manually editing this file may put your
|
||||
# system in an unknown state.
|
||||
#
|
||||
# updated: Wed May 8 09:45:28 2002
|
||||
bar.invalid.tld=host|ExternalIP||HostType|Self|InternalIP||MACAddress||Visibility|Local
|
||||
baz.invalid.tld=host|ExternalIP||HostType|Self|InternalIP||MACAddress||Visibility|Local
|
||||
foo.invalid.tld=host|ExternalIP||HostType|Self|InternalIP||MACAddress||Visibility|Local
|
||||
wibble.invalid.tld=host|ExternalIP|InternalIP|MACAddress||Visibility|self
|
137
root/etc/e-smith/web/functions/hostentries
Executable file
137
root/etc/e-smith/web/functions/hostentries
Executable file
@ -0,0 +1,137 @@
|
||||
#!/usr/bin/perl -wT
|
||||
# vim: set ft=xml:
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# heading : Configuration
|
||||
# description : Hostnames and addresses
|
||||
# navigation : 6000 6500
|
||||
#----------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------
|
||||
# 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::hostentries;
|
||||
my $fm = esmith::FormMagick::Panel::hostentries->new();
|
||||
$fm->display();
|
||||
|
||||
=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");
|
||||
#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/Hostnames and addresses/, "Saw translated form title");
|
||||
|
||||
ok ($ua->get_panel($panel), "ABOUT TO TEST CREATING HOST");
|
||||
ok ($ua->follow("Click here"), "Follow 'create host' link");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
like($ua->{content}, qr/Create\/modify host/, "Saw page
|
||||
title");
|
||||
like($ua->{content}, qr/Publish globally/, "Saw fields");
|
||||
like($ua->{content}, qr/Next/, "Saw next button");
|
||||
|
||||
ok ($ua->get_panel($panel), "ABOUT TO TEST MODIFYING HOST");
|
||||
ok ($ua->follow("Modify"), "Follow 'modify' link");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
|
||||
ok ($ua->get_panel($panel), "ABOUT TO TEST REMOVING HOST");
|
||||
ok ($ua->follow("Remove"), "Follow 'remove' link");
|
||||
is ($ua->{status}, 200, "200 OK");
|
||||
|
||||
|
||||
=end testing
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
__DATA__
|
||||
<form title="Hostnames and addresses" 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="print_hosts_tables()" />
|
||||
</page>
|
||||
<page name="CreateModify" pre-event="turn_off_buttons()" post-event="more_options()">
|
||||
<title>CREATE_TITLE</title>
|
||||
<subroutine src="print_hostname_field()" />
|
||||
<subroutine src="print_domain_field()" />
|
||||
<field
|
||||
type="text" size="30"
|
||||
id="comment" >
|
||||
<label>COMMENT</label>
|
||||
</field>
|
||||
<field type="select"
|
||||
id="hosttype"
|
||||
options="'Self' => 'SELF', 'Local' => 'LOCAL', 'Remote' => 'REMOTE'"
|
||||
value='Self'>
|
||||
<label>LOCATION</label>
|
||||
</field>
|
||||
<subroutine src="print_button('NEXT')" />
|
||||
</page>
|
||||
<page name="Remove" pre-event="turn_off_buttons()" post-event="remove()">
|
||||
<description>REMOVE_PAGE_DESCRIPTION</description>
|
||||
<subroutine src="print_button('REMOVE')" />
|
||||
|
||||
</page>
|
||||
<page name="Local" pre-event="turn_off_buttons()"
|
||||
post-event="goto_confirm()">
|
||||
<description>LOCAL_PAGE_DESCRIPTION</description>
|
||||
<field type="text" id="local_ip"
|
||||
validation="ip_number, not_in_dhcp_range, not_taken, must_be_local">
|
||||
<label>LOCAL_IP</label>
|
||||
<description>LOCAL_IP_DESCRIPTION</description>
|
||||
</field>
|
||||
<field type="text" id="ethernet_address"
|
||||
validation="mac_address_or_blank">
|
||||
<label>ETHERNET_ADDRESS</label>
|
||||
<description>ETHERNET_ADDRESS_DESCRIPTION</description>
|
||||
</field>
|
||||
<subroutine src="print_button('NEXT')" />
|
||||
</page>
|
||||
<page name="Remote" pre-event="turn_off_buttons()" post-event="goto_confirm()">
|
||||
<description>REMOTE_PAGE_DESCRIPTION</description>
|
||||
<field type="text" id="global_ip" validation="hostname_or_ip">
|
||||
<label>IP_ADDRESS_OR_FQDN</label>
|
||||
</field>
|
||||
<subroutine src="print_button('NEXT')" />
|
||||
</page>
|
||||
|
||||
<page name="Confirm" pre-event="turn_off_buttons()"
|
||||
post-event="create_or_modify()">
|
||||
<description>CONFIRM_DESCRIPTION</description>
|
||||
<subroutine src="print_confirmation_details('FINISH')" />
|
||||
<subroutine src="print_save_or_add_button()" />
|
||||
</page>
|
||||
</form>
|
0
root/etc/e-smith/web/panels/manager/cgi-bin/.gitignore
vendored
Normal file
0
root/etc/e-smith/web/panels/manager/cgi-bin/.gitignore
vendored
Normal file
@ -0,0 +1,736 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 1999-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
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
package esmith::FormMagick::Panel::hostentries;
|
||||
|
||||
use strict;
|
||||
|
||||
use esmith::FormMagick;
|
||||
use esmith::ConfigDB;
|
||||
use esmith::DomainsDB;
|
||||
use esmith::HostsDB;
|
||||
use esmith::NetworksDB;
|
||||
use esmith::cgi;
|
||||
use esmith::util;
|
||||
use File::Basename;
|
||||
use Exporter;
|
||||
use Carp;
|
||||
use Net::IPv4Addr;
|
||||
use HTML::Entities;
|
||||
|
||||
our @ISA = qw(esmith::FormMagick Exporter);
|
||||
|
||||
our @EXPORT = qw(
|
||||
print_hosts_tables
|
||||
print_hostname_field
|
||||
print_domain_field
|
||||
domains_list
|
||||
more_options
|
||||
goto_confirm
|
||||
print_confirmation_details
|
||||
create_or_modify
|
||||
lexicon_params
|
||||
remove
|
||||
mac_address_or_blank
|
||||
not_in_dhcp_range
|
||||
print_save_or_add_button
|
||||
not_taken
|
||||
must_be_local
|
||||
hostname_or_ip
|
||||
);
|
||||
|
||||
our $VERSION = sprintf '%d.%03d', q$Revision: 1.54 $ =~ /: (\d+).(\d+)/;
|
||||
|
||||
our $db = esmith::ConfigDB->open();
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
esmith::FormMagick::Panels::hostentries - useful panel functions
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use esmith::FormMagick::Panels::hostentries;
|
||||
|
||||
my $panel = esmith::FormMagick::Panel::hostentries->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";
|
||||
|
||||
use_ok('esmith::FormMagick::Panel::hostentries');
|
||||
use vars qw($panel);
|
||||
ok($panel = esmith::FormMagick::Panel::hostentries->new(),
|
||||
"Create panel object");
|
||||
isa_ok($panel, 'esmith::FormMagick::Panel::hostentries');
|
||||
|
||||
=end testing
|
||||
|
||||
=cut
|
||||
|
||||
sub new
|
||||
{
|
||||
shift;
|
||||
my $self = esmith::FormMagick->new();
|
||||
$self->{calling_package} = (caller)[0];
|
||||
bless $self;
|
||||
# Uncomment the next line for debugging.
|
||||
#$self->debug(1);
|
||||
return $self;
|
||||
}
|
||||
|
||||
=head2 hostname_or_ip
|
||||
|
||||
Validation routine for the remote address field for network printers.
|
||||
|
||||
=for testing
|
||||
my $fm = esmith::FormMagick::Panel::hostentries->new();
|
||||
can_ok('main', 'hostname_or_ip');
|
||||
can_ok('CGI::FormMagick::Validator', 'ip_number');
|
||||
isnt(CGI::FormMagick::Validator::ip_number($fm, '1.2.3'), "OK", "ip_number works OK");
|
||||
like(CGI::FormMagick::Validator::ip_number($fm, '1.2.3'), qr(enough octets), "ip_number works OK");
|
||||
foreach ("1.2.3.4", "255.255.255.255", "foo.com", "foo.bar.com", "123.foo.xxx"){
|
||||
is(hostname_or_ip($fm, $_), "OK", "$_ should be OK");
|
||||
}
|
||||
foreach ("1.2.3", "foo bar", "foo;bar;com", " ", undef) {
|
||||
isnt(hostname_or_ip($fm, $_), "OK", "$_ should not be OK");
|
||||
}
|
||||
|
||||
=cut
|
||||
|
||||
sub hostname_or_ip
|
||||
{
|
||||
my ($fm, $data) = @_;
|
||||
if ($data =~ /^[\d\.]+$/) {
|
||||
if (CGI::FormMagick::Validator::ip_number($fm, $data) eq "OK")
|
||||
{
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "MUST_BE_VALID_HOSTNAME_OR_IP";
|
||||
}
|
||||
}
|
||||
elsif ($data =~ /^([a-zA-Z0-9\.\-]+)$/ )
|
||||
{
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "MUST_BE_VALID_HOSTNAME_OR_IP";
|
||||
}
|
||||
}
|
||||
|
||||
=head1 HTML GENERATION ROUTINES
|
||||
|
||||
Routines for generating chunks of HTML needed by the panel.
|
||||
|
||||
=for testing
|
||||
use_ok('esmith::DomainsDB');
|
||||
my $d = esmith::DomainsDB->create();
|
||||
isa_ok($d, 'esmith::DomainsDB');
|
||||
can_ok($d, 'domains');
|
||||
#can_ok($d, 'get_by_prop');
|
||||
|
||||
=cut
|
||||
|
||||
sub print_hosts_tables
|
||||
{
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
unless ($db)
|
||||
{
|
||||
$self->error('UNABLE_TO_OPEN_CONFIGDB', 'First');
|
||||
$self->print_status_message();
|
||||
return undef;
|
||||
}
|
||||
|
||||
unless (scalar @{$self->domains_list()})
|
||||
{
|
||||
$self->success('DNS_FORWARDER_ENABLED', 'First');
|
||||
$self->print_status_message();
|
||||
return undef;
|
||||
}
|
||||
|
||||
print $q->start_Tr,"<td>",$q->start_table ({-CLASS => "sme-noborders"}),"\n";
|
||||
print $q->start_Tr,"<td>",$self->localise('ADD_HOSTNAME'),"</td>",$q->end_Tr,"\n";
|
||||
|
||||
my $hosts_db = esmith::HostsDB->open();
|
||||
|
||||
foreach my $d (@{$self->domains_list()})
|
||||
{
|
||||
print $q->start_Tr,"<td>","\n";
|
||||
print $q->h3($self->localise('CURRENT_HOSTNAMES_FOR_DOMAIN', {domain => $d})),"\n";
|
||||
print "</td>",$q->end_Tr,"\n";
|
||||
|
||||
if (my @hosts = $hosts_db->get_hosts_by_domain($d))
|
||||
{
|
||||
print $q->start_Tr,"<td>\n",$q->start_table ({-CLASS => "sme-border"}),"\n";
|
||||
print $q->Tr (esmith::cgi::genSmallCell($q, $self->localise('HOSTNAME'),"header"),
|
||||
esmith::cgi::genSmallCell($q, $self->localise('LOCATION'),"header"),
|
||||
esmith::cgi::genSmallCell($q, $self->localise('IP_ADDRESS_OR_FQDN'),"header"),
|
||||
esmith::cgi::genSmallCell($q, $self->localise('ETHERNET_ADDRESS'),"header"),
|
||||
esmith::cgi::genSmallCell($q, $self->localise('COMMENT'),"header"),
|
||||
esmith::cgi::genSmallCell($q, $self->localise('ACTION'),"header",2));
|
||||
$self->print_host_row($_) foreach @hosts;
|
||||
print $q->end_table, "\n";
|
||||
print "</td>",$q->end_Tr,"\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print $q->start_Tr,"<td>\n";
|
||||
print $self->localise('NO_HOSTS_FOR_THIS_DOMAIN');
|
||||
print "</td>",$q->end_Tr,"\n";
|
||||
}
|
||||
}
|
||||
print $q->end_table,"\n";
|
||||
return undef;
|
||||
}
|
||||
|
||||
=head2 $panel->print_table_headers()
|
||||
|
||||
Prints the table header row for the hosts tables.
|
||||
|
||||
=for testing
|
||||
can_ok($panel, 'print_table_headers');
|
||||
can_ok($panel, 'localise');
|
||||
$panel->print_table_headers;
|
||||
like($_STDOUT_, qr(HOSTNAME), "Printed table headers");
|
||||
|
||||
=cut
|
||||
|
||||
sub print_table_headers
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
sub print_host_row
|
||||
{
|
||||
my ($self,$host_record) = @_;
|
||||
my $q = $self->{cgi};
|
||||
my $ht = $host_record->prop('HostType');
|
||||
my $ip =
|
||||
($ht eq 'Self') ? $db->get_value('LocalIP') :
|
||||
($ht eq 'Remote') ? $host_record->prop('ExternalIP') :
|
||||
$host_record->prop('InternalIP');
|
||||
|
||||
print $q->start_Tr;
|
||||
|
||||
$self->print_td($host_record->key());
|
||||
$self->print_td($self->localise($host_record->prop('HostType')) || " ");
|
||||
$self->print_td($ip);
|
||||
$self->print_td($host_record->prop('MACAddress') || " ");
|
||||
$self->print_td(HTML::Entities::encode($host_record->prop('Comment')) || " ");
|
||||
my $static = $host_record->prop('static') || "no";
|
||||
if ($static ne 'yes') {
|
||||
my $propstring = $self->build_host_cgi_params($host_record->key(), $host_record->props());
|
||||
$self->print_td(qq(<a href="hostentries?wherenext=CreateModify&$propstring">)
|
||||
. $self->localise('MODIFY')
|
||||
. qq(</a>\n));
|
||||
$self->print_td(qq(<a href="hostentries?wherenext=Remove&$propstring">)
|
||||
. $self->localise('REMOVE')
|
||||
. qq(</a>\n));
|
||||
} else {
|
||||
$self->print_td(" ");
|
||||
$self->print_td(" ");
|
||||
}
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
=for testing
|
||||
$panel->print_td("foo");
|
||||
like($_STDOUT_, qr(<td>foo</td>), "print_td");
|
||||
|
||||
=cut
|
||||
|
||||
sub print_td
|
||||
{
|
||||
my ($self, $value) = @_;
|
||||
print "<td class=\"sme-border\">$value</td>\n";
|
||||
}
|
||||
|
||||
sub build_host_cgi_params {
|
||||
my ($self, $hostname, %oldprops) = @_;
|
||||
|
||||
my ($host, $domain) = $self->split_hostname($hostname);
|
||||
|
||||
my %props = (
|
||||
page => 0,
|
||||
page_stack => "",
|
||||
".id" => $self->{cgi}->param('.id') || "",
|
||||
name => $host,
|
||||
domain => $domain,
|
||||
local_ip => $oldprops{InternalIP},
|
||||
global_ip => $oldprops{ExternalIP},
|
||||
ethernet_address => $oldprops{MACAddress},
|
||||
hosttype => $oldprops{HostType},
|
||||
comment => HTML::Entities::encode($oldprops{Comment}),
|
||||
);
|
||||
|
||||
return $self->props_to_query_string(\%props);
|
||||
}
|
||||
|
||||
=for testing
|
||||
my @expect = qw(foo bar.com);
|
||||
is_deeply(\@expect, [$panel->split_hostname("foo.bar.com")], "Split hostname");
|
||||
|
||||
=cut
|
||||
|
||||
sub split_hostname {
|
||||
my ($self, $hostname) = @_;
|
||||
return ($hostname =~ /^([^\.]+)\.(.+)$/);
|
||||
}
|
||||
|
||||
sub print_hostname_field {
|
||||
my $fm = shift;
|
||||
|
||||
print qq(<tr><td colspan=2>) . $fm->localise('HOSTNAME_DESCRIPTION') . qq(</td></tr>);
|
||||
print qq(<tr><td class="sme-noborders-label">) . $fm->localise('HOSTNAME') . qq(</td>\n);
|
||||
|
||||
my $h = $fm->{cgi}->param('name');
|
||||
|
||||
if ($h) {
|
||||
print qq(
|
||||
<td>$h
|
||||
<input type="hidden" name="name" value="$h">
|
||||
<input type="hidden" name="action" value="modify">
|
||||
</td>
|
||||
);
|
||||
} else {
|
||||
print qq(
|
||||
<td><input type="text" name="name">
|
||||
<input type="hidden" name="action" value="create">
|
||||
</td>
|
||||
);
|
||||
}
|
||||
|
||||
print qq(</tr>\n);
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
sub print_domain_field
|
||||
{
|
||||
my $fm = shift;
|
||||
print qq( <tr>) ."\n". qq( <td class="sme-noborders-label">) . $fm->localise('DOMAIN') . qq(</td>\n);
|
||||
|
||||
my $h = $fm->{cgi}->param('name');
|
||||
my $dom = $fm->{cgi}->param('domain');
|
||||
if ($h) {
|
||||
print qq(
|
||||
<td>$dom
|
||||
<input type="hidden" name="domain" value="$dom">
|
||||
</td>
|
||||
);
|
||||
} else {
|
||||
print qq(
|
||||
<td>
|
||||
<select type="select" name="domain">\n);
|
||||
foreach my $d (@{$fm->domains_list()})
|
||||
{
|
||||
print " <option>$d\n";
|
||||
}
|
||||
print qq(
|
||||
</select>
|
||||
</td>\n);
|
||||
}
|
||||
|
||||
print qq( </tr>\n);
|
||||
return undef;
|
||||
}
|
||||
|
||||
=head2 mac_address_or_blank
|
||||
|
||||
Validation routine for optional ethernet address
|
||||
|
||||
=for testing
|
||||
can_ok('main', 'mac_address_or_blank');
|
||||
is(mac_address_or_blank(undef, ""), "OK", "blank mac address is OK");
|
||||
is(mac_address_or_blank(undef, "aa:bb:cc:dd:ee:ff"), "OK", "OK mac address is OK");
|
||||
isnt(mac_address_or_blank(undef, "blah"), "OK", "wrong mac address is not OK");
|
||||
|
||||
=cut
|
||||
|
||||
sub mac_address_or_blank {
|
||||
my ($fm, $data) = @_;
|
||||
return "OK" unless $data;
|
||||
return CGI::FormMagick::Validator::mac_address($fm, $data);
|
||||
}
|
||||
|
||||
=for testing
|
||||
can_ok('main', 'domains_list');
|
||||
|
||||
=cut
|
||||
|
||||
sub domains_list
|
||||
{
|
||||
my $self = shift;
|
||||
|
||||
my $d = esmith::DomainsDB->open_ro() or die "Couldn't open DomainsDB";
|
||||
|
||||
my @domains;
|
||||
|
||||
for ($d->domains)
|
||||
{
|
||||
my $ns = $_->prop("Nameservers") || 'localhost';
|
||||
push @domains, $_->key if ($ns eq 'localhost');
|
||||
}
|
||||
|
||||
return \@domains;
|
||||
}
|
||||
|
||||
=for testing
|
||||
can_ok('main', 'more_options');
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
sub more_options
|
||||
{
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
my $hostsdb = esmith::HostsDB->open_ro;
|
||||
|
||||
my $hostname = lc $q->param('name');
|
||||
my $domain = lc $q->param('domain');
|
||||
my $fqdn = "$hostname.$domain";
|
||||
my $comment = $q->param('comment');
|
||||
$self->cgi->param(-name=>'name', -value=>$hostname);
|
||||
|
||||
unless ( $hostname =~ /^[a-z0-9][a-z0-9-]*$/ )
|
||||
{
|
||||
return $self->error('HOSTNAME_VALIDATOR_ERROR');
|
||||
}
|
||||
|
||||
unless ( $comment =~ /^([a-zA-Z0-9][\_\.\-,A-Za-z0-9\s]*)$/ || $comment eq '' )
|
||||
{
|
||||
return $self->error('HOSTNAME_COMMENT_ERROR');
|
||||
}
|
||||
# Look for duplicate hosts.
|
||||
my $hostrec = undef;
|
||||
if ($self->cgi->param('action') eq 'create' and $hostrec = $hostsdb->get($fqdn))
|
||||
{
|
||||
return $self->error(
|
||||
$self->localise('HOSTNAME_EXISTS_ERROR',
|
||||
{fullHostName => $fqdn,
|
||||
type => $hostrec->prop('HostType')}));
|
||||
}
|
||||
|
||||
my $hosttype = $self->cgi->param('hosttype');
|
||||
if ($hosttype eq 'Self') {
|
||||
$self->wherenext('Confirm');
|
||||
} elsif ($hosttype eq 'Local') {
|
||||
$self->wherenext('Local');
|
||||
} elsif ($hosttype eq 'Remote') {
|
||||
$self->wherenext('Remote');
|
||||
} else {
|
||||
$self->wherenext('Confirm');
|
||||
}
|
||||
}
|
||||
|
||||
=for testing
|
||||
can_ok('main', 'goto_confirm');
|
||||
|
||||
=cut
|
||||
|
||||
sub goto_confirm
|
||||
{
|
||||
my $self = shift;
|
||||
$self->wherenext('Confirm');
|
||||
}
|
||||
|
||||
=for testing
|
||||
can_ok('main', 'print_confirmation_details');
|
||||
|
||||
=cut
|
||||
|
||||
sub print_confirmation_details {
|
||||
my ($self) = @_;
|
||||
my $q = $self->{cgi};
|
||||
print $q->start_table ({-CLASS => "sme-border"}),"\n";
|
||||
|
||||
my $type = $self->{cgi}->param('hosttype') || '';
|
||||
if ($type eq "Self")
|
||||
{
|
||||
$self->{cgi}->delete('local_ip');
|
||||
$self->{cgi}->delete('global_ip');
|
||||
$self->{cgi}->delete('ethernet_address');
|
||||
}
|
||||
|
||||
if ($type eq "Remote")
|
||||
{
|
||||
$self->{cgi}->delete('local_ip');
|
||||
$self->{cgi}->delete('ethernet_address');
|
||||
}
|
||||
|
||||
if ($type eq "Local")
|
||||
{
|
||||
$self->{cgi}->delete('global_ip');
|
||||
}
|
||||
|
||||
my %label_map = (
|
||||
global_ip => "IP_ADDRESS_OR_FQDN",
|
||||
local_ip => "IP_ADDRESS",
|
||||
);
|
||||
foreach my $f (qw( name domain hosttype local_ip global_ip
|
||||
ethernet_address comment) ) {
|
||||
my $val = $self->cgi->param($f) || '';
|
||||
$self->debug_msg("looping on param $f, val is $val");
|
||||
next unless $val;
|
||||
my $label = $label_map{$f} || uc($f);
|
||||
print $q->Tr (esmith::cgi::genSmallCell($q, $self->localise($label),"normal"),
|
||||
esmith::cgi::genSmallCell($q, HTML::Entities::encode($val),"normal"));
|
||||
}
|
||||
|
||||
print qq(</table>);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
=head2 create_or_modify()
|
||||
|
||||
This is the subroutine that does the actual work when you create/modify
|
||||
a host.
|
||||
|
||||
=begin testing
|
||||
|
||||
#$ENV{ESMITH_HOSTS_DB} = scratch_copy("50-hosts/hosts.conf");
|
||||
$ENV{ESMITH_HOSTS_DB} = "50-hosts/hosts.conf";
|
||||
|
||||
ok($panel = esmith::FormMagick::Panel::hostentries->new(),
|
||||
"Create panel object");
|
||||
isa_ok($panel, 'esmith::FormMagick::Panel::hostentries');
|
||||
|
||||
$panel->{cgi} = CGI->new({
|
||||
name => 'wibble',
|
||||
domain => 'invalid.tld',
|
||||
hosttype => 'Self',
|
||||
action => 'create',
|
||||
});
|
||||
|
||||
$panel->create_or_modify();
|
||||
isnt($panel->cgi->param('status_message'), undef, "Set status message");
|
||||
|
||||
my $h = esmith::HostsDB->open();
|
||||
ok($h->get('wibble.invalid.tld'), "Host added to db");
|
||||
|
||||
=end testing
|
||||
|
||||
=cut
|
||||
|
||||
sub create_or_modify {
|
||||
my ($self) = @_;
|
||||
$self->wherenext('First');
|
||||
my $h = esmith::HostsDB->open() || esmith::HostsDB->create();
|
||||
my $hostname = $self->cgi->param('name') . "." .
|
||||
$self->cgi->param('domain');
|
||||
|
||||
# Untaint and lowercase $hostname
|
||||
$hostname =~ /([\w\.-]+)/; $hostname = lc($1);
|
||||
|
||||
my %props = (
|
||||
type => 'host',
|
||||
HostType => $self->cgi->param('hosttype') || "",
|
||||
ExternalIP => $self->cgi->param('global_ip') || "",
|
||||
InternalIP => $self->cgi->param('local_ip') || "",
|
||||
MACAddress => $self->cgi->param('ethernet_address') || "",
|
||||
Comment => $self->cgi->param('comment') || "",
|
||||
);
|
||||
|
||||
if ($self->cgi->param('action') eq 'create') {
|
||||
if ($h->new_record($hostname, \%props)) {
|
||||
if (system("/sbin/e-smith/signal-event", "host-create", $hostname) == 0) {
|
||||
return $self->success('SUCCESSFULLY_CREATED');
|
||||
}
|
||||
}
|
||||
return $self->error('ERROR_WHILE_CREATING_HOST');
|
||||
} else {
|
||||
my $record = $h->get($hostname);
|
||||
if ($record->merge_props(%props)) {
|
||||
if (system("/sbin/e-smith/signal-event", "host-modify", $hostname) == 0) {
|
||||
return $self->success('SUCCESSFULLY_MODIFIED');
|
||||
}
|
||||
}
|
||||
$self->error('ERROR_WHILE_MODIFYING_HOST');
|
||||
}
|
||||
}
|
||||
|
||||
=head2 print_save_or_add_button()
|
||||
|
||||
=cut
|
||||
|
||||
sub print_save_or_add_button {
|
||||
my ($self) = @_;
|
||||
|
||||
if ($self->cgi->param('action') eq 'modify') {
|
||||
$self->print_button("SAVE");
|
||||
} else {
|
||||
$self->print_button("ADD");
|
||||
}
|
||||
}
|
||||
|
||||
=head2 remove()
|
||||
|
||||
=for testing
|
||||
can_ok('main', 'remove');
|
||||
|
||||
=cut
|
||||
|
||||
sub remove {
|
||||
my ($self) = @_;
|
||||
$self->wherenext('First');
|
||||
my $h = esmith::HostsDB->open();
|
||||
my $hostname = $self->cgi->param('name') . "." .
|
||||
$self->cgi->param('domain');
|
||||
|
||||
# Untaint $hostname before use in system()
|
||||
$hostname =~ /([\w\.-]+)/; $hostname = $1;
|
||||
|
||||
my $record = $h->get($hostname);
|
||||
if ($record->delete()) {
|
||||
if (system("/sbin/e-smith/signal-event", "host-delete", $hostname) == 0) {
|
||||
return $self->success('SUCCESSFULLY_DELETED');
|
||||
}
|
||||
}
|
||||
return $self->error('ERROR_WHILE_DELETING_HOST');
|
||||
}
|
||||
|
||||
=head2 lexicon_params()
|
||||
|
||||
Provides lexicon parameters for interpolation.
|
||||
|
||||
=for testing
|
||||
can_ok('main', 'lexicon_params');
|
||||
my $panel = esmith::FormMagick::Panel::hostentries->new();
|
||||
my %expect = (
|
||||
hostname => 'wibble',
|
||||
domain => 'invalid.tld'
|
||||
);
|
||||
$panel->{cgi} = CGI->new({
|
||||
name => 'wibble',
|
||||
domain => 'invalid.tld'
|
||||
});
|
||||
is_deeply({lexicon_params($panel)}, \%expect, "Get lexicon params");
|
||||
|
||||
=cut
|
||||
|
||||
sub lexicon_params {
|
||||
my ($self) = @_;
|
||||
return (
|
||||
hostname => $self->cgi->param('name') || "",
|
||||
domain => $self->cgi->param('domain') || "",
|
||||
);
|
||||
}
|
||||
|
||||
sub not_in_dhcp_range
|
||||
{
|
||||
my $self = shift;
|
||||
my $address = shift;
|
||||
my $status = $db->get('dhcpd')->prop('status') || "disabled";
|
||||
return "OK" unless $status eq "enabled";
|
||||
my $start = $db->get('dhcpd')->prop('start');
|
||||
my $end = $db->get('dhcpd')->prop('end');
|
||||
return (esmith::util::IPquadToAddr($start)
|
||||
<= esmith::util::IPquadToAddr($address)
|
||||
&&
|
||||
esmith::util::IPquadToAddr($address)
|
||||
<= esmith::util::IPquadToAddr($end)) ?
|
||||
"ADDR_IN_DHCP_RANGE" :
|
||||
"OK";
|
||||
}
|
||||
|
||||
=head2 not_taken
|
||||
|
||||
This function checks the local ip address being set in the panel, and
|
||||
ensures that it is not already taken as the gateway ip or the local ip
|
||||
of the server.
|
||||
|
||||
=cut
|
||||
|
||||
sub not_taken
|
||||
{
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
my $localip = $q->param('local_ip');
|
||||
|
||||
my $server_localip = $db->get_value('LocalIP') || '';
|
||||
my $server_gateway = $db->get_value('GatewayIP') || '';
|
||||
my $server_extip = $db->get_value('ExternalIP') || '';
|
||||
|
||||
$self->debug_msg("\$localip is $localip");
|
||||
$self->debug_msg("\$server_localip is $server_localip");
|
||||
$self->debug_msg("\$server_gateway is $server_gateway");
|
||||
$self->debug_msg("\$server_extip is $server_extip");
|
||||
|
||||
if ($localip eq $server_localip)
|
||||
{
|
||||
return 'ERR_IP_IS_LOCAL_OR_GATEWAY';
|
||||
}
|
||||
elsif ($localip eq $server_gateway)
|
||||
{
|
||||
return 'ERR_IP_IS_LOCAL_OR_GATEWAY';
|
||||
}
|
||||
elsif (($db->get_value('SystemMode') ne 'serveronly') &&
|
||||
($server_extip eq $localip))
|
||||
{
|
||||
return 'ERR_IP_IS_LOCAL_OR_GATEWAY';
|
||||
}
|
||||
elsif ($localip eq '127.0.0.1')
|
||||
{
|
||||
return 'ERR_IP_IS_LOCAL_OR_GATEWAY';
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'OK';
|
||||
}
|
||||
}
|
||||
|
||||
sub must_be_local
|
||||
{
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
my $localip = $q->param('local_ip');
|
||||
|
||||
# Make sure that the IP is indeed local.
|
||||
my $ndb = esmith::NetworksDB->open_ro;
|
||||
my @local_list = $ndb->local_access_spec;
|
||||
|
||||
foreach my $spec (@local_list)
|
||||
{
|
||||
next if $spec eq '127.0.0.1';
|
||||
if (eval{Net::IPv4Addr::ipv4_in_network($spec, $localip)})
|
||||
{
|
||||
return 'OK';
|
||||
}
|
||||
}
|
||||
# Not OK. The IP is not on any of our local networks.
|
||||
return 'ERR_IP_NOT_LOCAL';
|
||||
}
|
||||
|
||||
1;
|
Loading…
Reference in New Issue
Block a user