Skip to content
Permalink
Browse files

Correct mount zfs to jail

  • Loading branch information
alexey1234 committed Jul 29, 2016
1 parent f608096 commit 8c1901d5b109d3ee9ab88d0a94560e718a87b1a8
Showing with 44 additions and 45 deletions.
  1. +6 −43 conf/ext/thebrig/extensions_thebrig_edit.php
  2. +37 −1 conf/ext/thebrig/functions.inc
  3. +1 −1 conf/ext/thebrig/gui_addons.inc
@@ -116,10 +116,7 @@
// This identifies the jail section of the XML, but does so by reference.
$a_jail = &$config['thebrig']['content'];

//$a_interface = array(get_ifname($config['interfaces']['lan']['if']) => "LAN"); for ($i = 1; isset($config['interfaces']['opt' . $i]); ++$i) { $a_interface[$config['interfaces']['opt' . $i]['if']] = $config['interfaces']['opt' . $i]['descr']; }

//$input_errors[] = implode ( " | " , array_keys ( $a_interface ));
//$input_errors[] = implode( " | " , $a_interface);
// This checks that the $uuid variable is set, and that the
// attempt to determine the index of the jail config that has the same
// uuid as the page was entered with is not empty
@@ -361,24 +358,7 @@
$base_count++;
$pconfig['base_ver'] = $file_split[2] . "-" . $file_split[3];
}
/* elseif ( strcmp($file_split[0], 'FreeBSD') == 0 && strcmp($file_split[4], 'lib32.txz') == 0 ){
$lib_count++;
$pconfig['lib_ver'] = $file_split[2] . "-" . $file_split[3] ;
}
elseif ( strcmp($file_split[0], 'FreeBSD') == 0 && strcmp($file_split[4], 'doc.txz') == 0 ){
$doc_count++;
$pconfig['doc_ver'] = $file_split[2] . "-" . $file_split[3] ;
}
elseif ( strcmp($file_split[0], 'FreeBSD') == 0 && strcmp($file_split[4], 'src.txz') == 0 ){
$src_count++;
$pconfig['src_ver'] = $file_split[2] . "-" . $file_split[3] ;
}
else {
$pconfig['base_ver']= "Unknown";
$pconfig['lib_ver'] = "Unknown";
$pconfig['src_ver'] = "Unknown";
$pconfig['doc_ver'] = "Unknown";
} */

} // End of foreach
// Need to deal with keeping track of the lib version as the same as the base version
if ( $myarch != "amd64" ){
@@ -402,16 +382,6 @@
}
}

// This is a second test to see if the directory was created properly.
//if ( !is_dir( $pconfig['jailpath'] )){
// $input_errors[] = "Could not create directory for jail to live in!";
//}

// Validate if jail number is unique in order to reorder the jails (if necessary)
// Alexey - why do we care about the jail number or the uuid?
// Why not use the name?
// a_jail is the list of all jails, sorted by their jail number

