]> git.proxmox.com Git - pve-manager.git/commitdiff
fix #2190: Base64 encode SMBIOS value strings in order to allow more characters
authorChristian Ebner <c.ebner@proxmox.com>
Tue, 11 Jun 2019 13:31:12 +0000 (15:31 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 11 Jun 2019 15:42:33 +0000 (17:42 +0200)
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@proxmox.com>
www/manager6/Parser.js
www/manager6/qemu/Smbios1Edit.js

index 958deae59a9b139c90ba952bfb3f964025c873cb..242965dd12b6aa7a367cf065b1f49f796b4cb6e6 100644 (file)
@@ -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;
index fdb0d150b7ca3b4af92e0d2f247f141cac95c966..2184b918c1111fccb81a4386450453e713035570 100644 (file)
@@ -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'
            }
        ];