mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-08 21:17:43 +03:00
(cherry picked from commit 726a6a8547
)
This commit is contained in:
parent
af093bffcc
commit
59ec26c931
@ -141,6 +141,9 @@ public:
|
||||
HOTPLUG_SAVEAS_STOPPED = 68
|
||||
};
|
||||
|
||||
static const int MAX_VNC_PASSWD_LENGTH = 8;
|
||||
static const int MAX_SPICE_PASSWD_LENGTH = 60;
|
||||
|
||||
/**
|
||||
* Functions to convert to/from string the VM states
|
||||
*/
|
||||
|
@ -426,15 +426,21 @@ int VirtualMachine::parse_graphics(string& error_str, Template * tmpl)
|
||||
{
|
||||
password = one_util::random_password();
|
||||
|
||||
if ( graphics->vector_value("TYPE") == "SPICE" )
|
||||
{
|
||||
// Spice password must be 60 characters maximum
|
||||
graphics->replace("PASSWD", password.substr(0, 59));
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics->replace("PASSWD", password);
|
||||
}
|
||||
graphics->replace("PASSWD", password);
|
||||
}
|
||||
|
||||
string type = graphics->vector_value("TYPE");
|
||||
one_util::tolower(type);
|
||||
|
||||
if ( type == "spice" && password.size() > MAX_SPICE_PASSWD_LENGTH )
|
||||
{
|
||||
// Spice password must be 60 characters maximum
|
||||
graphics->replace("PASSWD", password.substr(0, MAX_SPICE_PASSWD_LENGTH));
|
||||
}
|
||||
else if ( type == "vnc" && password.size() > MAX_VNC_PASSWD_LENGTH )
|
||||
{
|
||||
// Vnc password must be 8 characters maximum
|
||||
graphics->replace("PASSWD", password.substr(0, MAX_VNC_PASSWD_LENGTH));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1706,21 +1706,26 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
|
||||
port = graphics->vector_value("PORT");
|
||||
|
||||
one_util::tolower(type);
|
||||
|
||||
if ( random_passwrd && passwd.empty())
|
||||
{
|
||||
passwd = one_util::random_password();
|
||||
|
||||
if ( graphics->vector_value("TYPE") == "SPICE" )
|
||||
if ( type == "spice" )
|
||||
{
|
||||
// Spice password must be 60 characters maximum
|
||||
passwd = passwd.substr(0, 59);
|
||||
passwd = passwd.substr(0, VirtualMachine::MAX_SPICE_PASSWD_LENGTH);
|
||||
}
|
||||
else if ( type == "vnc" )
|
||||
{
|
||||
// Vnc password must be 8 characters maximum
|
||||
passwd = passwd.substr(0, VirtualMachine::MAX_VNC_PASSWD_LENGTH);
|
||||
}
|
||||
|
||||
const_cast<VectorAttribute*>(graphics)->replace("PASSWD", passwd);
|
||||
}
|
||||
|
||||
one_util::tolower(type);
|
||||
|
||||
if ( type == "vnc" || type == "spice" )
|
||||
{
|
||||
file << "\t\t<graphics type=" << one_util::escape_xml_attr(type);
|
||||
|
Loading…
Reference in New Issue
Block a user