From 5120905f1c225e3a9d089e46433fc6893d39a915 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 23 Sep 2016 09:40:43 +0200 Subject: [PATCH] dashboard: advertise LiveCD mode and SSH choices --- src/etc/inc/interfaces.inc | 18 ++++++++++++++++++ src/etc/inc/util.inc | 18 ++++++++++++++++++ src/etc/rc.bootup | 34 +--------------------------------- src/www/guiconfig.inc | 9 +++++++++ src/www/index.php | 1 + 5 files changed, 47 insertions(+), 33 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index e2bfd3f32..72bc3c158 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -5208,3 +5208,21 @@ function get_carp_interface_status($carpinterface) } return; } + +function is_interface_mismatch() +{ + global $config; + + if (isset($config['interfaces'])) { + foreach (legacy_config_get_interfaces(array("virtual" => false)) as $ifname => $ifcfg) { + if (preg_match("/^enc|^cua|^tun|^tap|^l2tp|^pptp|^ppp|^ovpn|^gif|^gre|^lagg|^bridge|vlan|_wlan/i", $ifcfg['if'])) { + /* Do not check these interfaces */ + continue; + } elseif (does_interface_exist($ifcfg['if']) == false) { + return true; + } + } + } + + return false; +} diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index ece4e1aaf..059ab1062 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -1559,3 +1559,21 @@ function is_fqdn($fqdn) return $hostname; } + +function is_install_media() +{ + /* + * Despite unionfs underneath, / is still not writeable, + * making the following the perfect test for install media. + */ + + $file = '/.probe.for.install.media'; + $fd = @fopen($file, 'w'); + if ($fd) { + fclose($fd); + unlink($file); + return false; + } + + return true; +} diff --git a/src/etc/rc.bootup b/src/etc/rc.bootup index 7cefcf61a..a3239e546 100755 --- a/src/etc/rc.bootup +++ b/src/etc/rc.bootup @@ -29,39 +29,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -function is_install_media() -{ - /* - * Despite unionfs underneath, / is still not writeable, - * making the following the perfect test for install media. - */ - - $file = '/.probe.for.install.media'; - $fd = @fopen($file, 'w'); - if ($fd) { - fclose($fd); - unlink($file); - return false; - } - return true; -} - -function is_interface_mismatch() -{ - global $config; - if (isset($config['interfaces'])) { - foreach (legacy_config_get_interfaces(array("virtual" => false)) as $ifname => $ifcfg) { - if (preg_match("/^enc|^cua|^tun|^tap|^l2tp|^pptp|^ppp|^ovpn|^gif|^gre|^lagg|^bridge|vlan|_wlan/i", $ifcfg['if'])) { - /* Do not check these interfaces */ - continue; - } elseif (does_interface_exist($ifcfg['if']) == false) { - return true; - } - } - } - return false; -} - +/* looks weird, but means we started PHP successfully */ echo " done.\n"; echo "Initializing..."; diff --git a/src/www/guiconfig.inc b/src/www/guiconfig.inc index 5aacd1b58..16d3e582d 100644 --- a/src/www/guiconfig.inc +++ b/src/www/guiconfig.inc @@ -269,6 +269,15 @@ function print_service_banner($service) '' )); break; + case 'livecd': + if (!is_install_media()) { + break; + } + print_alert_box( + gettext('You are currently running in LiveCD mode. A reboot will reset the configuration.') .' ' . + (is_process_running('sshd') ? gettext('SSH remote login is enabled for the users "root" and ' . + '"installer" using the same password.') : gettext('SSH remote login is disabled.')) + ); default: break; } diff --git a/src/www/index.php b/src/www/index.php index 4840a8412..443216954 100644 --- a/src/www/index.php +++ b/src/www/index.php @@ -310,6 +310,7 @@ include("fbegin.inc");?>