Added ov user/password sender

This commit is contained in:
Adolfo Gómez García 2019-10-03 07:11:42 +02:00
parent a32bb87a78
commit 66f498e7ed
5 changed files with 34 additions and 0 deletions

View File

@ -170,6 +170,12 @@ class HTTPServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
raise Exception('Invalid preConnect parameters')
return HTTPServerHandler.service.preConnect(params.get('user'), params.get('protocol'))
def post_ovLogon(self, params):
logger.debug('Received ov logon')
if 'username' not in params or 'pasword' not in params:
raise Exception('Invalid ovLogon parameters')
return HTTPServerHandler.service.ovLogon(params.get('username'), params.get('pasword'))
def get_information(self, params):
# TODO: Return something useful? :)
return 'Up and running'

View File

@ -121,6 +121,9 @@ class UDSActorSvc(Daemon, CommonService):
return 'ok'
def ovLogon(self, username, password):
pass
def run(self):
cfg = initCfg() # Gets a local copy of config to get "reboot"

View File

@ -188,6 +188,9 @@ class XScreenSaverInfo(ctypes.Structure):
try:
xlibPath = ctypes.util.find_library('X11')
xssPath = ctypes.util.find_library('Xss')
xlib = xss = None
if not xlibPath or not xssPath:
raise Exception()
xlib = ctypes.cdll.LoadLibrary(xlibPath)
xss = ctypes.cdll.LoadLibrary(xssPath)

View File

@ -32,6 +32,7 @@
from __future__ import unicode_literals
# pylint: disable=unused-wildcard-import, wildcard-import
import struct
import subprocess
import os
import stat
@ -223,6 +224,15 @@ class UDSActorSvc(win32serviceutil.ServiceFramework, CommonService):
return 'ok'
def ovLogon(self, username, password):
# Compose packet for ov
ub = username.encode('utf8')
up = username.encode('utf8')
packet = struct.pack('!I', len(ub)) + ub + struct.pack('!I', len(up)) + up
# Send packet with username/password to ov pipe
operations.writeToPipe("\\\\.\\pipe\\VDSMDPipe", packet, True)
return 'done'
def onLogout(self, user):
logger.debug('Windows onLogout invoked: {}, {}'.format(user, self._user))
try:

View File

@ -229,3 +229,15 @@ def getCurrentUser():
Returns current logged in username
'''
return os.environ['USERNAME']
def writeToPipe(pipeName, bytesPayload, waitForResponse):
# (str, bytes, bool) -> Optional[bytes]
try:
with open(pipeName, 'r+b', 0) as f:
f.write(bytesPayload)
# f.seek(0) # As recommended on intenet, but seems to work fin without thos
if waitForResponse:
return f.read()
return b'ok'
except Exception as e:
None