luci-app-samba4: prevent calling split() on array or null values
Since `uci.get()` may return null or array values, we cannot blindly call split() on the result. Use the safe `L.toArray()` helper which is intended to deal with such situations. Also clean up whitespace while we're at. Fixes: #5080 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
00d518d697
commit
c4cdfcbe51
1 changed files with 13 additions and 13 deletions
|
@ -19,7 +19,7 @@ return view.extend({
|
||||||
render: function(stats) {
|
render: function(stats) {
|
||||||
var m, s, o, v;
|
var m, s, o, v;
|
||||||
v = '';
|
v = '';
|
||||||
|
|
||||||
m = new form.Map('samba4', _('Network Shares'));
|
m = new form.Map('samba4', _('Network Shares'));
|
||||||
|
|
||||||
if (stats[5] && stats[5].code === 0) {
|
if (stats[5] && stats[5].code === 0) {
|
||||||
|
@ -35,7 +35,7 @@ return view.extend({
|
||||||
_('Listen only on the given interface or, if unspecified, on lan'));
|
_('Listen only on the given interface or, if unspecified, on lan'));
|
||||||
o.multiple = true;
|
o.multiple = true;
|
||||||
o.cfgvalue = function(section_id) {
|
o.cfgvalue = function(section_id) {
|
||||||
return uci.get('samba4', section_id, 'interface').split(' ');
|
return L.toArray(uci.get('samba4', section_id, 'interface'));
|
||||||
};
|
};
|
||||||
o.write = function(section_id, formvalue) {
|
o.write = function(section_id, formvalue) {
|
||||||
var cfgvalue = this.cfgvalue(section_id),
|
var cfgvalue = this.cfgvalue(section_id),
|
||||||
|
@ -53,30 +53,30 @@ return view.extend({
|
||||||
|
|
||||||
o = s.taboption('general', form.Value, 'description', _('Description'));
|
o = s.taboption('general', form.Value, 'description', _('Description'));
|
||||||
o.placeholder = 'Samba4 on OpenWrt';
|
o.placeholder = 'Samba4 on OpenWrt';
|
||||||
|
|
||||||
s.taboption('general', form.Flag, 'enable_extra_tuning', _('Enable extra Tuning'),
|
s.taboption('general', form.Flag, 'enable_extra_tuning', _('Enable extra Tuning'),
|
||||||
_('Enable some community driven tuning parameters, that may improve write speeds and better operation via WiFi.\
|
_('Enable some community driven tuning parameters, that may improve write speeds and better operation via WiFi.\
|
||||||
Not recommend if multiple clients write to the same files, at the same time!'));
|
Not recommend if multiple clients write to the same files, at the same time!'));
|
||||||
|
|
||||||
s.taboption('general', form.Flag, 'disable_async_io', _('Force synchronous I/O'),
|
s.taboption('general', form.Flag, 'disable_async_io', _('Force synchronous I/O'),
|
||||||
_('On lower-end devices may increase speeds, by forceing synchronous I/O instead of the default asynchronous.'));
|
_('On lower-end devices may increase speeds, by forceing synchronous I/O instead of the default asynchronous.'));
|
||||||
|
|
||||||
s.taboption('general', form.Flag, 'macos', _('Enable macOS compatible shares'),
|
s.taboption('general', form.Flag, 'macos', _('Enable macOS compatible shares'),
|
||||||
_('Enables Apple\'s AAPL extension globally and adds macOS compatibility options to all shares.'));
|
_('Enables Apple\'s AAPL extension globally and adds macOS compatibility options to all shares.'));
|
||||||
|
|
||||||
s.taboption('general', form.Flag, 'allow_legacy_protocols', _('Allow legacy (insecure) protocols/authentication.'),
|
s.taboption('general', form.Flag, 'allow_legacy_protocols', _('Allow legacy (insecure) protocols/authentication.'),
|
||||||
_('Allow legacy smb(v1)/Lanman connections, needed for older devices without smb(v2.1/3) support.'));
|
_('Allow legacy smb(v1)/Lanman connections, needed for older devices without smb(v2.1/3) support.'));
|
||||||
|
|
||||||
if (stats[2].type === 'file') {
|
if (stats[2].type === 'file') {
|
||||||
s.taboption('general', form.Flag, 'disable_netbios', _('Disable Netbios'))
|
s.taboption('general', form.Flag, 'disable_netbios', _('Disable Netbios'))
|
||||||
}
|
}
|
||||||
if (stats[3].type === 'file') {
|
if (stats[3].type === 'file') {
|
||||||
s.taboption('general', form.Flag, 'disable_ad_dc', _('Disable Active Directory Domain Controller'))
|
s.taboption('general', form.Flag, 'disable_ad_dc', _('Disable Active Directory Domain Controller'))
|
||||||
}
|
}
|
||||||
if (stats[4].type === 'file') {
|
if (stats[4].type === 'file') {
|
||||||
s.taboption('general', form.Flag, 'disable_winbind', _('Disable Winbind'))
|
s.taboption('general', form.Flag, 'disable_winbind', _('Disable Winbind'))
|
||||||
}
|
}
|
||||||
|
|
||||||
o = s.taboption('template', form.TextValue, '_tmpl',
|
o = s.taboption('template', form.TextValue, '_tmpl',
|
||||||
_('Edit the template that is used for generating the samba configuration.'),
|
_('Edit the template that is used for generating the samba configuration.'),
|
||||||
_("This is the content of the file '/etc/samba/smb.conf.template' from which your samba configuration will be generated. \
|
_("This is the content of the file '/etc/samba/smb.conf.template' from which your samba configuration will be generated. \
|
||||||
|
@ -127,7 +127,7 @@ return view.extend({
|
||||||
o.enabled = 'yes';
|
o.enabled = 'yes';
|
||||||
o.disabled = 'no';
|
o.disabled = 'no';
|
||||||
o.default = 'no';
|
o.default = 'no';
|
||||||
|
|
||||||
o = s.option(form.Flag, 'inherit_owner', _('Inherit owner'));
|
o = s.option(form.Flag, 'inherit_owner', _('Inherit owner'));
|
||||||
o.enabled = 'yes';
|
o.enabled = 'yes';
|
||||||
o.disabled = 'no';
|
o.disabled = 'no';
|
||||||
|
@ -144,12 +144,12 @@ return view.extend({
|
||||||
o.default = '0777'; // smb.conf default is '0755'
|
o.default = '0777'; // smb.conf default is '0755'
|
||||||
o.placeholder = '0777';
|
o.placeholder = '0777';
|
||||||
o.rmempty = false;
|
o.rmempty = false;
|
||||||
|
|
||||||
o = s.option(form.Value, 'vfs_objects', _('Vfs objects'));
|
o = s.option(form.Value, 'vfs_objects', _('Vfs objects'));
|
||||||
o.rmempty = true;
|
o.rmempty = true;
|
||||||
|
|
||||||
s.option(form.Flag, 'timemachine', _('Apple Time-machine share'));
|
s.option(form.Flag, 'timemachine', _('Apple Time-machine share'));
|
||||||
|
|
||||||
o = s.option(form.Value, 'timemachine_maxsize', _('Time-machine size in GB'));
|
o = s.option(form.Value, 'timemachine_maxsize', _('Time-machine size in GB'));
|
||||||
o.rmempty = true;
|
o.rmempty = true;
|
||||||
o.maxlength = 5;
|
o.maxlength = 5;
|
||||||
|
|
Loading…
Reference in a new issue