Commit 42225286 authored by Ad Schellevis's avatar Ad Schellevis

more legacy package system cleanups

parent e04e73fa
......@@ -726,37 +726,6 @@ function enable_rrd_graphing() {
/* End mbuf statistics */
/* SPAMD, set up the spamd rrd file */
if (isset($config['installedpackages']['spamdsettings']) &&
$config['installedpackages']['spamdsettings']['config'][0]['enablerrd']) {
/* set up the spamd rrd file */
if (!file_exists("$rrddbpath$ifname$spamd")) {
$rrdcreate = "$rrdtool create $rrddbpath$ifname$spamd --step $rrdspamdinterval ";
$rrdcreate .= "DS:conn:GAUGE:$spamdvalid:0:10000 ";
$rrdcreate .= "DS:time:GAUGE:$spamdvalid:0:86400 ";
$rrdcreate .= "RRA:MIN:0.5:1:1200 ";
$rrdcreate .= "RRA:MIN:0.5:5:720 ";
$rrdcreate .= "RRA:MIN:0.5:60:1860 ";
$rrdcreate .= "RRA:MIN:0.5:1440:2284 ";
$rrdcreate .= "RRA:AVERAGE:0.5:1:1200 ";
$rrdcreate .= "RRA:AVERAGE:0.5:5:720 ";
$rrdcreate .= "RRA:AVERAGE:0.5:60:1860 ";
$rrdcreate .= "RRA:AVERAGE:0.5:1440:2284 ";
$rrdcreate .= "RRA:MAX:0.5:1:1200 ";
$rrdcreate .= "RRA:MAX:0.5:5:720 ";
$rrdcreate .= "RRA:MAX:0.5:60:1860 ";
$rrdcreate .= "RRA:MAX:0.5:1440:2284 ";
create_new_rrd($rrdcreate);
unset($rrdcreate);
}
$rrdupdatesh .= "\n";
$rrdupdatesh .= "# polling spamd for connections and tarpitness \n";
$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$spamd \\\n";
$rrdupdatesh .= "`$php -q $spamd_gather`\n";
}
/* End System statistics */
/* Captive Portal statistics, set up the rrd file */
......
......@@ -34,62 +34,12 @@ require_once("vpn.inc");
require_once("vslb.inc");
require_once("gwlb.inc");
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();
$services = array();
/* Add services that are in the base.
*
......@@ -190,13 +140,6 @@ if (!function_exists('get_services')) {
$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";
......@@ -289,22 +232,6 @@ if (!function_exists('service_name_compare')) {
}
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')) {
......@@ -330,7 +257,7 @@ if (!function_exists('get_service_status')) {
$running = isvalidpid("{$g['varrun_path']}/charon.pid");
break;
default:
$running = is_service_running($service['name']);
$running = is_process_running($service['name']);
}
return $running;
}
......@@ -346,16 +273,9 @@ if (!function_exists('get_service_status_icon')) {
$output = "";
if(get_service_status($service)) {
$statustext = gettext("Running");
$output .= '<span class="btn btn-success"><span class="glyphicon glyphicon-play" title="'.sprintf(gettext('%s Service is'),$service['name']).' '.$statustext.'" data-toggle="tooltip" data-placement="bottom" ></span></span>&nbsp;';
}
else {
$service_enabled = is_service_enabled($service['name']);
$statustext = ($service_enabled) ? gettext("Stopped") : gettext("Disabled");
} else {
$statustext = gettext("Stopped") ;
$output .= '<span class="btn btn-danger"><span class="glyphicon glyphicon-stop" title="'.sprintf(gettext('%s Service is'),$service['name']).' '.$statustext.'" data-toggle="tooltip" data-placement="bottom" ></span></span>&nbsp;';
}
......@@ -397,7 +317,6 @@ if (!function_exists('get_service_control_links')) {
$output .= "<span data-toggle=\"tooltip\" data-placement=\"bottom\" 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&amp;service={$service['name']}&amp;vpnmode={$service['mode']}&amp;id={$service['vpnid']}' class=\"btn btn-default\">";
......@@ -409,8 +328,7 @@ if (!function_exists('get_service_control_links')) {
if ($service_enabled)
$output .= "<a href='status_services.php?mode=startservice&amp;service={$service['name']}' class=\"btn btn-default\">";
}
if ($service_enabled)
$output .= "<span data-toggle=\"tooltip\" data-placement=\"bottom\" title='" . sprintf(gettext("Start %sService"),$stitle) . "' alt='start' class=\"glyphicon glyphicon-play\"/></a>\n";
$output .= "<span data-toggle=\"tooltip\" data-placement=\"bottom\" title='" . sprintf(gettext("Start %sService"),$stitle) . "' alt='start' class=\"glyphicon glyphicon-play\"/></a>\n";
}
return $output;
}
......
......@@ -427,38 +427,25 @@ function system_routing_configure($interface = '')
$gatewayipv6 = get_interface_gateway_v6("wan");
@touch("/tmp/{$defaultif}_defaultgwv6");
}
$dont_add_route = false;
/* if OLSRD is enabled, allow WAN to house DHCP. */
if (is_array($config['installedpackages']['olsrd'])) {
foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
if(($olsrd['enabledyngw'] == "on") && ($olsrd['enable'] == "on")) {
$dont_add_route = true;
log_error(sprintf(gettext("Not adding default route because OLSR dynamic gateway is enabled.")));
break;
}
}
}
if ($dont_add_route == false ) {
if (!empty($interface) && $interface != $interfacegw)
;
else if (is_ipaddrv4($gatewayip)) {
log_error("ROUTING: remove current default route to $gatewayip");
mwexec("/sbin/route delete default");
log_error("ROUTING: setting default route to $gatewayip");
mwexec("/sbin/route add -inet default " . escapeshellarg($gatewayip));
}
if (!empty($interface) && $interface != $interfacegw)
;
else if (is_ipaddrv4($gatewayip)) {
log_error("ROUTING: remove current default route to $gatewayip");
mwexec("/sbin/route delete default");
log_error("ROUTING: setting default route to $gatewayip");
mwexec("/sbin/route add -inet default " . escapeshellarg($gatewayip));
}
if (!empty($interface) && $interface != $interfacegwv6)
;
else if (is_ipaddrv6($gatewayipv6)) {
$ifscope = "";
if (is_linklocal($gatewayipv6))
$ifscope = "%{$defaultifv6}";
log_error("ROUTING: setting IPv6 default route to {$gatewayipv6}{$ifscope}");
mwexec("/sbin/route delete -inet6 default " . escapeshellarg("{$gatewayipv6}{$ifscope}"));
mwexec("/sbin/route add -inet6 default " . escapeshellarg("{$gatewayipv6}{$ifscope}"));
}
if (!empty($interface) && $interface != $interfacegwv6)
;
else if (is_ipaddrv6($gatewayipv6)) {
$ifscope = "";
if (is_linklocal($gatewayipv6))
$ifscope = "%{$defaultifv6}";
log_error("ROUTING: setting IPv6 default route to {$gatewayipv6}{$ifscope}");
mwexec("/sbin/route delete -inet6 default " . escapeshellarg("{$gatewayipv6}{$ifscope}"));
mwexec("/sbin/route add -inet6 default " . escapeshellarg("{$gatewayipv6}{$ifscope}"));
}
system_staticroutes_configure($interface, false);
......@@ -639,15 +626,7 @@ function system_syslogd_start()
if (isset($syslogcfg)) {
$separatelogfacilities = array('ntp','ntpd','ntpdate','charon','openvpn','pptps','poes','l2tps','relayd','hostapd','dnsmasq','filterdns','unbound','dhcpd','dhcrelay','dhclient','dhcp6c','apinger','radvd','routed','olsrd','zebra','ospfd','bgpd','miniupnpd','filterlog');
$syslogconf = "";
if($config['installedpackages']['package']) {
foreach($config['installedpackages']['package'] as $package) {
if($package['logging']) {
array_push($separatelogfacilities, $package['logging']['facilityname']);
mwexec("{$log_create_directive} {$log_size} {$g['varlog_path']}/{$package['logging']['logfilename']}");
$syslogconf .= "!{$package['logging']['facilityname']}\n*.*\t\t\t\t\t\t {$log_directive}{$g['varlog_path']}/{$package['logging']['logfilename']}\n";
}
}
}
$facilitylist = implode(',', array_unique($separatelogfacilities));
$syslogconf .= "!radvd,routed,olsrd,zebra,ospfd,bgpd,miniupnpd\n";
if (!isset($syslogcfg['disablelocallogging']))
......
......@@ -382,7 +382,7 @@ function sync_unbound_service() {
unbound_generate_config();
do_as_unbound_user("start");
require_once("service-utils.inc");
if (is_service_running("unbound"))
if (is_process_running("unbound"))
do_as_unbound_user("restore_cache");
}
......@@ -573,7 +573,7 @@ function unbound_control($action) {
case "start":
// Start Unbound
if ($config['unbound']['enable'] == "on") {
if (!is_service_running("unbound"))
if (!is_process_running("unbound"))
do_as_unbound_user("start");
}
break;
......@@ -592,7 +592,7 @@ function unbound_control($action) {
break;
case "restore_cache":
// Restore Unbound's Cache
if ((is_service_running("unbound")) && ($config['unbound']['dumpcache'] == "on")) {
if ((is_process_running("unbound")) && ($config['unbound']['dumpcache'] == "on")) {
if (file_exists($cache_dumpfile) && filesize($cache_dumpfile) > 0)
do_as_unbound_user("load_cache < /var/tmp/unbound_cache");
}
......
......@@ -64,35 +64,6 @@ if (($pagename == "pkg.php") || ($pagename == "pkg_edit.php") || ($pagename == "
/* Build the full help URL. */
$helpurl .= "/help.php?page={$pagename}";
function return_ext_menu($section) {
global $config;
$htmltext = "";
$extarray = array();
if($config['installedpackages']['menu'] <> "") {
foreach($config['installedpackages']['menu'] as $menuitem) {
if($menuitem['section'] != $section) continue;
if($menuitem['url'] <> "") {
$test_url=$menuitem['url'];
$addresswithport = getenv("HTTP_HOST");
$colonpos = strpos($addresswithport, ":");
if ($colonpos !== False){
//my url is actually just the IP address of the OPNsense box
$myurl = substr($addresswithport, 0, $colonpos);
} else {
$myurl = $addresswithport;
}
$description = str_replace('$myurl', $myurl, $menuitem['url']);
} else {
$description = '/pkg.php?xml=' . $menuitem['configfile'];
$test_url=$description;
}
if(isAllowedPage($test_url)){
$extarray[] = array($menuitem['name'], $description);
}
}
}
return $extarray;
}
function output_menu($arrayitem, $target = null) {
foreach ($arrayitem as $item) {
......@@ -166,7 +137,7 @@ if (!isAllowedPage("system_usermanager.php*"))
$system_menu[] = array(gettext("User Manager"), "/system_usermanager_passwordmg.php");
else
$system_menu[] = array(gettext("User Manager"), "/system_usermanager.php");
$system_menu = msort(array_merge($system_menu, return_ext_menu("System")),0);
$system_menu = msort($system_menu,0);
// Interfaces
$interfaces_menu = array();
......@@ -176,7 +147,7 @@ $opts = get_configured_interface_with_descr(false, true);
foreach ($opts as $oif => $odescr)
if (!isset($config['interfaces'][$oif]['ovpn']))
$interfaces_menu[] = array(htmlspecialchars($odescr), "/interfaces.php?if={$oif}");
$interfaces_menu = msort(array_merge($interfaces_menu, return_ext_menu("Interfaces")),0);
$interfaces_menu = msort($interfaces_menu,0);
// Firewall
$firewall_menu = array();
......@@ -186,7 +157,7 @@ $firewall_menu[] = array(gettext("Rules"), "/firewall_rules.php");
$firewall_menu[] = array(gettext("Schedules"), "/firewall_schedule.php");
$firewall_menu[] = array(gettext("Traffic Shaper"), "/firewall_shaper.php");
$firewall_menu[] = array(gettext("Virtual IPs"), "/firewall_virtual_ip.php");
$firewall_menu = msort(array_merge($firewall_menu, return_ext_menu("Firewall")),0);
$firewall_menu = msort($firewall_menu,0);
// Services
$services_menu = array();
......@@ -210,7 +181,7 @@ if(count($config['interfaces']) > 1) {
$services_menu[] = array(gettext("UPnP &amp; NAT-PMP"), "/pkg_edit.php?xml=miniupnpd.xml");
}
$services_menu[] = array(gettext("Wake on LAN"), "/services_wol.php");
$services_menu = msort(array_merge($services_menu, return_ext_menu("Services")),0);
$services_menu = msort($services_menu, 0);
// VPN
$vpn_menu = array();
......@@ -218,7 +189,7 @@ $vpn_menu[] = array(gettext("IPsec"), "/vpn_ipsec.php");
$vpn_menu[] = array(gettext("OpenVPN"), "/vpn_openvpn_server.php");
$vpn_menu[] = array(gettext("PPTP"), "/vpn_pptp.php");
$vpn_menu[] = array(gettext("L2TP"), "/vpn_l2tp.php");
$vpn_menu = msort(array_merge($vpn_menu, return_ext_menu("VPN")),0);
$vpn_menu = msort($vpn_menu, 0);
// Status
$status_menu = array();
......@@ -249,7 +220,7 @@ foreach ($ifentries as $ent => $entdesc) {
}
if (count($wifdescrs) > 0)
$status_menu[] = array(gettext("Wireless"), "/status_wireless.php");
$status_menu = msort(array_merge($status_menu, return_ext_menu("Status")),0);
$status_menu = msort($status_menu, 0);
// Diagnostics
$diagnostics_menu = array();
......@@ -286,7 +257,7 @@ if (isset($config['system']['developer'])) {
$diagnostics_menu[] = array(gettext("Restart HTTPD"), "/restart_httpd.php", "style" => "font-weight: bold; color: yellow;");
}
$diagnostics_menu = msort(array_merge($diagnostics_menu, return_ext_menu("Diagnostics")),0);
$diagnostics_menu = msort($diagnostics_menu, 0);
$help_menu = array();
$help_menu[] = array(gettext("About this Page"), $helpurl);
......@@ -296,7 +267,7 @@ $help_menu[] = array(gettext("Documentation"), "https://wiki.opnsense.org/");
$help_menu[] = array(gettext("Developers Wiki"), "https://wiki.opnsense.org/index.php/Develop:Info");
$help_menu[] = array(gettext("Paid Support"), "https://opnsense.org/support-overview/commercial-support/");
$help_menu[] = array(gettext("FreeBSD Handbook"), "https://www.freebsd.org/doc/handbook/");
$help_menu = msort(array_merge($help_menu, return_ext_menu("Help")),0);
$help_menu = msort($help_menu, 0);
function add_to_menu($url, $name) {
if (isAllowedPage($url))
......
......@@ -80,16 +80,6 @@ $if = $_GET['if'];
if (!empty($_POST['if']))
$if = $_POST['if'];
/* if OLSRD is enabled, allow WAN to house DHCP. */
if($config['installedpackages']['olsrd']) {
foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
if($olsrd['enable']) {
$is_olsr_enabled = true;
break;
}
}
}
if (!$_GET['if'])
$savemsg = gettext("The DHCP Server can only be enabled on interfaces configured with static IP addresses") . ".<br/><br/>" . gettext("Only interfaces configured with a static IP will be shown") . ".";
......@@ -810,24 +800,6 @@ include("head.inc");
<?php endif; ?>
</td>
</tr>
<?php if($is_olsr_enabled): ?>
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet Mask");?></td>
<td width="78%" class="vtable">
<select name="netmask" class="form-control" id="netmask">
<?php
for ($i = 32; $i > 0; $i--) {
if($i <> 31) {
echo "<option value=\"{$i}\" ";
if ($i == $pconfig['netmask']) echo "selected=\"selected\"";
echo ">" . $i . "</option>";
}
}
?>
</select>
</td>
</tr>
<?php endif; ?>
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Range");?></td>
<td width="78%" class="vtable">
......
......@@ -38,16 +38,6 @@ $if = $_GET['if'];
if ($_POST['if'])
$if = $_POST['if'];
/* if OLSRD is enabled, allow WAN to house DHCP. */
if($config['installedpackages']['olsrd']) {
foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
if($olsrd['enable']) {
$is_olsr_enabled = true;
break;
}
}
}
if (!$_GET['if'])
$savemsg = "<p><b>" . gettext("The DHCPv6 Server can only be enabled on interfaces configured with static IP addresses") . ".</b></p>" .
"<p><b>" . gettext("Only interfaces configured with a static IP will be shown") . ".</b></p>";
......
......@@ -93,8 +93,6 @@ include("fbegin.inc");
foreach($services as $service) {
if (empty($service['name']))
continue;
if (empty($service['description']))
$service['description'] = get_pkg_descr($service['name']);
echo "<tr><td class=\"listlr\" >" . $service['name'] . "</td>\n";
echo "<td class=\"listr\">" . $service['description'] . "</td>\n";
// if service is running then listr else listbg
......
......@@ -67,10 +67,9 @@ $skipservices = explode(",", $config['widgets']['servicestatusfilter']);
if (count($services) > 0) {
uasort($services, "service_name_compare");
foreach($services as $service) {
if((!$service['name']) || (in_array($service['name'], $skipservices)) || (!is_service_enabled($service['name'])))
if(!$service['name'] || in_array($service['name'], $skipservices)) {
continue;
if (empty($service['description']))
$service['description'] = get_pkg_descr($service['name']);
}
$service_desc = explode(".",$service['description']);
echo "<tr><td class=\"listlr\">" . $service['name'] . "</td>\n";
echo "<td class=\"listr\">" . $service_desc[0] . "</td>\n";
......
......@@ -287,25 +287,6 @@ $merge_config_section_sig = array(
)
);
function merge_installedpackages_section_xmlrpc($raw_params) {
global $config, $xmlrpc_g;
if (xmlrpc_loop_detect()) {
log_error("Disallowing CARP sync loop");
return;
}
$params = xmlrpc_params_to_php($raw_params);
if(!xmlrpc_auth($params)) {
xmlrpc_authfail();
return $xmlrpc_g['return']['authfail'];
}
$config['installedpackages'] = array_merge($config['installedpackages'], $params[0]);
$mergedkeys = implode(",", array_keys($params[0]));
write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."),$mergedkeys));
return $xmlrpc_g['return']['true'];
}
/*****************************/
$merge_config_section_doc = gettext("XMLRPC wrapper for merge_config_section. This method must be called with two parameters: a string containing the local system\'s password and an array to merge into the system\'s config. This function returns true upon completion.");
......@@ -515,9 +496,6 @@ $server = new XML_RPC_Server(
'pfsense.merge_config_section' => array('function' => 'merge_config_section_xmlrpc',
'signature' => $merge_config_section_sig,
'docstring' => $merge_config_section_doc),
'pfsense.merge_installedpackages_section_xmlrpc' => array('function' => 'merge_installedpackages_section_xmlrpc',
'signature' => $merge_config_section_sig,
'docstring' => $merge_config_section_doc),
'pfsense.check_firmware_version' => array('function' => 'check_firmware_version_xmlrpc',
'signature' => $check_firmware_version_sig,
'docstring' => $check_firmware_version_doc),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment