From 083f926424ff2d80ccac3950110108d103e77e8e Mon Sep 17 00:00:00 2001 From: Jose Date: Sat, 9 May 2020 18:19:45 -0400 Subject: [PATCH] Don't allow for blank fields in the jail config page --- CHANGELOG | 1 + gui/bastille_manager_jconf.php | 27 +++++++++++++++------------ version | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0642dfe..f4d3028 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ ====================== Version Description +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. 1.0.46......Added simple page for quick jail config, cosmetic changes. diff --git a/gui/bastille_manager_jconf.php b/gui/bastille_manager_jconf.php index 2dbbfa4..2467faa 100644 --- a/gui/bastille_manager_jconf.php +++ b/gui/bastille_manager_jconf.php @@ -104,40 +104,43 @@ if ($_POST): if(!preg_match('/^[A-Za-z0-9-_]+$/D', $pconfig['jname'])): $input_errors[] = gtext("A valid jail name must be specified."); endif; + else: + $input_errors[] = gtext("A valid jail name must be specified, it can't be left blank."); endif; if(isset($_POST['hostname']) && ($pconfig['hostname'])): if(preg_match('/\s/', $pconfig['hostname'])): $input_errors[] = gtext("A valid hostname must be specified."); endif; + else: + $input_errors[] = gtext("A valid hostname must be specified, it can't be left blank."); endif; - if(isset($_POST['ipv4']) && ($pconfig['ipv4'])): + if(isset($_POST['ipv4'])): if(!preg_match('/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))?$/', $pconfig['ipv4'])): $input_errors[] = gtext("A valid IPv4 address must be specified."); - endif; endif; - if(isset($_POST['ipv6']) && ($pconfig['ipv6'])): + if(isset($_POST['ipv6'])): if(!preg_match('/^(([a-fA-F0-9:]+$)|([a-fA-F0-9:]+\/[0-9]{1,3}$))/', $pconfig['ipv6'])): $input_errors[] = gtext("A valid IPv6 address must be specified."); endif; endif; - if(isset($_POST['securelevel']) && ($pconfig['securelevel'])): + if(isset($_POST['securelevel'])): if(!preg_match('/^[0-3]$/', $pconfig['securelevel'])): $input_errors[] = gtext("A valid number must be specified for securelevel, between 0-3."); endif; endif; - if(isset($_POST['devfs_ruleset']) && ($pconfig['devfs_ruleset'])): + if(isset($_POST['devfs_ruleset'])): if(!preg_match('/^([0-9]{1,3})$/', $pconfig['devfs_ruleset'])): $input_errors[] = gtext("A valid number must be specified for devfs_ruleset."); endif; endif; - if(isset($_POST['enforce_statfs']) && ($pconfig['enforce_statfs'])): + if(isset($_POST['enforce_statfs'])): if(!preg_match('/^[0-2]$/', $pconfig['enforce_statfs'])): $input_errors[] = gtext("A valid number must be specified for enforce_statfs, between 0-2."); endif; @@ -304,14 +307,14 @@ endif;