Fixing up password & rdp transport to allow working with tickets

This commit is contained in:
Adolfo Gómez García 2016-06-28 10:33:10 +02:00
parent 3f7fb77086
commit 83cdd9446b
6 changed files with 65 additions and 13 deletions

View File

@ -292,9 +292,10 @@ class UDSSystemTray(QtGui.QSystemTrayIcon):
def about(self):
self.aboutDlg.exec_()
def quit(self):
logger.debug('Quit invoked')
def cleanUp(self):
logger.debug('Cleaning up')
if self.stopped is False:
logger.debug('Not stopped, proceding to cleanup')
self.stopped = True
try:
# If we close Client, send Logoff to Broker
@ -310,8 +311,17 @@ class UDSSystemTray(QtGui.QSystemTrayIcon):
except Exception:
pass
def quit(self):
logger.debug('Quit invoked')
if self.stopped is False:
self.cleanUp()
self.app.quit()
def closeEvent(self, event):
event.accept()
self.quit()
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
@ -328,6 +338,8 @@ if __name__ == '__main__':
logger.error('UDS Service is not running, or it can\'t contact with UDS Server. User Tools stopped')
sys.exit(1)
app.aboutToQuit.connect(trayIcon.cleanUp)
# Sets a default idle duration, but will not be used unless idle is notified from server
operations.initIdleDuration(3600 * 10)

View File

@ -54,8 +54,10 @@ class WinRandomPassManager(WindowsOsManager):
def processUserPassword(self, service, username, password):
if username == self._userAccount:
return [username, service.recoverValue('winOsRandomPass')]
return [username, password]
password = service.recoverValue('winOsRandomPass')
return WindowsOsManager.processUserPassword(self, service, username, password)
def genPassword(self, service):
import random

View File

@ -18,6 +18,9 @@ from uds.core import osmanagers
from uds.core.managers.UserServiceManager import UserServiceManager
from uds.core.util.State import State
from uds.core.util import log
from uds.models import TicketStore
from uds.REST.methods.actor import SECURE_OWNER
import six
import logging
@ -201,6 +204,25 @@ class WindowsOsManager(osmanagers.OSManager):
return ret
return scrambleMsg(ret)
def processUserPassword(self, service, username, password):
if service.getProperty('sso_available') == '1':
# Generate a ticket, store it and return username with no password
domain = ''
if '@' in username:
username, domain = username.split('@')
elif '\\' in username:
username, domain = username.split('\\')
creds = {
'username': username,
'password': password,
'domain': domain
}
ticket = TicketStore.create(creds, validator=None, validity=300, owner=SECURE_OWNER, secure=True)
return (ticket, '')
else:
return osmanagers.OSManager.processUserPassword(self, service, username, password)
def processUnused(self, userService):
'''
This will be invoked for every assigned and unused user service that has been in this state at least 1/2 of Globalconfig.CHECK_UNUSED_TIME

View File

@ -42,7 +42,7 @@ from uds.core.util import connection
import logging
import os
__updated__ = '2016-04-18'
__updated__ = '2016-06-17'
logger = logging.getLogger(__name__)
@ -117,14 +117,25 @@ class BaseRDPTransport(Transport):
if '.' in domain: # Dotter domain form
username = username + '@' + domain
domain = ''
else: # In case of a NETBIOS domain (not recomended), join it so processUserPassword can deal with it
username = domain + '\\' + username
domain = ''
# Temporal "fix" to check if we do something on processUserPassword
# Fix username/password acording to os manager
username, password = service.processUserPassword(username, password)
# Recover domain name if needed
if '\\' in username:
username, domain = username.split('\\')
return {'protocol': self.protocol, 'username': username, 'password': password, 'domain': domain}
def getConnectionInfo(self, service, user, password):
return self.processUserPassword(service, user, password)
dct = self.processUserPassword(service, user, password)
dct['sso'] = service.getProperty('sso_available') == '1'
return dct
def getScript(self, script):
with open(os.path.join(os.path.dirname(__file__), script)) as f:

View File

@ -40,7 +40,7 @@ from uds.core.util import OsDetector
import six
import os
__updated__ = '2016-05-13'
__updated__ = '2016-06-17'
class RDPFile(object):
@ -62,6 +62,7 @@ class RDPFile(object):
showWallpaper = False
multimon = False
desktopComposition = False
enablecredsspsupport = True
def __init__(self, fullScreen, width, height, bpp, target=OsDetector.Windows):
self.width = six.text_type(width)
@ -239,6 +240,8 @@ class RDPFile(object):
if self.redirectAudio is True:
res += 'audiocapturemode:i:1\n'
res += 'enablecredsspsupport:i:{}\n'.format(0 if self.enablecredsspsupport is False else 1)
return res
def getMacOsX(self):

View File

@ -44,7 +44,7 @@ logger = logging.getLogger(__name__)
READY_CACHE_TIMEOUT = 30
__updated__ = '2015-05-14'
__updated__ = '2016-06-17'
class RDPTransport(BaseRDPTransport):
@ -91,6 +91,8 @@ class RDPTransport(BaseRDPTransport):
r.showWallpaper = self.wallpaper.isTrue()
r.multimon = self.multimon.isTrue()
r.desktopComposition = self.aero.isTrue()
r.enablecredsspsupport = not ci['sso'] # with SSO, credssspsuport must be disabled
logger.debug('SSO: {}'.format(ci['sso']))
# data
data = {