[pve-devel] [PATCH v5 manager] fix #2190: Base64 encode SMBIOS value strings in order to allow more characters
Christian Ebner
c.ebner at proxmox.com
Tue Jun 11 15:31:12 CEST 2019
On some occasions e.g. license checking, the manufacturer string in the
SMBIOS settings edit has to allow characters such as whitespaces.
https://forum.proxmox.com/threads/proxmox-and-windows-rok-license-for-dell.53236/
In principle SMBIOS allows to pass any zero terminated string to the
corresponding fields in the structure type 1 (System Information).
By base64 encoding the values clashing of the config is avoided.
Relies on the corresponding patch to qemu-server to pass parameter verification
and correct parsing.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
Version 5:
* As discussed offline, allow multiline editing of the fields in the UI
www/manager6/Parser.js | 31 +++++++++++++++++++++--------
www/manager6/qemu/Smbios1Edit.js | 42 ++++++++++++++++++++++++++++------------
2 files changed, 53 insertions(+), 20 deletions(-)
diff --git a/www/manager6/Parser.js b/www/manager6/Parser.js
index 958deae5..242965dd 100644
--- a/www/manager6/Parser.js
+++ b/www/manager6/Parser.js
@@ -528,12 +528,18 @@ Ext.define('PVE.Parser', { statics: {
},
parseQemuSmbios1: function(value) {
- var res = {};
-
- Ext.Array.each(value.split(','), function(p) {
- var kva = p.split('=', 2);
- res[kva[0]] = kva[1];
- });
+ var res = value.split(',').reduce(function (accumulator, currentValue) {
+ var splitted = currentValue.split(new RegExp("=(.+)"));
+ accumulator[splitted[0]] = splitted[1];
+ return accumulator;
+ }, {});
+
+ if (PVE.Parser.parseBoolean(res.base64, false)) {
+ Ext.Object.each(res, function(key, value) {
+ if (key === 'uuid') { return; }
+ res[key] = Ext.util.Base64.decode(value);
+ });
+ }
return res;
},
@@ -541,10 +547,19 @@ Ext.define('PVE.Parser', { statics: {
printQemuSmbios1: function(data) {
var datastr = '';
-
+ var base64 = false;
Ext.Object.each(data, function(key, value) {
if (value === '') { return; }
- datastr += (datastr !== '' ? ',' : '') + key + '=' + value;
+ if (key === 'uuid') {
+ datastr += (datastr !== '' ? ',' : '') + key + '=' + value;
+ } else {
+ // values should be base64 encoded from now on, mark config strings correspondingly
+ if (!base64) {
+ base64 = true;
+ datastr += (datastr !== '' ? ',' : '') + 'base64=1';
+ }
+ datastr += (datastr !== '' ? ',' : '') + key + '=' + Ext.util.Base64.encode(value);
+ }
});
return datastr;
diff --git a/www/manager6/qemu/Smbios1Edit.js b/www/manager6/qemu/Smbios1Edit.js
index fdb0d150..2184b918 100644
--- a/www/manager6/qemu/Smbios1Edit.js
+++ b/www/manager6/qemu/Smbios1Edit.js
@@ -36,39 +36,57 @@ Ext.define('PVE.qemu.Smbios1InputPanel', {
name: 'uuid'
},
{
- xtype: 'textfield',
+ xtype: 'textareafield',
fieldLabel: gettext('Manufacturer'),
- regex: /^\S+$/,
+ fieldStyle: {
+ height: '2em',
+ minHeight: '2em'
+ },
name: 'manufacturer'
},
{
- xtype: 'textfield',
+ xtype: 'textareafield',
fieldLabel: gettext('Product'),
- regex: /^\S+$/,
+ fieldStyle: {
+ height: '2em',
+ minHeight: '2em'
+ },
name: 'product'
},
{
- xtype: 'textfield',
+ xtype: 'textareafield',
fieldLabel: gettext('Version'),
- regex: /^\S+$/,
+ fieldStyle: {
+ height: '2em',
+ minHeight: '2em'
+ },
name: 'version'
},
{
- xtype: 'textfield',
+ xtype: 'textareafield',
fieldLabel: gettext('Serial'),
- regex: /^\S+$/,
+ fieldStyle: {
+ height: '2em',
+ minHeight: '2em'
+ },
name: 'serial'
},
{
- xtype: 'textfield',
+ xtype: 'textareafield',
fieldLabel: 'SKU',
- regex: /^\S+$/,
+ fieldStyle: {
+ height: '2em',
+ minHeight: '2em'
+ },
name: 'sku'
},
{
- xtype: 'textfield',
+ xtype: 'textareafield',
fieldLabel: gettext('Family'),
- regex: /^\S+$/,
+ fieldStyle: {
+ height: '2em',
+ minHeight: '2em'
+ },
name: 'family'
}
];
--
2.11.0
More information about the pve-devel
mailing list