pve-manager/www/manager6/lxc/FeaturesEdit.js
Wolfgang Bumiller 7bf152bf22 ui: lxc/features: disable nfs and cifs for unprivileged
While we can allow them via the apparmor profile, they still
won't be usable as the kernel doesn't have FS_USERNS_MOUNT
set on those.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
2018-12-06 15:42:13 +01:00

121 lines
2.3 KiB
JavaScript

Ext.define('PVE.lxc.FeaturesInputPanel', {
extend: 'Proxmox.panel.InputPanel',
xtype: 'pveLxcFeaturesInputPanel',
// used to save the mounts fstypes until sending
mounts: [],
fstypes: ['nfs', 'cifs'],
viewModel: {
parent: null,
data: {
unprivileged: false,
},
formulas: {
privilegedOnly: function(get) {
return (get('unprivileged') ? gettext('privileged only') : '');
},
unprivilegedOnly: function(get) {
return (!get('unprivileged') ? gettext('unprivileged only') : '');
}
}
},
items: [
{
xtype: 'proxmoxcheckbox',
fieldLabel: gettext('keyctl'),
name: 'keyctl',
bind: {
disabled: '{!unprivileged}',
boxLabel: '{unprivilegedOnly}',
}
},
{
xtype: 'proxmoxcheckbox',
fieldLabel: gettext('Nesting'),
name: 'nesting'
},
{
xtype: 'proxmoxcheckbox',
name: 'nfs',
fieldLabel: 'NFS',
bind: {
disabled: '{unprivileged}',
boxLabel: '{privilegedOnly}',
}
},
{
xtype: 'proxmoxcheckbox',
name: 'cifs',
fieldLabel: 'CIFS',
bind: {
disabled: '{unprivileged}',
boxLabel: '{privilegedOnly}',
}
}
],
onGetValues: function(values) {
var me = this;
var mounts = me.mounts;
me.fstypes.forEach(function(fs) {
if (values[fs]) {
mounts.push(fs);
}
delete values[fs];
});
if (mounts.length) {
values.mount = mounts.join(';');
}
var featuresstring = PVE.Parser.printPropertyString(values, undefined);
if (featuresstring == '') {
return { 'delete': 'features' };
}
return { features: featuresstring };
},
setValues: function(values) {
var me = this;
me.viewModel.set({ unprivileged: values.unprivileged });
if (values.features) {
var res = PVE.Parser.parsePropertyString(values.features);
me.mounts = [];
if (res.mount) {
res.mount.split(/[; ]/).forEach(function(item) {
if (me.fstypes.indexOf(item) === -1) {
me.mounts.push(item);
} else {
res[item] = 1;
}
});
}
this.callParent([res]);
}
}
});
Ext.define('PVE.lxc.FeaturesEdit', {
extend: 'Proxmox.window.Edit',
xtype: 'pveLxcFeaturesEdit',
subject: gettext('Features'),
items: [{
xtype: 'pveLxcFeaturesInputPanel'
}],
initComponent : function() {
var me = this;
me.callParent();
me.load();
}
});