Code and Cosmetic changes, some PHP8.x warning fixes

This commit is contained in:
JRGTH
2022-08-29 10:53:40 -04:00
parent a3829b1d3f
commit 010f964e36
8 changed files with 87 additions and 49 deletions

View File

@@ -3,6 +3,7 @@
======================
Version Description
1.1.18......Code and Cosmetic changes, some PHP8.x warning fixes.
1.1.17......Cosmetic changes, some PHP8.x warning fixes.
1.1.16......Add help support section for useful commands.
1.1.15......Add required files from FreeBSD 13.1 base release, update config.

View File

@@ -41,10 +41,12 @@ require_once("bastille_manager-lib.inc");
$pgtitle = array(gtext("Extensions"), "Bastille", "Create");
if(!$pconfig['jailname']):
$pconfig = [];
if(!(isset($pconfig['jailname']))):
$pconfig['jailname'] = 'jail1';
endif;
if(!$pconfig['ipaddress']):
if(!(isset($pconfig['ipaddress']))):
$pconfig['ipaddress'] = '';
endif;
@@ -89,21 +91,21 @@ if($_POST):
$release = "debian-buster";
endif;
if($_POST['thickjail'] && $_POST['vnetjail']):
if(isset($_POST['thickjail']) && isset($_POST['vnetjail'])):
$options = "-T -V";
elseif($_POST['thickjail']):
elseif(isset($_POST['thickjail'])):
$options = "-T";
elseif($_POST['vnetjail']):
elseif(isset($_POST['vnetjail'])):
$options = "-V";
elseif($_POST['linuxjail']):
elseif(isset($_POST['linuxjail'])):
$options = "-L";
endif;
if($_POST['emptyjail']):
if(isset($_POST['emptyjail'])):
// Just create an empty container with minimal jail.conf.
$cmd = ("/usr/local/bin/bastille create -E {$jname}");
else:
if ($_POST['nowstart']):
if (isset($_POST['nowstart'])):
$cmd = ("/usr/local/bin/bastille create {$options} {$jname} {$release} {$ipaddr} {$interface} && /usr/local/bin/bastille start {$jname}");
else:
$cmd = ("/usr/local/bin/bastille create {$options} {$jname} {$release} {$ipaddr} {$interface}");
@@ -114,7 +116,7 @@ if($_POST):
if(get_all_release_list()):
unset($output,$retval);mwexec2($cmd,$output,$retval);
if($retval == 0):
if ($_POST['autostart']):
if (isset($_POST['autostart'])):
exec("/usr/sbin/sysrc -f {$configfile} {$jname}_AUTO_START=\"YES\"");
endif;
if(is_link($resolv_conf)):
@@ -238,17 +240,17 @@ $document->render();
html_inputbox2('ipaddress',gettext('IP Address'),$pconfig['ipaddress'],'',true,20);
$a_action = $l_interfaces;
$b_action = $l_release;
html_combobox2('interface',gettext('Network interface'),$pconfig['interface'],$a_action,'',true,false);
html_combobox2('release',gettext('Base release'),$pconfig['release'],$b_action,'',true,false);
html_combobox2('interface',gettext('Network interface'),!empty($pconfig['interface']),$a_action,'',true,false);
html_combobox2('release',gettext('Base release'),!empty($pconfig['release']),$b_action,'',true,false);
if($bastille_version_min > "0700000000"):
html_checkbox2('thickjail',gettext('Create a thick container'),!empty($pconfig['thickjail']) ? true : false,gettext('These containers consume more space, but are self contained.'),'',false);
if($host_version > "12100"):
html_checkbox2('vnetjail',gettext('Enable VNET(VIMAGE)'),!empty($pconfig['vnetjail']) ? true : false,gettext('VNET-enabled containers are attached to a virtual bridge interface for connectivity(Advanced).'),'',false);
html_checkbox2('vnetjail',gettext('Enable VNET(VIMAGE)'),!empty($pconfig['vnetjail']) ? true : false,gettext('VNET-enabled containers are attached to a virtual bridge interface for connectivity(Only supported on 13.x and above).'),'',false);
endif;
html_checkbox2('emptyjail',gettext('Create an empty container'),!empty($pconfig['emptyjail']) ? true : false,gettext('This are ideal for custom builds, experimenting with unsupported RELEASES or Linux jails.'),'',false,false,'emptyjail_change()');
html_checkbox2('linuxjail',gettext('Create a Linux container'),!empty($pconfig['linuxjail']) ? true : false,gettext('This will create a Linux container, this is highly experimental and for testing purposes.'),'',false,false,'linuxjail_change()');
if($linux_compat_support == "YES"):
html_checkbox2('linuxjail',gettext('Create a Linux container'),!empty($pconfig['linuxjail']) ? true : false,gettext('This will create a Linux container, this is highly experimental and for testing purposes.'),'',false,false,'linuxjail_change()');
endif;
endif;
html_checkbox2('nowstart',gettext('Start after creation'),!empty($pconfig['nowstart']) ? true : false,gettext('Start the container after creation(May be overridden by later bastille releases).'),'',false);
html_checkbox2('autostart',gettext('Auto start on boot'),!empty($pconfig['autostart']) ? true : false,gettext('Automatically start the container at boot time.'),'',false);

