mirror of
https://github.com/lucaspalomodevelop/opnsense-core.git
synced 2026-03-13 08:09:42 +00:00
remove temp includes
This commit is contained in:
parent
13e0d12171
commit
44e47bb572
@ -1,317 +0,0 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2007, 2008 Scott Ullrich <sullrich@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Copyright (C) 2005-2006 Bill Marquette <bill.marquette@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Copyright (C) 2006 Paul Taylor <paultaylor@winn-dixie.com>.
|
||||
All rights reserved.
|
||||
|
||||
Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
|
||||
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.
|
||||
|
||||
pfSense_MODULE: authgui
|
||||
*/
|
||||
include_once("auth.inc");
|
||||
include_once("priv.inc");
|
||||
|
||||
/* Authenticate user - exit if failed */
|
||||
if (!session_auth()) {
|
||||
display_login_form();
|
||||
exit;
|
||||
}
|
||||
|
||||
/*
|
||||
* Once here, the user has authenticated with the web server.
|
||||
* We give them access only to the appropriate pages based on
|
||||
* the user or group privileges.
|
||||
*/
|
||||
$allowedpages = getAllowedPages($_SESSION['Username']);
|
||||
|
||||
/*
|
||||
* redirect to first allowed page if requesting a wrong url
|
||||
*/
|
||||
if (!isAllowedPage($_SERVER['REQUEST_URI'])) {
|
||||
if (count($allowedpages) > 0) {
|
||||
$page = str_replace('*', '', $allowedpages[0]);
|
||||
$_SESSION['Post_Login'] = true;
|
||||
require_once("functions.inc");
|
||||
pfSenseHeader("/{$page}");
|
||||
|
||||
$username = empty($_SESSION["Username"]) ? "(system)" : $_SESSION['Username'];
|
||||
if (!empty($_SERVER['REMOTE_ADDR']))
|
||||
$username .= '@' . $_SERVER['REMOTE_ADDR'];
|
||||
log_error("{$username} attempted to access {$_SERVER['SCRIPT_NAME']} but does not have access to that page. Redirecting to {$page}.");
|
||||
|
||||
exit;
|
||||
} else {
|
||||
display_error_form("201", gettext("No page assigned to this user! Click here to logout."));
|
||||
exit;
|
||||
}
|
||||
} else
|
||||
$_SESSION['Post_Login'] = true;
|
||||
|
||||
/*
|
||||
* redirect browsers post-login to avoid pages
|
||||
* taking action in reponse to a POST request
|
||||
*/
|
||||
if (!$_SESSION['Post_Login']) {
|
||||
$_SESSION['Post_Login'] = true;
|
||||
require_once("functions.inc");
|
||||
pfSenseHeader($_SERVER['REQUEST_URI']);
|
||||
exit;
|
||||
}
|
||||
|
||||
/*
|
||||
* Close session data to allow other scripts from same host to come in.
|
||||
* A session can be reactivated from calling session_start again
|
||||
*/
|
||||
session_commit();
|
||||
|
||||
/*
|
||||
* determine if the user is allowed access to the requested page
|
||||
*/
|
||||
function display_error_form($http_code, $desc) {
|
||||
global $config, $g;
|
||||
$g['theme'] = get_current_theme();
|
||||
if(isAjax()) {
|
||||
printf(gettext('Error: %1$s Description: %2$s'), $http_code, $desc);
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<!--[if IE 8 ]><html lang="en" class="ie ie8 lte9 lte8 no-js"><![endif]-->
|
||||
<!--[if IE 9 ]><html lang="en" class="ie ie9 lte9 no-js"><![endif]-->
|
||||
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en" class="no-js"><!--<![endif]-->
|
||||
<head>
|
||||
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
|
||||
<meta name="robots" content="index, follow, noodp, noydir" />
|
||||
<meta name="keywords" content="" />
|
||||
<meta name="description" content="" />
|
||||
<meta name="copyright" content="" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||
|
||||
<title><?=$http_code?></title>
|
||||
|
||||
<link href="/themes/<?=$g['theme'];?>/build/css/main.css" media="screen, projection" rel="stylesheet">
|
||||
<link href="/themes/<?=$g['theme'];?>/assets/images/favicon.png" rel="shortcut icon">
|
||||
|
||||
<!--[if lt IE 9]><script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script><![endif]-->
|
||||
</head>
|
||||
<body class="page-login">
|
||||
<div id="errordesc">
|
||||
<h1> </h1>
|
||||
<a href="/index.php?logout">
|
||||
<p id="errortext" style="vertical-align: middle; text-align: center;">
|
||||
<span style="color: #000000; font-weight: bold;">
|
||||
<?=$desc;?>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
} // end function
|
||||
|
||||
|
||||
function display_login_form() {
|
||||
require_once("globals.inc");
|
||||
global $config, $g;
|
||||
$g['theme'] = get_current_theme();
|
||||
|
||||
unset($input_errors);
|
||||
|
||||
if(isAjax()) {
|
||||
if (isset($_POST['login'])) {
|
||||
if($_SESSION['Logged_In'] <> "True") {
|
||||
isset($_SESSION['Login_Error']) ? $login_error = $_SESSION['Login_Error'] : $login_error = gettext("unknown reason");
|
||||
printf("showajaxmessage('" . gettext("Invalid login (%s).") . "')", $login_error);
|
||||
}
|
||||
if (file_exists("{$g['tmp_path']}/webconfigurator.lock")) {
|
||||
// TODO: add the IP from the user who did lock the device
|
||||
$whom = file_get_contents("{$g['tmp_path']}/webconfigurator.lock");
|
||||
printf("showajaxmessage('" . gettext("This device is currently being maintained by: %s.") . "');", $whom);
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Check against locally configured IP addresses, which will catch when someone
|
||||
port forwards WebGUI access from WAN to an internal IP on the router. */
|
||||
global $FilterIflist, $nifty_background;
|
||||
$local_ip = false;
|
||||
if(strstr($_SERVER['HTTP_HOST'], ":")) {
|
||||
$http_host_port = explode(":", $_SERVER['HTTP_HOST']);
|
||||
$http_host = $http_host_port[0];
|
||||
} else {
|
||||
$http_host = $_SERVER['HTTP_HOST'];
|
||||
}
|
||||
if (empty($FilterIflist)) {
|
||||
require_once('filter.inc');
|
||||
require_once('shaper.inc');
|
||||
filter_generate_optcfg_array();
|
||||
}
|
||||
foreach ($FilterIflist as $iflist) {
|
||||
if($iflist['ip'] == $http_host)
|
||||
$local_ip = true;
|
||||
if($iflist['ipv6'] == $http_host)
|
||||
$local_ip = true;
|
||||
}
|
||||
unset($FilterIflist);
|
||||
|
||||
if($config['virtualip']) {
|
||||
if($config['virtualip']['vip']) {
|
||||
foreach($config['virtualip']['vip'] as $vip) {
|
||||
if($vip['subnet'] == $http_host)
|
||||
$local_ip = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_array($config['openvpn']['openvpn-server'])) {
|
||||
foreach ($config['openvpn']['openvpn-server'] as $ovpns) {
|
||||
if (is_ipaddrv4($http_host) && !empty($ovpns['tunnel_network']) && ip_in_subnet($http_host, $ovpns['tunnel_network'])) {
|
||||
$local_ip = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_ipaddrv6($http_host) && !empty($ovpns['tunnel_networkv6']) && ip_in_subnet($http_host, $ovpns['tunnel_networkv6'])) {
|
||||
$local_ip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
setcookie("cookie_test", time() + 3600);
|
||||
$have_cookies = isset($_COOKIE["cookie_test"]);
|
||||
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<!--[if IE 8 ]><html lang="en" class="ie ie8 lte9 lte8 no-js"><![endif]-->
|
||||
<!--[if IE 9 ]><html lang="en" class="ie ie9 lte9 no-js"><![endif]-->
|
||||
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en" class="no-js"><!--<![endif]-->
|
||||
<head>
|
||||
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
|
||||
<meta name="robots" content="index, follow, noodp, noydir" />
|
||||
<meta name="keywords" content="" />
|
||||
<meta name="description" content="" />
|
||||
<meta name="copyright" content="" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||
|
||||
<title><?=gettext("Login"); ?></title>
|
||||
|
||||
<link href="/themes/<?=$g['theme'];?>/build/css/main.css" media="screen, projection" rel="stylesheet">
|
||||
<link href="/themes/<?=$g['theme'];?>/assets/images/favicon.png" rel="shortcut icon">
|
||||
|
||||
<!--[if lt IE 9]><script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script><![endif]-->
|
||||
|
||||
</head>
|
||||
<body class="page-login">
|
||||
|
||||
<div class="container">
|
||||
<?php
|
||||
if(is_ipaddr($http_host) && !$local_ip && !isset($config['system']['webgui']['nohttpreferercheck'])) {
|
||||
$nifty_background = "#999";
|
||||
print_info_box(gettext("You are accessing this router by an IP address not configured locally, which may be forwarded by NAT or other means. <br /><br />If you did not setup this forwarding, you may be the target of a man-in-the-middle attack."));
|
||||
}
|
||||
$loginautocomplete = isset($config['system']['webgui']['loginautocomplete']) ? '' : 'autocomplete="off"';
|
||||
?>
|
||||
|
||||
|
||||
<main class="login-modal-container">
|
||||
<header class="login-modal-head" style="height:55px;">
|
||||
<a class="navbar-brand" href="/">
|
||||
<img class="brand-logo" src="/themes/<?=$g['theme'];?>/assets/images/default-logo.png" height="30" width="150"/>
|
||||
<img class="brand-icon" src="/themes/<?=$g['theme'];?>/assets/images/icon-logo.png" height="30" width="29"/>
|
||||
</a>
|
||||
</header>
|
||||
|
||||
<div class="login-modal-content">
|
||||
<div id="inputerrors"><?=$_SESSION['Login_Error'];?></div>
|
||||
|
||||
<form class="clearfix" id="iform" name="iform" method="post" <?= $loginautocomplete ?> action="<?=$_SERVER['SCRIPT_NAME'];?>">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="usernamefld"><?=gettext("Username:"); ?>*</label>
|
||||
<input id="usernamefld" type="text" name="usernamefld" class="form-control user" tabindex="1" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="passwordfld"><?=gettext("Password:"); ?>*</label>
|
||||
<input id="passwordfld" type="password" name="passwordfld" class="form-control pwd" tabindex="2" />
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="login" value="1" /><!-- XXX login workaround -->
|
||||
|
||||
<button type="submit" name="login" class="btn btn-primary pull-right"><?=gettext("Login"); ?></button>
|
||||
|
||||
</form>
|
||||
|
||||
<?php if (!$have_cookies && isset($_POST['login'])): ?>
|
||||
<br /><br />
|
||||
<span class="text-danger">
|
||||
<?= gettext("Your browser must support cookies to login."); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="login-foot container-fluid">
|
||||
<a target="_blank" href="<?=$g['product_website_footer']?>" class="redlnk"><?=$g['product_name']?></a> is ©
|
||||
<?=$g['product_copyright_years']?> by <a href="<?=$g['product_copyright_url']?>" class="tblnk"><?=$g['product_copyright']?></a> All Rights Reserved.
|
||||
[<a href="/license.php" class="tblnk">view license</a>]
|
||||
</footer>
|
||||
|
||||
<script src="/themes/<?=$g['theme'];?>/build/js/main.min.js" type="text/javascript"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
$(document).ready(function() { jQuery('#usernamefld').focus(); });
|
||||
//]]>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
<?php
|
||||
} // end function
|
||||
|
||||
?>
|
||||
@ -1,152 +0,0 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
/*
|
||||
functions.inc
|
||||
Copyright (C) 2004-2006 Scott Ullrich
|
||||
All rights reserved.
|
||||
|
||||
originally part of m0n0wall (http://m0n0.ch/wall)
|
||||
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
||||
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.
|
||||
|
||||
pfSense_MODULE: utils
|
||||
|
||||
*/
|
||||
|
||||
/* BEGIN compatibility goo with HEAD */
|
||||
if(!function_exists("gettext")) {
|
||||
function gettext($text) {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists("pfSenseHeader")) {
|
||||
/****f* pfsense-utils/pfSenseHeader
|
||||
* NAME
|
||||
* pfSenseHeader
|
||||
* INPUTS
|
||||
* none
|
||||
* RESULT
|
||||
* Javascript header change or browser Location:
|
||||
******/
|
||||
function pfSenseHeader($text) {
|
||||
global $_SERVER;
|
||||
if (isAjax()) {
|
||||
if ($_SERVER['HTTPS'] == "on")
|
||||
$protocol = "https";
|
||||
else
|
||||
$protocol = "http";
|
||||
|
||||
$port = ":{$_SERVER['SERVER_PORT']}";
|
||||
if ($_SERVER['SERVER_PORT'] == "80" && $protocol == "http")
|
||||
$port = "";
|
||||
if ($_SERVER['SERVER_PORT'] == "443" && $protocol == "https")
|
||||
$port = "";
|
||||
$complete_url = "{$protocol}://{$_SERVER['SERVER_NAME']}{$port}/{$text}";
|
||||
echo "\ndocument.location.href = '{$complete_url}';\n";
|
||||
} else {
|
||||
header("Location: $text");
|
||||
}
|
||||
}
|
||||
}
|
||||
/* END compatibility goo with HEAD */
|
||||
|
||||
/*fetch menu notices function*/
|
||||
if(!function_exists("get_menu_messages")) {
|
||||
function get_menu_messages(){
|
||||
global $g,$config;
|
||||
if (are_notices_pending()) {
|
||||
$notices = get_notices();
|
||||
$requests=array();
|
||||
|
||||
## Get Query Arguments from URL ###
|
||||
foreach ($_REQUEST as $key => $value) {
|
||||
if ($key != "PHPSESSID")
|
||||
$requests[] = $key.'='.$value;
|
||||
}
|
||||
if(is_array($requests))
|
||||
$request_string = implode("&", $requests);
|
||||
|
||||
if(is_array($notices)) {
|
||||
$notice_msgs = "<ul class=\"dropdown-menu\" role=\"menu\">";
|
||||
|
||||
$notice_msgs .= "<li><a href=\"#\" onclick=\"notice_action('acknowledge','all');\" >".gettext("Acknowledge All Notices")."</a></li><li class=\"divider\"></li>";
|
||||
|
||||
foreach ($notices as $key => $value) {
|
||||
$date = date("m-d-y H:i:s", $key);
|
||||
$noticemsg = ($value['notice'] != "" ? $value['notice'] : $value['id']);
|
||||
$noticemsg = preg_replace("/(\"|\'|\n|<.?\w+>)/i","",$noticemsg);
|
||||
if ((strlen($noticemsg)* 8) > $domtt_width)
|
||||
$domtt_width=(strlen($noticemsg) *8);
|
||||
if ((strlen($noticemsg)* 8) > 900)
|
||||
$domtt_width= 900;
|
||||
$alert_action ="onclick=\"notice_action('acknowledge','{$key}'); jQuery(this).parent().parent().remove();\"";
|
||||
$notice_msgs .= "<li><a href=\"#\" {$alert_link} {$alert_action}>{$date} [ ".htmlspecialchars($noticemsg)."]</a></li>";
|
||||
}
|
||||
$notice_msgs .="</ul>";
|
||||
|
||||
|
||||
$menu_messages = '';
|
||||
|
||||
if(count($notices)==1)
|
||||
$msg= sprintf("%1$02d",count($notices))." ".gettext("unread notice");
|
||||
else
|
||||
$msg= sprintf("%1$02d",count($notices))." ".gettext("unread notices");
|
||||
|
||||
$menu_messages.="<a href=\"/\" class=\"dropdown-toggle \" data-toggle=\"dropdown\" role=\"button\" aria-expanded=\"false\"><span class=\"text-primary\">{$msg} </span><span class=\"caret text-primary\"></span></a>{$notice_msgs}\n";
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
$menu_messages='';
|
||||
$menu_messages.= "<a href=\"#\">".$config['system']['hostname'] . "." . $config['system']['domain']."</a>";
|
||||
$menu_messages.='';
|
||||
}
|
||||
return ($menu_messages);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists("dom_title")) {
|
||||
function dom_title($title_msg,$width=NULL){
|
||||
$width=preg_replace("/\D+/","",$width);
|
||||
if (!empty($width)){
|
||||
$width=",'width',$width";
|
||||
}
|
||||
if (!empty($title_msg)){
|
||||
$title_msg=preg_replace("/\s+/"," ",$title_msg);
|
||||
$title_msg=preg_replace("/'/","\'",$title_msg);
|
||||
return "onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\" onmouseover=\"domTT_activate(this, event, 'content', '{$title_msg}', 'trail', true, 'delay', 250, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle' $width);\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
/* include all configuration functions */
|
||||
require_once("interfaces.inc");
|
||||
require_once("gwlb.inc");
|
||||
require_once("services.inc");
|
||||
require_once("pfsense-utils.inc");
|
||||
require_once("certs.inc");
|
||||
require_once("system.inc");
|
||||
require_once("vslb.inc");
|
||||
|
||||
?>
|
||||
@ -1,164 +0,0 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
/*
|
||||
globals.inc
|
||||
part of pfSense (https://www.pfsense.org)
|
||||
Copyright (C) 2004-2010 Scott Ullrich
|
||||
|
||||
Originally Part of m0n0wall
|
||||
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
||||
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.
|
||||
|
||||
pfSense_MODULE: utils
|
||||
|
||||
*/
|
||||
|
||||
global $g;
|
||||
$g = array(
|
||||
"base_packages" => "siproxd",
|
||||
"event_address" => "unix:///var/run/check_reload_status",
|
||||
"factory_shipped_username" => "admin",
|
||||
"factory_shipped_password" => "opnsense",
|
||||
"upload_path" => "/root",
|
||||
"dhcpd_chroot_path" => "/var/dhcpd",
|
||||
"unbound_chroot_path" => "/var/unbound",
|
||||
"varrun_path" => "/var/run",
|
||||
"varetc_path" => "/var/etc",
|
||||
"vardb_path" => "/var/db",
|
||||
"varlog_path" => "/var/log",
|
||||
"etc_path" => "/etc",
|
||||
"tmp_path" => "/tmp",
|
||||
"conf_path" => "/conf",
|
||||
"ftmp_path" => "/ftmp",
|
||||
"conf_default_path" => "/conf.default",
|
||||
"cf_path" => "/cf",
|
||||
"cf_conf_path" => "/cf/conf",
|
||||
"www_path" => "/usr/local/www",
|
||||
"xml_rootobj" => "pfsense",
|
||||
"admin_group" => "admins",
|
||||
"product_name" => "OPNsense",
|
||||
"product_copyright" => "Deciso B.V.",
|
||||
"product_copyright_url" => "http://www.deciso.com",
|
||||
"product_copyright_years" => "2014 - ".date("Y"),
|
||||
"product_website" => "www.opnsense.org",
|
||||
"product_website_footer" => "https://www.opnsense.org/?gui22",
|
||||
"product_email" => "coreteam@opnsense.org",
|
||||
"hideplatform" => false,
|
||||
"hidedownloadbackup" => false,
|
||||
"hidebackupbeforeupgrade" => false,
|
||||
"disablethemeselection" => false,
|
||||
"disablehelpmenu" => false,
|
||||
"disablehelpicon" => false,
|
||||
"disablecrashreporter" => false,
|
||||
"crashreporterurl" => "https://crashreporter.opnsense.org/crash_reporter.php",
|
||||
"debug" => false,
|
||||
"latest_config" => "11.1",
|
||||
"nopkg_platforms" => array("cdrom"),
|
||||
"minimum_ram_warning" => "101",
|
||||
"minimum_ram_warning_text" => "128 MB",
|
||||
"wan_interface_name" => "wan",
|
||||
"nopccard_platforms" => array("wrap", "net48xx"),
|
||||
"xmlrpcbaseurl" => "https://packages.pfsense.org",
|
||||
"captiveportal_path" => "/usr/local/captiveportal",
|
||||
"captiveportal_element_path" => "/var/db/cpelements",
|
||||
"captiveportal_element_sizelimit" => 1048576,
|
||||
"xmlrpcpath" => "/xmlrpc.php",
|
||||
"embeddedbootupslice" => "/dev/ad0a",
|
||||
"services_dhcp_server_enable" => true,
|
||||
"wireless_regex" => "/^(ndis|wi|ath|an|ral|ural|iwi|wlan|rum|run|bwn|zyd|mwl|bwi|ipw|iwn|malo|uath|upgt|urtw|wpi)/",
|
||||
"help_base_url" => "/help.php"
|
||||
);
|
||||
|
||||
/* IP TOS flags */
|
||||
$iptos = array("lowdelay", "throughput", "reliability");
|
||||
|
||||
/* TCP flags */
|
||||
$tcpflags = array("syn", "ack", "fin", "rst", "psh", "urg", "ece", "cwr");
|
||||
|
||||
if(file_exists("/etc/platform")) {
|
||||
$arch = php_uname("m");
|
||||
/* Do not remove this, it is not needed for the snapshots URL but is needed later for the -RELEASE/stable URLs */
|
||||
//$arch = ($arch == "i386") ? "" : '/' . $arch;
|
||||
|
||||
/* Full installs and NanoBSD use the same update directory and manifest in 2.x */
|
||||
$g['update_url']="https://snapshots.opnsense.org/FreeBSD_releng/10.1/{$arch}/pfSense_HEAD/.updaters/";
|
||||
$g['update_manifest']="https://updates.opnsense.org/manifest";
|
||||
|
||||
$g['platform'] = trim(file_get_contents("/etc/platform"));
|
||||
if($g['platform'] == "nanobsd") {
|
||||
$g['firmware_update_text']="OPNsense-*.img.gz";
|
||||
$g['hidedownloadbackup'] = true;
|
||||
$g['hidebackupbeforeupgrade'] = true;
|
||||
|
||||
} else {
|
||||
$g['firmware_update_text']="pfSense-*.tgz";
|
||||
}
|
||||
}
|
||||
|
||||
/* Default sysctls */
|
||||
$sysctls = array("net.inet.ip.portrange.first" => "1024",
|
||||
"net.inet.tcp.blackhole" => "2",
|
||||
"net.inet.udp.blackhole" => "1",
|
||||
"net.inet.ip.random_id" => "1",
|
||||
"net.inet.tcp.drop_synfin" => "1",
|
||||
"net.inet.ip.redirect" => "1",
|
||||
"net.inet6.ip6.redirect" => "1",
|
||||
"net.inet6.ip6.use_tempaddr" => "0",
|
||||
"net.inet6.ip6.prefer_tempaddr" => "0",
|
||||
"net.inet.tcp.syncookies" => "1",
|
||||
"net.inet.tcp.recvspace" => "65228",
|
||||
"net.inet.tcp.sendspace" => "65228",
|
||||
"net.inet.ip.fastforwarding" => "0",
|
||||
"net.inet.tcp.delayed_ack" => "0",
|
||||
"net.inet.udp.maxdgram" => "57344",
|
||||
"net.link.bridge.pfil_onlyip" => "0",
|
||||
"net.link.bridge.pfil_member" => "1",
|
||||
"net.link.bridge.pfil_bridge" => "0",
|
||||
"net.link.tap.user_open" => "1",
|
||||
"kern.randompid" => "347",
|
||||
"net.inet.ip.intr_queue_maxlen" => "1000",
|
||||
"hw.syscons.kbd_reboot" => "0",
|
||||
"net.inet.tcp.log_debug" => "0",
|
||||
"net.inet.tcp.tso" => "1",
|
||||
"net.inet.icmp.icmplim" => "0",
|
||||
"vfs.read_max" => "32",
|
||||
"kern.ipc.maxsockbuf" => "4262144",
|
||||
"debug.pfftpproxy" => "0",
|
||||
"net.inet.ip.process_options" => 0,
|
||||
"kern.random.sys.harvest.interrupt" => 0,
|
||||
"kern.random.sys.harvest.point_to_point" => 0,
|
||||
"kern.random.sys.harvest.ethernet" => 0,
|
||||
"net.route.netisr_maxqlen" => 1024,
|
||||
"net.inet.udp.checksum" => 1,
|
||||
"net.bpf.zerocopy_enable" => 1,
|
||||
"net.inet.icmp.reply_from_interface" => 1
|
||||
);
|
||||
|
||||
/* Include override values for the above if needed. If the file doesn't exist, don't try to load it. */
|
||||
if (file_exists("/etc/inc/globals_override.inc"))
|
||||
@include("globals_override.inc");
|
||||
|
||||
$config_parsed = false;
|
||||
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,825 +0,0 @@
|
||||
<?php
|
||||
/****h* pfSense/service-utils
|
||||
* NAME
|
||||
* service-utils.inc - Service facility
|
||||
* DESCRIPTION
|
||||
* This file contains various functions used by the pfSense service facility.
|
||||
* HISTORY
|
||||
* $Id$
|
||||
******
|
||||
*
|
||||
* Copyright (C) 2005-2006 Colin Smith (ethethlay@gmail.com)
|
||||
* 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)
|
||||
* RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
pfSense_BUILDER_BINARIES: /bin/pgrep /bin/sh /usr/bin/killall
|
||||
pfSense_MODULE: utils
|
||||
*/
|
||||
require_once("globals.inc");
|
||||
require_once("captiveportal.inc");
|
||||
require_once("openvpn.inc");
|
||||
require_once("ipsec.inc");
|
||||
require_once("vpn.inc");
|
||||
require_once("vslb.inc");
|
||||
require_once("gwlb.inc");
|
||||
|
||||
define("RCFILEPREFIX", "/usr/local/etc/rc.d/");
|
||||
|
||||
if (!function_exists('write_rcfile')) {
|
||||
function write_rcfile($params) {
|
||||
global $g;
|
||||
|
||||
safe_mkdir(RCFILEPREFIX);
|
||||
$rcfile_fullname = RCFILEPREFIX . $params['file'];
|
||||
if (!file_exists($rcfile_fullname) && !is_link($rcfile_fullname) && !touch($rcfile_fullname))
|
||||
return false;
|
||||
|
||||
if (!is_writable($rcfile_fullname) || empty($params['start']))
|
||||
return false;
|
||||
|
||||
$towrite = "#!/bin/sh\n";
|
||||
$towrite .= "# This file was automatically generated\n# by the {$g['product_name']} service handler.\n\n";
|
||||
|
||||
/* write our rc functions */
|
||||
$towrite .= "rc_start() {\n";
|
||||
$towrite .= "\t{$params['start']}\n";
|
||||
$towrite .= "}\n\n";
|
||||
if(!empty($params['stop'])) {
|
||||
$tokill =& $params['stop'];
|
||||
} else if(!empty($params['executable'])) {
|
||||
/* just nuke the executable */
|
||||
$tokill = "/usr/bin/killall " . escapeshellarg($params['executable']);
|
||||
} else {
|
||||
/* make an educated guess (bad) */
|
||||
$tokill = array_pop(explode('/', array_shift(explode(' ', $params['start']))));
|
||||
}
|
||||
$towrite .= "rc_stop() {\n";
|
||||
$towrite .= "\t{$tokill}\n";
|
||||
$towrite .= "}\n\n";
|
||||
|
||||
/* begin rcfile logic */
|
||||
$towrite .= "case \$1 in\n\tstart)\n\t\trc_start\n\t\t;;\n\tstop)\n\t\trc_stop\n\t\t;;\n\trestart)\n\t\trc_stop\n\t\trc_start\n\t\t;;\nesac\n\n";
|
||||
|
||||
@file_put_contents($rcfile_fullname, $towrite);
|
||||
unset($towrite);
|
||||
@chmod("{$rcfile_fullname}", 0755);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('start_service')) {
|
||||
function start_service($name) {
|
||||
global $config;
|
||||
|
||||
if (empty($name))
|
||||
return;
|
||||
|
||||
if (is_array($config['installedpackages']) && is_array($config['installedpackages']['service'])) {
|
||||
foreach($config['installedpackages']['service'] as $service) {
|
||||
if(strtolower($service['name']) == strtolower($name)) {
|
||||
if($service['rcfile']) {
|
||||
$prefix = RCFILEPREFIX;
|
||||
if (!empty($service['prefix'])) {
|
||||
$prefix =& $service['prefix'];
|
||||
}
|
||||
if(file_exists("{$prefix}{$service['rcfile']}") || is_link("{$prefix}{$service['rcfile']}")) {
|
||||
mwexec_bg("{$prefix}{$service['rcfile']} start");
|
||||
}
|
||||
}
|
||||
if (!empty($service['startcmd']))
|
||||
eval($service['startcmd']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!function_exists('stop_service')) {
|
||||
|
||||
function stop_service($name) {
|
||||
global $config;
|
||||
|
||||
if (empty($name))
|
||||
return;
|
||||
|
||||
if (is_array($config['installedpackages']) && is_array($config['installedpackages']['service'])) {
|
||||
foreach($config['installedpackages']['service'] as $service) {
|
||||
if(strtolower($service['name']) == strtolower($name)) {
|
||||
if($service['rcfile']) {
|
||||
$prefix = RCFILEPREFIX;
|
||||
if(!empty($service['prefix'])) {
|
||||
$prefix =& $service['prefix'];
|
||||
}
|
||||
if(file_exists("{$prefix}{$service['rcfile']}") || is_link("{$prefix}{$service['rcfile']}")) {
|
||||
mwexec("{$prefix}{$service['rcfile']} stop");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!empty($service['stopcmd']))
|
||||
eval($service['stopcmd']);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('restart_service')) {
|
||||
|
||||
function restart_service($name) {
|
||||
global $config;
|
||||
|
||||
if (empty($name))
|
||||
return;
|
||||
|
||||
stop_service($name);
|
||||
start_service($name);
|
||||
|
||||
if (is_array($config['installedpackages']) && is_array($config['installedpackages']['service'])) {
|
||||
foreach($config['installedpackages']['service'] as $service) {
|
||||
if(strtolower($service['name']) == strtolower($name)) {
|
||||
if($service['restartcmd']) {
|
||||
eval($service['restartcmd']);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('is_pid_running')) {
|
||||
|
||||
function is_pid_running($pidfile) {
|
||||
if (!file_exists($pidfile))
|
||||
return false;
|
||||
|
||||
return (isvalidpid($pidfile));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('is_dhcp_running')) {
|
||||
|
||||
function is_dhcp_running($interface) {
|
||||
$status = find_dhclient_process($interface);
|
||||
if($status != 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('restart_service_if_running')) {
|
||||
|
||||
function restart_service_if_running($service) {
|
||||
global $config;
|
||||
if(is_service_running($service))
|
||||
restart_service($service);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('is_service_enabled')) {
|
||||
|
||||
function is_service_enabled($service_name) {
|
||||
global $config;
|
||||
if ($service_name == "")
|
||||
return false;
|
||||
if (is_array($config['installedpackages'])) {
|
||||
if (isset($config['installedpackages'][$service_name]['config'][0]['enable']) &&
|
||||
((empty($config['installedpackages'][$service_name]['config'][0]['enable'])) ||
|
||||
($config['installedpackages'][$service_name]['config'][0]['enable'] === 'off'))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('is_service_running')) {
|
||||
|
||||
function is_service_running($service, $ps = "") {
|
||||
global $config;
|
||||
|
||||
if(is_array($config['installedpackages']['service'])) {
|
||||
foreach($config['installedpackages']['service'] as $aservice) {
|
||||
if(strtolower($service) == strtolower($aservice['name'])) {
|
||||
if ($aservice['custom_php_service_status_command'] <> "") {
|
||||
eval("\$rc={$aservice['custom_php_service_status_command']};");
|
||||
return $rc;
|
||||
}
|
||||
if(empty($aservice['executable']))
|
||||
return false;
|
||||
if (is_process_running($aservice['executable']))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_process_running($service))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('get_services')) {
|
||||
|
||||
function get_services() {
|
||||
global $config;
|
||||
if (is_array($config['installedpackages']['service']))
|
||||
$services = $config['installedpackages']['service'];
|
||||
else
|
||||
$services = array();
|
||||
|
||||
/* Add services that are in the base.
|
||||
*
|
||||
*/
|
||||
if (is_radvd_enabled()) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "radvd";
|
||||
$pconfig['description'] = gettext("Router Advertisement Daemon");
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
|
||||
if (isset($config['dnsmasq']['enable'])) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "dnsmasq";
|
||||
$pconfig['description'] = gettext("DNS Forwarder");
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
|
||||
if (isset($config['unbound']['enable'])) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "unbound";
|
||||
$pconfig['description'] = gettext("Unbound DNS Forwarder");
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "ntpd";
|
||||
$pconfig['description'] = gettext("NTP clock sync");
|
||||
$services[] = $pconfig;
|
||||
|
||||
if (is_array($config['captiveportal'])) {
|
||||
foreach ($config['captiveportal'] as $zone => $setting) {
|
||||
if (isset($setting['enable'])) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "captiveportal";
|
||||
$pconfig['zone'] = $zone;
|
||||
$pconfig['description'] = gettext("Captive Portal") . ": ".htmlspecialchars($setting['zone']);
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$iflist = array();
|
||||
$ifdescrs = get_configured_interface_list();
|
||||
foreach ($ifdescrs as $if) {
|
||||
$oc = $config['interfaces'][$if];
|
||||
if ($oc['if'] && (!link_interface_to_bridge($if)))
|
||||
$iflist[$if] = $if;
|
||||
}
|
||||
|
||||
if (isset($config['dhcrelay']['enable'])) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "dhcrelay";
|
||||
$pconfig['description'] = gettext("DHCP Relay");
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
|
||||
if (isset($config['dhcrelay6']['enable'])) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "dhcrelay6";
|
||||
$pconfig['description'] = gettext("DHCPv6 Relay");
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
|
||||
if (is_dhcp_server_enabled()) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "dhcpd";
|
||||
$pconfig['description'] = gettext("DHCP Service");
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
|
||||
$gateways_arr = return_gateways_array();
|
||||
if (is_array($gateways_arr)) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "apinger";
|
||||
$pconfig['description'] = gettext("Gateway Monitoring Daemon");
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
|
||||
if (isset($config['snmpd']['enable'])) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "bsnmpd";
|
||||
$pconfig['description'] = gettext("SNMP Service");
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
|
||||
if (is_array($config['igmpproxy']['igmpentry']) && (count($config['igmpproxy']['igmpentry']) > 0)) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "igmpproxy";
|
||||
$pconfig['description'] = gettext("IGMP proxy");
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
|
||||
if (isset($config['installedpackages']['miniupnpd']) && $config['installedpackages']['miniupnpd']['config'][0]['enable']) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "miniupnpd";
|
||||
$pconfig['description'] = gettext("UPnP Service");
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
|
||||
if (isset($config['installedpackages']['routed']) && $config['installedpackages']['routed']['config'][0]['enable']) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "routed";
|
||||
$pconfig['description'] = gettext("RIP Daemon");
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
|
||||
if (isset($config['ipsec']['enable'])) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "ipsec";
|
||||
$pconfig['description'] = gettext("IPsec VPN");
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
|
||||
if (isset($config['system']['enablesshd'])) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "sshd";
|
||||
$pconfig['description'] = gettext("Secure Shell Daemon");
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
|
||||
foreach (array('server', 'client') as $mode) {
|
||||
if (is_array($config['openvpn']["openvpn-{$mode}"])) {
|
||||
foreach ($config['openvpn']["openvpn-{$mode}"] as $id => $setting) {
|
||||
if (!isset($setting['disable'])) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "openvpn";
|
||||
$pconfig['mode'] = $mode;
|
||||
$pconfig['id'] = $id;
|
||||
$pconfig['vpnid'] = $setting['vpnid'];
|
||||
$pconfig['description'] = gettext("OpenVPN") . " ".$mode.": ".htmlspecialchars($setting['description']);
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($config['load_balancer']['virtual_server']) && count($config['load_balancer']['lbpool'])) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "relayd";
|
||||
$pconfig['description'] = gettext("Server load balancing daemon");
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
return $services;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('find_service_by_name')) {
|
||||
|
||||
function find_service_by_name($name) {
|
||||
$services = get_services();
|
||||
foreach ($services as $service)
|
||||
if ($service["name"] == $name)
|
||||
return $service;
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('find_service_by_openvpn_vpnid')) {
|
||||
|
||||
function find_service_by_openvpn_vpnid($vpnid) {
|
||||
$services = get_services();
|
||||
foreach ($services as $service)
|
||||
if (($service["name"] == "openvpn") && isset($service["vpnid"]) && ($service["vpnid"] == $vpnid))
|
||||
return $service;
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('find_service_by_cp_zone')) {
|
||||
|
||||
|
||||
function find_service_by_cp_zone($zone) {
|
||||
$services = get_services();
|
||||
foreach ($services as $service)
|
||||
if (($service["name"] == "captiveportal") && isset($service["zone"]) && ($service["zone"] == $zone))
|
||||
return $service;
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('service_name_compare')) {
|
||||
|
||||
|
||||
function service_name_compare($a, $b) {
|
||||
if (strtolower($a['name']) == strtolower($b['name']))
|
||||
return 0;
|
||||
return (strtolower($a['name']) < strtolower($b['name'])) ? -1 : 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('get_pkg_descr')) {
|
||||
|
||||
|
||||
function get_pkg_descr($package_name) {
|
||||
global $config;
|
||||
if (is_array($config['installedpackages']['package'])) {
|
||||
foreach($config['installedpackages']['package'] as $pkg) {
|
||||
if($pkg['name'] == $package_name)
|
||||
return $pkg['descr'];
|
||||
}
|
||||
}
|
||||
return gettext("Not available.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('get_service_status')) {
|
||||
|
||||
|
||||
function get_service_status($service) {
|
||||
global $g;
|
||||
switch ($service['name']) {
|
||||
case "openvpn":
|
||||
$running = is_pid_running("{$g['varrun_path']}/openvpn_{$service['mode']}{$service['vpnid']}.pid");
|
||||
break;
|
||||
case "captiveportal":
|
||||
$running = is_pid_running("{$g['varrun_path']}/lighty-{$service['zone']}-CaptivePortal.pid");
|
||||
if (isset($config['captiveportal'][$service['zone']]['httpslogin']))
|
||||
$running = $running && is_pid_running("{$g['varrun_path']}/lighty-{$service['zone']}-CaptivePortal-SSL.pid");
|
||||
break;
|
||||
case "vhosts-http":
|
||||
$running = is_pid_running("{$g['varrun_path']}/vhosts-http.pid");
|
||||
break;
|
||||
case "dhcrelay6":
|
||||
$running = is_pid_running("{$g['varrun_path']}/dhcrelay6.pid");
|
||||
break;
|
||||
case 'ipsec':
|
||||
$running = is_pid_running("{$g['varrun_path']}/charon.pid");
|
||||
break;
|
||||
default:
|
||||
$running = is_service_running($service['name']);
|
||||
}
|
||||
return $running;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('get_service_status_icon')) {
|
||||
|
||||
|
||||
function get_service_status_icon($service, $withtext = true, $smallicon = false) {
|
||||
global $g;
|
||||
$output = "";
|
||||
if(get_service_status($service)) {
|
||||
$statustext = gettext("Running");
|
||||
|
||||
$output .= '<span class="btn btn-success"><span class="glyphicon glyphicon-play"></span></span> ';
|
||||
|
||||
/*
|
||||
$output .= "<img style=\"vertical-align:middle\" title=\"" . sprintf(gettext("%s Service is"),$service["name"]) . " {$statustext}\" src=\"/themes/" . $g["theme"] . "/images/icons/";
|
||||
$output .= ($smallicon) ? "icon_pass.gif" : "icon_service_running.gif";
|
||||
$output .= "\" alt=\"status\" /> ";
|
||||
if ($withtext)
|
||||
$output .= " " . $statustext;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
$service_enabled = is_service_enabled($service['name']);
|
||||
$statustext = ($service_enabled) ? gettext("Stopped") : gettext("Disabled");
|
||||
|
||||
$output .= '<span class="btn btn-danger"><span class="glyphicon glyphicon-stop"></span></span> ';
|
||||
/*
|
||||
|
||||
$output .= "<img style=\"vertical-align:middle\" title=\"" . sprintf(gettext("%s Service is"),$service["name"]) . " {$statustext}\" src=\"/themes/" . $g["theme"] . "/images/icons/";
|
||||
$output .= ($smallicon) ? "icon_block.gif" : "icon_service_stopped.gif";
|
||||
$output .= "\" alt=\"status\" /> ";
|
||||
if ($withtext)
|
||||
$output .= " <font color=\"white\">{$statustext}</font>";
|
||||
*/
|
||||
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('get_service_control_links')) {
|
||||
|
||||
|
||||
function get_service_control_links($service, $addname = false) {
|
||||
global $g;
|
||||
$output = "";
|
||||
$stitle = ($addname) ? $service['name'] . " " : "";
|
||||
if(get_service_status($service)) {
|
||||
switch ($service['name']) {
|
||||
case "openvpn":
|
||||
$output .= "<a href='status_services.php?mode=restartservice&service={$service['name']}&vpnmode={$service['mode']}&id={$service['vpnid']}' class=\"btn btn-default\">";
|
||||
break;
|
||||
case "captiveportal":
|
||||
$output .= "<a href='status_services.php?mode=restartservice&service={$service['name']}&zone={$service['zone']}' class=\"btn btn-default\">";
|
||||
break;
|
||||
default:
|
||||
$output .= "<a href='status_services.php?mode=restartservice&service={$service['name']}' class=\"btn btn-default\">";
|
||||
}
|
||||
$output .= "<span title='" . sprintf(gettext("Restart %sService"),$stitle) . "' class=\"glyphicon glyphicon-refresh\"/></a>\n";
|
||||
switch ($service['name']) {
|
||||
case "openvpn":
|
||||
$output .= "<a href='status_services.php?mode=stopservice&service={$service['name']}&vpnmode={$service['mode']}&id={$service['vpnid']}' class=\"btn btn-default\">";
|
||||
break;
|
||||
case "captiveportal":
|
||||
$output .= "<a href='status_services.php?mode=stopservice&service={$service['name']}&zone={$service['zone']}' class=\"btn btn-default\">";
|
||||
break;
|
||||
default:
|
||||
$output .= "<a href='status_services.php?mode=stopservice&service={$service['name']}' class=\"btn btn-default\">";
|
||||
}
|
||||
$output .= "<span title='" . sprintf(gettext("Stop %sService"),$stitle) . "' class=\"glyphicon glyphicon-stop\" />";
|
||||
$output .= "</a>";
|
||||
} else {
|
||||
$service_enabled = is_service_enabled($service['name']);
|
||||
switch ($service['name']) {
|
||||
case "openvpn":
|
||||
$output .= "<a href='status_services.php?mode=startservice&service={$service['name']}&vpnmode={$service['mode']}&id={$service['vpnid']}' class=\"btn btn-default\">";
|
||||
break;
|
||||
case "captiveportal":
|
||||
$output .= "<a href='status_services.php?mode=startservice&service={$service['name']}&zone={$service['zone']}' class=\"btn btn-default\">";
|
||||
break;
|
||||
default:
|
||||
if ($service_enabled)
|
||||
$output .= "<a href='status_services.php?mode=startservice&service={$service['name']}' class=\"btn btn-default\">";
|
||||
}
|
||||
if ($service_enabled)
|
||||
$output .= "<span title='" . sprintf(gettext("Start %sService"),$stitle) . "' alt='start' class=\"glyphicon glyphicon-play\"/></a>\n";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('service_control_start')) {
|
||||
|
||||
|
||||
function service_control_start($name, $extras) {
|
||||
global $g;
|
||||
switch($name) {
|
||||
case 'radvd':
|
||||
services_radvd_configure();
|
||||
break;
|
||||
case 'captiveportal':
|
||||
$zone = htmlspecialchars($extras['zone']);
|
||||
captiveportal_init_webgui_zonename($zone);
|
||||
break;
|
||||
case 'ntpd':
|
||||
case 'openntpd':
|
||||
system_ntp_configure();
|
||||
break;
|
||||
case 'apinger':
|
||||
setup_gateways_monitor();
|
||||
break;
|
||||
case 'bsnmpd':
|
||||
services_snmpd_configure();
|
||||
break;
|
||||
case 'dhcrelay':
|
||||
services_dhcrelay_configure();
|
||||
break;
|
||||
case 'dhcrelay6':
|
||||
services_dhcrelay6_configure();
|
||||
break;
|
||||
case 'dnsmasq':
|
||||
services_dnsmasq_configure();
|
||||
break;
|
||||
case 'dhcpd':
|
||||
services_dhcpd_configure();
|
||||
break;
|
||||
case 'igmpproxy':
|
||||
services_igmpproxy_configure();
|
||||
break;
|
||||
case 'miniupnpd':
|
||||
upnp_action('start');
|
||||
break;
|
||||
case 'ipsec':
|
||||
vpn_ipsec_force_reload();
|
||||
break;
|
||||
case 'sshd':
|
||||
send_event("service restart sshd");
|
||||
break;
|
||||
case 'openvpn':
|
||||
$vpnmode = isset($extras['vpnmode']) ? htmlspecialchars($extras['vpnmode']) : htmlspecialchars($extras['mode']);
|
||||
if (($vpnmode == "server") || ($vpnmode == "client")) {
|
||||
$id = isset($extras['vpnid']) ? htmlspecialchars($extras['vpnid']) : htmlspecialchars($extras['id']);
|
||||
$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
|
||||
if (file_exists($configfile))
|
||||
openvpn_restart_by_vpnid($vpnmode, $id);
|
||||
}
|
||||
break;
|
||||
case 'relayd':
|
||||
relayd_configure();
|
||||
break;
|
||||
default:
|
||||
start_service($name);
|
||||
break;
|
||||
}
|
||||
return sprintf(gettext("%s has been started."),htmlspecialchars($name));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('service_control_stop')) {
|
||||
|
||||
|
||||
function service_control_stop($name, $extras) {
|
||||
global $g;
|
||||
switch($name) {
|
||||
case 'radvd':
|
||||
killbypid("{$g['varrun_path']}/radvd.pid");
|
||||
break;
|
||||
case 'captiveportal':
|
||||
$zone = htmlspecialchars($extras['zone']);
|
||||
killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal.pid");
|
||||
killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal-SSL.pid");
|
||||
break;
|
||||
case 'ntpd':
|
||||
killbyname("ntpd");
|
||||
break;
|
||||
case 'openntpd':
|
||||
killbyname("openntpd");
|
||||
break;
|
||||
case 'apinger':
|
||||
killbypid("{$g['varrun_path']}/apinger.pid");
|
||||
break;
|
||||
case 'bsnmpd':
|
||||
killbypid("{$g['varrun_path']}/snmpd.pid");
|
||||
break;
|
||||
case 'choparp':
|
||||
killbyname("choparp");
|
||||
break;
|
||||
case 'dhcpd':
|
||||
killbyname("dhcpd");
|
||||
break;
|
||||
case 'dhcrelay':
|
||||
killbypid("{$g['varrun_path']}/dhcrelay.pid");
|
||||
break;
|
||||
case 'dhcrelay6':
|
||||
killbypid("{$g['varrun_path']}/dhcrelay6.pid");
|
||||
break;
|
||||
case 'dnsmasq':
|
||||
killbypid("{$g['varrun_path']}/dnsmasq.pid");
|
||||
break;
|
||||
case 'unbound':
|
||||
killbypid("{$g['varrun_path']}/unbound.pid");
|
||||
break;
|
||||
case 'igmpproxy':
|
||||
killbyname("igmpproxy");
|
||||
break;
|
||||
case 'miniupnpd':
|
||||
upnp_action('stop');
|
||||
break;
|
||||
case 'sshd':
|
||||
killbyname("sshd");
|
||||
break;
|
||||
case 'ipsec':
|
||||
exec("/usr/local/sbin/ipsec stop");
|
||||
break;
|
||||
case 'openvpn':
|
||||
$vpnmode = htmlspecialchars($extras['vpnmode']);
|
||||
if (($vpnmode == "server") or ($vpnmode == "client")) {
|
||||
$id = htmlspecialchars($extras['id']);
|
||||
$pidfile = "{$g['varrun_path']}/openvpn_{$vpnmode}{$id}.pid";
|
||||
killbypid($pidfile);
|
||||
}
|
||||
break;
|
||||
case 'relayd':
|
||||
mwexec('pkill relayd');
|
||||
break;
|
||||
default:
|
||||
stop_service($name);
|
||||
break;
|
||||
}
|
||||
return sprintf(gettext("%s has been stopped."), htmlspecialchars($name));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('service_control_restart')) {
|
||||
|
||||
|
||||
function service_control_restart($name, $extras) {
|
||||
global $g;
|
||||
switch($name) {
|
||||
case 'radvd':
|
||||
services_radvd_configure();
|
||||
break;
|
||||
case 'captiveportal':
|
||||
$zone = htmlspecialchars($extras['zone']);
|
||||
killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal.pid");
|
||||
killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal-SSL.pid");
|
||||
captiveportal_init_webgui_zonename($zone);
|
||||
break;
|
||||
case 'ntpd':
|
||||
case 'openntpd':
|
||||
system_ntp_configure();
|
||||
break;
|
||||
case 'apinger':
|
||||
killbypid("{$g['varrun_path']}/apinger.pid");
|
||||
setup_gateways_monitor();
|
||||
break;
|
||||
case 'bsnmpd':
|
||||
services_snmpd_configure();
|
||||
break;
|
||||
case 'dhcrelay':
|
||||
services_dhcrelay_configure();
|
||||
break;
|
||||
case 'dhcrelay6':
|
||||
services_dhcrelay6_configure();
|
||||
break;
|
||||
case 'dnsmasq':
|
||||
services_dnsmasq_configure();
|
||||
break;
|
||||
case 'unbound':
|
||||
services_unbound_configure();
|
||||
break;
|
||||
case 'dhcpd':
|
||||
services_dhcpd_configure();
|
||||
break;
|
||||
case 'igmpproxy':
|
||||
services_igmpproxy_configure();
|
||||
break;
|
||||
case 'miniupnpd':
|
||||
upnp_action('restart');
|
||||
break;
|
||||
case 'ipsec':
|
||||
vpn_ipsec_force_reload();
|
||||
break;
|
||||
case 'sshd':
|
||||
send_event("service restart sshd");
|
||||
break;
|
||||
case 'openvpn':
|
||||
$vpnmode = htmlspecialchars($extras['vpnmode']);
|
||||
if ($vpnmode == "server" || $vpnmode == "client") {
|
||||
$id = htmlspecialchars($extras['id']);
|
||||
$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
|
||||
if (file_exists($configfile))
|
||||
openvpn_restart_by_vpnid($vpnmode, $id);
|
||||
}
|
||||
break;
|
||||
case 'relayd':
|
||||
relayd_configure(true);
|
||||
break;
|
||||
default:
|
||||
restart_service($name);
|
||||
break;
|
||||
}
|
||||
return sprintf(gettext("%s has been restarted."),htmlspecialchars($name));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user