Vinzenz Feenstra has uploaded a new change for review. Change subject: win: Enable policy for software SAS ......................................................................
win: Enable policy for software SAS On some systems the policy for enabling the Secure Attention Sequence might not have been set or has been set to a value which would not allow the guest agent to perform SSO. This patch introduces setting the policy before calling 'SendSAS' and reverting the policy to the previous value (in case it was set before). Change-Id: Ie2b5f58e461c92e06789d46fa9113441ea48e659 Bug-Url: https://bugzilla.redhat.com/1124263 Signed-off-by: Vinzenz Feenstra <vfeen...@redhat.com> --- M ovirt-guest-agent/GuestAgentWin32.py 1 file changed, 35 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-guest-agent refs/changes/33/33533/1 diff --git a/ovirt-guest-agent/GuestAgentWin32.py b/ovirt-guest-agent/GuestAgentWin32.py index 0845f02..8678b05 100644 --- a/ovirt-guest-agent/GuestAgentWin32.py +++ b/ovirt-guest-agent/GuestAgentWin32.py @@ -23,6 +23,12 @@ import _winreg +# Constants according to +# http://msdn.microsoft.com/en-us/library/windows/desktop/ms724878.aspx +KEY_WOW64_32KEY = 0x0100 +KEY_WOW64_64KEY = 0x0200 + + # _winreg.QueryValueEx and win32api.RegQueryValueEx don't support reading # Unicode strings from the registry (at least on Python 2.5.1). def QueryStringValue(hkey, name): @@ -191,14 +197,40 @@ def lock_screen(self): self.LockWorkStation() + def _setSoftwareSASPolicy(self, value): + KEY_PATH = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion" \ + "\\Policies\\System" + if value is not None: + view_flag = KEY_WOW64_64KEY + handle = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, KEY_PATH, + view_flag | _winreg.KEY_READ | + _winreg.KEY_WRITE) + try: + old = _winreg.QueryValueEx(handle, 'SoftwareSASGeneration') + except OSError: + # Expected to happen if it does not exist + old = (None, None) + _winreg.SetValue(handle, 'SoftwareSASGeneration', + _winreg.REG_DWORD, value) + return old[0] + return None + + def _performSAS(self): + if find_library('sas') is not None: + logging.debug("Simulating a secure attention sequence (SAS).") + # setSoftwareSASPolicy is used to set the value to 3 to enable the + # simulated secure attention sequence, and reverts the to the + # previous value after the function was performed. + oldValue = self._setSoftwareSASPolicy(3) + windll.sas.SendSAS(0) + self._setSoftwareSASPolicy(oldValue) + def login(self, credentials): PIPE_NAME = "\\\\.\\pipe\\VDSMDPipe" BUFSIZE = 1024 RETIRES = 3 try: - if find_library('sas') is not None: - logging.debug("Simulating a secure attention sequence (SAS).") - windll.sas.SendSAS(0) + self._performSAS() retries = 1 while retries <= RETIRES: try: @@ -348,10 +380,6 @@ def getApplications(self): retval = set() - # Constants according to - # http://msdn.microsoft.com/en-us/library/windows/desktop/ms724878.aspx - KEY_WOW64_32KEY = 0x0100 - KEY_WOW64_64KEY = 0x0200 key_path = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall" for view_flag in (KEY_WOW64_32KEY, KEY_WOW64_64KEY): rootkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key_path, -- To view, visit http://gerrit.ovirt.org/33533 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie2b5f58e461c92e06789d46fa9113441ea48e659 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-guest-agent Gerrit-Branch: ovirt-3.5 Gerrit-Owner: Vinzenz Feenstra <vfeen...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches