1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-25 23:21:41 +03:00

Working on supporting better clients on Mac

This commit is contained in:
Adolfo Gómez García 2020-10-30 09:44:55 +01:00
parent 5d604bb629
commit da23222f0f
7 changed files with 108 additions and 356 deletions

View File

@ -170,13 +170,7 @@ class RDPTransport(BaseRDPTransport):
else: # Mac
sp.update({
'as_new_xfreerdp_params': r.as_new_xfreerdp_params,
'as_file': r.as_file,
'as_cord_url': r.as_cord_url,
'as_rdp_url': r.as_rdp_url,
})
if domain != '':
sp['usernameWithDomain'] = '{}\\\\{}'.format(domain, username)
else:
sp['usernameWithDomain'] = username
return self.getScript('scripts/{}/direct.py', osName, sp)

View File

@ -238,37 +238,6 @@ class RDPFile:
return params
@property
def as_cord_url(self):
url = 'rdp://'
if self.username != '':
url += urllib.parse.quote(self.username)
if self.password != '':
url += ':' + urllib.parse.quote(self.password)
url += '@'
url += self.address + '/'
if self.domain != '':
url += self.domain
url += '?screenDepth###{}'.format(self.bpp)
if self.fullScreen: # @UndefinedVariable
url += '&fullscreen###true'
else:
url += '&screenWidth###{}&screenHeight###{}'.format(self.width, self.height)
# url += '&forwardAudio###' + '01'[{m.r.redirectAudio}] # @UndefinedVariable
if self.redirectDrives: # @UndefinedVariable
url += '&forwardDisks###true'
if self.redirectPrinters: # @UndefinedVariable
url += '&forwardPrinters###true'
return url
def getGeneric(self): # pylint: disable=too-many-statements
password = '{password}'
screenMode = '2' if self.fullScreen else '1'
@ -352,207 +321,47 @@ class RDPFile:
return res
def getMacOsX(self):
if self.fullScreen:
desktopSize = ' <string>DesktopFullScreen</string>'
else:
desktopSize = ''' <dict>
<key>DesktopHeight</key>
<integer>{}</integer>
<key>DesktopWidth</key>
<integer>{}</integer>
</dict>'''.format(self.width, self.height)
@property
def as_rdp_url(self) -> str:
# Some parameters
screenMode = '2' if self.fullScreen else '1'
audioMode = self.redirectAudio and '0' or '2'
useMultimon = self.multimon and '1' or '0'
disableWallpaper = self.showWallpaper and '0' or '1'
printers = self.redirectPrinters and '1' or '0'
credsspsupport = '0' if self.enablecredsspsupport is False else '1'
drives = self.redirectDrives != 'false' and "1" or "0"
audioMode = self.redirectAudio and "0" or "2"
wallpaper = self.showWallpaper and 'true' or 'false'
parameters = [
('full address', f's:{self.address}'),
('audiomode', f'i:{audioMode}'),
('screen mode id', f'i:{screenMode}'),
('use multimon', f'i:{useMultimon}'),
('desktopwidth', f'i:{self.width}'),
('desktopheight', f':{self.height}'),
('session bpp', f'i:{self.bpp}'),
('disable menu anims', f'i:{disableWallpaper}'),
('disable themes', f'i:{disableWallpaper}'),
('disable wallpaper', f'i:{disableWallpaper}'),
('redirectprinters', f'i:{printers}'),
('disable full window drag', 'i:1'),
('authentication level', f'i:0'),
# Not listed, but maybe usable?
('enablecredsspsupport', f'i:{credsspsupport}')
]
if self.username:
parameters.append(('username', f's:{urllib.parse.quote(self.username)}'))
if self.domain:
parameters.append(('domain', f's:{urllib.parse.quote(self.domain)}'))
if self.desktopComposition:
parameters.append(('allow desktop composition', 'i:1'))
if self.smoothFonts:
parameters.append(('allow font smoothing', 'i:1'))
if self.redirectDrives != 'false': # Only "all drives" is supported
parameters.append(('drivestoredirect', f's:*'))
return 'rdp://' + '&'.join((urllib.parse.quote(i[0]) + '=' + i[1] for i in parameters))
return '''
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AddToKeychain</key>
<true/>
<key>ApplicationPath</key>
<string></string>
<key>AudioRedirectionMode</key>
<integer>{audioMode}</integer>
<key>AuthenticateLevel</key>
<integer>0</integer>
<key>AutoReconnect</key>
<true/>
<key>BitmapCaching</key>
<true/>
<key>ColorDepth</key>
<integer>1</integer>
<key>ConnectionString</key>
<string>{host}</string>
<key>DesktopSize</key>
{desktopSize}
<key>Display</key>
<integer>0</integer>
<key>Domain</key>
<string>{domain}</string>
<key>DontWarnOnChange</key>
<true/>
<key>DontWarnOnDriveMount</key>
<true/>
<key>DontWarnOnQuit</key>
<true/>
<key>DriveRedirectionMode</key>
<integer>{drives}</integer>
<key>FontSmoothing</key>
<true/>
<key>FullWindowDrag</key>
<false/>
<key>HideMacDock</key>
<true/>
<key>KeyMappingTable</key>
<dict>
<key>UI_ALPHANUMERIC_KEY</key>
<dict>
<key>MacKeyCode</key>
<integer>102</integer>
<key>MacModifier</key>
<integer>0</integer>
<key>On</key>
<true/>
</dict>
<key>UI_ALT_KEY</key>
<dict>
<key>MacKeyCode</key>
<integer>4294967295</integer>
<key>MacModifier</key>
<integer>2048</integer>
<key>On</key>
<true/>
</dict>
<key>UI_CONTEXT_MENU_KEY</key>
<dict>
<key>MacKeyCode</key>
<integer>120</integer>
<key>MacModifier</key>
<integer>2048</integer>
<key>On</key>
<true/>
</dict>
<key>UI_CONVERSION_KEY</key>
<dict>
<key>MacKeyCode</key>
<integer>4294967295</integer>
<key>MacModifier</key>
<integer>0</integer>
<key>On</key>
<false/>
</dict>
<key>UI_HALF_FULL_WIDTH_KEY</key>
<dict>
<key>MacKeyCode</key>
<integer>49</integer>
<key>MacModifier</key>
<integer>256</integer>
<key>On</key>
<true/>
</dict>
<key>UI_HIRAGANA_KEY</key>
<dict>
<key>MacKeyCode</key>
<integer>104</integer>
<key>MacModifier</key>
<integer>0</integer>
<key>On</key>
<true/>
</dict>
<key>UI_NON_CONVERSION_KEY</key>
<dict>
<key>MacKeyCode</key>
<integer>4294967295</integer>
<key>MacModifier</key>
<integer>0</integer>
<key>On</key>
<false/>
</dict>
<key>UI_NUM_LOCK_KEY</key>
<dict>
<key>MacKeyCode</key>
<integer>71</integer>
<key>MacModifier</key>
<integer>0</integer>
<key>On</key>
<true/>
</dict>
<key>UI_PAUSE_BREAK_KEY</key>
<dict>
<key>MacKeyCode</key>
<integer>99</integer>
<key>MacModifier</key>
<integer>2048</integer>
<key>On</key>
<true/>
</dict>
<key>UI_PRINT_SCREEN_KEY</key>
<dict>
<key>MacKeyCode</key>
<integer>118</integer>
<key>MacModifier</key>
<integer>2048</integer>
<key>On</key>
<true/>
</dict>
<key>UI_SCROLL_LOCK_KEY</key>
<dict>
<key>MacKeyCode</key>
<integer>107</integer>
<key>MacModifier</key>
<integer>0</integer>
<key>On</key>
<true/>
</dict>
<key>UI_SECONDARY_MOUSE_BUTTON</key>
<dict>
<key>MacKeyCode</key>
<integer>256</integer>
<key>MacModifier</key>
<integer>4608</integer>
<key>On</key>
<true/>
</dict>
<key>UI_WINDOWS_START_KEY</key>
<dict>
<key>MacKeyCode</key>
<integer>122</integer>
<key>MacModifier</key>
<integer>2048</integer>
<key>On</key>
<true/>
</dict>
</dict>
<key>MenuAnimations</key>
<false/>
<key>PrinterRedirection</key>
<true/>
<key>RedirectFolder</key>
<string>/Users/admin</string>
<key>RedirectPrinter</key>
<string></string>
<key>RemoteApplication</key>
<false/>
<key>Themes</key>
<true/>
<key>UserName</key>
<string>{username}</string>
<key>Wallpaper</key>
<{wallpaper}/>
<key>WorkingDirectory</key>
<string></string>
</dict>
</plist>'''.format(
desktopSize=desktopSize,
drives=drives,
audioMode=audioMode,
host=self.address,
domain=self.domain,
username=self.username,
wallpaper=wallpaper
)

View File

@ -194,14 +194,9 @@ class TRDPTransport(BaseRDPTransport):
})
else: # Mac
sp.update({
'as_file': r.as_file,
'as_cord_url': r.as_cord_url,
'as_new_xfreerdp_params': r.as_new_xfreerdp_params,
'as_rdp_url': r.as_rdp_url,
})
if domain != '':
sp['usernameWithDomain'] = '{}\\\\{}'.format(domain, username)
else:
sp['usernameWithDomain'] = username
return self.getScript('scripts/{}/tunnel.py', osName, sp)

View File

@ -11,63 +11,39 @@ from uds import tools # @UnresolvedImport
# Inject local passed sp into globals for functions
globals()['sp'] = sp # type: ignore # pylint: disable=undefined-variable
msrdc = '/Applications/Remote Desktop Connection.app/Contents/MacOS/Remote Desktop Connection'
cord = "/Applications/CoRD.app/Contents/MacOS/CoRD"
msrdc = '/Applications/Microsoft Remote Desktop.app/Contents/MacOS/Microsoft Remote Desktop'
xfreerdp = 'xfreerdp' # TODO
executable = None
if os.path.isfile(cord):
executable = cord
elif os.path.isfile(msrdc):
# Check first xfreerdp, allow password redir
if os.path.isfile(xfreerdp):
executable = xfreerdp
elif os.path.isfile(msrdc) and sp['as_rdp_url']:
executable = msrdc
else:
executable = None
def onExit():
import subprocess # @Reimport
subprocess.call(
[
'security',
'delete-generic-password',
'-a', sp['usernameWithDomain'], # @UndefinedVariable
'-s', 'Remote Desktop Connection 2 Password for {}'.format(sp['ip']), # @UndefinedVariable
]
)
if executable is None:
raise Exception('''<p><b>Microsoft Remote Desktop Connection not found</b></p>
<p>In order to connect to UDS RDP Sessions, you need to have at least one of the following:<p>
<ul>
<li>
<p><b>CoRD</b> (A bit unstable from 10.7 onwards)</p>
<p>You can get it from <a href="{}uds/res/other/CoRD.pkg">this link</a></p>
</li>
</ul>
<p>If both apps are installed, Remote Desktop Connection will be used as first option</p>'''.format(
sp['this_server'])) # @UndefinedVariable
if sp['as_rdp_url']:
raise Exception('''<p><b>Microsoft Remote Desktop or xfreerdp not found</b></p>
<p>In order to connect to UDS RDP Sessions, you need to have a<p>
<ul>
<li>
<p><b>Microsoft Remote Desktop</b> from Apple Store</p>
</li>
<li>
<p><b>Xfreerdp</b> from homebrew</p>
</li>
</ul>
''')
else:
raise Exception('''<p><b>xfreerdp not found</b></p>
<p>In order to connect to UDS RDP Sessions, you need to have a<p>
<ul>
<li>
<p><b>Xfreerdp</b> from homebrew</p>
</li>
</ul>
''')
elif executable == msrdc:
try:
filename = tools.saveTempFile(sp['as_file']) # @UndefinedVariable
if sp['password'] != '': # @UndefinedVariable
subprocess.call(
[
'security',
'add-generic-password',
'-w', sp['password'], # @UndefinedVariable
'-U',
'-a', sp['usernameWithDomain'], # @UndefinedVariable
'-s', 'Remote Desktop Connection 2 Password for {}'.format(sp['ip']), # @UndefinedVariable
'-T', '/Applications/Remote Desktop Connection.app',
]
)
tools.addExecBeforeExit(onExit)
# Call and wait for exit
tools.addTaskToWait(subprocess.Popen([executable, filename]))
tools.addFileToUnlink(filename)
except Exception as e:
raise
else: # CoRD
url = sp['as_cord_url'] # @UndefinedVariable
url = sp['as_rdp_url'] # @UndefinedVariable
tools.addTaskToWait(subprocess.Popen(['open', url]))

