mirror of
https://github.com/unraid/webgui.git
synced 2026-01-15 14:09:54 -06:00
299 lines
13 KiB
Plaintext
299 lines
13 KiB
Plaintext
Menu="Disk Share Flash"
|
|
Title="SMB Security Settings"
|
|
Tag="windows"
|
|
Cond="(($var['shareSMBEnabled']!='no') && (isset($name)?array_key_exists($name,$sec):0))"
|
|
---
|
|
<?PHP
|
|
/* Copyright 2005-2018, Lime Technology
|
|
* Copyright 2012-2018, Bergware International.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License version 2,
|
|
* as published by the Free Software Foundation.
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*/
|
|
?>
|
|
<?
|
|
$width = [123,305];
|
|
?>
|
|
> *Read settings from* is used to preset the SMB security settings of the current selected share with the settings of an existing share.
|
|
>
|
|
> Select the desired share name and press **Read** to copy the SMB security settings from the selected source.
|
|
>
|
|
> *Write settings to* is used to copy the SMB security settings of the current selected share to one or more other existing shares.
|
|
>
|
|
> Select the desired destinations and press **Write** to copy the SMB security settings to the selected shares.
|
|
|
|
<div class="clone1">
|
|
<span class="clone">Read settings from</span><i class="fa fa-arrow-left clone"></i>
|
|
<select name="readsmb" size="1" class="clone" onchange="toggleButton('readsmb',false)">
|
|
<option disabled selected>select...</option>
|
|
<?
|
|
if (isset($disks[$name])) {
|
|
foreach (array_filter($disks,'clone_list') as $list) if ($list['name']!=$name) echo mk_option("", $list['name'], my_disk($list['name']));
|
|
} else {
|
|
foreach ($shares as $list) if ($list['name']!=$name) echo mk_option("", $list['name'], $list['name']);
|
|
}
|
|
?>
|
|
</select><input type="button" id="readsmb" value="Read" class="clone" onclick="readSMB()" disabled>
|
|
</div>
|
|
<div class="clone2">
|
|
<span class="clone">Write settings to</span><i class="fa fa-arrow-right clone"></i>
|
|
<select id="smb1" name="writesmb" size="1" multiple="multiple" style="display:none" onchange="toggleButton('writesmb',this.id)">
|
|
<?
|
|
$rows = [];
|
|
if (isset($disks[$name])) {
|
|
foreach (array_filter($disks,'clone_list') as $list) if ($list['name']!=$name) $rows[] = mk_option("", $list['name'], my_disk($list['name']));
|
|
} else {
|
|
foreach ($shares as $list) if ($list['name']!=$name) $rows[] = mk_option("", $list['name'], $list['name']);
|
|
}
|
|
if ($rows) echo "<option>All</option>";
|
|
foreach ($rows as $row) echo $row;
|
|
?>
|
|
</select><input type="button" id="writesmb" value="Write" class="clone" onclick="writeSMB()" disabled>
|
|
</div>
|
|
|
|
<form markdown="1" name="smb_edit" method="POST" action="/update.htm" target="progressFrame" onchange="toggleButton('writesmb',true);$('#smb1').dropdownchecklist('disable')">
|
|
<input type="hidden" name="shareName" value="<?=htmlspecialchars($name)?>">
|
|
|
|
Share name:
|
|
: <span class="big"><?=htmlspecialchars($name)?></span>
|
|
|
|
Export:
|
|
: <select name="shareExport" size="1">
|
|
<?=mk_option($sec[$name]['export'], "-", "No");?>
|
|
<?=mk_option($sec[$name]['export'], "e", "Yes");?>
|
|
<?=mk_option($sec[$name]['export'], "eh", "Yes (hidden)");?>
|
|
</select>
|
|
|
|
> This setting determines whether the share is visible and/or accessible. The 'Yes (hidden)' setting
|
|
> will *hide* the share from *browsing* but is still accessible if you know the share name.
|
|
|
|
<?if ($name !== 'flash'):?>
|
|
Enhanced OS X interoperability:
|
|
: <select name="shareFruit" size="1">
|
|
<?=mk_option($sec[$name]['fruit'], "no", "No");?>
|
|
<?=mk_option($sec[$name]['fruit'], "yes", "Yes");?>
|
|
</select>
|
|
|
|
> When set to 'Yes' provides enhanced compatibility with Apple SMB clients, resulting, for example, in faster
|
|
> Finder browsing. This may cause some issues with Windows clients, however. Please also refer to
|
|
> the [VFS_FRUIT MAN PAGE](https://www.mankier.com/8/vfs_fruit).
|
|
|
|
<?endif;?>
|
|
Security:
|
|
: <select name="shareSecurity" size="1">
|
|
<?=mk_option($sec[$name]['security'], "public", "Public");?>
|
|
<?=mk_option($sec[$name]['security'], "secure", "Secure");?>
|
|
<?=mk_option($sec[$name]['security'], "private", "Private");?>
|
|
</select>
|
|
|
|
> Summary of security modes:
|
|
>
|
|
> **Public** All users including guests have full read/write access.
|
|
>
|
|
> **Secure** All users including guests have read access, you select which of your users
|
|
> have write access.
|
|
>
|
|
> **Private** No guest access at all, you select which of your users have read/write or
|
|
> read-only access.
|
|
|
|
|
|
: <input type="submit" name="changeShareSecurity" value="Apply" disabled><input type="button" value="Done" onclick="done()">
|
|
</form>
|
|
|
|
<?if ($sec[$name]['security'] == 'secure'):?>
|
|
<div id="title" class="nocontrol"><dt>SMB User Access</dt><i>Guests have <b>read-only</b> access.</i></div>
|
|
|
|
> *Read settings from* is used to preset the SMB User Access settings of the current selected share with the settings of an existing share.
|
|
>
|
|
> Select the desired share name and press **Read** to copy the SMB security settings from the selected source.
|
|
>
|
|
> *Write settings to* is used to copy the SMB User Access settings of the current share to one or more other existing shares.
|
|
>
|
|
> Select the desired destinations and press **Write** to copy the SMB User access settings to the selected shares.
|
|
|
|
<div class="clone1">
|
|
<span class="clone">Read settings from</span><i class="fa fa-arrow-left clone"></i>
|
|
<select name="readusersmb" size="1" class="clone" onchange="toggleButton('readusersmb',false)">
|
|
<option disabled selected>select...</option>
|
|
<?
|
|
if (isset($disks[$name])) {
|
|
foreach (array_filter($disks,'clone_list') as $list) if ($list['name']!=$name && $sec[$list['name']]['security']=='secure') echo mk_option("", $list['name'], my_disk($list['name']));
|
|
} else {
|
|
foreach ($shares as $list) if ($list['name']!=$name && $sec[$list['name']]['security']=='secure') echo mk_option("", $list['name'], $list['name']);
|
|
}
|
|
?>
|
|
</select><input type="button" id="readusersmb" value="Read" class="clone" onclick="readUserSMB()" disabled>
|
|
</div>
|
|
<div class="clone2">
|
|
<span class="clone">Write settings to</span><i class="fa fa-arrow-right clone"></i>
|
|
<select id="smb2" name="writeusersmb" size="1" multiple="multiple" style="display:none" onchange="toggleButton('writeusersmb',this.id)">
|
|
<?
|
|
$rows = [];
|
|
if (isset($disks[$name])) {
|
|
foreach (array_filter($disks,'clone_list') as $list) if ($list['name']!=$name && $sec[$list['name']]['security']=='secure') $rows[] = mk_option("", $list['name'], my_disk($list['name']));
|
|
} else {
|
|
foreach ($shares as $list) if ($list['name']!=$name && $sec[$list['name']]['security']=='secure') $rows[] = mk_option("", $list['name'], $list['name']);
|
|
}
|
|
if ($rows) echo "<option>All</option>";
|
|
foreach ($rows as $row) echo $row;
|
|
?>
|
|
</select><input type="button" id="writeusersmb" value="Write" class="clone" onclick="writeUserSMB()" disabled>
|
|
</div>
|
|
|
|
<form markdown="1" name="smb_user_edit" method="POST" action="/update.htm" target="progressFrame" onchange="toggleButton('writeusersmb',true);$('#smb2').dropdownchecklist('disable')">
|
|
<input type="hidden" name="shareName" value="<?=htmlspecialchars($name)?>">
|
|
<?input_secure_users($sec);?>
|
|
|
|
|
|
: <input type="submit" name="changeShareAccess" value="Apply" disabled><input type="button" value="Done" onclick="done()">
|
|
</form>
|
|
|
|
<?elseif ($sec[$name]['security'] == 'private'):?>
|
|
<div id="title" class="nocontrol"><dt>SMB User Access</dt><i>Guests have <b>no</b> access.</i></div>
|
|
|
|
> *Read settings from* is used to preset the SMB User Access settings of the current selected share with the settings of an existing share.
|
|
>
|
|
> Select the desired share name and press **Read** to copy the SMB security settings from the selected source.
|
|
>
|
|
> *Write settings to* is used to copy the SMB User Access settings of the current share to one or more other existing shares.
|
|
>
|
|
> Select the desired destinations and press **Write** to copy the SMB User access settings to the selected shares.
|
|
|
|
<div class="clone1">
|
|
<span class="clone">Read settings from</span><i class="fa fa-arrow-left clone"></i>
|
|
<select name="readusersmb" size="1" class="clone" onchange="toggleButton('readusersmb',false)">
|
|
<option disabled selected>select...</option>
|
|
<?
|
|
if (isset($disks[$name])) {
|
|
foreach (array_filter($disks,'clone_list') as $list) if ($list['name']!=$name && $sec[$list['name']]['security']=='private') echo mk_option("", $list['name'], my_disk($list['name']));
|
|
} else {
|
|
foreach ($shares as $list) if ($list['name']!=$name && $sec[$list['name']]['security']=='private') echo mk_option("", $list['name'], $list['name']);
|
|
}
|
|
?>
|
|
</select><input type="button" id="readusersmb" value="Read" class="clone" onclick="readUserSMB()" disabled>
|
|
</div>
|
|
<div class="clone2">
|
|
<span class="clone">Write settings to</span><i class="fa fa-arrow-right clone"></i>
|
|
<select id="smb2" name="writeusersmb" size="1" multiple="multiple" style="display:none" onchange="toggleButton('writeusersmb',this.id)">
|
|
<?
|
|
$rows = [];
|
|
if (isset($disks[$name])) {
|
|
foreach (array_filter($disks,'clone_list') as $list) if ($list['name']!=$name && $sec[$list['name']]['security']=='private') $rows[] = mk_option("", $list['name'], my_disk($list['name']));
|
|
} else {
|
|
foreach ($shares as $list) if ($list['name']!=$name && $sec[$list['name']]['security']=='private') $rows[] = mk_option("", $list['name'], $list['name']);
|
|
}
|
|
if ($rows) echo "<option>All</option>";
|
|
foreach ($rows as $row) echo $row;
|
|
?>
|
|
</select><input type="button" id="writeusersmb" value="Write" class="clone" onclick="writeUserSMB()" disabled>
|
|
</div>
|
|
|
|
<form markdown="1" name="smb_user_edit" method="POST" action="/update.htm" target="progressFrame" onchange="toggleButton('writeusersmb',true);$('#smb2').dropdownchecklist('disable')">
|
|
<input type="hidden" name="shareName" value="<?=htmlspecialchars($name)?>">
|
|
<?input_private_users($sec);?>
|
|
|
|
|
|
: <input type="submit" name="changeShareAccess" value="Apply" disabled><input type="button" value="Done" onclick="done()">
|
|
</form>
|
|
<?endif;?>
|
|
|
|
<script>
|
|
$(function() {
|
|
initDropdownSMB(false);
|
|
<?if ($tabbed):?>
|
|
$('#tab'+$('input[name$="tabs"]').length).bind({click:function(){initDropdownSMB(true);}});
|
|
<?endif;?>
|
|
<?if (count($users)==1):?>
|
|
toggleButton('readusersmb',true);
|
|
toggleButton('writeusersmb',true);
|
|
$('#smb2').dropdownchecklist('disable');
|
|
<?endif;?>
|
|
});
|
|
function initDropdownSMB(reset) {
|
|
if (reset) {
|
|
$('#smb1').dropdownchecklist('destroy');
|
|
$('#smb2').dropdownchecklist('destroy');
|
|
}
|
|
$("#smb1").dropdownchecklist({firstItemChecksAll:true, emptyText:'select...', width:<?=$width[0]?>, explicitClose:'...close'});
|
|
$("#smb2").dropdownchecklist({firstItemChecksAll:true, emptyText:'select...', width:<?=$width[0]?>, explicitClose:'...close'});
|
|
}
|
|
function readSMB() {
|
|
var form = document.smb_edit;
|
|
var name = $('select[name="readsmb"]').val();
|
|
$.get('/webGui/include/ProtocolData.php',{protocol:'smb',name:name},function(json) {
|
|
var data = $.parseJSON(json);
|
|
form.shareExport.value = data.export;
|
|
form.shareFruit.value = data.fruit;
|
|
form.shareSecurity.value = data.security;
|
|
});
|
|
$(form).find('select').trigger('change');
|
|
}
|
|
function writeSMB() {
|
|
var data = {}, copied = false;
|
|
data.shareExport = '<?=addslashes(htmlspecialchars($sec[$name]['export']))?>';
|
|
data.shareFruit = '<?=addslashes(htmlspecialchars($sec[$name]['fruit']))?>';
|
|
data.shareSecurity = '<?=addslashes(htmlspecialchars($sec[$name]['security']))?>';
|
|
data.changeShareSecurity = 'Apply';
|
|
$('select#smb1 option').map(function() {
|
|
if ($(this).prop('selected')==true) {
|
|
data.shareName = $(this).val();
|
|
$.post('/update.htm', data);
|
|
copied = true;
|
|
}
|
|
});
|
|
if (copied) swal({title:'Clone complete',text:'SMB security settings are written to the selected shares',type:'success'},function(){refresh();});
|
|
}
|
|
function readUserSMB() {
|
|
var form = document.smb_user_edit;
|
|
var name = $('select[name="readusersmb"]').val();
|
|
var users = {};
|
|
<?
|
|
foreach ($users as $user) {
|
|
if ($user['name'] == "root") continue;
|
|
echo "users['{$user['name']}'] = {$user['idx']};\n";
|
|
}
|
|
?>
|
|
$.get('/webGui/include/ProtocolData.php',{protocol:'smb',name:name},function(json) {
|
|
var data = $.parseJSON(json);
|
|
var readList = data.readList.split(',');
|
|
var writeList = data.writeList.split(',');
|
|
$(form).find('select[name^="userAccess."]').each(function(){$(this).val('no-access');});
|
|
for (var i=0; i < readList.length; i++) $(form).find('select[name="userAccess.'+users[readList[i]]+'"]').val('read-only');
|
|
for (var i=0; i < writeList.length; i++) $(form).find('select[name="userAccess.'+users[writeList[i]]+'"]').val('read-write');
|
|
});
|
|
$(form).find('select').trigger('change');
|
|
}
|
|
function writeUserSMB() {
|
|
var data = {}, copied = false;
|
|
data['userAccess.0'] = 'no-access';
|
|
<?
|
|
$read_list = explode(",", $sec[$name]['readList']);
|
|
$write_list = explode(",", $sec[$name]['writeList']);
|
|
foreach ($users as $user) {
|
|
if ($user['name'] == "root") continue;
|
|
$idx = $user['idx'];
|
|
$userAccess = null;
|
|
if ($sec[$name]['security']=='secure') {
|
|
$userAccess = in_array($user['name'], $write_list) ? "read-write" : "read-only";
|
|
} elseif ($sec[$name]['security'] == 'private') {
|
|
$userAccess = in_array($user['name'], $write_list) ? "read-write" : (in_array($user['name'], $read_list) ? "read-only" : "no-access");
|
|
}
|
|
if ($userAccess) echo " data['userAccess.$idx'] = '$userAccess';\n";
|
|
}
|
|
?>
|
|
data.changeShareAccess = 'Apply';
|
|
$('select#smb2 option').map(function() {
|
|
if ($(this).prop('selected')==true) {
|
|
data.shareName = $(this).val();
|
|
$.post('/update.htm', data);
|
|
copied = true;
|
|
}
|
|
});
|
|
if (copied) swal({title:'Clone complete',text:'SMB User Access settings are written to the selected shares',type:'success'},function(){refresh();});
|
|
}
|
|
</script>
|