diff --git a/CHANGELOG b/CHANGELOG index f4d3028..285bb76 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ ====================== Version Description +1.0.50......Cosmetic changes, add misc configuration row to jail quick config. 1.0.49......Don't allow for blank fields in the jail config page. 1.0.48......Added jail name validation. 1.0.47......Cosmetic changes, display notify on success. diff --git a/gui/bastille_manager_jconf.php b/gui/bastille_manager_jconf.php index 2467faa..5279301 100644 --- a/gui/bastille_manager_jconf.php +++ b/gui/bastille_manager_jconf.php @@ -63,9 +63,12 @@ endif; $pgtitle = [gtext('Extensions'),gtext('Bastille'),gtext('Configuration'), $container]; $jail_config = "$jail_dir/$container/jail.conf"; +// Get some jail system settings. +$is_vnet = exec("/usr/bin/grep '.*vnet;' $jail_config"); +$pconfig['autostart'] = exec("/usr/bin/grep '{$container}_AUTO_START=\"YES\"' $bastille_config"); + // Get some jail config parameters. // This could be done with a nice php preg loop in the future. -$is_vnet = exec("/usr/bin/grep '.*vnet;' $jail_config"); $pconfig['jname'] = "$container"; $pconfig['hostname'] = exec("/usr/bin/grep '.*host.hostname.*=' $jail_config | /usr/bin/sed 's/.*host.hostname.*= //;s/;//'"); $pconfig['ipv4'] = exec("/usr/bin/grep '.*ip4.addr.*=' $jail_config | /usr/bin/sed 's/.*ip4.addr.*= //;s/;//'"); @@ -88,6 +91,7 @@ $jail_enforce_statfs_def = $pconfig['enforce_statfs']; $jail_vnet_interface_def = $pconfig['vnet_interface']; if ($_POST): + global $configfile; unset($savemsg); unset($input_errors); $pconfig = $_POST; @@ -153,24 +157,50 @@ if ($_POST): else: if(isset($_POST['Submit']) && $_POST['Submit']): - // Check if the jail is running. - $cmd = "/usr/sbin/jls -j $container >/dev/null 2>&1"; - unset($output,$retval);mwexec2($cmd,$output,$retval); - if($retval == 0): - $savemsg .= gtext("This jail is running, please stop it before making config changes."); + // Set current config values. + $jail_name = $pconfig['jname']; + $jail_hostname = $pconfig['hostname']; + $jail_ipv4 = $pconfig['ipv4']; + $jail_ipv6 = $pconfig['ipv6']; + $jail_interface = $pconfig['interface']; + $jail_securelevel = $pconfig['securelevel']; + $jail_devfs_ruleset = $pconfig['devfs_ruleset']; + $jail_enforce_statfs = $pconfig['enforce_statfs']; + $jail_vnet_interface = $pconfig['vnet_interface']; + + // Check if the config has changed. + // This could be done with a nice foreach loop in the future. + if($jail_name_def !== $jail_name): + $is_changed = "1"; + elseif($jail_hostname_def !== $jail_hostname): + $is_changed = "1"; + elseif(isset($_POST['ipv4']) && ($jail_ipv4_def !== $jail_ipv4)): + $is_changed = "1"; + elseif(isset($_POST['ipv6']) && ($jail_ipv6_def !== $jail_ipv6)): + $is_changed = "1"; + elseif(isset($_POST['interface']) && ($jail_interface_def !== $jail_interface)): + $is_changed = "1"; + elseif($jail_securelevel_def !== $jail_securelevel): + $is_changed = "1"; + elseif($jail_devfs_ruleset_def !== $jail_devfs_ruleset): + $is_changed = "1"; + elseif($jail_enforce_statfs_def !== $jail_enforce_statfs): + $is_changed = "1"; + elseif(isset($_POST['vnet_interface']) && ($jail_vnet_interface_def !== $jail_vnet_interface)): + $is_changed = "1"; + endif; + + if($is_changed): + // Check if the jail is running. + $cmd = "/usr/sbin/jls -j $container >/dev/null 2>&1"; + unset($output,$retval);mwexec2($cmd,$output,$retval); + else: + // Skip jail running check. + $retval = "1"; + endif; + if($retval == 0): + $input_errors[] = gtext("This jail is running, please stop it before making jail.conf changes."); else: - - // Set current config values. - $jail_name = $pconfig['jname']; - $jail_hostname = $pconfig['hostname']; - $jail_ipv4 = $pconfig['ipv4']; - $jail_ipv6 = $pconfig['ipv6']; - $jail_interface = $pconfig['interface']; - $jail_securelevel = $pconfig['securelevel']; - $jail_devfs_ruleset = $pconfig['devfs_ruleset']; - $jail_enforce_statfs = $pconfig['enforce_statfs']; - $jail_vnet_interface = $pconfig['vnet_interface']; - if (isset($_POST['hostname']) && $_POST['hostname']): if($jail_hostname_def !== $jail_hostname): $cmd = "/usr/bin/sed -i '' 's/.*host.hostname.*=.*;/ host.hostname = $jail_hostname;/' $jail_config"; @@ -282,6 +312,24 @@ if ($_POST): endif; endif; endif; + + if (isset($_POST['autostart']) && $_POST['autostart']): + $cmd = ("/usr/sbin/sysrc -f $configfile {$container}_AUTO_START=\"YES\""); + unset($output,$retval);mwexec2($cmd,$output,$retval); + if($retval == 0): + //$savemsg .= gtext("Autostart changed successfully."); + else: + $input_errors[] = gtext("Failed to enable autostart."); + endif; + else: + $cmd = ("/usr/sbin/sysrc -f $configfile {$container}_AUTO_START=\"NO\""); + unset($output,$retval);mwexec2($cmd,$output,$retval); + if($retval == 0): + //$savemsg .= gtext("Autostart changed successfully."); + else: + $input_errors[] = gtext("Failed to disable autostart."); + endif; + endif; //header("Location: bastille_manager_gui.php"); $savemsg .= gtext("Configuration has been saved successfully."); endif; @@ -294,11 +342,11 @@ endif;
| - - |