diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index e240f9e00..61d1a3c7b 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -1,7 +1,7 @@ + * Copyright (C) 2014-2019 Franco Fichtner * Copyright (C) 2010 Ermal Luçi * Copyright (C) 2005-2006 Colin Smith * Copyright (C) 2003-2004 Manuel Kasper @@ -30,18 +30,13 @@ */ /* - * Base services are slowly being converted into plugins, - * hooks are created and expanded to accomodate for their - * feature set, which allows us to build a better plugin - * system in general. + * XXX OpenVPN is the last base plugin that is not gracefully registering + * its functionality to core. With it being gone we can assume all + * plugins even if core functionality must adhere to this idiom. * - * Ideally this may allow us to remove all service-relevant - * parts from system.inc and services.inc so that the latter - * will eventually become obsolete. - * - * The goal may not be to remove all of the base system - * as plugins, but the things listed below are viable - * targets in the future: + * This will allow us to remove all service-relevant parts from system.inc + * and services.inc so that the latter does become obsolete. For this to + * succeed DHCP functionality needs to be put into a plugin as well. */ require_once('plugins.inc.d/openvpn.inc'); @@ -1758,6 +1753,27 @@ function get_dyndns_ip($int, $ipver = 4) return $ip_address; } +function is_radvd_enabled() +{ + global $config; + + /* handle manually configured DHCP6 server settings first */ + foreach (config_read_array('dhcpdv6') as $dhcpv6if => $dhcpv6ifconf) { + if (isset($config['interfaces'][$dhcpv6if]['enable']) && isset($dhcpv6ifconf['ramode']) && $dhcpv6ifconf['ramode'] != 'disabled') { + return true; + } + } + + /* handle DHCP-PD prefixes and 6RD dynamic interfaces */ + foreach (legacy_config_get_interfaces(array('virtual' => false)) as $ifcfg) { + if (isset($ifcfg['enable']) && !empty($ifcfg['track6-interface']) && !isset($ifcfg['dhcpd6track6allowoverride'])) { + return true; + } + } + + return false; +} + function services_get() { $services = array(); @@ -1773,7 +1789,7 @@ function services_get() return $services; } -function find_service_by_name($name, $filter = array()) +function service_by_name($name, $filter = array()) { $services = services_get(); @@ -1795,7 +1811,7 @@ function find_service_by_name($name, $filter = array()) return array(); } -function get_service_status($service) +function service_status($service) { if (!empty($service['nocheck'])) { return true; @@ -1808,12 +1824,11 @@ function get_service_status($service) return is_process_running($service['name']); } - -function get_service_status_icon($service, $xs = false) +function service_control_icon($service, $xs = false) { $output = ''; - if (get_service_status($service)) { + if (service_status($service)) { $output .= '' . PHP_EOL; } else { $output .= '' . PHP_EOL; @@ -1822,7 +1837,7 @@ function get_service_status_icon($service, $xs = false) return sprintf($output, $xs ? 'xs' : 'sm'); } -function get_service_control_links($service, $xs = false) +function service_control_links($service, $xs = false) { $service_id = isset($service['id']) ? $service['id'] : ''; @@ -1831,7 +1846,7 @@ function get_service_control_links($service, $xs = false) $output = ''; - if (get_service_status($service)) { + if (service_status($service)) { $output .= sprintf( $template, $service_id, @@ -1867,27 +1882,6 @@ function get_service_control_links($service, $xs = false) return $output; } -function is_radvd_enabled() -{ - global $config; - - /* handle manually configured DHCP6 server settings first */ - foreach (config_read_array('dhcpdv6') as $dhcpv6if => $dhcpv6ifconf) { - if (isset($config['interfaces'][$dhcpv6if]['enable']) && isset($dhcpv6ifconf['ramode']) && $dhcpv6ifconf['ramode'] != 'disabled') { - return true; - } - } - - /* handle DHCP-PD prefixes and 6RD dynamic interfaces */ - foreach (legacy_config_get_interfaces(array('virtual' => false)) as $ifcfg) { - if (isset($ifcfg['enable']) && !empty($ifcfg['track6-interface']) && !isset($ifcfg['dhcpd6track6allowoverride'])) { - return true; - } - } - - return false; -} - function service_control_start($name, $extras) { $filter = array(); @@ -1896,7 +1890,7 @@ function service_control_start($name, $extras) $filter['id'] = $extras['id']; } - $service = find_service_by_name($name, $filter); + $service = service_by_name($name, $filter); if (!isset($service['name'])) { return sprintf(gettext("Could not start unknown service `%s'"), htmlspecialchars($name)); } @@ -1934,7 +1928,7 @@ function service_control_stop($name, $extras) $filter['id'] = $extras['id']; } - $service = find_service_by_name($name, $filter); + $service = service_by_name($name, $filter); if (!isset($service['name'])) { return sprintf(gettext("Could not stop unknown service `%s'"), htmlspecialchars($name)); } @@ -1969,7 +1963,7 @@ function service_control_restart($name, $extras) $filter['id'] = $extras['id']; } - $service = find_service_by_name($name, $filter); + $service = service_by_name($name, $filter); if (!isset($service['name'])) { return sprintf(gettext("Could not restart unknown service `%s'"), htmlspecialchars($name)); } diff --git a/src/etc/inc/xmlrpc/service.inc b/src/etc/inc/xmlrpc/service.inc index 7e727b849..7d1c757cd 100644 --- a/src/etc/inc/xmlrpc/service.inc +++ b/src/etc/inc/xmlrpc/service.inc @@ -53,7 +53,7 @@ function list_services_xmlrpc() $services = services_get(); foreach ($services as &$service) { - $service['status'] = get_service_status($service); + $service['status'] = service_status($service); } return $services; diff --git a/src/www/fbegin.inc b/src/www/fbegin.inc index 70af58a6f..9e9e6015e 100644 --- a/src/www/fbegin.inc +++ b/src/www/fbegin.inc @@ -184,10 +184,10 @@ if($need_alert_display == true) {
diff --git a/src/www/status_openvpn.php b/src/www/status_openvpn.php index 5741e661f..185ac1768 100644 --- a/src/www/status_openvpn.php +++ b/src/www/status_openvpn.php @@ -1,34 +1,34 @@ - Copyright (C) 2008 Shrew Soft Inc. - Copyright (C) 2005 Scott Ullrich - Copyright (C) 2005 Colin Smith - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ + * Copyright (C) 2014-2015 Deciso B.V. + * Copyright (C) 2010 Jim Pingle + * Copyright (C) 2008 Shrew Soft Inc. + * Copyright (C) 2005 Scott Ullrich + * Copyright (C) 2005 Colin Smith + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ require_once("guiconfig.inc"); require_once("plugins.inc.d/openvpn.inc"); @@ -174,9 +174,9 @@ include("head.inc"); ?> endforeach; ?> - $server['vpnid'])); ?> - - + $server['vpnid'])); ?> + +   @@ -253,9 +253,9 @@ include("head.inc"); ?>
- $sk_server['vpnid'])); ?> - - + $sk_server['vpnid'])); ?> + +
@@ -291,9 +291,9 @@ include("head.inc"); ?>
- $client['vpnid'])); ?> - - + $client['vpnid'])); ?> + +
diff --git a/src/www/status_services.php b/src/www/status_services.php index ccbe3ea87..8a9da75e8 100644 --- a/src/www/status_services.php +++ b/src/www/status_services.php @@ -1,32 +1,32 @@ - Copyright (C) 2004-2005 Scott Ullrich - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INClUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ + * Copyright (C) 2014-2015 Deciso B.V. + * Copyright (C) 2005-2006 Colin Smith + * Copyright (C) 2004-2005 Scott Ullrich + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INClUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ require_once("guiconfig.inc"); require_once("services.inc"); @@ -83,8 +83,8 @@ include("head.inc"); - - + + - - + +