mirror of
https://github.com/unraid/webgui.git
synced 2026-05-12 23:30:01 -05:00
Merge pull request #165 from bergware/6.4-wip
Revert latest encryption changes to previous state
This commit is contained in:
@@ -15,22 +15,6 @@ Tag="snowflake-o"
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
function help_text() {
|
||||
global $flag;
|
||||
switch ($flag) {
|
||||
case 'file': return "<em>To unlock encrypted devices<br>select the keyfile which was originally set</em>";
|
||||
case 'text': return "<em>To unlock encrypted devices<br>enter the passphrase which was originally set</em>";
|
||||
default: return "<em>Encrypted device(s) present<br>Encryption settings required</em>";
|
||||
}
|
||||
}
|
||||
function input_text() {
|
||||
global $flag;
|
||||
switch ($flag) {
|
||||
case 'file': return "Keyfile: <input type='file' name='local' onchange='getFileContent(event,this.form)'";
|
||||
case 'text': return "Passphrase: <input type='password' name='text' maxlength='512' value='' onKeyUp=\"$('input[name=cmdStart]').prop('disabled',this.value.length==0)\"><input id='eye' type='checkbox' onchange='showPass(this.checked)'>show passphrase";
|
||||
default: return "<a href='/Settings/EncryptionSettings'><i class='fa fa-key'></i> GO TO ENCRYPTION SETTINGS</a>";
|
||||
}
|
||||
}
|
||||
function maintenance_mode() {
|
||||
echo "<tr>";
|
||||
echo "<td></td>";
|
||||
@@ -49,45 +33,17 @@ function status_indicator() {
|
||||
}
|
||||
return "<a class='info nohand' onclick='return false'><img src='$ball' class='icon'><span>$help</span></a>";
|
||||
}
|
||||
$keyfile = file_exists($var['luksKeyfile']);
|
||||
$cfg = '/boot/config/keyfile.cfg';
|
||||
$luks = false; foreach ($disks as $disk) $luks |= substr($disk['fsType'],0,5)=='luks:';
|
||||
$flag = $luks ? (file_exists($cfg) ? file_get_contents($cfg) : false) : false;
|
||||
?>
|
||||
<script>
|
||||
var ask1 = <?=$confirm['stop'] ? 'true' : 'false'?>;
|
||||
var ask2 = <?=$confirm['down'] ? 'true' : 'false'?>;
|
||||
var ctrl = "<span class='status'><a style='cursor:pointer' class='tooltip_diskio' title='Toggle reads/writes display' onclick='toggle_diskio();return false'><i class='toggle fa'></i></a></span>";
|
||||
|
||||
function showPass(checked) {
|
||||
$('input[name="text"]').attr('type',checked ? 'text' : 'password');
|
||||
}
|
||||
function getFileContent(event,form) {
|
||||
var input = event.target;
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(){form.file.value=reader.result; form.cmdStart.disabled=false;};
|
||||
reader.readAsText(input.files[0]);
|
||||
}
|
||||
function keyUpload(form) {
|
||||
<?if ($flag=='file'):?>
|
||||
form.file.disabled = true;
|
||||
form.local.disabled = true;
|
||||
$.post('/webGui/include/KeyUpload.php',{text:'',file:form.file.value});
|
||||
<?elseif ($flag=='text'):?>
|
||||
form.text.disabled = true;
|
||||
$.post('/webGui/include/KeyUpload.php',{text:form.text.value,file:''});
|
||||
<?endif;?>
|
||||
}
|
||||
function verify(form) {
|
||||
swal({title:'What do you want to do?',text:'Erase data OR correct encryption key',type:'warning',confirmButtonText:'Format',cancelButtonText:'Stop Array',showCancelButton:true},function(p){
|
||||
swal({title:'Found wrong encryption key',text:'Format unmountable disk(s) and ERASE ALL data?',type:'warning',showCancelButton:true},function(p){
|
||||
if (p) {
|
||||
$(form).append('<input type="hidden" name="cmdFormat" value="Format">');
|
||||
form.submit();
|
||||
} else {
|
||||
$.post('/webGui/include/KeyUpload.php',{text:'',file:''},function(){
|
||||
$(form).append('<input type="hidden" name="cmdStop" value="Stop">');
|
||||
form.submit();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -180,7 +136,6 @@ toggle_diskio(true);
|
||||
</script>
|
||||
<form name="arrayOps" method="POST" action="/update.htm" target="progressFrame">
|
||||
<input type="hidden" name="startState" value="<?=htmlspecialchars($var['mdState'])?>">
|
||||
<input type="hidden" name="file" value="" disabled>
|
||||
<table class="array_status">
|
||||
<?$parity = $var['mdResync']>0 ? '<small>Disabled -- Parity operation is running</small>' : '';
|
||||
$mover = file_exists('/var/run/mover.pid') ? '<small>Disabled -- Mover is running</small>' : '';
|
||||
@@ -197,17 +152,16 @@ toggle_diskio(true);
|
||||
<? $verify = false;
|
||||
foreach ($disks as $disk) if (strpos($disk['fsStatus'],'Unmountable')!==false) {
|
||||
echo "<br><span class='blue-text'>".my_disk($disk['name'])."</span> • ".my_id($disk['id'])." (".$disk['device'].")";
|
||||
if (strpos($disk['fsStatus'],'encryption')!==false) $verify = true;
|
||||
if (strpos($disk['fsStatus'],'Wrong')!==false) $verify = true;
|
||||
}
|
||||
?> </td>
|
||||
<? if ($verify):?>
|
||||
<td><input type="button" id="cmdFix" value="Fix" onclick="verify(this.form)"><input type="hidden" name="unmountable_mask" value="<?=$var['fsUnmountableMask']?>"></td>
|
||||
<td><strong>Fix</strong> allows to format all <strong>unmountable disks</strong> <u>OR</u> to stop the array and correct the <strong>encryption key</strong></td>
|
||||
<td><input type="button" id="cmdFormat" value="Format" disabled onclick="verify(this.form)"><input type="hidden" name="unmountable_mask" value="<?=$var['fsUnmountableMask']?>"></td>
|
||||
<? else:?>
|
||||
<td><input type="submit" name="cmdFormat" value="Format" disabled><input type="hidden" name="unmountable_mask" value="<?=$var['fsUnmountableMask']?>"></td>
|
||||
<td><strong>Format</strong> will create a file system in all <strong>Unmountable</strong> disks, discarding all data currently on those disks.<br>
|
||||
<input type="checkbox" name="confirmFormat" value="OFF" onClick="arrayOps.cmdFormat.disabled=!arrayOps.confirmFormat.checked"><small>Yes I want to do this</small></td>
|
||||
<td><input type="submit" id="cmdFormat" name="cmdFormat" value="Format" disabled><input type="hidden" name="unmountable_mask" value="<?=$var['fsUnmountableMask']?>"></td>
|
||||
<? endif;?>
|
||||
<td><strong>Format</strong> will create a file system in all <strong>Unmountable</strong> disks, discarding all data currently on those disks.<br>
|
||||
<input type="checkbox" name="confirmFormat" value="OFF" onClick="$('#cmdFormat').prop('disabled',!arrayOps.confirmFormat.checked)"><small>Yes I want to do this</small></td>
|
||||
</tr>
|
||||
<? endif;
|
||||
if (!$parity):
|
||||
@@ -402,15 +356,9 @@ toggle_diskio(true);
|
||||
case "STOPPED":
|
||||
if (strstr($var['mdResyncAction'],"recon")):?>
|
||||
<tr>
|
||||
<? if ($luks && !$keyfile):?>
|
||||
<td><?=status_indicator()?><span class="strong big">Stopped</span>. Missing encryption keyfile<br><br><?=help_text()?></td>
|
||||
<td><input type="submit" name="cmdStart" value="Start" onclick="keyUpload(this.form)" disabled></td>
|
||||
<td><?=input_text()?></td>
|
||||
<? else:?>
|
||||
<td><?=status_indicator()?><span class="strong big">Stopped</span>. Configuration valid.</td>
|
||||
<td><input type="submit" name="cmdStart" value="Start"></td>
|
||||
<td><strong>Start</strong> will bring the array on-line and start <strong>Parity-Sync</strong> and/or <strong>Data-Rebuild</strong>.</td>
|
||||
<? endif;?>
|
||||
</tr>
|
||||
<? elseif ($var['mdResyncAction']=="clear"):?>
|
||||
<tr>
|
||||
@@ -433,15 +381,9 @@ toggle_diskio(true);
|
||||
</tr>
|
||||
<? else:?>
|
||||
<tr>
|
||||
<? if ($luks && !$keyfile):?>
|
||||
<td><?=status_indicator()?><span class="strong big">Stopped</span>. Missing encryption keyfile<br><br><?=help_text()?></td>
|
||||
<td><input type="submit" name="cmdStart" value="Start" onclick="keyUpload(this.form)" disabled></td>
|
||||
<td><?=input_text()?></td>
|
||||
<? else:?>
|
||||
<td><?=status_indicator()?><span class="strong big">Stopped</span>. Configuration valid.</td>
|
||||
<td><input type="submit" name="cmdStart" value="Start"></td>
|
||||
<td><strong>Start</strong> will bring the array on-line.</td>
|
||||
<? endif;?>
|
||||
</tr>
|
||||
<? endif;
|
||||
maintenance_mode();
|
||||
@@ -449,30 +391,18 @@ toggle_diskio(true);
|
||||
case "NEW_ARRAY":
|
||||
if (strpos($disks['parity']['status'],"DISK_NP")===0 && (empty($disks['parity2']) || strpos($disks['parity2']['status'],"DISK_NP")===0)):?>
|
||||
<tr>
|
||||
<? if ($luks && !$keyfile):?>
|
||||
<td><?=status_indicator()?><span class="strong big">Stopped</span>. Missing encryption keyfile<br><br><?=help_text()?></td>
|
||||
<td><input type="submit" name="cmdStart" value="Start" onclick="keyUpload(this.form)" disabled></td>
|
||||
<td><?=input_text()?></td>
|
||||
<? else:?>
|
||||
<td><?=status_indicator()?><span class="strong big">Stopped</span>. Configuration valid.</td>
|
||||
<td><input type="submit" name="cmdStart" value="Start"></td>
|
||||
<td><strong>Start</strong> will record all disk information and bring the array on-line.
|
||||
<br>The array will be immediately available, but <strong>unprotected</strong> since <em>parity</em> has not been assigned.</td>
|
||||
<? endif;?>
|
||||
</tr>
|
||||
<? else:?>
|
||||
<tr>
|
||||
<? if ($luks && !$keyfile):?>
|
||||
<td><?=status_indicator()?><span class="strong big">Stopped</span>. Missing encryption keyfile<br><br><?=help_text()?></td>
|
||||
<td><input type="submit" name="cmdStart" value="Start" onclick="keyUpload(this.form)" disabled></td>
|
||||
<td><?=input_text()?></td>
|
||||
<? else:?>
|
||||
<td><?=status_indicator()?><span class="strong big">Stopped</span>. Configuration valid.</td>
|
||||
<td><input type="button" value="Start" onclick="parity_warning(this.form)"></td>
|
||||
<td><strong>Start</strong> will record all disk information, bring the array on-line, and start Parity-Sync.
|
||||
<br>The array will be immediately available, but <strong>unprotected</strong> until Parity-Sync completes.
|
||||
<br><input type="checkbox" name="md_invalidslot" value="99">Parity is already valid.</td>
|
||||
<? endif;?>
|
||||
</tr>
|
||||
<? endif;
|
||||
maintenance_mode();
|
||||
|
||||
@@ -18,9 +18,9 @@ Tag="key"
|
||||
<?
|
||||
$keyfile = file_exists($var['luksKeyfile']) ? $var['luksKeyfile'] : '';
|
||||
$online = $var['fsState']=='Stopped' ? '' : 'disabled';
|
||||
$cfg = '/boot/config/keyfile.cfg';
|
||||
$ini = '/var/local/emhttp/keyfile.ini';
|
||||
$luks = false; foreach ($disks as $disk) $luks |= substr($disk['fsType'],0,5)=='luks:';
|
||||
$flag = $luks ? (file_exists($cfg) ? file_get_contents($cfg) : false) : false;
|
||||
$flag = $luks ? (file_exists($ini) ? file_get_contents($ini) : false) : false;
|
||||
?>
|
||||
<script>
|
||||
<?if ($keyfile):?>
|
||||
@@ -29,7 +29,7 @@ function checkInput(form) {
|
||||
return true;
|
||||
}
|
||||
function toggleButton(checked) {
|
||||
$('input[name="#apply"],input[name="reset"]').prop('disabled',!checked);
|
||||
$('input[name="#apply"]').prop('disabled',!checked);
|
||||
}
|
||||
<?else:?>
|
||||
function checkInput(form) {
|
||||
@@ -83,11 +83,7 @@ Encryption key:
|
||||
> With array Started, the keyfile may be deleted to ensure there is no encryption key present on the server when
|
||||
> the array is online. Note that plugins are installed and may execute before and during the array Start process.
|
||||
|
||||
<?if ($flag):?>
|
||||
> Select **Reset** to forget the selected encryption input and start with a *clean* installation.
|
||||
|
||||
<?endif;?>
|
||||
Delete <input type="checkbox" name="keyfile" onchange="toggleButton(this.checked)"><?if ($flag):?> Reset <input type="checkbox" name="reset" disabled><?endif;?>
|
||||
Delete <input type="checkbox" name="keyfile" onchange="toggleButton(this.checked)">
|
||||
: <input type="submit" name="#apply" value="Delete" disabled><input type="button" value="Done" class="lock" onclick="done()">
|
||||
|
||||
<?else:?>
|
||||
|
||||
@@ -52,10 +52,10 @@ foreach ($file as $row) {
|
||||
if ($show) foreach ($rows as $row) {
|
||||
switch ($disks[$tag.str_replace($tag,'',$row)]['luksState']) {
|
||||
case 0: $luks .= "<i class='padlock grey-text fa fa-unlock' title='Not encrypted'></i>"; break;
|
||||
case 1: $luks .= "<i class='padlock green-text fa fa-unlock-alt' title='Encrypted'></i>"; break;
|
||||
case 2: $luks .= "<i class='padlock red-text fa fa-lock' title='Missing encryption key'></i>"; break;
|
||||
case 3: $luks .= "<i class='padlock red-text fa fa-lock' title='Wrong encryption key'></i>"; break;
|
||||
default: $luks .= "<i class='padlock red-text fa fa-lock' title='Unknown error'></i>"; break;}
|
||||
case 1: $luks .= "<i class='padlock green-text fa fa-unlock-alt' title='Encrypted and unlocked'></i>"; break;
|
||||
case 2: $luks .= "<i class='padlock red-text fa fa-lock' title='Locked: missing encryption key'></i>"; break;
|
||||
case 3: $luks .= "<i class='padlock red-text fa fa-lock' title='Locked: wrong encryption key'></i>"; break;
|
||||
default: $luks .= "<i class='padlock red-text fa fa-lock' title='Locked: unknown error'></i>"; break;}
|
||||
}
|
||||
$list[] = [
|
||||
'type' => $attr[0],
|
||||
|
||||
@@ -402,6 +402,9 @@ echo " <a href='http://lime-technology.com/wiki/index.php/Official_Documentation
|
||||
echo "</span></div>";
|
||||
?>
|
||||
<script>
|
||||
// Firefox specific workaround
|
||||
if (typeof InstallTrigger!=='undefined') $('#nav-block').addClass('mozilla');
|
||||
|
||||
function parseINI(data){
|
||||
var regex = {
|
||||
section: /^\s*\[\s*\"*([^\]]*)\s*\"*\]\s*$/,
|
||||
@@ -510,25 +513,31 @@ $(function() {
|
||||
var watchdog = new NchanSubscriber('/sub/var');
|
||||
watchdog.on('message', function(data){
|
||||
var ini=parseINI(data);
|
||||
var status, progress;
|
||||
if (ini['fsState']=="Stopped") {
|
||||
status="<span class='red strong'>Array Stopped</span>";
|
||||
}else if (ini['fsState']=="Starting") {
|
||||
status="<span class='orange strong'>Array Starting</span>";
|
||||
}else {
|
||||
status="<span class='green strong'>Array Started</span>";
|
||||
var status;
|
||||
if (ini['fsProgress']) {
|
||||
var flux=$.cookie('flux')||(ini['fsProgress'].search(/^Mount/)==0 ? 'Starting' : (ini['fsProgress'].search(/^Spin/)==0 ? 'Stopping' : null));
|
||||
if ($.cookie('flux')==null && flux) $.cookie('flux',flux);
|
||||
if (flux) {
|
||||
status="<span class='orange strong'>Array "+flux+"</span>•<span class='blue strong'>"+ini['fsProgress']+"</span>";
|
||||
} else {
|
||||
status=(ini['fsState']=="Stopped" ? "<span class='red strong'>Array Stopped</span>" : "<span class='green strong'>Array Started</span>")+"•<span class='orange strong'>"+ini['fsProgress']+"</span>";
|
||||
}
|
||||
} else if (ini['fsState']=="Stopped") {
|
||||
status=$.cookie('flux')=="Starting" ? "<span class='green strong'>Array Started</span>" : "<span class='red strong'>Array Stopped</span>";
|
||||
$.removeCookie('flux');
|
||||
} else {
|
||||
status=$.cookie('flux')=="Stopping" ? "<span class='red strong'>Array Stopped</span>" : "<span class='green strong'>Array Started</span>";
|
||||
$.removeCookie('flux');
|
||||
if (ini['mdResync'] > 0) {
|
||||
var action;
|
||||
if (ini['mdResyncAction'].indexOf("recon")>=0) action="Parity-Sync / Data-Rebuild";
|
||||
else if (ini['mdResyncAction'].indexOf("clear")>=0) action="Clearing";
|
||||
else if (ini['mdResyncAction'] == "check") action="Read-Check";
|
||||
else if (ini['mdResyncAction'].indexOf("check")>=0) action="Parity-Check";
|
||||
action += " " + (ini['mdResyncPos']/(ini['mdResync']/100+1)).toFixed(1) + " %";
|
||||
status += "•<span class='orange strong'>"+action+"</span>";
|
||||
action+=" "+(ini['mdResyncPos']/(ini['mdResync']/100+1)).toFixed(1)+" %";
|
||||
status+="•<span class='orange strong'>"+action+"</span>";
|
||||
}
|
||||
}
|
||||
if (ini['fsProgress'].length)
|
||||
status += "•<span class='blue strong'>"+ini['fsProgress']+"</span>";
|
||||
$('#statusbar').html(status);
|
||||
});
|
||||
watchdog.start();
|
||||
|
||||
@@ -60,10 +60,10 @@ function device_info(&$disk,$online) {
|
||||
$link = (strpos($disk['status'], 'DISK_NP')===false || $disk['name']=="cache") ? "<a href=\"".htmlspecialchars("$path/$type?name=$name")."\">".$fancyname."</a>" : $fancyname;
|
||||
switch ($disk['luksState']) {
|
||||
case 0: $luks = ""; break;
|
||||
case 1: $luks = "<i class='padlock fa ".($online?'fa-unlock-alt green-text':'fa-lock grey-text')."' title='Encrypted'></i>"; break;
|
||||
case 2: $luks = "<i class='padlock fa fa-lock red-text' title='Missing encryption key'></i>"; break;
|
||||
case 3: $luks = "<i class='padlock fa fa-lock red-text' title='Wrong encryption key'></i>"; break;
|
||||
default: $luks = "<i class='padlock fa fa-lock red-text' title='Unknown error'></i>"; break;
|
||||
case 1: $luks = "<i ".($online?"class='padlock fa fa-unlock-alt green-text' title='Encrypted and unlocked'":"class='padlock fa fa-lock grey-text' title='Encrypted and locked'")."></i>"; break;
|
||||
case 2: $luks = "<i class='padlock fa fa-lock red-text' title='Locked: missing encryption key'></i>"; break;
|
||||
case 3: $luks = "<i class='padlock fa fa-lock red-text' title='Locked: wrong encryption key'></i>"; break;
|
||||
default: $luks = "<i class='padlock fa fa-lock red-text' title='Locked: unknown error'></i>"; break;
|
||||
}
|
||||
return $status.$link.$luks;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
?>
|
||||
<?
|
||||
$var = parse_ini_file('/var/local/emhttp/var.ini');
|
||||
$cfg = '/boot/config/keyfile.cfg';
|
||||
$ini = '/var/local/emhttp/keyfile.ini';
|
||||
$luks = $var['luksKeyfile'];
|
||||
$text = $_POST['text'] ?? false;
|
||||
$file = $_POST['file'] ?? false;
|
||||
@@ -20,13 +20,12 @@ $flag = $_POST['flag'] ?? false;
|
||||
|
||||
if ($text) {
|
||||
file_put_contents($luks, $text);
|
||||
if ($flag) file_put_contents($cfg,'text');
|
||||
if ($flag) file_put_contents($ini,'text');
|
||||
} elseif ($file) {
|
||||
file_put_contents($luks, $file);
|
||||
if ($flag) file_put_contents($cfg,'file');
|
||||
if ($flag) file_put_contents($ini,'file');
|
||||
} else {
|
||||
@unlink($luks);
|
||||
if ($_POST['reset']) @unlink($cfg);
|
||||
}
|
||||
$save = false;
|
||||
?>
|
||||
|
||||
@@ -53,6 +53,7 @@ form+p{display:none}
|
||||
#nav-block{position:absolute;top:0;bottom:12px;color:#5D6833;white-space:nowrap;float:left;overflow-y:scroll;direction:rtl}
|
||||
#nav-block::-webkit-scrollbar{display:none}
|
||||
#nav-block{-ms-overflow-style:none;overflow:-moz-scrollbars-none}
|
||||
#nav-block.mozilla{margin-left:-17px;overflow-y:scroll}
|
||||
#nav-block>div{direction:ltr}
|
||||
#nav-item{width:24px;text-align:left;padding:14px 24px 14px 16px;border-bottom:#42453E 1px solid;font-size:18px;overflow:hidden}
|
||||
#nav-item:hover{width:150px;color:#5D6833;background:#ABC056;border-bottom-color:#5D6833;-webkit-transition:all 0.2s ease-in-out;transition:all 0.2s ease-in-out}
|
||||
|
||||
@@ -53,6 +53,7 @@ form+p{display:none}
|
||||
#nav-block{position:absolute;top:0;bottom:12px;color:#5D6833;white-space:nowrap;float:left;overflow-y:scroll;direction:rtl}
|
||||
#nav-block::-webkit-scrollbar{display:none}
|
||||
#nav-block{-ms-overflow-style:none;overflow:-moz-scrollbars-none}
|
||||
#nav-block.mozilla{margin-left:-17px;overflow-y:scroll}
|
||||
#nav-block>div{direction:ltr}
|
||||
#nav-item{width:24px;text-align:left;padding:14px 24px 14px 16px;border-bottom:#42453E 1px solid;font-size:18px;overflow:hidden}
|
||||
#nav-item:hover{width:150px;color:#5D6833;background:#ABC056;border-bottom-color:#5D6833;-webkit-transition:all 0.2s ease-in-out;transition:all 0.2s ease-in-out}
|
||||
|
||||
Reference in New Issue
Block a user