View File

@ -1 +1 @@
WAFrqiAZrjqNES0tqQ4xht8v2qvDnAluav3U5wpb6n0KqsoRscgy16E9u1bVQObX/GrwoJPNt31wS55Hm2f6+JWp0cOejsYYtOHtwgvOWcHk3jxxOwO4/llFDvWwYOmlE3UxpCsh9BCa8GejdOYf4RDPZVELjbYNXvvEhDXnok5k1wLT+L+x1FP52kiznpH4NiMqEfBrtxdJKXanS5qSjHSae2+UNXjbol8Le57yCKtLoT4+7+VN/sviWqp+J3A/R2jtqKaegxNa96MxcSLN9rpgKFQN8yK9L43JaC5WOPWyUEYWY/vO/5uwbPH/9xrqXpLwP0IX60KQuUiDCyzIfdN+b5IzY3GtcPE8UqJatZbU1ESW1YLixf339JceF3csFk1pgCAimfQwvMz22hcKjDQBDW1Y7eJ+I0vLPcE9CQOtI+0Qj9UbkJXomStrKiRtEVtrHGYpNU1h4TXtdZB+g6oz5MCYkyznJseY7gIRfAKlmLIIp/e/e20IGnZeU7PcXy0VhFwaCTkDfpgNPeUV59RuLPlq9LUZ5fQshgUWQJKGpoX6ubN4reKtOyLYCCSE1G8lG0nVWs3QJ+47HwhkhjVfOIExO38S3+1Vkn9wrsQ75iYkXmyJP8Vh6JpQAoaDrkVDskqUx/eVUabfTk8tQZwXVzP1Kwg+LB91o0Z0waI=
Nyiuosn1S6FeFLxz7BT7vOOt0WCnObOYM+vi6PkKbGj+hkwuFIPV/OFml7SxneujX3/197wVZxnhu0JTNb32sa8VB0FWz2OJoinH+l5cjcugA9Hsde9tjtMkhPc84tv0pQf+vPL3kHmfq7Qw1cQ/UuYfnp02HGmHDzIlnLmxoOy1CqxomTd8W4Ko0qVgLGUrvACinl8Z/Ya/LViECenIvC/ske8ZAlyIF/ICMp3VxB5QedNezwxm6KthL/BtgttX6IYNcr+caxnYfVO+VAzpfe4P9hg+91OE71zG0DpY1/CQIOEBd3ejxhRjfGnNGGisimxrQ1sutzsNBMjUJYxJNFGVdRlRNp4phM1pIrb9LWRoKaqXlRbSNyXn041oL10EP9wf3GzG0KnQVLhZ/bYl88tTIBJC7res9Q90fffw1EzbPFkcG6QyCaabv6mQ+9GsIH/zOPQsihqREtCL2HCDc+wlY9DBiU5q4KJp3hRzHFjwzzqqXpejV/cJfOENhlJA5AGRmlu3hLREsfyC9QR3G26dgSXF/FR6VeZZzB44KEY3DI7hq6CplyTwoOgGzUJW7wxkqRhdzV3tpZereBYJW3ntkeNsBOzzzEJax+robmzHPiYPQM7WCWsGWdP3jux+yDPAtFnAC5YKGyhXhOgjeLiByI/nmw3k+/g5M8XOASQ=

