From 4de5be80a062e2b6f4985cac9a9c2a092b469747 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Wed, 10 Dec 2014 23:25:46 +0100 Subject: [PATCH] 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. --- src/etc/inc/filter.inc | 7 +--- src/etc/inc/interfaces.inc | 20 +++++----- src/etc/inc/openvpn.inc | 5 +-- src/etc/inc/services.inc | 12 ------ src/etc/inc/system.inc | 33 +++++++---------- src/etc/inc/util.inc | 14 +------ src/etc/inc/vpn.inc | 9 +---- src/etc/rc | 67 +++++++++++++++------------------- src/etc/rc.bootup | 75 ++++++++++++-------------------------- src/etc/rc.initial | 4 -- 10 files changed, 84 insertions(+), 162 deletions(-) diff --git a/src/etc/inc/filter.inc b/src/etc/inc/filter.inc index 67c40fdcc..0b4d829ff 100644 --- a/src/etc/inc/filter.inc +++ b/src/etc/inc/filter.inc @@ -1,7 +1,6 @@ "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'])) diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index 98cf3c68d..52ac83fe8 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -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; diff --git a/src/etc/inc/vpn.inc b/src/etc/inc/vpn.inc index 4034d5166..65eb7ca63 100644 --- a/src/etc/inc/vpn.inc +++ b/src/etc/inc/vpn.inc @@ -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(); diff --git a/src/etc/rc b/src/etc/rc index a418a9c43..9ca72d773 100755 --- a/src/etc/rc +++ b/src/etc/rc @@ -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." diff --git a/src/etc/rc.bootup b/src/etc/rc.bootup index 205578a5a..c55215ee8 100755 --- a/src/etc/rc.bootup +++ b/src/etc/rc.bootup @@ -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(); - -?> diff --git a/src/etc/rc.initial b/src/etc/rc.initial index 153a9f87a..3a4fc24da 100755 --- a/src/etc/rc.initial +++ b/src/etc/rc.initial @@ -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