View File

@@ -287,6 +287,7 @@ $document->render();
</thead>
<tbody>
<?php
global $identifier;
foreach ($sphere_array as $sphere_record):
$notificationmode = updatenotify_get_mode($sphere_notifier, $identifier);
$notdirty = (UPDATENOTIFY_MODE_DIRTY != $notificationmode) && (UPDATENOTIFY_MODE_DIRTY_CONFIG != $notificationmode);

View File

@@ -95,8 +95,9 @@ $is_linux_jail = exec("/usr/bin/grep linsysfs {$jail_dir}/{$jail_name_def}/fstab
if ($_POST):
global $configfile;
unset($savemsg);
unset($input_errors);
global $is_changed;
//unset($savemsg);
//unset($input_errors);
$pconfig = $_POST;
// Return to index.
@@ -161,15 +162,33 @@ if ($_POST):
if(isset($_POST['Submit']) && $_POST['Submit']):
// 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($pconfig['jname'])):
$jail_name = $pconfig['jname'];
endif;
if(isset($pconfig['hostname'])):
$jail_hostname = $pconfig['hostname'];
endif;
if(isset($pconfig['ipv4'])):
$jail_ipv4 = $pconfig['ipv4'];
endif;
if(isset($pconfig['ipv6'])):
$jail_ipv6 = $pconfig['ipv6'];
endif;
if(isset($pconfig['interface'])):
$jail_interface = $pconfig['interface'];
endif;
if(isset($pconfig['securelevel'])):
$jail_securelevel = $pconfig['securelevel'];
endif;
if(isset($pconfig['devfs_ruleset'])):
$jail_devfs_ruleset = $pconfig['devfs_ruleset'];
endif;
if(isset($pconfig['enforce_statfs'])):
$jail_enforce_statfs = $pconfig['enforce_statfs'];
endif;
if(isset($pconfig['vnet_interface'])):
$jail_vnet_interface = $pconfig['vnet_interface'];
endif;
// Check if the config has changed.
// This could be done with a nice foreach loop in the future.

View File

@@ -55,8 +55,8 @@ if(!initial_install_banner()):
endif;
// For legacy product versions.
$return_val = mwexec("/bin/cat /etc/prd.version | cut -d'.' -f1 | /usr/bin/grep '10'", true);
if ($return_val == 0) {
$legacy_check = mwexec("/bin/cat /etc/prd.version | cut -d'.' -f1 | /usr/bin/grep '10'", true);
if ($legacy_check == 0) {
if (is_array($config['rc']['postinit'] ) && is_array( $config['rc']['postinit']['cmd'] ) ) {
for ($i = 0; $i < count($config['rc']['postinit']['cmd']);) { if (preg_match('/bastille-init/', $config['rc']['postinit']['cmd'][$i])) break; ++$i; }
}
@@ -69,6 +69,7 @@ if (1 == mwexec("/bin/cat {$configfile} | /usr/bin/grep 'BACKUP_DIR='")) {
$backup_path = exec("/bin/cat {$configfile} | /usr/bin/grep 'BACKUP_DIR=' | cut -d'\"' -f2");
if ($_POST) {
global $retval;
global $zfs_activated;
global $backup_path_bastille;
global $configfile_bastille;
@@ -168,7 +169,8 @@ if ($_POST) {
if($backup_path_bastille !== $backup_path):
// Update bastille config if required.
$cmd = "/usr/sbin/sysrc -f {$configfile_bastille} bastille_backupsdir={$backup_path}";
unset($retval);mwexec($cmd,$retval);
//unset($retval);
mwexec($cmd,$retval);
if ($retval == 0) {
$savemsg .= gtext("Bastille config updated successfully.");
exec("echo '{$date}: {$application}: Bastille config updated successfully' >> {$logfile}");
@@ -180,7 +182,8 @@ if ($_POST) {
endif;
// Update extension config.
$cmd = "/usr/sbin/sysrc -f {$configfile} BACKUP_DIR={$backup_path}";
unset($retval);mwexec($cmd,$retval);
//unset($retval);
mwexec($cmd,$retval);
if ($retval == 0) {
$savemsg .= gtext("Extension settings saved successfully.");
exec("echo '{$date}: {$application}: Extension settings saved successfully' >> {$logfile}");
@@ -253,7 +256,8 @@ if ($_POST) {
else:
if (is_file($backup_file)) {
$cmd = ("/usr/local/bin/bastille import '{$filename_trim}'");
unset($output,$retval);mwexec2($cmd,$output,$retval);
//unset($output,$retval);
mwexec2($cmd,$output,$retval);
if ($retval == 0) {
$savemsg .= gtext("Container restored successfully.");
exec("echo '{$date}: {$application}: Container restored successfully from {$filename_trim}' >> {$logfile}");

View File

@@ -44,6 +44,7 @@ $pgtitle = [gtext("Extensions"), gtext('Bastille'),gtext('Releases')];
$sphere_array = [];
$sphere_record = [];
$pconfig = [];
function get_rel_list() {
global $rootfolder;
@@ -74,6 +75,7 @@ if ($linux_compat_support == "YES"):
'13.1-RELEASE' => gettext('13.1-RELEASE'),
'13.0-RELEASE' => gettext('13.0-RELEASE'),
'12.3-RELEASE' => gettext('12.3-RELEASE'),
//'12.4-RELEASE' => gettext('12.4-RELEASE'), -> To be uncommented when avail
'12.2-RELEASE' => gettext('12.2-RELEASE'),
'12.1-RELEASE' => gettext('12.1-RELEASE'),
'12.0-RELEASE' => gettext('12.0-RELEASE'),
@@ -91,6 +93,7 @@ else:
'13.1-RELEASE' => gettext('13.1-RELEASE'),
'13.0-RELEASE' => gettext('13.0-RELEASE'),
'12.3-RELEASE' => gettext('12.3-RELEASE'),
//'12.4-RELEASE' => gettext('12.4-RELEASE'), -> To be uncommented when avail
'12.2-RELEASE' => gettext('12.2-RELEASE'),
'12.1-RELEASE' => gettext('12.1-RELEASE'),
'12.0-RELEASE' => gettext('12.0-RELEASE'),
@@ -111,19 +114,22 @@ if($_POST):
endif;
if (isset($_POST['Download']) && $_POST['Download']):
$lib32 = "";
$ports = "";
$src = "";
$get_release = $pconfig['release_item'];
$check_release = ("{$rootfolder}/releases/{$get_release}");
$cmd = sprintf('/bin/echo "Y" | /usr/local/bin/bastille bootstrap %1$s > %2$s',$get_release,$logevent);
$base_mandatory = "base";
unset($lib32,$ports,$src);
if ($_POST['lib32']):
//unset($lib32,$ports,$src);
if (isset($_POST['lib32'])):
$lib32 = "lib32";
endif;
if ($_POST['ports']):
if (isset($_POST['ports'])):
$ports = "ports";
endif;
if ($_POST['src']):
if (isset($_POST['src'])):
$src = "src";
endif;
$opt_tarballs = "$lib32 $ports $src";
@@ -134,6 +140,8 @@ if($_POST):
//else:
// Download a FreeBSD base release.
if ($_POST['Download']):
$savemsg = "";
$errormsg = "";
if ($opt_tarballs):
if ($config_path):
// Override default distfiles once.
@@ -161,7 +169,6 @@ if($_POST):
if (isset($_POST['Destroy']) && $_POST['Destroy']):
if ($_POST['Destroy']):
$get_release = $pconfig['release_item'];
if($get_release == 'ubuntu-bionic'):
$get_release = "Ubuntu_1804";
@@ -279,8 +286,7 @@ $document->render();
</thead>
<tbody>
<?php
html_combobox2('release_item',gettext('Select Base Release'),$pconfig['release_item'],$a_action,'',true,false);
html_combobox2('release_item',gettext('Select Base Release'),!empty($pconfig['release_item']),$a_action,'',true,false);
html_titleline2(gettext('Optional Distfiles (Overrides config, has no effect on Linux Releases)'));
html_checkbox2('lib32',gettext('32-bit Compatibility'),!empty($pconfig['lib32']) ? true : false,gettext('lib32.txz'),'',false);
html_checkbox2('ports',gettext('Ports tree'),!empty($pconfig['ports']) ? true : false,gettext('ports.txz'),'',false);

View File

@@ -522,6 +522,7 @@ $document->render();
?>
<form action="bastille_manager_util.php" method="post" name="iform" id="iform"><table id="area_data"><tbody><tr><td id="area_data_frame">
<?php
global $sphere_notifier;
if(!empty($errormsg)):
print_error_box($errormsg);
endif;
@@ -551,9 +552,13 @@ $document->render();
#$current_release = exec("/usr/sbin/jexec {$pconfig['jailname']} freebsd-version 2>/dev/null");
unset($disable_base_change);
$current_release = exec("/usr/bin/grep '\-RELEASE' {$jail_dir}/{$pconfig['jailname']}/fstab | awk '{print $1}' | grep -o '[^/]*$'");
$is_thickjail = exec("/usr/bin/grep -w '/.*/.bastille' {$jail_dir}/{$pconfig['jailname']}/fstab");
$is_thinjail = exec("/usr/bin/grep -w '/.*/.bastille' {$jail_dir}/{$pconfig['jailname']}/fstab");
if (!$current_release):
$current_release = exec("/usr/bin/grep 'releng' {$jail_dir}/{$pconfig['jailname']}/root/COPYRIGHT | cut -d '/' -f2");
if(!$current_release):
//Assume is a running thickjail.
$current_release = exec("/usr/sbin/jexec {$pconfig['jailname']} freebsd-version 2>/dev/null");
endif;
$disable_base_change = "1";
if (!$current_release):
$current_release = "-";
@@ -591,24 +596,24 @@ $document->render();
];
endif;
html_combobox2('action',gettext('Action'),$pconfig['action'],$a_action,'',true,false,'action_change()');
html_combobox2('format',gettext('Archive format'),$pconfig['format'],$c_action,'',true,false);
html_combobox2('action',gettext('Action'),!empty($pconfig['action']),$a_action,'',true,false,'action_change()');
html_combobox2('format',gettext('Archive format'),!empty($pconfig['format']),$c_action,'',true,false);
if ($zfs_activated == "YES"):
html_checkbox2('safemode',gettext('Safe ZFS export'),!empty($pconfig['safemode']) ? true : false,gettext('Safely stop and start a ZFS jail before the exporting process, this has no effect on .TGZ/TXZ since the jail should be stopped regardless.'),'',false);
endif;
html_inputbox2('confirmname',gettext('Enter name for confirmation'),$pconfig['confirmname'],'',true,30);
html_inputbox2('confirmname',gettext('Enter name for confirmation'),!empty($pconfig['confirmname']),'',true,30);
html_checkbox2('nowstop',gettext('Stop container'),!empty($pconfig['nowstop']) ? true : false,gettext('Stop the container if running before deletion.'),'',false);
html_inputbox2('newname',gettext('Enter a name for the new container'),$pconfig['newname'],'',true,30);
html_inputbox2('newipaddr',gettext('Enter a IP address for the new container'),$pconfig['newipaddr'],'',true,30);
html_inputbox2('newname',gettext('Enter a name for the new container'),!empty($pconfig['newname']),'',true,30);
html_inputbox2('newipaddr',gettext('Enter a IP address for the new container'),!empty($pconfig['newipaddr']),'',true,30);
html_checkbox2('clonestop',gettext('Stop container'),!empty($pconfig['clonestop']) ? true : false,gettext('Stop the container if running before cloning, mandatory on UFS filesystem.'),'',false);
html_filechooser("source_path", gtext("Source Data Directory"), $pconfig['source_path'], gtext("Source data directory to be shared, full path here, if the path contain spaces they will be automatically escaped with the ASCII \"\\040\" octal code."), $source_path, false, 60);
html_filechooser("target_path", gtext("Target Data Directory"), $pconfig['target_path'], gtext("Target data directory to be mapped, full path to jail here, if the path contain spaces they will be automatically escaped with the ASCII \"\\040\" octal code."), $target_path, false, 60);
html_filechooser("source_path",gtext("Source Data Directory"),!empty($pconfig['source_path']), gtext("Source data directory to be shared, full path here, if the path contain spaces they will be automatically escaped with the ASCII \"\\040\" octal code."), !empty($source_path), false, 60);
html_filechooser("target_path",gtext("Target Data Directory"),!empty($pconfig['target_path']), gtext("Target data directory to be mapped, full path to jail here, if the path contain spaces they will be automatically escaped with the ASCII \"\\040\" octal code."), !empty($target_path), false, 60);
html_checkbox2("path_check", gettext("Source/Target path check"),!empty($pconfig['path_check']) ? true : false, gettext("If this option is selected no examination of the source/target directory paths will be performed."), "<b><font color='red'>".gettext("Please use this option only if you know what you are doing here!")."</font></b>", false);
html_checkbox2('advanced',gettext('Advanced jail configuration Files'),!empty($pconfig['advanced']) ? true : false,gettext('I want to edit the jail files manually, Warning: It is recommended to stop the jail before config edit to prevent issues.'),'',true);
html_checkbox2('readonly',gettext('Read-Only Mode'),!empty($pconfig['readonly']) ? true : false,gettext('Set target directory in Read-Only mode.'),'',true);
html_checkbox2('automount',gettext('Auto-mount Nullfs'),!empty($pconfig['automount']) ? true : false,gettext('Auto-mount the nullfs mountpoint if the container is already running.'),'',true);
html_checkbox2('createdir',gettext('Create Target Directory'),!empty($pconfig['createdir']) ? true : true,gettext('Create target directory if missing (recommended).'),'',true);
if ($is_thickjail):
if ($is_thinjail):
html_checkbox2('update_base',gettext('Base update confirm'),!empty($pconfig['update_base']) ? true : false,gettext('This is a thin container, therefore the base release will be updated, this affects child containers.'),'',true);
else:
html_checkbox2('update_jail',gettext('Container update confirm:'),!empty($pconfig['update_jail']) ? true : false,gettext('This is a thick container, therefore the update will be performed within its root, current containers are not affected.'),'',true);
@@ -619,7 +624,7 @@ $document->render();
html_text2('backup',gettext('Export container'),htmlspecialchars("This will export a container to a compressed file/image, please execute `bastille export` for more info in regards exporting formats, Default is .XZ on ZFS setups or .TXZ otherwise, For faster compressed backups consider .GZ/.TGZ."));
if (!$disable_base_change):
html_combobox2('release',gettext('New base release'),$pconfig['release'],$b_action,gettext("Warning: this will change current base to the selected base on the thin container only, the user is responsible for package updates and/or general incompatibilities issues, or use the command line for native upgrade."),true,false,);
html_combobox2('release',gettext('New base release'),!empty($pconfig['release']),$b_action,gettext("Warning: This will change current shared base to the selected base on the thin container only, the user is responsible for package updates and/or general incompatibilities issues, or use the command line for native upgrade."),true,false,);
endif;
//html_checkbox2('dateadd',gettext('Date'),!empty($pconfig['dateadd']) ? true : false,gettext('Append the date in the following format: ITEM-XXXX-XX-XX-XXXXXX.'),'',false);
?>

View File

@@ -1 +1 @@
1.1.17
1.1.18