inc: no idea why jails are special...

We can dash out jails, use them for development or production
environments even.  Sure, they may not support some priviledged
operation, but keeping weird glue around that is probably not
in all the places it should be is weird.
This commit is contained in:
Franco Fichtner 2014-12-10 23:25:46 +01:00
parent dcb849678a
commit 4de5be80a0
10 changed files with 84 additions and 162 deletions

View File

@ -1,7 +1,6 @@
<?php
/* $Id$ */
/*
filter.inc
Copyright (C) 2004-2006 Scott Ullrich
Copyright (C) 2005 Bill Marquette
Copyright (C) 2006 Peter Allgeyer
@ -122,10 +121,6 @@ function filter_pflog_start($kill_first = false)
{
global $config, $g;
if ($g['platform'] == 'jail') {
return;
}
if (!file_exists("{$g['varrun_path']}/filterlog.pid") ||
!isvalidpid("{$g['varrun_path']}/filterlog.pid")) {
mwexec("/usr/local/sbin/filterlog -i pflog0 -p {$g['varrun_path']}/filterlog.pid");

View File

@ -199,17 +199,21 @@ This block of code is only entered for OPTx interfaces that are configured for P
*/
}
function interfaces_loopback_configure() {
function interfaces_loopback_configure()
{
global $g;
if ($g['platform'] == 'jail')
return;
if($g['booting'])
if($g['booting']) {
echo gettext("Configuring loopback interface...");
}
pfSense_interface_setaddress("lo0", "127.0.0.1");
interfaces_bring_up("lo0");
if($g['booting'])
if($g['booting']) {
echo gettext("done.") . "\n";
}
return 0;
}
@ -1010,12 +1014,10 @@ function interface_gif_configure(&$gif, $gifkey = "") {
return $gifif;
}
function interfaces_configure() {
function interfaces_configure()
{
global $config, $g;
if ($g['platform'] == 'jail')
return;
/* Set up our loopback interface */
interfaces_loopback_configure();

View File

@ -991,11 +991,10 @@ function openvpn_resync($mode, $settings) {
}
// Resync and restart all VPNs
function openvpn_resync_all($interface = "") {
function openvpn_resync_all($interface = '')
{
global $g, $config;
if ($g['platform'] == 'jail')
return;
openvpn_create_dirs();
if (!is_array($config['openvpn']))

View File

@ -46,10 +46,6 @@ function services_radvd_configure($blacklist = array())
{
global $config, $g;
if ($g['platform'] == 'jail') {
return;
}
if (!is_array($config['dhcpdv6'])) {
$config['dhcpdv6'] = array();
}
@ -1378,10 +1374,6 @@ function services_dhcrelay_configure()
{
global $config, $g;
if ($g['platform'] == 'jail') {
return;
}
/* kill any running dhcrelay */
killbypid("{$g['varrun_path']}/dhcrelay.pid");
@ -1499,10 +1491,6 @@ function services_dhcrelay6_configure()
{
global $config, $g;
if ($g['platform'] == 'jail') {
return;
}
/* kill any running dhcrelay */
killbypid("{$g['varrun_path']}/dhcrelay6.pid");

View File

@ -39,12 +39,14 @@
pfSense_MODULE: utils
*/
function activate_powerd() {
function activate_powerd()
{
global $config, $g;
if ($g['platform'] == 'jail')
return;
if(is_process_running("powerd"))
exec("/usr/bin/killall powerd");
if (is_process_running('powerd')) {
exec('/usr/bin/killall powerd');
}
if(isset($config['system']['powerd_enable'])) {
if ($g["platform"] == "nanobsd")
exec("/sbin/kldload cpufreq");
@ -72,12 +74,10 @@ function get_default_sysctl_value($id) {
return $sysctls[$id];
}
function activate_sysctls() {
function activate_sysctls()
{
global $config, $g;
if ($g['platform'] == 'jail')
return;
$sysctls = array(
"net.enc.out.ipsec_bpf_mask" => "0x0001",
"net.enc.out.ipsec_filter_mask" => "0x0001",
@ -337,11 +337,10 @@ function system_hosts_generate()
return 0;
}
function system_dhcpleases_configure() {
function system_dhcpleases_configure()
{
global $config, $g;
if ($g['platform'] == 'jail')
return;
/* Start the monitoring process for dynamic dhcpclients. */
if ((isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcp']))
|| (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcp']))) {
@ -388,10 +387,6 @@ function system_routing_configure($interface = '')
{
global $config, $g;
if ($g['platform'] == 'jail') {
return;
}
$gatewayip = "";
$interfacegw = "";
$foundgw = false;
@ -1358,16 +1353,14 @@ function system_ntp_setup_pps($serialport) {
}
function system_ntp_configure($start_ntpd=true) {
function system_ntp_configure($start_ntpd = true)
{
global $config, $g;
$driftfile = "/var/db/ntpd.drift";
$statsdir = "/var/log/ntp";
$gps_device = '/dev/gps0';
if ($g['platform'] == 'jail')
return;
safe_mkdir($statsdir);
if (!is_array($config['ntpd']))

View File

@ -1637,13 +1637,13 @@ function get_memory() {
return array(($physmem/1048576),($realmem/1048576));
}
function mute_kernel_msgs() {
function mute_kernel_msgs()
{
global $config;
// Do not mute serial console. The kernel gets very very cranky
// and will start dishing you cannot control tty errors.
switch (trim(file_get_contents("/usr/local/etc/platform"))) {
case "nanobsd":
case "jail":
return;
}
if($config['system']['enableserial'])
@ -1657,21 +1657,11 @@ function unmute_kernel_msgs() {
// and will start dishing you cannot control tty errors.
switch (trim(file_get_contents("/usr/local/etc/platform"))) {
case "nanobsd":
case "jail":
return;
}
exec("/sbin/conscontrol mute off");
}
function start_devd() {
global $g;
if ($g['platform'] == 'jail')
return;
exec("/sbin/devd");
sleep(1);
}
function is_interface_vlan_mismatch() {
global $config, $g;

View File

@ -98,9 +98,6 @@ function vpn_ipsec_configure($ipchg = false)
{
global $config, $g, $sa, $sn, $p1_ealgos, $p2_ealgos;
if ($g['platform'] == 'jail')
return;
/* get the automatic ping_hosts.sh ready */
unlink_if_exists("{$g['vardb_path']}/ipsecpinghosts");
touch("{$g['vardb_path']}/ipsecpinghosts");
@ -900,12 +897,10 @@ function vpn_ipsec_force_reload($interface = "") {
}
/* master setup for vpn (mpd) */
function vpn_setup() {
function vpn_setup()
{
global $g;
if ($g['platform'] == 'jail')
return;
/* start pptpd */
vpn_pptpd_configure();

View File

@ -107,22 +107,20 @@ else
/usr/bin/make -C /root/core mount
fi
if [ ! "$PLATFORM" = "jail" ]; then
# Check to see if a compact flash mountpoint exists
# If it fails to mount then run a fsck -y
if grep -q cf /etc/fstab; then
# Check to see if a compact flash mountpoint exists
# If it fails to mount then run a fsck -y
if grep -q cf /etc/fstab; then
/sbin/mount -w /cf 2>/dev/null
/sbin/mount -uw /cf 2>/dev/null
mount_rc=$?
attempts=0
while [ ${mount_rc} != 0 -a ${attempts} -lt 3 ]; do
/sbin/umount /cf
/sbin/fsck -y /cf
/sbin/mount -w /cf 2>/dev/null
/sbin/mount -uw /cf 2>/dev/null
mount_rc=$?
attempts=0
while [ ${mount_rc} != 0 -a ${attempts} -lt 3 ]; do
/sbin/umount /cf
/sbin/fsck -y /cf
/sbin/mount -w /cf 2>/dev/null
mount_rc=$?
attempts=$((attempts+1))
done
fi
attempts=$((attempts+1))
done
fi
USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /cf/conf/config.xml`
@ -166,10 +164,8 @@ if [ "$PLATFORM" = "pfSense" ] && [ ${USE_MFS_TMPVAR} -eq 0 ]; then
/sbin/mdmfs -S -M -s 4m md /var/run
fi
if [ ! "$PLATFORM" = "jail" ]; then
# Enable console output if its muted.
/sbin/conscontrol mute off >/dev/null
fi
# Enable console output if its muted.
/sbin/conscontrol mute off >/dev/null
if [ "$PLATFORM" = "cdrom" ] ; then
# do nothing for cdrom platform
@ -182,8 +178,6 @@ elif [ "$PLATFORM" = "nanobsd" ] || [ ${USE_MFS_TMPVAR} -gt 0 ]; then
/bin/mkdir -p /root/var/db/pbi
/bin/rm -rf /var/db/pbi
/bin/ln -s /root/var/db/pbi/ /var/db/pbi
elif [ "$PLATFORM" = "jail" ]; then
# do nothing for jail platform
else
/sbin/swapon -a
/usr/local/etc/rc.savecore
@ -309,11 +303,10 @@ done
/bin/chmod 0600 /var/log/*.log
echo -n "."
if [ ! "$PLATFORM" = "jail" ]; then
DEVFS=`/sbin/mount | /usr/bin/grep devfs | /usr/bin/wc -l | /usr/bin/cut -d" " -f8`
if [ "$DEVFS" = "0" ]; then
mount_devfs devfs /dev
fi
DEVFS=`/sbin/mount | /usr/bin/grep devfs | /usr/bin/wc -l | /usr/bin/cut -d" " -f8`
if [ "$DEVFS" = "0" ]; then
mount_devfs devfs /dev
fi
# Create an initial utmp file
@ -323,20 +316,18 @@ echo -n "."
/sbin/ldconfig -elf /usr/lib /usr/local/lib /lib
/etc/rc.d/ldconfig start 2>/dev/null
if [ ! "$PLATFORM" = "jail" ]; then
# Launching kbdmux(4)
if [ -f "/dev/kbdmux0" ]; then
echo -n "."
/usr/sbin/kbdcontrol -k /dev/kbdmux0 < /dev/console
[ -c "/dev/atkbd0" ] && kbdcontrol -a atkbd0 < /dev/console
[ -c "/dev/ukbd0" ] && kbdcontrol -a ukbd0 < /dev/console
fi
# Launching kbdmux(4)
if [ -f "/dev/kbdmux0" ]; then
echo -n "."
/usr/sbin/kbdcontrol -k /dev/kbdmux0 < /dev/console
[ -c "/dev/atkbd0" ] && kbdcontrol -a atkbd0 < /dev/console
[ -c "/dev/ukbd0" ] && kbdcontrol -a ukbd0 < /dev/console
fi
# Fire up unionfs if mount points exist.
if [ -f /dist/uniondirs ]; then
echo -n "."
/etc/rc.d/unionfs start
fi
# Fire up unionfs if mount points exist.
if [ -f /dist/uniondirs ]; then
echo -n "."
/etc/rc.d/unionfs start
fi
echo "done."

View File

@ -144,66 +144,41 @@ if (file_exists("/root/firmware.tgz"))
/* start devd (dhclient now uses it) */
echo "Starting device manager (devd)...";
mute_kernel_msgs();
start_devd();
exec('/sbin/devd');
sleep(1);
set_device_perms();
unmute_kernel_msgs();
echo "done.\n";
// Display rescue configuration option
if($g['platform'] == "cdrom")
rescue_detect_keypress();
if ($g['platform'] == 'cdrom') {
rescue_detect_keypress();
}
echo "Loading configuration...";
parse_config_bootup();
echo "done.\n";
if($g['platform'] == "jail") {
/* We must determine what network settings have been configured for us */
$wanif = "lo0"; /* defaults, if the jail admin hasn't set us up */
$ipaddr = "127.0.0.1";
$iflist = get_interface_list();
foreach ($iflist as $iface => $ifa) {
if (isset($ifa['ipaddr'])) {
$wanif = $iface;
$ipaddr = $ifa['ipaddr'];
break;
}
}
$config['interfaces'] = array();
$config['interfaces']['lan'] = array();
$config['interfaces']['lan']['enable'] = false;
$config['interfaces']['wan'] = array();
/* XXX, todo */
$config['interfaces']['wan']['if'] = $wanif;
$config['interfaces']['wan']['ipaddr'] = $ipaddr;
$config['interfaces']['wan']['subnet'] = "32"; /* XXX right? */
$config['interfaces']['wan']['enable'] = true;
if($config['dhcpd']['lan'])
unset($config['dhcpd']['lan']['enable']);
unlink_if_exists('/conf/trigger_initial_wizard');
write_config();
} else {
/*
* Determine if we need to throw a interface exception
* and ask the user to reassign interfaces. This will
* avoid a reboot and thats a good thing.
*/
while(is_interface_mismatch() == true) {
led_assigninterfaces();
if (isset($config['revision'])) {
if (file_exists("{$g['tmp_path']}/missing_interfaces"))
echo "Warning: Configuration references interfaces that do not exist: " . file_get_contents("{$g['tmp_path']}/missing_interfaces") . "\n";
echo "\nNetwork interface mismatch -- Running interface assignment option.\n";
} else
echo "\nDefault interfaces not found -- Running interface assignment option.\n";
$ifaces = get_interface_list();
if (is_array($ifaces)) {
foreach($ifaces as $iface => $ifdata)
interfaces_bring_up($iface);
}
set_networking_interfaces_ports();
led_kitt();
/*
* Determine if we need to throw a interface exception
* and ask the user to reassign interfaces. This will
* avoid a reboot and thats a good thing.
*/
while(is_interface_mismatch() == true) {
led_assigninterfaces();
if (isset($config['revision'])) {
if (file_exists("{$g['tmp_path']}/missing_interfaces"))
echo "Warning: Configuration references interfaces that do not exist: " . file_get_contents("{$g['tmp_path']}/missing_interfaces") . "\n";
echo "\nNetwork interface mismatch -- Running interface assignment option.\n";
} else
echo "\nDefault interfaces not found -- Running interface assignment option.\n";
$ifaces = get_interface_list();
if (is_array($ifaces)) {
foreach($ifaces as $iface => $ifdata)
interfaces_bring_up($iface);
}
set_networking_interfaces_ports();
led_kitt();
}
/* convert config and clean backups */
@ -436,5 +411,3 @@ if ($ipsec_dynamic_hosts) {
led_normalize();
conf_mount_ro();
?>

View File

@ -28,10 +28,6 @@ WORD="https"
# Set our operating platform
PLATFORM=`cat /usr/local/etc/platform`
if [ "$PLATFORM" = "jail" ]; then
exit
fi
# endless loop
while : ; do