zentyal-services-2.3.8+quantal1/0000775000000000000000000000000012017102324013435 5ustar zentyal-services-2.3.8+quantal1/COPYING0000664000000000000000000004311012017102324014467 0ustar 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. Copyright (C) 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) year 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. , 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. zentyal-services-2.3.8+quantal1/debian/0000775000000000000000000000000012017102324014657 5ustar zentyal-services-2.3.8+quantal1/debian/zentyal-services.postrm0000664000000000000000000000033512017102324021435 0ustar #!/bin/bash set -e #DEBHELPER# case "$1" in purge) # purge configuration /usr/share/zentyal/purge-module services ;; remove) dpkg-trigger --no-await zentyal-core ;; esac exit 0 zentyal-services-2.3.8+quantal1/debian/compat0000664000000000000000000000000212017102324016055 0ustar 5 zentyal-services-2.3.8+quantal1/debian/copyright0000664000000000000000000000214112017102324016610 0ustar This package was debianized by Zentyal Packaging Maintainers Fri, 20 Feb 2005 15:13:22 +0100. It was downloaded from http://www.zentyal.org/ Files: * Upstream Author: eBox Technologies S.L. Copyright (C) 2004-2012 eBox Technologies S.L. License: 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. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL-2 file. The Debian packaging is: (C) 2004-2011, Zentyal Packaging Maintainers and is licensed under the GPL, see `/usr/share/common-licenses/GPL-2'. zentyal-services-2.3.8+quantal1/debian/control0000664000000000000000000000174112017102324016265 0ustar Source: zentyal-services Section: web Priority: optional Maintainer: Zentyal Packaging Maintainers Uploaders: Jorge Salamero Sanz Build-Depends: zbuildtools Standards-Version: 3.9.2 Homepage: http://www.zentyal.org/ Vcs-Browser: http://git.zentyal.org/zentyal.git/tree/quantal:/main/services Vcs-Git: git://git.zentyal.org/zentyal.git Package: zentyal-services Architecture: all Replaces: ebox-services (<< 2.0.100) Breaks: ebox-services (<< 2.0.100) Depends: zentyal-core (>= 2.3), zentyal-core (<< 2.3.100), ${misc:Depends} Description: Zentyal - Network Services Zentyal is a Linux small business server that can act as a Gateway, Unified Threat Manager, Office Server, Infrastructure Manager, Unified Communications Server or a combination of them. One single, easy-to-use platform to manage all your network services. . This module adds services support, allowing to create and manage services which could be used by firewall rules. zentyal-services-2.3.8+quantal1/debian/source/0000775000000000000000000000000012017102324016157 5ustar zentyal-services-2.3.8+quantal1/debian/source/format0000664000000000000000000000001512017102324017366 0ustar 3.0 (native) zentyal-services-2.3.8+quantal1/debian/rules0000775000000000000000000000010612017102324015734 0ustar #!/usr/bin/make -f include /usr/share/zbuildtools/1/rules/zentyal.mk zentyal-services-2.3.8+quantal1/debian/zentyal-services.postinst0000664000000000000000000000031612017102324021773 0ustar #!/bin/bash set -e #DEBHELPER# case "$1" in configure) # initial setup /usr/share/zentyal/initial-setup services $2 dpkg-trigger --no-await zentyal-core ;; esac exit 0 zentyal-services-2.3.8+quantal1/debian/changelog0000664000000000000000000001427412017102324016541 0ustar zentyal-services (2.3.8+quantal1) quantal; urgency=low * New upstream release for Quantal -- Jorge Salamero Sanz Tue, 28 Aug 2012 10:28:06 +0200 zentyal-services (2.3.8) precise; urgency=low * New upstream release -- José A. Calvo Thu, 23 Aug 2012 02:28:53 +0200 zentyal-services (2.3.7) precise; urgency=low * New upstream release -- José A. Calvo Fri, 13 Jul 2012 11:03:33 +0200 zentyal-services (2.3.6) precise; urgency=low * New upstream release -- José A. Calvo Thu, 14 Jun 2012 04:53:10 +0200 zentyal-services (2.3.5) precise; urgency=low * New upstream release -- José A. Calvo Mon, 11 Jun 2012 00:06:31 +0200 zentyal-services (2.3.4) precise; urgency=low * New upstream release -- José A. Calvo Mon, 26 Mar 2012 17:12:30 +0200 zentyal-services (2.3.2) precise; urgency=low * New upstream release -- José A. Calvo Tue, 06 Mar 2012 17:33:15 +0100 zentyal-services (2.3.1) precise; urgency=low * New upstream release -- José A. Calvo Tue, 14 Feb 2012 20:41:50 +0100 zentyal-services (2.3) precise; urgency=low * New upstream release -- José A. Calvo Mon, 30 Jan 2012 01:45:21 +0100 zentyal-services (2.2) lucid; urgency=low * New upstream release -- José A. Calvo Tue, 13 Sep 2011 04:45:30 +0200 zentyal-services (2.1.7) lucid; urgency=low * New upstream release -- José A. Calvo Wed, 24 Aug 2011 11:54:05 +0200 zentyal-services (2.1.6) lucid; urgency=low * New upstream release -- José A. Calvo Mon, 15 Aug 2011 09:39:24 +0200 zentyal-services (2.1.5) lucid; urgency=low * New upstream release -- José A. Calvo Wed, 27 Jul 2011 23:11:58 +0200 zentyal-services (2.1.4) lucid; urgency=low * New upstream release -- José A. Calvo Thu, 21 Jul 2011 06:52:48 +0200 zentyal-services (2.1.3) lucid; urgency=low * New upstream release -- José A. Calvo Tue, 19 Jul 2011 13:56:50 +0200 zentyal-services (2.1.2) lucid; urgency=low * New upstream release -- José A. Calvo Thu, 14 Jul 2011 22:38:27 +0200 zentyal-services (2.1.1) lucid; urgency=low * New upstream release -- José A. Calvo Tue, 10 May 2011 22:16:38 +0200 zentyal-services (2.1) lucid; urgency=low * New upstream release -- José A. Calvo Wed, 12 Jan 2011 02:38:30 +0100 ebox-services (2.0) lucid; urgency=low * New upstream release -- José A. Calvo Mon, 30 Aug 2010 22:04:45 +0200 ebox-services (1.5.4-0ubuntu1~ppa1~lucid1) lucid; urgency=low * New upstream release -- José A. Calvo Mon, 23 Aug 2010 02:24:27 +0200 ebox-services (1.5.3-0ubuntu1~ppa1~lucid1) lucid; urgency=low * New upstream release -- José A. Calvo Fri, 25 Jun 2010 08:31:14 +0200 ebox-services (1.5.2-0ubuntu1~ppa1~lucid1) lucid; urgency=low * New upstream release -- José A. Calvo Sun, 20 Jun 2010 23:04:57 +0200 ebox-services (1.5.1-0ubuntu1~ppa1~lucid1) lucid; urgency=low * New upstream release -- José A. Calvo Wed, 16 Jun 2010 21:10:30 +0200 ebox-services (1.5-0ubuntu1) lucid; urgency=low [Javier Uruen Val] * New upstream release (LP: #521800) * debian/control - Bump eBox dependency - Update description * debian/ebox-services.postinst - Do not run migration scripts as upstream dropped them for 1.4 -- Javier Uruen Val Sun, 07 Feb 2010 18:51:11 +0100 ebox-services (1.3.5-0ubuntu1) karmic; urgency=low [Javier Uruen Val] * New upstream release [LP: #411468] * cdbs/ebox.mk - GConf schemas are not used anymore - Remove SCHEMASPATH variable - Remove schemadir variable - Fix the script that copy upstart scripts - Use new upstart directory and file naming convention * debian/control - Bump standards version - Bump eBox depenency * debian/ebox-services.postinst - Fix indentation - Do not pkill gconfd as it's not necessary anymore - Run ebox trigger - Add set -e * debian/ebox-services.postrm - Run ebox trigger - Do not pkill gconfd as it's not necessary anymore - Add set -e * remove debian/ebox-services.prerm - Not needed anymore as we don't use gconf schemas * debian/rules - Do not include debian/cdbs/gnome.mk * debian/watch - Change URL -- Javier Uruen Val Wed, 05 Aug 2009 12:29:43 +0200 ebox-services (0.12-0ubuntu1) jaunty; urgency=low [ Javier Uruen Val ] * New upstream release. Closes (LP: #318717) * debian/watch: - add watch file. -- Mathias Gug Mon, 26 Jan 2009 22:11:59 -0500 ebox-services (0.11.99-0ubuntu2) hardy; urgency=low * debian/patches/01_fetch_apache_port.dpatch - Adds eBox administration service using the configured apache port. -- Chuck Short Wed, 26 Mar 2008 09:24:00 -0400 ebox-services (0.11.99-0ubuntu1) hardy; urgency=low * New upstream version. -- Chuck Short Wed, 27 Feb 2008 13:47:01 -0500 ebox-services (0.11.99-0ubuntu1~ppa1) hardy; urgency=low * New upstream release -- Javier Uruen Val Mon, 25 Feb 2008 15:16:26 +0100 ebox-services (0.11.99) unstable; urgency=low * New upstream release -- Enrique José Hernández Blasco Tue, 8 Jan 2008 16:14:40 +0100 ebox-services (0.11-0ubuntu1~ppa1) hardy; urgency=low * New upstream release -- Javier Uruen Val Wed, 28 Nov 2007 15:23:35 +0100 ebox-services (0.10.99) unstable; urgency=low * New upstream release -- Javier Uruen Val Thu, 01 Nov 2007 21:38:15 +0100 ebox-services (0.10) unstable; urgency=low * New upstream release -- Javier Uruen Val Wed, 10 Oct 2007 21:53:52 +0200 ebox-services (0.9.100) unstable; urgency=low * New upstream release -- Javier Uruen Val Mon, 03 Sep 2007 13:45:04 +0200 zentyal-services-2.3.8+quantal1/src/0000775000000000000000000000000012017102324014224 5ustar zentyal-services-2.3.8+quantal1/src/EBox/0000775000000000000000000000000012017102324015061 5ustar zentyal-services-2.3.8+quantal1/src/EBox/Services.pm0000664000000000000000000003627012017102324017212 0ustar # Copyright (C) 2008-2012 eBox Technologies S.L. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as # published by the Free Software Foundation. # # 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 # Class: EBox::Services # # This class is used to abstract services composed of # protocols and ports. # package EBox::Services; use strict; use warnings; use base qw(EBox::Module::Config); use EBox::Validate qw( :all ); use EBox::Services::Model::ServiceConfigurationTable; use EBox::Services::Model::ServiceTable; use EBox::Gettext; use EBox::Exceptions::InvalidData; use EBox::Exceptions::MissingArgument; use EBox::Exceptions::DataExists; use EBox::Exceptions::DataMissing; use EBox::Exceptions::DataNotFound; use Error qw(:try); sub _create { my $class = shift; my $self = $class->SUPER::_create(name => 'services', printableName => __('Services'), @_); bless($self, $class); return $self; } # Method: initialSetup # # Overrides: # EBox::Module::Base::initialSetup # sub initialSetup { my ($self, $version) = @_; foreach my $service (@{$self->_defaultServices()}) { $service->{'sourcePort'} = 'any'; $service->{'readOnly'} = 1; if ($self->serviceExists('name' => $service->{'name'})) { $self->setService(%{$service}); } else { $self->addService(%{$service}); } } } sub _defaultServices { my ($self) = @_; my $apachePort; try { $apachePort = $self->global()->modInstance('apache')->port(); } otherwise { $apachePort = 443; }; return [ { 'name' => 'any', 'printableName' => __('Any'), 'description' => __('Any protocol and port'), 'protocol' => 'any', 'destinationPort' => 'any', 'internal' => 0, }, { 'name' => 'any UDP', 'printableName' => __('Any UDP'), 'description' => __('Any UDP port'), 'protocol' => 'udp', 'destinationPort' => 'any', 'internal' => 0, }, { 'name' => 'any TCP', 'printableName' => __('Any TCP'), 'description' => __('Any TCP port'), 'protocol' => 'tcp', 'destinationPort' => 'any', 'internal' => 0, }, { 'name' => 'administration', 'printableName' => __('Zentyal Administration'), 'description' => __('Zentyal Administration Web Server'), 'protocol' => 'tcp', 'destinationPort' => $apachePort, 'internal' => 1, }, { 'name' => 'ssh', 'printableName' => 'SSH', 'description' => __('Secure Shell'), 'protocol' => 'tcp', 'destinationPort' => '22', 'internal' => 0, }, { 'name' => 'HTTP', 'printableName' => 'HTTP', 'description' => __('HyperText Transport Protocol'), 'protocol' => 'tcp', 'destinationPort' => '80', 'internal' => 0, }, ]; } # Method: serviceNames # # Fetch all the service identifiers and names # # Returns: # # Array ref of hash refs which contain: # # 'id' - service identifier # 'name' service name # # Example: # [ # { # 'name' => 'ssh', # 'id' => 'serv7999' # }, # { # 'name' => 'ftp', # 'id' => 'serv7867' # } # ]; sub serviceNames { my ($self) = @_; my $servicesModel = $self->model('ServiceTable'); my @services; foreach my $id (@{$servicesModel->ids()}) { my $name = $servicesModel->row($id)->valueByName('name'); push @services, { 'id' => $id, 'name' => $name }; } return \@services; } # Method: serviceConfiguration # # For a given service identifier it returns its service configuration, # that is, the set of protocols and ports. # # Returns: # # Array ref of hash refs which contain: # # protocol - it can take one of these: any, tcp, udp, tcp/udp, grep, icmp # source - it can take: # "any" # An integer from 1 to 65536 -> 22 # Two integers separated by colons -> 22:25 # destination - same as source # # Example: # [ # { # 'protocol' => 'tcp', # 'source' => 'any', # 'destination' => '21:22', # } # ] sub serviceConfiguration { my ($self, $id) = @_; throw EBox::Exceptions::ArgumentMissing("id") unless defined($id); my $row = $self->model('ServiceTable')->row($id); unless (defined($row)) { throw EBox::Exceptions::DataNotFound('data' => 'service by id', 'value' => $id); } my $model = $row->subModel('configuration'); my @conf; foreach my $id (@{$model->ids()}) { my $subRow = $model->row($id); push (@conf, { 'protocol' => $subRow->valueByName('protocol'), 'source' => $subRow->valueByName('source'), 'destination' => $subRow->valueByName('destination') }); } return \@conf; } # Method: serviceIptablesArgs # # get a list with the iptables arguments required to match each of the # configurations of the service (see serviceConfiguration) # # Warning: # for any/any/any configuration a empty string is the correct iptables argument sub serviceIptablesArgs { my ($self, $id) = @_; my @args; my @conf = @{ $self->serviceConfiguration($id) }; foreach my $conf (@conf) { my $args = ''; if ($conf->{protocol} ne 'any') { $args .= '--protocol ' . $conf->{protocol}; } if ($conf->{source} ne 'any') { $args .= ' --sport ' . $conf->{source}; } if ($conf->{destination} ne 'any') { $args .= ' --dport ' . $conf->{destination}; } push @args, $args; } return \@args; } # Method: addService # # Add a service to the services table # # Parameters: # # (NAMED) # # name - service's name # description - service's description # protocol - it can take one of these: any, tcp, udp, tcp/udp, grep, icmp # sourcePort - it can take: # "any" # An integer from 1 to 65536 -> 22 # Two integers separated by colons -> 22:25 # destinationPort - same as source # internal - boolean, internal services can't be modified from the UI # readOnly - boolean, set the row unremovable from the UI # # Example: # # 'name' => 'ssh', # 'description' => 'secure shell'. # 'protocol' => 'tcp', # 'sourcePort' => 'any', # 'destinationPort' => '21:22', # # Returns: # # string - id of the new created row sub addService { my ($self, %params) = @_; return $self->model('ServiceTable')->addService(%params); } # Method: addMultipleService # # Add a multi protocol service to the services table # # Parameters: # # (NAMED) # # name - service's name # description - service's description # internal - boolean, internal services can't be modified from the UI # readOnly - boolean, set the row unremovable from the UI # # services - array ref of hash ref containing: # # protocol - it can take one of these: any, tcp, udp, # tcp/udp, grep, icmp # sourcePort - it can take: "any" # An integer from 1 to 65536 -> 22 # Two integers separated by colons -> 22:25 # destinationPort - same as source # # # Example: # # 'name' => 'ssh', # 'description' => 'secure shell'. # 'services' => [ # { # 'protocol' => 'tcp', # 'sourcePort' => 'any', # 'destinationPort' => '21:22' # }, # { # 'protocol' => 'tcp', # 'sourcePort' => 'any', # 'destinationPort' => '21:22' # } # ]; # # Returns: # # string - id of the new created row sub addMultipleService { my ($self, %params) = @_; return $self->model('ServiceTable')->addMultipleService(%params); } # Method: setService # # Set a existing service to the services table # # Parameters: # # (NAMED) # # name - service's name # description - service's description # protocol - it can take one of these: any, tcp, udp, tcp/udp, grep, icmp # sourcePort - it can take: # "any" # An integer from 1 to 65536 -> 22 # Two integers separated by colons -> 22:25 # destinationPort - same as source # internal - boolean, internal services can't be modified from the UI # readOnly - boolean, set the row unremovable from the UI # # Example: # # 'name' => 'ssh', # 'description' => 'secure shell'. # 'protocol' => 'tcp', # 'sourcePort' => 'any', # 'destinationPort' => '21:22', sub setService { my ($self, %params) = @_; $self->model('ServiceTable')->setService(%params); } # Method: setMultipleService # # Set a multi protocol service to the services table # # Parameters: # # (NAMED) # # name - service's name # description - service's description # internal - boolean, internal services can't be modified from the UI # readOnly - boolean, set the row unremovable from the UI # # services - array ref of hash ref containing: # # protocol - it can take one of these: any, tcp, udp, # tcp/udp, grep, icmp # sourcePort - it can take: "any" # An integer from 1 to 65536 -> 22 # Two integers separated by colons -> 22:25 # destinationPort - same as source # # # Example: # # 'name' => 'ssh', # 'description' => 'secure shell'. # 'services' => [ # { # 'protocol' => 'tcp', # 'sourcePort' => 'any', # 'destinationPort' => '21:22' # }, # { # 'protocol' => 'tcp', # 'sourcePort' => 'any', # 'destinationPort' => '21:22' # } # ]; # # Returns: # # string - id of the updated row # sub setMultipleService { my ($self, %params) = @_; $self->model('ServiceTable')->setMultipleService(%params); } # Method: setAdministrationPort # # Set administration port on service # # Parameters: # # port - port # sub setAdministrationPort { my ($self, $port) = @_; checkPort($port, __("port")); $self->setService( 'name' => 'administration', 'printableName' => __('Zentyal Administration'), 'description' => __('Zentyal Administration Web Server'), 'protocol' => 'tcp', 'sourcePort' => 'any', 'destinationPort' => $port, 'internal' => 1, 'readOnly' => 1 ); } # Method: availablePort # # Check if a given port for a given protocol is available. That is, # no internal service uses it. # # Parameters: # # (POSITIONAL) # protocol - it can take one of these: tcp, udp # port - An integer from 1 to 65536 -> 22 # # Returns: # boolean - true if it's available, otherwise false # sub availablePort { my ($self, %params) = @_; return $self->model('ServiceTable')->availablePort(%params); } # Method: serviceFromPort # # Get the service name that it's using a port. # # Parameters: # # (POSITIONAL) # protocol - it can take one of these: tcp, udp # port - An integer from 1 to 65536 -> 22 # # Returns: # string - the service name, undef otherwise # sub serviceFromPort { my ($self, %params) = @_; return $self->model('ServiceTable')->serviceFromPort(%params); } # Method: removeService # # Remove a service from the services table # # Parameters: # # (NAMED) # # You can select the service using one of the following parameters: # # name - service's name # id - service's id sub removeService { my ($self, %params) = @_; unless (exists $params{'id'} or exists $params{'name'}) { throw EBox::Exceptions::MissingArgument('service'); } my $model = $self->model('ServiceTable'); my $id = $params{'id'}; if (not defined($id)) { my $name = $params{'name'}; my $row = $model->findValue('name' => $name); unless (defined($row)) { throw EBox::Exceptions::External("service $name not found"); } $id = $row->id(); } $model->removeRow($id, 1); } # Method: serviceExists # # Check if a given service already exits # # Paremeters: # # (NAMED) # You can select the service using one of the following parameters: # # name - service's name # id - service's id sub serviceExists { my ($self, %params) = @_; unless (exists $params{'id'} or exists $params{'name'}) { throw EBox::Exceptions::MissingArgument('service id or name'); } my $model = $self->model('ServiceTable'); my $id = $params{'id'}; my $row; if (not defined($id)) { my $name = $params{'name'}; $row = $model->findValue('name' => $name); } else { $row = $model->row($id); } return defined($row); } # Method: serviceId # # Given a service's name it returns its id # # Paremeters: # # (POSITIONAL) # # name - service's name # # Returns: # # service's id if it exists, otherwise undef sub serviceId { my ($self, $name) = @_; unless (defined($name)) { throw EBox::Exceptions::MissingArgument('name'); } my $model = $self->model('ServiceTable'); my $row = $model->findValue('name' => $name); if (not defined $row) { return undef; } return $row->id(); } # Method: menu # # Overrides EBox::Module method. # # sub menu { my ($self, $root) = @_; my $folder = new EBox::Menu::Folder('name' => 'Network', 'text' => __('Network'), 'separator' => 'Core', 'order' => 40); my $item = new EBox::Menu::Item('url' => 'Network/Services', 'text' => __($self->title), 'order' => 50); $folder->add($item); $root->add($folder); } 1; zentyal-services-2.3.8+quantal1/src/EBox/Model/0000775000000000000000000000000012017102324016121 5ustar zentyal-services-2.3.8+quantal1/src/EBox/Model/ServiceTable.pm0000664000000000000000000004356412017102324021043 0ustar # Copyright (C) 2008-2012 eBox Technologies S.L. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as # published by the Free Software Foundation. # # 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 # Class: EBox::Services::Model::ServiceTable # # This class describes the data model used to store services. # That is, a set of abstractions for protocols and ports. # # This table stores basically the following fields: # # name - service's name # description - service's description (optional) # configuration - hasMany relation with model # # # # Let's see an example of the structure returned by printableValueRows() # # [ # { # 'name' => 'ssh', # 'id' => 'serv7999', # 'description' => 'Secure Shell' # # 'configuration' => { # 'model' => 'ServiceConfigurationTable', # 'values' => [ # { # 'source' => 'any', # 'protocol' => 'TCP', # 'destination' => '22', # 'id' => 'serv16' # } # ], # }, # }, # { # 'id' => 'serv7867', # 'name' => 'ftp', # 'description' => 'File transfer protocol' # 'configuration' => { # 'model' => 'ServiceConfigurationTable', # 'values' => [ # { # 'source' => 'any', # 'protocol' => 'TCP', # 'destination' => '21:22', # 'id' => 'serv6891' # } # ], # }, # } # ] package EBox::Services::Model::ServiceTable; use EBox::Global; use EBox::Gettext; use EBox::Validate qw(:all); use EBox::Types::Text; use EBox::Types::Boolean; use EBox::Types::HasMany; use EBox::Sudo; use EBox::Exceptions::Internal; use EBox::Exceptions::MissingArgument; use strict; use warnings; use base 'EBox::Model::DataTable'; sub new { my $class = shift; my %parms = @_; my $self = $class->SUPER::new(@_); bless($self, $class); return $self; } sub _table { my @tableHead = ( new EBox::Types::Boolean( 'fieldName' => 'internal', 'printableName' => __('Internal'), 'editable' => 1, 'hidden' => 1, 'help' => __('Tick this field if there is actually a service ' . 'on the machine using the ports configured for this service. ' . 'This helps Zentyal to know what ports are already busy') ), new EBox::Types::Text( 'fieldName' => 'name', 'printableName' => __('Internal name'), 'localizable' => 1, 'size' => '20', 'unique' => 1, 'editable' => 1, 'hidden' => 1, 'optional' => 1, ), new EBox::Types::Text( 'fieldName' => 'printableName', 'printableName' => __('Service name'), 'localizable' => 1, 'size' => '20', 'unique' => 1, 'editable' => 1 ), new EBox::Types::Text( 'fieldName' => 'description', 'printableName' => __('Description'), 'size' => '30', 'editable' => 1, 'optional' => 1, ), new EBox::Types::HasMany ( 'fieldName' => 'configuration', 'printableName' => __('Configuration'), 'foreignModel' => 'ServiceConfigurationTable', 'view' => '/Services/View/ServiceConfigurationTable', ) ); my $dataTable = { 'tableName' => 'ServiceTable', 'automaticRemove' => 1, 'printableTableName' => __('List of services'), 'pageTitle' => __('Services'), 'defaultController' => '/Services/Controller/ServiceTable', 'defaultActions' => [ 'add', 'del', 'editField', 'changeView' ], 'tableDescription' => \@tableHead, 'menuNamespace' => 'Services/View/ServiceTable', 'HTTPUrlView' => 'Services/View/ServiceTable', 'class' => 'dataTable', 'help' => _servicesHelp(), # FIXME 'printableRowName' => __('service'), 'sortedBy' => 'name', }; return $dataTable; } # Method: _tailoredOrder # # Overrides # sub _tailoredOrder # (rows) { my ($self, $rows_ref) = @_; # Order rules per priority my @orderedRows = sort { $a->valueByName('name') cmp $b->valueByName('name') } @{$rows_ref}; return \@orderedRows; } # Method: availablePort # # Check if a given port for a given protocol is available. That is, # no internal service uses it. # # Parameters: # # (POSITIONAL) # protocol - it can take one of these: tcp, udp # port - An integer from 1 to 65536 -> 22 # # Returns: # boolean - true if it's available, otherwise false # sub availablePort { my ($self, $protocol, $port) = @_; unless (defined($protocol)) { throw EBox::Exceptions::MissingArgument('protocol'); } unless (defined($port)) { throw EBox::Exceptions::MissingArgument('port'); } my $internals = $self->findAll('internal' => 1); for my $id (@{$internals}) { my $service = $self->row($id); my $serviceConf = $service->subModel('configuration'); for my $subId (@{$serviceConf->findAllValue('destination' => $port)}) { my $row = $serviceConf->row($subId); return undef if ($row->valueByName('protocol') eq $protocol); } } return 1; } # Method: serviceFromPort # # Get the service name that it's using a port. # # Parameters: # # (POSITIONAL) # protocol - it can take one of these: tcp, udp # port - An integer from 1 to 65536 -> 22 # # Returns: # string - the service name, undef otherwise # sub serviceFromPort { my ($self, $protocol, $port) = @_; unless (defined($protocol)) { throw EBox::Exceptions::MissingArgument('protocol'); } unless (defined($port)) { throw EBox::Exceptions::MissingArgument('port'); } my $internals = $self->findAll('internal' => 1); for my $id (@{$internals}) { my $service = $self->row($id); my $serviceConf = $service->subModel('configuration'); for my $subId (@{$serviceConf->findAllValue('destination' => $port)}) { my $row = $serviceConf->row($subId); return $service->valueByName('name') if ($row->valueByName('protocol') eq $protocol); } } return undef; } # Method: addService # # Add service to the services table. Note this method must exist # because we add services manually from other modules # # Parameters: # # (NAMED) # name - service's internal name # printableName - service's printable name # description - service's description # protocol - it can take one of these: any, tcp, udp, tcp/udp, grep, icmp # sourcePort - it can take: # "any" # An integer from 1 to 65536 -> 22 # Two integers separated by colons -> 22:25 # destinationPort - same as source # internal - booelan, to indicate if the service is internal or not # readOnly - the service can't be deleted or modified # # Example: # # 'protocol' => 'tcp', # 'source' => 'any', # 'destination' => '21:22', # sub addService { my ($self, %params) = @_; my $id = $self->addRow(_serviceParams(%params)); unless (defined($id)) { throw EBox::Exceptions::Internal("Couldn't add name and description"); } my $serviceConf = $self->parentModule()->model('ServiceConfigurationTable'); unless (defined($serviceConf)) { throw EBox::Exceptions::Internal( "Couldn't get ServiceConfigurationTable"); } $serviceConf->setDirectory($self->{'directory'} . "/$id/configuration"); $serviceConf->addRow(_serviceConfParams(%params)); return $id; } # Method: setService # # Add service to the services table. Note this method must exist # because we set services manually from other modules. # # It only makes sense with services having just one protocol. # # Parameters: # # (NAMED) # name - service's name # description - service's description # protocol - it can take one of these: any, tcp, udp, tcp/udp, grep, icmp # sourcePort - it can take: # "any" # An integer from 1 to 65536 -> 22 # Two integers separated by colons -> 22:25 # destinationPort - same as source # internal - booelan, to indicate if the service is internal or not # readOnly - the service can't be deleted or modified # # Example: # # 'protocol' => 'tcp', # 'source' => 'any', # 'destination' => '21:22', # sub setService { my ($self, %params) = @_; my $name = $params{'name'}; unless (defined($name)) { throw EBox::Exceptions::MissingArgument('name'); } my $row = $self->findValue('name' => $name); unless (defined($row)) { throw EBox::Exceptions::DataNotFound('data' => 'service', 'value' => 'name'); } my $id = $row->id(); $self->setRow(1, _serviceParams(%params), 'id' => $id); my $serviceConf = $self->parentModule()->model('ServiceConfigurationTable'); unless (defined($serviceConf)) { throw EBox::Exceptions::Internal( "Couldn't get ServiceConfigurationTable"); } $serviceConf->setDirectory($self->{'directory'} . "/$id/configuration"); my %confParams = _serviceConfParams(%params); my @ids = @{$serviceConf->ids()}; if (@ids) { my $idConf = $ids[0]; $confParams{'id'} = $idConf; $serviceConf->setRow(1, %confParams); } else { $serviceConf->addRow(%confParams); } } # Method: addMultipleService # # Add a multi protocol service to the services table # # Parameters: # # (NAMED) # # name - service's name # description - service's description # internal - boolean, internal services can't be modified from the UI # readOnly - boolean, set the row unremovable from the UI # # services - array ref of hash ref containing: # # protocol - it can take one of these: any, tcp, udp, # tcp/udp, grep, icmp # sourcePort - it can take: "any" # An integer from 1 to 65536 -> 22 # Two integers separated by colons -> 22:25 # destinationPort - same as source # # Example: # # 'name' => 'ssh', # 'description' => 'secure shell'. # 'services' => [ # { # 'protocol' => 'tcp', # 'sourcePort' => 'any', # 'destinationPort' => '21:22' # }, # { # 'protocol' => 'tcp', # 'sourcePort' => 'any', # 'destinationPort' => '21:22' # } # ]; # # Returns: # # string - id of the new created row # sub addMultipleService { my ($self, %params) = @_; my $id = $self->addRow(_serviceParams(%params)); unless (defined($id)) { throw EBox::Exceptions::Internal("Couldn't add name and description"); } my $serviceConf = $self->parentModule()->model('ServiceConfigurationTable'); unless (defined($serviceConf)) { throw EBox::Exceptions::Internal( "Couldn't get ServiceConfigurationTable"); } $serviceConf->setDirectory($self->{'directory'} . "/$id/configuration"); for my $service (@{$params{'services'}}) { $service->{'internal'} = $params{'internal'}; $service->{'readOnly'} = $params{'readOnly'}; $serviceConf->addRow(_serviceConfParams(%{$service})); } return $id; } # Method: setMultipleService # # Set a multi protocol service to the services table # # Parameters: # # (NAMED) # # name - service's name # description - service's description # internal - boolean, internal services can't be modified from the UI # readOnly - boolean, set the row unremovable from the UI # # services - array ref of hash ref containing: # # protocol - it can take one of these: any, tcp, udp, # tcp/udp, grep, icmp # sourcePort - it can take: "any" # An integer from 1 to 65536 -> 22 # Two integers separated by colons -> 22:25 # destinationPort - same as source # # # Example: # # 'name' => 'ssh', # 'description' => 'secure shell'. # 'services' => [ # { # 'protocol' => 'tcp', # 'sourcePort' => 'any', # 'destinationPort' => '21:22' # }, # { # 'protocol' => 'tcp', # 'sourcePort' => 'any', # 'destinationPort' => '21:22' # } # ]; # # Returns: # # string - id of the updated row # sub setMultipleService { my ($self, %params) = @_; my $name = $params{'name'}; unless (defined($name)) { throw EBox::Exceptions::MissingArgument('name'); } my $row = $self->findValue('name' => $name); unless (defined($row)) { throw EBox::Exceptions::DataNotFound('data' => 'service', 'value' => 'name'); } my $id = $row->id(); $self->setRow(1, _serviceParams(%params), 'id' => $id); my $serviceConf = $self->parentModule()->model('ServiceConfigurationTable'); unless (defined($serviceConf)) { throw EBox::Exceptions::Internal( "Couldn't get ServiceConfigurationTable"); } $serviceConf->setDirectory($self->{'directory'} . "/$id/configuration"); my @ids = @{$serviceConf->ids()}; unless (@ids or $params{'allowEmpty'}) { throw EBox::Exceptions::External( "This service has no protocols configured"); } for my $row (@{$serviceConf->ids()}) { $serviceConf->removeRow($row); } for my $service (@{$params{'services'}}) { $service->{'internal'} = $params{'internal'}; $service->{'readOnly'} = $params{'readOnly'}; $serviceConf->addRow(_serviceConfParams(%{$service})); } return $id; } sub _serviceParams { my (%params) = @_; my $name = delete $params{'name'}; my $printableName = delete $params{'printableName'}; unless ($name) { $name = $printableName; } unless ($printableName) { $printableName = $name; } my $description = delete $params{'description'}; my $internal = $params{'internal'}; my $readonly = $params{'readOnly'}; return ('name' => $name, 'printableName' => $printableName, 'description' => $description, 'internal' => $internal, 'readOnly' => $readonly); } sub _serviceConfParams { my (%params) = @_; my $protocol = delete $params{'protocol'}; my $sourcePort = delete $params{'sourcePort'}; my $destinationPort = delete $params{'destinationPort'}; my $internal = $params{'internal'}; my $readonly = $params{'readOnly'}; my $sourcePortType; my $sourcePortFrom; my $sourcePortTo; my $sourceSinglePort; if ($sourcePort eq 'any') { $sourcePortType = 'any'; } elsif ($sourcePort =~ /^\d+$/) { $sourcePortType = 'single'; $sourceSinglePort = $sourcePort; } elsif ($sourcePort =~ /^\d+:\d+/) { $sourcePortType = 'range'; ($sourcePortFrom, $sourcePortTo) = split (/:/, $sourcePort); } my $destinationPortType; my $destinationPortFrom; my $destinationPortTo; my $destinationSinglePort; if ($destinationPort eq 'any') { $destinationPortType = 'any'; } elsif ($destinationPort =~ /^\d+$/) { $destinationPortType = 'single'; $destinationSinglePort = $destinationPort; } elsif ($destinationPort =~ /^\d+:\d+/) { $destinationPortType = 'range'; ($destinationPortFrom, $destinationPortTo) = split (/:/, $destinationPort); } return ('protocol' => $protocol, 'source_range_type' => $sourcePortType, 'source_single_port' => $sourceSinglePort, 'source_from_port' => $sourcePortFrom, 'source_to_port' => $sourcePortTo, 'destination_range_type' => $destinationPortType, 'destination_single_port' => $destinationSinglePort, 'destination_from_port' => $destinationPortFrom, 'destination_to_port' => $destinationPortTo, 'internal' => $internal, 'readOnly' => $readonly); } sub _servicesHelp { return __('A service is an abstraction of one or more network protocols '. 'which can be used in other modules such as: firewall, traffic '. 'shaping...'); } sub serviceForAnyConnectionId { my ($self, $protocol) = @_; my $name; if ($protocol eq 'tcp/udp') { $name = 'any'; } elsif ($protocol eq 'tcp') { $name = 'any TCP'; } elsif ($protocol eq 'udp') { $name = 'any UDP'; } else { return undef; } my $row = $self->findRow(name => $name); if ($row) { return $row->id(); } return undef; } 1; zentyal-services-2.3.8+quantal1/src/EBox/Model/ServiceConfigurationTable.pm0000664000000000000000000001572512017102324023571 0ustar # Copyright (C) 2008-2012 eBox Technologies S.L. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as # published by the Free Software Foundation. # # 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 # Class: EBox::Services::Model::ServiceConfigurationTable # # This class describes the data model used to store services. # That is, a set of abstractions for protocols and ports. # # This model is intended to be used as 'hasMany' relationship # with model . # # Let's see the data structure returned by printableValueRows() # # [ # { # 'source' => 'any', # 'protocol' => 'TCP', # 'destination' => '22', # 'id' => 'serv16' # } # ], # package EBox::Services::Model::ServiceConfigurationTable; use EBox::Global; use EBox::Gettext; use EBox::Validate qw(:all); use EBox::Exceptions::External; use EBox::View::Customizer; use EBox::Types::Select; use EBox::Types::PortRange; use EBox::Sudo; use Perl6::Junction qw( any ); use strict; use warnings; use base 'EBox::Model::DataTable'; sub new { my $class = shift; my %parms = @_; my $self = $class->SUPER::new(@_); bless($self, $class); return $self; } sub protocols { my ($self) = @_; my @options = ( { 'value' => 'tcp/udp', 'printableValue' => 'TCP/UDP' }, { 'value' => 'tcp', 'printableValue' => 'TCP' }, { 'value' => 'udp', 'printableValue' => 'UDP' }, { 'value' => 'ah', 'printableValue' => 'AH' }, { 'value' => 'esp', 'printableValue' => 'ESP' }, { 'value' => 'gre', 'printableValue' => 'GRE' }, { 'value' => 'icmp', 'printableValue' => 'ICMP' }, { 'value' => 'any', 'printableValue' => 'Any' } ); return \@options; } # Method: viewCustomizer # # Overrides to implement # a custom behaviour to show and hide source and destination ports # depending on the protocol # # sub viewCustomizer { my ($self) = @_; my $customizer = new EBox::View::Customizer(); $customizer->setModel($self); $customizer->setOnChangeActions( { protocol => { any => { disable => [qw/source destination/] }, icmp => { disable => [qw/source destination/] }, gre => { disable => [qw/source destination/] }, esp => { disable => [qw/source destination/] }, ah => { disable => [qw/source destination/] }, tcp => { enable => [qw/source destination/] }, udp => { enable => [qw/source destination/] }, 'tcp/udp' => { enable => [qw/source destination/] }, } }); return $customizer; } sub _table { my @tableHead = ( new EBox::Types::Select( 'fieldName' => 'protocol', 'printableName' => __('Protocol'), 'populate' => \&protocols, 'editable' => 1 ), new EBox::Types::PortRange( 'fieldName' => 'source', 'printableName' => __('Source port'), 'editable' => 1, 'help' => __('This field is usually set to any') ), new EBox::Types::PortRange( 'fieldName' => 'destination', 'printableName' => __('Destination port'), 'editable' => 1, # FIXME: this usability improvement cannot be # implemented because PortRange type cannot be # optional, maybe we should fix viewCustomizer to # automatically ignore hidden values even # if not marked as optional # 'defaultSelectedType' => 'single', ) ); my $dataTable = { 'tableName' => 'ServiceConfigurationTable', 'printableTableName' => __('Service configuration'), 'defaultController' => '/Services/Controller/ServiceConfigurationTable', 'defaultActions' => ['add', 'del', 'move', 'editField', 'changeView', 'clone' ], 'tableDescription' => \@tableHead, 'menuNamespace' => 'Services/View/ServiceConfigurationTable', 'HTTPUrlView' => 'Services/View/ServiceConfigurationTable', 'class' => 'dataTable', 'rowUnique' => 1, 'printableRowName' => __('service'), 'insertPosition' => 'back', }; return $dataTable; } # Method: pageTitle # # Overrides # to show the name of the domain sub pageTitle { my ($self) = @_; return $self->parentRow()->printableValueByName('printableName'); } sub validateTypedRow { my ($self, $action, $params_r, $all_r) = @_; if (($all_r->{source}->value() eq 'any') and ($all_r->{destination}->value() eq 'any') ) { my $protocol = $all_r->{protocol}->value(); my $serviceTable = $self->parentModule()->model('ServiceTable'); my $anyServiceId = $serviceTable->serviceForAnyConnectionId($protocol); if ($anyServiceId) { # already exists 'any' service for this protocol if ($anyServiceId eq $self->parentRow()->id()) { # the service itself is any service return; } my $anyService = $serviceTable->row($anyServiceId)->valueByName('printableName'); throw EBox::Exceptions::External( __x('If you want a service for any connections on this protocol, use the predefined service {ser}', ser => $anyService ) ) } } } 1; zentyal-services-2.3.8+quantal1/ChangeLog0000664000000000000000000000604712017102324015216 0ustar 2.3.8 + Forbid to user to create equivalents to any tcp/udp,tcp,udp services 2.3.7 + Added serviceIptablesArgs method 2.3.6 + Adapted to new Model management framework 2.3.5 + setService method does not fail if the existent service has not any configuration + Added clone action to service configuration table 2.3.4 + Packaging fixes for precise 2.3.2 + Now name is just an internal id, it is optional and hidden and defaults to printableName in case of services manually added by the user + Better printableNames for default services + Service names are now translatable 2.3.1 + Updated Standard-Versions to 3.9.2 2.3 + Replaced autotools with zbuildtools 2.1.7 + Removed /zentyal prefix from URLs 2.1.6 + Fixed problems adding portless protocols such as ICMP + Removed validateTypedRow as it is unnecessary with viewCustomizer 2.1.5 + Single port is selected by default for the destination port field 2.1.4 + New 'allowEmpty' parameter on setMultipleService to allow empty services 2.1.3 + Fixed bug which unallowed changing some protocols in service configuration 2.1.2 + Add support for AH in service protocols 2.1.1 + Services menu moved inside the Network menu + Implements modelClasses (allows to access models without ModelManager) + Delete unused ServiceTableFilter model 2.1 + Set internal attribute as hidden to make it simpler and avoid confusion + Added HTTP to default services + Added serviceId to exposedMethods + New _defaultServices method called on initialSetup + Removed obsolete migration 1.5.4 + Zentyal rebrand 1.5.3 + Add serviceFromPort method to get the service which has a port 1.5.2 + Add setMultipleService method to update changes in services with multiple ports 1.5.1 + Add setMultipleService method to update changes in services with + Add 'insertPosition' => 'back' to ServiceConfigurationTable to allow _exposedMethods hacks. New exposedMethods to work with services addSrvConf, delSrvConf and srvConf 1.3.12 + Add breadcrumbs 1.3.6 + Bug fix: set editable property of internal service to 1 + Bug fix: serviceId now ocnforms to it specification when called for a inexistent service + Bug fix: set service configuration using the new EBox::Model::Row API, this prevented eBox administration port from being updated when users change the value in System->General->Listening Port 1.1.20 + UI improvement: hide and show port fields depending on the configuration 1.1 + Use the new row() and ids() API 0.12.100 + New release 0.12.99 + New release 0.12 + Use the new EBox::Model::Row API + Add help to fields in service model + Increase some field length + Add support for ESP protocol 0.11.102 + Remove optional attribute from PortRange as it didn't make sense and we were getting warinings 0.11.101 + New upstream release 0.11.100 + add translationDomain parameter to services + fix translation domain to ebox-services 0.11.99 + Added "updateDestPort" to the API to change a destination port in a service configuration agily 0.11 + New release 0.10.99 + New release 0.10 + New release 0.9.100 + New release zentyal-services-2.3.8+quantal1/AUTHORS0000664000000000000000000000024012017102324014501 0ustar Copyright (C) 2004-2012 eBox Technologies S.L. For an updated list of the current and past developers please visit: http://trac.zentyal.org/wiki/Contributors zentyal-services-2.3.8+quantal1/schemas/0000775000000000000000000000000012017102324015060 5ustar zentyal-services-2.3.8+quantal1/schemas/services.yaml0000664000000000000000000000021412017102324017564 0ustar class: 'EBox::Services' models: - ServiceTable - ServiceConfigurationTable foreign: ServiceTable: [ServiceConfigurationTable] zentyal-services-2.3.8+quantal1/schemas/urls/0000775000000000000000000000000012017102324016045 5ustar zentyal-services-2.3.8+quantal1/schemas/urls/services.urls0000664000000000000000000000005412017102324020576 0ustar Network/Services Services/View/ServiceTable