if ( empty( $input_errors )) {
// Index is the location within a_jail that has the same jailnumber as the one just entered
@@ -669,10 +639,7 @@ function redirect() { window.location = "extensions_thebrig_fstab.php?uuid=<?=$p
<tr><td class="tabnavtbl">
<ul id="tabnav">
<li class="tabact"><a href="extensions_thebrig.php"><span><?=_THEBRIG_JAILS;?></span></a></li>
<?php /* If (!empty($config['thebrig']['content'])) {
$thebrigupdates=_THEBRIG_UPDATES;
echo "<li class=\"tabinact\"><a href=\"extensions_thebrig_update.php\"><span>{$thebrigupdates}</span></a></li>";
} else {} */?>

<li class="tabinact"><a href="extensions_thebrig_config.php"><span><?=_THEBRIG_MAINTENANCE;?></span></a></li>
</ul>
</td></tr>
@@ -701,18 +668,16 @@ function redirect() { window.location = "extensions_thebrig_fstab.php?uuid=<?=$p

html_combobox("statfs", _THEBRIG_J_STATFS, $pconfig['statfs'], $combovalues , _THEBRIG_J_STATFS_EXPL, false,false);?>

<?php//html_combobox("devfs_enable", gettext("Enable mount devfs \n <input type=\"button\" onclick=\"helpboxdevfs()\" value=\"Help\" />"), $pconfig['devfs_enable'], array('parent' =>'Main devfs','standart'=> 'Standart', 'custom'=> 'With ruleset'), "Choose devfs type", false,false,"devfs_change()");?>


<?php html_checkbox("devfs_enable", _THEBRIG_J_DEVFS, $pconfig['devfs_enable'], _THEBRIG_J_DEVFS_EXPL, "", "", "");?>
<?php html_brigdevfs_box("rule", _THEBRIG_J_DEVFSRULES, !empty($pconfig['rule']) ? $pconfig['rule'] : array(), _THEBRIG_J_DEVFSRULES_EXPL, false);?>


<?php //html_inputbox("devfsrules", gettext("Devfs ruleset name"), !empty($pconfig['devfsrules']) ? $pconfig['devfsrules'] : "devfsrules_jail", gettext("You can change standart ruleset"), false, 30);?>
<?php html_checkbox("proc_enable", _THEBRIG_J_PROCFS, $pconfig['proc_enable'], "", _THEBRIG_J_PROCFS_EXPL, " ", " ");?>
<?php html_checkbox("proc_enable", _THEBRIG_J_PROCFS, $pconfig['proc_enable'], "", _THEBRIG_J_PROCFS_EXPL, " ", " ");?>
<?php html_checkbox("fdescfs_enable", _THEBRIG_J_FDESCFS, $pconfig['fdescfs_enable'], "", _THEBRIG_J_FDESCFS_NOTE, " ");?>
<?php if (FALSE !== ($datasets_list = brig_datasets_list())) {
html_checkbox("zfs_enable", _THEBRIG_J_ZFS, isset($pconfig['zfs_enable']) ? true : false, "", "", " ");
html_zfs_box("zfs_dataset", _THEBRIG_J_ZFS_MOUNTED, $pconfig['zfs_dataset'], $datasets_list, false, false);
html_checkbox("zfs_enable", _THEBRIG_J_ZFS, isset($pconfig['zfs_enable']) ? true : false, "", "", " ");
html_zfs_box("zfs_dataset", _THEBRIG_J_ZFS_MOUNTED, $pconfig['zfs_dataset'], $datasets_list, false, false);
} else { echo " <input name='zfs_enable' type='hidden' value='' />";}
?>
<?php html_textarea("auxparam", _THEBRIG_J_FSTAB, $pconfig['auxparam'] , _THEBRIG_J_FSTAB_EXPL, false, 65, 5, false, false);?>
@@ -749,8 +714,6 @@ function redirect() { window.location = "extensions_thebrig_fstab.php?uuid=<?=$p
$a_interface[$config['interfaces']['opt' . $i]['if']] = $config['interfaces']['opt' . $i]['descr']; }?>
<?php html_combobox("if", _THEBRIG_VNET_LAN, $pconfig['if'], $a_interface, _THEBRIG_VNET_LAN_EXPL, true);?>
<?php } ?>
<?php //html_ipv4addrbox("ipaddr", "subnet", _THEBRIG_NETWORK gettext("Jail IPv4 address"), $pconfig['ipaddr'], $pconfig['subnet'], "", false);?>
<?php // html_ipv6addrbox("ipaddr6", "subnet6", gettext("Jail IPv6 address"), $pconfig['ipaddr6'], $pconfig['subnet6'], "", false);?>
<?php html_brig_network_box("allowedip", _THEBRIG_J_NETWORK, $pconfig['allowedip'], "May be multiple IPs and LANs", false, false) ; ?>

<?php html_separator();?>
@@ -704,6 +704,42 @@ function brig_zfs_check() {
if ( 0 < ( (count($dataset_names)) - (count($pool_names)) ) ){ return true; } else { return false;}
}
function brig_datasets_list() {
global $config;
$pool_names = array(); $dataset_names = array(); $errors = array();
// Using the -H option removes the headers, and uses a single \t between
// column entries
cmd_exec("zpool list -Ho name",$pool_names, $errors);
cmd_exec("zfs list -t filesystem -H -o jailed,name,mountpoint",$dataset_names, $errors);
$pool_count = count($pool_names);
$dataset_count = count($dataset_names);
$unique_count = $dataset_count - $pool_count ;
if (0 < $unique_count ){
for ($i=0; $i < $dataset_count;$i++) {
$cell[$i] = explode ( "\t" , $dataset_names[$i]);
for ($k=0; $k<$pool_count;$k++){
// Remove the pools from the list of datasets
if ( strcmp( $cell[$i][1] , rtrim($pool_names[$k]) ) === 0 ) {
unset ( $cell[$i]);
}
}
}
foreach ($cell as $cells ) { $cell1[] = array_filter($cells); }
for ($i=0; $i< count($cell1);) {
$pattern1=$cell1[$i][1];
$pattern1 = preg_quote($pattern1, '/' );
$pattern = "/".$pattern1."/";
$match = preg_match($pattern, $config['thebrig']['rootfolder']);
if (1 === $match) { unset ($cell1[$i]); }
$i++;
}
$cell1 = array_filter($cell1);
foreach ($cell1 as $cells ) { $datasets_list[] = array_filter($cells); }

return $datasets_list;
} else { return false; }
}

function brig_datasets_list_old() {
global $config;
$pool_names = array(); $dataset_names = array(); $errors = array();
// Using the -H option removes the headers, and uses a single \t between
@@ -831,7 +867,7 @@ function write_jailcommands ($out_jail) {
*/
$commandfile= $config['thebrig']['rootfolder'] . "conf/jails/poststart.". $out_jail['jailname'];
$post_handle = fopen( $commandfile, "w");
fwrite ($post_handle, "#!/bin/sh\n#\n");
fwrite ($post_handle, "#!/bin/sh\n#\nset -x\n");
$delete_post = true;
if (isset($out_jail['jail_vnet'] )) {
$delete_post = false;
@@ -530,7 +530,7 @@ class HTMLzfs_set extends HTMLBaseControl {
echo " <tr><td width='40%'><select name='{$ctrlname}filetype' class='formfld' id='{$ctrlname}filetype' >\n ";
if (isset($value)){
foreach ($options as $optionsv) {
echo " <option value='{$optionsv[2]}' {$optparam}>{$optionsv[2]}</option>\n";
echo " <option value='{$optionsv[1]}' {$optparam}>{$optionsv[1]}</option>\n";
}}


0 comments on commit 8c1901d

Please sign in to comment.