This commit is contained in:
Adolfo Gómez García 2017-03-10 10:04:19 +01:00
commit 35a3e48b89
3 changed files with 26 additions and 3 deletions

View File

@ -50,6 +50,7 @@ import stat
import subprocess
POST_CMD = '/etc/udsactor/post'
PRECONNECT_CMD = '/etc/udsactor/pre'
try:
from prctl import set_proctitle # @UnresolvedImport
@ -100,6 +101,26 @@ class UDSActorSvc(Daemon, CommonService):
def joinDomain(self, name, domain, ou, account, password):
logger.fatal('Join domain is not supported on linux platforms right now')
def preConnect(self, user, protocol):
'''
Invoked when received a PRE Connection request via REST
'''
# Execute script in /etc/udsactor/post after interacting with broker, if no reboot is requested ofc
# This will be executed only when machine gets "ready"
try:
if os.path.isfile(PRECONNECT_CMD):
if (os.stat(PRECONNECT_CMD).st_mode & stat.S_IXUSR) != 0:
subprocess.call([PRECONNECT_CMD, user, protocol])
else:
logger.info('PRECONNECT file exists but it it is not executable (needs execution permission by root)')
else:
logger.info('PRECONNECT file not found & not executed')
except Exception as e:
# Ignore output of execution command
logger.error('Executing preconnect command give')
def run(self):
cfg = initCfg() # Gets a local copy of config to get "reboot"
@ -141,7 +162,7 @@ class UDSActorSvc(Daemon, CommonService):
if os.path.isfile(POST_CMD):
if (os.stat(POST_CMD).st_mode & stat.S_IXUSR) != 0:
subprocess.call('/etc/udsactor/post')
subprocess.call([POST_CMD, ])
else:
logger.info('POST file exists but it it is not executable (needs execution permission by root)')
else:

View File

@ -3,6 +3,7 @@
from __future__ import unicode_literals
# pylint: disable=import-error, no-name-in-module, too-many-format-args, undefined-variable, invalid-sequence-index
from PyQt4 import QtCore, QtGui
import subprocess
import re
from uds.forward import forward # @UnresolvedImport
@ -50,6 +51,7 @@ if xfreerdp is not None:
fnc, app = execNewXFreeRdp, xfreerdp
except Exception as e: # Valid version not found, pass to check rdesktop
# QtGui.QMessageBox.critical(parent, 'Notice', six.text_type(e), QtGui.QMessageBox.Ok) # @UndefinedVariable
pass
if app is None or fnc is None:
@ -59,7 +61,7 @@ if app is None or fnc is None:
''')
else:
# Open tunnel
forwardThread, port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], '{m.ip}', 3389, {m.tunWait}) # @UndefinedVariable
forwardThread, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', 3389, {m.tunWait}) # @UndefinedVariable
if forwardThread.status == 2:
raise Exception('Unable to open tunnel')

View File

@ -54,7 +54,7 @@ if executable is None:
forwardThread, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', 3389, {m.tunnelWait}) # @UndefinedVariable
forwardThread, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', 3389, {m.tunWait}) # @UndefinedVariable
if forwardThread.status == 2:
raise Exception('Unable to open tunnel')