Merge pull request #1387 from SimonFair/VNC-Password

Retain VNC password during update.
This commit is contained in:
tom mortensen
2023-07-21 10:18:18 -07:00
committed by GitHub
3 changed files with 16 additions and 1 deletions

View File

@@ -1944,6 +1944,20 @@
return $var;
}
function domain_get_vnc_password($domain) {
$domain_name = $this->domain_get_name($domain) ;
$password = shell_exec("cat /etc/libvirt/qemu/'{$domain_name}.xml' | grep 'passwd'") ;
if (!$password)
return '';
$strpos = strpos($password, "passwd=") +8 ;
$endpos = strpos($password, "'",$strpos) ;
$password = substr($password,$strpos, $endpos-$strpos) ;
return $password ;
}
function domain_get_ws_port($domain) {
$tmp = $this->get_xpath($domain, '//domain/devices/graphics/@websocket', false);
$var = (int)$tmp[0];

View File

@@ -1149,6 +1149,7 @@ private static $encoding = 'UTF-8';
'protocol' => $lv->domain_get_vmrc_protocol($res),
'model' => $lv->domain_get_vnc_model($res),
'keymap' => $lv->domain_get_vnc_keymap($res),
'password' => $lv->domain_get_vnc_password($res),
'port' => $vmrcport,
'wsport' => $lv->domain_get_ws_port($res),
'autoport' => $autoport,

View File

@@ -1044,7 +1044,7 @@
<tr class="vncpassword">
<td>_(VM Console Password)_:</td>
<td><input type="password" name="domain[password]" autocomplete='new-password' title="_(password for VNC)_" placeholder="_(password for VNC)_ (_(optional)_)" /></td>
<td><input type="password" name="domain[password]" autocomplete='new-password' value="<?=$arrGPU['password']?>" title="_(password for VNC)_" placeholder="_(password for VNC)_ (_(optional)_)" /></td>
</tr>
<tr class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced vnckeymap">
<td>_(VM Console Keyboard)_:</td>