mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-02 09:47:16 +03:00
console: add support to forget password
If password for console is saved currently there is no way how to tell virt-manager to forget that password. This patch improves the authentication page in order to provide a way how to forget password simply by unchecking the "Save this password in your keyring". Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
7e1bd1d762
commit
09cc6f3832
@ -5906,6 +5906,7 @@ if you know what you are doing.</small></property>
|
||||
<property name="label" translatable="yes">_Save this password in your keyring</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Check to save password, uncheck to forget password.</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
|
@ -708,3 +708,16 @@ class vmmConfig(object):
|
||||
return
|
||||
|
||||
vm.set_console_password(username, keyid)
|
||||
|
||||
def del_console_password(self, vm):
|
||||
if not self.has_keyring():
|
||||
return
|
||||
|
||||
username, keyid = vm.get_console_password()
|
||||
|
||||
if keyid == -1:
|
||||
return
|
||||
|
||||
self.keyring.del_secret(keyid)
|
||||
|
||||
vm.del_console_password()
|
||||
|
@ -749,6 +749,8 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
if self.widget("console-auth-remember").get_active():
|
||||
self.config.set_console_password(self.vm, passwd.get_text(),
|
||||
username.get_text())
|
||||
else:
|
||||
self.config.del_console_password(self.vm)
|
||||
|
||||
|
||||
##########################
|
||||
|
@ -1706,6 +1706,10 @@ class vmmDomain(vmmLibvirtObject):
|
||||
def set_console_password(self, username, keyid):
|
||||
return self.config.set_pervm(self.get_uuid(), "/console-password",
|
||||
(username, keyid))
|
||||
def del_console_password(self):
|
||||
return self.config.set_pervm(self.get_uuid(), "/console-password",
|
||||
("", -1))
|
||||
|
||||
|
||||
def _on_config_sample_network_traffic_changed(self, ignore=None):
|
||||
self._enable_net_poll = self.config.get_stats_enable_net_poll()
|
||||
|
@ -88,6 +88,16 @@ class vmmKeyring(object):
|
||||
|
||||
return ret
|
||||
|
||||
def del_secret(self, _id):
|
||||
try:
|
||||
path = self._collection.get_object_path() + "/" + str(_id)
|
||||
iface = Gio.DBusProxy.new_sync(self._dbus, 0, None,
|
||||
"org.freedesktop.secrets", path,
|
||||
"org.freedesktop.Secret.Item", None)
|
||||
iface.Delete("(s)", "/")
|
||||
except:
|
||||
logging.exception("Failed to delete keyring secret")
|
||||
|
||||
def get_secret(self, _id):
|
||||
ret = None
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user