View File

@ -12,39 +12,42 @@ from uds import tools # @UnresolvedImport
# Inject local passed sp into globals for functions
globals()['sp'] = sp # type: ignore # pylint: disable=undefined-variable
msrdc = '/Applications/Remote Desktop Connection.app/Contents/MacOS/Remote Desktop Connection'
cord = "/Applications/CoRD.app/Contents/MacOS/CoRD"
# Inject local passed sp into globals for functions
globals()['sp'] = sp # type: ignore # pylint: disable=undefined-variable
if os.path.isfile(cord):
executable = cord
elif os.path.isfile(msrdc):
msrdc = '/Applications/Microsoft Remote Desktop.app/Contents/MacOS/Microsoft Remote Desktop'
xfreerdp = 'xfreerdp' # TODO
executable = None
# Check first xfreerdp, allow password redir
if os.path.isfile(xfreerdp):
executable = xfreerdp
elif os.path.isfile(msrdc) and sp['as_rdp_url']:
executable = msrdc
else:
executable = None
def onExit():
import subprocess # @Reimport
subprocess.call(
[
'security',
'delete-generic-password',
'-a', sp['usernameWithDomain'], # @UndefinedVariable
'-s', 'Remote Desktop Connection 2 Password for 127.0.0.1',
]
)
if executable is None:
raise Exception('''<p><b>Microsoft Remote Desktop Connection not found</b></p>
<p>In order to connect to UDS RDP Sessions, you need to have at least one of the following:<p>
<ul>
<li>
<p><b>CoRD</b> (A bit unstable from 10.7 onwards)</p>
<p>You can get it from <a href="{}uds/res/other/CoRD.pkg">this link</a></p>
</li>
</ul>
<p>If both apps are installed, Remote Desktop Connection will be used as first option</p>
'''.format(sp['this_server'])) # @UndefinedVariable
if sp['as_rdp_url']:
raise Exception('''<p><b>Microsoft Remote Desktop or xfreerdp not found</b></p>
<p>In order to connect to UDS RDP Sessions, you need to have a<p>
<ul>
<li>
<p><b>Microsoft Remote Desktop</b> from Apple Store</p>
</li>
<li>
<p><b>Xfreerdp</b> from homebrew</p>
</li>
</ul>
''')
else:
raise Exception('''<p><b>xfreerdp not found</b></p>
<p>In order to connect to UDS RDP Sessions, you need to have a<p>
<ul>
<li>
<p><b>Xfreerdp</b> from homebrew</p>
</li>
</ul>
''')
elif executable == msrdc:
forwardThread, port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], 3389, waitTime=sp['tunWait']) # @UndefinedVariable
address = '127.0.0.1:{}'.format(port)
@ -54,31 +57,6 @@ if forwardThread.status == 2:
else:
if executable == msrdc:
theFile = sp['as_file'].format(address=address) # @UndefinedVariable
filename = tools.saveTempFile(theFile)
tools.addFileToUnlink(filename)
try:
if sp['password'] != '': # @UndefinedVariable
subprocess.call(
[
'security',
'add-generic-password',
'-w', sp['password'], # @UndefinedVariable
'-U',
'-a', sp['usernameWithDomain'], # @UndefinedVariable
'-s', 'Remote Desktop Connection 2 Password for 127.0.0.1'.format(port),
'-T', '/Applications/Remote Desktop Connection.app',
]
)
tools.addExecBeforeExit(onExit)
# Call but do not wait for exit
tools.addTaskToWait(subprocess.Popen([executable, filename]))
tools.addFileToUnlink(filename)
except Exception as e:
raise
else: # CoRD
url = sp['as_cord_url'].format(address=address) # @UndefinedVariable
url = sp['as_rdp_url'] # @UndefinedVariable
tools.addTaskToWait(subprocess.Popen(['open', url]))

View File

@ -1 +1 @@
AEKks/fDJVOaooJBnmYFvQej3xs6Ir+Fqudrlv/m2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