[Kimchi-devel] [PATCH] set the password for spice and VNC page.
Aline Manera
alinefm at linux.vnet.ibm.com
Mon Aug 4 17:34:58 UTC 2014
I think we will have license issues with this patch set:
http://stackoverflow.com/questions/1174240/apache-and-lgpl-license-compatibility
Here you are modifying files imported from noVNC and Spice communities.
noVNC is under MPL 2.0 and Spice under LGPLv3 and everything under ui/
is Apache 2.0 according to Kimchi.
From the link above, we can only USE imported LGPLv3 code with Apache
license, ie, we can not modify them otherwise we need to re-license the
project under LGPLv3
On 08/04/2014 11:48 AM, shaohef at linux.vnet.ibm.com wrote:
> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>
> set a cookie to store the ticket before connect a VM.
> get the password from cookie and pass it to spice and VNC server.
>
> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
> ---
> ui/js/novnc/main.js | 10 +++++++++-
> ui/js/src/kimchi.guest_main.js | 22 ++++++++++++++++------
> ui/pages/spice.html.tmpl | 10 +++++++++-
> 3 files changed, 34 insertions(+), 8 deletions(-)
>
> diff --git a/ui/js/novnc/main.js b/ui/js/novnc/main.js
> index 22037ec..84a813b 100644
> --- a/ui/js/novnc/main.js
> +++ b/ui/js/novnc/main.js
> @@ -79,7 +79,15 @@ if (token) {
> WebUtil.createCookie('token', token, 1)
> }
>
> -password = WebUtil.getQueryVar('password', '');
> +// password = WebUtil.getQueryVar('password', '');
> +var cookieRe = new RegExp(';?\\\s*(ticketVM)=(\s*[^;]*);?', 'g');
> +var match = cookieRe.exec(document.cookie);
> +var password = match ? decodeURIComponent(match[2]) : '';
> +if (match) {
> + var utcString = new Date().toUTCString();
> + document.cookie = 'ticketVM' + '=; expires=' + utcString;
> +}
> +
> path = WebUtil.getQueryVar('path', 'websockify');
>
> if ((!host) || (!port)) {
> diff --git a/ui/js/src/kimchi.guest_main.js b/ui/js/src/kimchi.guest_main.js
> index ff6f2e1..1c1428f 100644
> --- a/ui/js/src/kimchi.guest_main.js
> +++ b/ui/js/src/kimchi.guest_main.js
> @@ -150,12 +150,22 @@ kimchi.vmedit = function(event) {
> kimchi.openVmConsole = function(event) {
> var vm=$(this).closest('li[name=guest]');
> var vmObject=vm.data();
> - if (vmObject.graphics['type'] == 'vnc') {
> - kimchi.vncToVM(vm.attr('id'));
> - }
> - else if (vmObject.graphics['type'] == 'spice') {
> - kimchi.spiceToVM(vm.attr('id'));
> - }
> + kimchi.retrieveVM(vm.attr('id'), function(result) {
> + if (result.ticket.expire && result.ticket.expire < 0) {
> + kimchi.message.error('please reset your password!');
> + return;
> + }
> + result.ticket.passwd != null && kimchi.cookie.set("ticketVM", result.ticket.passwd, 100);
> + if (vmObject.graphics['type'] == 'vnc') {
> + kimchi.vncToVM(vm.attr('id'));
> + }
> + else if (vmObject.graphics['type'] == 'spice') {
> + kimchi.spiceToVM(vm.attr('id'));
> + }
> + }, function(err) {
> + kimchi.message.error(err.responseJSON.reason);
> + }
> + );
>
> };
>
> diff --git a/ui/pages/spice.html.tmpl b/ui/pages/spice.html.tmpl
> index 213d216..cb7c331 100644
> --- a/ui/pages/spice.html.tmpl
> +++ b/ui/pages/spice.html.tmpl
> @@ -64,6 +64,14 @@
> host = getParameter("listen");
> port = getParameter("port");
> token = getParameter("token");
> + var cookieRe = new RegExp(';?\\\s*(ticketVM)=(\s*[^;]*);?', 'g');
> + var match = cookieRe.exec(document.cookie);
> + password = match ? decodeURIComponent(match[2]) : '';
> + if (match) {
> + var utcString = new Date().toUTCString();
> + document.cookie = 'ticketVM' + '=; expires=' + utcString;
> + }
> +
> document.getElementById("host").value = host;
> document.getElementById("port").value = port;
> if ((!host) || (!port)) {
> @@ -82,7 +90,7 @@
> screen_id : "spice-screen",
> dump_id : "debug-div",
> message_id : "message-div",
> - password : "",
> + password : password,
> onerror : spice_error
> });
> } catch (e) {
More information about the Kimchi-devel
mailing list