Commit ed03b793 by Belákovics Ádám

added multi user support (thx to szebi)

parent 402cfbde
;NSIS Modern User Interface
;Multilingual Cloud Installer Script
;Written by Csk Tams
;Written by Cs�k Tam�s and Bel�kovics �d�m
;--------------------------------
; MultiUser install setup
!define MULTIUSER_EXECUTIONLEVEL Highest
!define MULTIUSER_MUI
!define MULTIUSER_INSTALLMODE_COMMANDLINE
;--------------------------------
;Include Modules
!include "MultiUser.nsh"
!include "MUI2.nsh"
!include "LogicLib.nsh"
!include "FileFunc.nsh"
......@@ -18,15 +26,15 @@
!define AppUninstaller "Uninstall.exe"
!define IconName "cloud"
!define Show_output "True"
!define DefaulLocation "$LOCALAPPDATA\CIRCLE"
!define DefaulLocation "$PROGRAMFILES\CIRCLE"
!define LowestSupportedPythonVersion "6"
!define HighestSupportedPythonVersion "7"
!define LogInformationTime 2000
;String manipulations
!define Explode "!insertmacro Explode"
!define StrCase "!insertmacro StrCase"
!define StrTrimNewLines "!insertmacro StrTrimNewLines"
!define StrCase2 "!insertmacro StrCase2"
!define StrTrimNewLines2 "!insertmacro StrTrimNewLines2"
;--------------------------------
;General
!macro Explode Length Separator String
......@@ -35,19 +43,19 @@
Call Explode
Pop '${Length}'
!macroend
!macro StrCase ResultVar String Case
!macro StrCase2 ResultVar String Case
Push "${String}"
Push "${Case}"
Call StrCase
Call StrCase2
Pop "${ResultVar}"
!macroend
!macro StrTrimNewLines ResultVar String
!macro StrTrimNewLines2 ResultVar String
Push "${String}"
Call StrTrimNewLines
Call StrTrimNewLines2
Pop "${ResultVar}"
!macroend
;Properly display all languages (Installer will not work on Windows 95, 98 or ME!)
Unicode true
; Unicode true
;Name and file
Name "${Company} ${AppName}"
......@@ -91,6 +99,7 @@
;Pages
!insertmacro MUI_PAGE_LICENSE "gpl-3.0.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MULTIUSER_PAGE_INSTALLMODE
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
;Done fuction to launch install.bat
......@@ -116,7 +125,7 @@
LangString NAME_Install ${LANG_HUNGARIAN} "Komponensek"
LangString NAME_Functions ${LANG_ENGLISH} "Functions"
LangString NAME_Functions ${LANG_HUNGARIAN} "Funkcik"
LangString NAME_Functions ${LANG_HUNGARIAN} "Funkcik"
;CIRCLE Client (SecInstall)
;NAME
......@@ -127,53 +136,53 @@
LangString DESC_SecInstall ${LANG_ENGLISH} "Install the core of the CIRCLE Client.$\r$\n\
Used for [RDP / SSH] type of connections.$\r$\n\
Automates all installed, third party connection tools."
LangString DESC_SecInstall ${LANG_HUNGARIAN} "A CIRCLE Kliens alapjnak teleptse.$\r$\n\
[RDP / SSH] fle kapcsolatokhoz hasznlt.$\r$\n\
Automatizlja az installlt, harmadik fltl szrmaz szoftverek hasznlatt."
LangString DESC_SecInstall ${LANG_HUNGARIAN} "A CIRCLE Kliens alapj�nak telep�t�se.$\r$\n\
[RDP / SSH] f�le kapcsolatokhoz haszn�lt.$\r$\n\
Automatiz�lja az install�lt, harmadik f�lt�l sz�rmaz� szoftverek haszn�lat�t."
;Python search (PythonLookup)
;NAME
LangString NAME_PythonLookup ${LANG_ENGLISH} "Search Python"
LangString NAME_PythonLookup ${LANG_HUNGARIAN} "Python keress"
LangString NAME_PythonLookup ${LANG_HUNGARIAN} "Python keress"
;DESC
LangString DESC_PythonLookup ${LANG_ENGLISH} "Use ONLY if necessary!$\r$\n\
Search the filesystem for Python installation. Usefull when Python was installed without accessing registry before.$\r$\n\
Installation will take more time."
LangString DESC_PythonLookup ${LANG_HUNGARIAN} "Csak szksg esetn!$\r$\n\
A fjlrendszer keresse Python utn. Hasznos, ha a Python-t Registry nlkli opcival lett teleptve korbban.$\r$\n\
A teleptst jelentsen lelasstja."
LangString DESC_PythonLookup ${LANG_HUNGARIAN} "Csak sz�ks�g eset�n!$\r$\n\
A f�jlrendszer keres�se Python ut�n. Hasznos, ha a Python-t Registry n�lk�li opci�val lett telep�tve kor�bban.$\r$\n\
A telep�t�st jelent�sen lelass�tja."
;STATUS
LangString STATUS_PythonSearch ${LANG_ENGLISH} "Searching for Python. This could take some time. Looking at drive:"
LangString STATUS_PythonSearch ${LANG_HUNGARIAN} "Python keresse a fjlrendszerben. Ez eltarthat egy darabig. Keress alapja:"
LangString STATUS_PythonSearch ${LANG_HUNGARIAN} "Python keres�se a f�jlrendszerben. Ez eltarthat egy darabig. Keres�s alapja:"
LangString STATUS_PythonFound ${LANG_ENGLISH} "Python found at "
LangString STATUS_PythonFound ${LANG_HUNGARIAN} "Python megtallva az albbi knyvtrban: "
LangString STATUS_PythonFound ${LANG_HUNGARIAN} "Python megtal�lva az al�bbi k�nyvt�rban: "
LangString STATUS_PythonVersionSearch ${LANG_ENGLISH} "Determining Python version."
LangString STATUS_PythonVersionSearch ${LANG_HUNGARIAN} "Teleptett Python verzi kidertse."
LangString STATUS_PythonVersionSearch ${LANG_HUNGARIAN} "Telep�tett Python verzi� kider�t�se."
LangString STATUS_PythonVersionFound ${LANG_ENGLISH} "Installed Python version is:"
LangString STATUS_PythonVersionFound ${LANG_HUNGARIAN} "A teleptett Python verzija:"
LangString STATUS_PythonVersionFound ${LANG_HUNGARIAN} "A telep�tett Python verzi�ja:"
LangString STATUS_PythonArchitectSearch ${LANG_ENGLISH} "Deteremining installed Python mode (32bit or 64bit)."
LangString STATUS_PythonArchitectSearch ${LANG_HUNGARIAN} "Installlt Python futtatsi mdjnak kidertse (32bit vagy 64bit)."
LangString STATUS_PythonArchitectSearch ${LANG_HUNGARIAN} "Install�lt Python futtat�si m�dj�nak kider�t�se (32bit vagy 64bit)."
LangString STATUS_PythonArchitectFound ${LANG_ENGLISH} "Installed Python mode is:"
LangString STATUS_PythonArchitectFound ${LANG_HUNGARIAN} "A teleptett Python mdja:"
LangString STATUS_PythonArchitectFound ${LANG_HUNGARIAN} "A telep�tett Python m�dja:"
LangString STATUS_PythonNotSupported ${LANG_ENGLISH} "The installed Python version is not supported!$\r$\n\
To procede please uninstall Python first."
LangString STATUS_PythonNotSupported ${LANG_HUNGARIAN} "A felteleptett Python verzija nem tmogatott!$\r$\n\
A sikeres teleptshez el kell elbb tvoltania a Python-t."
LangString STATUS_PythonNotSupported ${LANG_HUNGARIAN} "A feltelep�tett Python verzi�ja nem t�mogatott!$\r$\n\
A sikeres telep�t�shez el kell el�bb t�vol�tania a Python-t."
LangString STATUS_PythonNotFound ${LANG_ENGLISH} "Python not found in the filesystem!"
LangString STATUS_PythonNotFound ${LANG_HUNGARIAN}} "Nem tallhat Python a fjlrendszerben!"
LangString STATUS_PythonNotFound ${LANG_HUNGARIAN}} "Nem tal�lhat� Python a f�jlrendszerben!"
LangString STATUS_PythonArchitectNotFound ${LANG_ENGLISH} "Could NOT determine the installed Python mode!$\r$\n\
To procede please uninstall Python first."
LangString STATUS_PythonArchitectNotFound ${LANG_HUNGARIAN} "Nem sikerlt kiderteni a felteleptett Python mdjt!$\r$\n\
A sikeres teleptshez el kell elbb tvoltania a Python-t."
LangString STATUS_PythonArchitectNotFound ${LANG_HUNGARIAN} "Nem siker�lt kider�teni a feltelep�tett Python m�dj�t!$\r$\n\
A sikeres telep�t�shez el kell el�bb t�vol�tania a Python-t."
;NX Client (NXClient)
;NAME
......@@ -183,12 +192,12 @@
;DESC
LangString DESC_NXClient ${LANG_ENGLISH} "Check whether you want to install a CIRCLE compatible NX Client by NoMachine.$\r$\n\
Used for [NX] type of connections."
LangString DESC_NXClient ${LANG_HUNGARIAN} "Vlassza ki, ha fel szeretn telepteni a NoMachine ltal gyrtott NX Klienst.$\r$\n\
[NX] fle kapcsolatokhoz hasznlt."
LangString DESC_NXClient ${LANG_HUNGARIAN} "V�lassza ki, ha fel szeretn� telep�teni a NoMachine �ltal gy�rtott NX Klienst.$\r$\n\
[NX] f�le kapcsolatokhoz haszn�lt."
;Setup
LangString STATUS_ExecutingScript ${LANG_ENGLISH} "Executing setup script. Log files can be found at:"
LangString STATUS_ExecutingScript ${LANG_HUNGARIAN} "Installcis script futtatsa. A folyamat naplja:"
LangString STATUS_ExecutingScript ${LANG_HUNGARIAN} "Install�ci�s script futtat�sa. A folyamat napl�ja:"
;--------------------------------
;Global variables
Var /GLOBAL python_location
......@@ -227,7 +236,7 @@ SectionGroup /e '!$(NAME_Install)'
;Creating ShortCuts
CreateDirectory '$SMPROGRAMS\${Company}\${AppName}'
StrCmp $LANGUAGE ${LANG_HUNGARIAN} 0 +3
WriteINIStr "$SMPROGRAMS\${Company}\Ltogasd meg a ${AppUrlName}-t.url" "InternetShortcut" "URL" "${AppUrl}"
WriteINIStr "$SMPROGRAMS\${Company}\Ltogasd meg a ${AppUrlName}-t.url" "InternetShortcut" "URL" "${AppUrl}"
Goto +2
WriteINIStr "$SMPROGRAMS\${Company}\Visit the ${AppUrlName}.url" "InternetShortcut" "URL" "${AppUrl}"
CreateShortCut '$SMPROGRAMS\${Company}\${AppName}\Uninstall ${AppName}.lnk' '$INSTDIR\${AppUninstaller}' "" '$INSTDIR\${AppUninstaller}' 0
......@@ -265,6 +274,7 @@ Function .onInit
ClearErrors
${EndIf}
!insertmacro MUI_LANGDLL_DISPLAY
!insertmacro MULTIUSER_INIT
FunctionEnd
Function PythonSearch
StrCpy $python_location ""
......@@ -285,7 +295,7 @@ Function PythonSearch
Pop $0
${If} $0 = 0
Pop $0
${StrTrimNewLines} $python_version $0
${StrTrimNewLines2} $python_version $0
loop:
${Explode} $0 $explodeChar $python_version
${For} $1 1 $0
......@@ -315,7 +325,7 @@ Function PythonSearch
${EndIf}
Goto loopNext
CutPython:
${StrCase} $3 $2 "U"
${StrCase2} $3 $2 "U"
StrCmp $3 "PYTHON" loopNext
StrCpy $python_version $2
StrCpy $explodeChar '.'
......@@ -335,7 +345,7 @@ Function PythonSearch
Pop $0
${If} $0 = 0
Pop $0
${StrTrimNewLines} $python_architect $0
${StrTrimNewLines2} $python_architect $0
DetailPrint '$(STATUS_PythonArchitectFound) $python_architectbit'
${Else}
StrCpy $found_python "false"
......@@ -633,7 +643,7 @@ Function Explode
Push $explArrCount
FunctionEnd
Function StrCase
Function StrCase2
/*After this point:
------------------------------------------
$0 = String (input)
......@@ -805,7 +815,7 @@ Function StrCase
Pop $1
Exch $0
FunctionEnd
Function StrTrimNewLines
Function StrTrimNewLines2
/*After this point:
------------------------------------------
$R0 = String (input)
......@@ -868,8 +878,8 @@ Section "Uninstall"
${EndIf}
StrCmp $LANGUAGE ${LANG_HUNGARIAN} 0 +4
IfFileExists "$SMPROGRAMS\${Company}\Ltogasd meg a ${AppUrlName}-t.url" 0 +2
Delete "$SMPROGRAMS\${Company}\Ltogasd meg a ${AppUrlName}-t.url"
IfFileExists "$SMPROGRAMS\${Company}\Ltogasd meg a ${AppUrlName}-t.url" 0 +2
Delete "$SMPROGRAMS\${Company}\Ltogasd meg a ${AppUrlName}-t.url"
Goto +3
IfFileExists "$SMPROGRAMS\${Company}\Visit the ${AppUrlName}.url" 0 +2
Delete "$SMPROGRAMS\${Company}\Visit the ${AppUrlName}.url"
......@@ -932,5 +942,6 @@ Function un.onInit
SetRegView 64
${EndIf}
!insertmacro MUI_UNGETLANGUAGE
!insertmacro MULTIUSER_UNINIT
FunctionEnd
\ No newline at end of file
......@@ -9,7 +9,9 @@ The Client job is to help the ease of use of the cloud system.
import argparse
import logging
import platform
import tempfile
from time import gmtime, strftime
from windowsclasses import ClientRegistry
......@@ -49,8 +51,8 @@ def parse_arguments():
help="Explicit location of the wanted logfile location and name",
type=unicode,
default=("%(directory)s\\%(file)s" % {
'directory': ClientRegistry.directory(),
'file': 'client.log'}))
'directory': tempfile.gettempdir(),
'file': 'circle_client.log'}))
args = parser.parse_args()
return args
......
......@@ -11,12 +11,13 @@ import binascii
import glob
import locale
import logging
import nxkey
import os
import subprocess
import time
import win32crypt
import tempfile
import nxkey
import win32crypt
from windowsclasses import ClientRegistry
......@@ -76,23 +77,13 @@ def connect(vm):
subprocess.Popen((u'"%s"' % config_file).encode(
locale.getpreferredencoding()), shell=True)
elif vm.protocol == "RDP":
logger.info('RDP protocol received')
listdir = ClientRegistry.directory() + "\\.rdp\\*.rdp"
found = False
logger.debug('RDP protocol received')
full_address = "full address:s:%s:%s" % (vm.host, vm.port)
user = "username:s:%s" % vm.user
for config_file in glob.glob(listdir):
with open(config_file) as f:
file = f.read()
if full_address in file and user in file:
found = True
logger.info('Config file found: %s', config_file)
break
if not found:
logger.info('No config file found, creating new one')
config_file = "%s%s%s" % ((
ClientRegistry.directory() + "\\.rdp\\"),
str(int(time.time() * 1000)), ".rdp")
config_file = "%s%s" % (
tempfile.gettempdir(),
"\\circle_" + vm.user + str(int(time.time() * 1000)) + ".rdp")
logger.info('Creating config file %s' % config_file)
password = binascii.hexlify(win32crypt.CryptProtectData(
u"%s" % vm.password, u'psw', None, None, None, 0))
config = RPD_template % {'USERNAME': vm.user, 'PASSWORD': password,
......@@ -100,12 +91,13 @@ def connect(vm):
f = open(config_file, 'w')
f.write(config)
f.close()
logger.info('Config file created: %s', config_file)
logger.debug('Popen the config file: %s', config_file)
subprocess.Popen((u'"%s"' % config_file).encode(
locale.getpreferredencoding()), shell=True)
locale.getpreferredencoding()), shell=True).wait()
os.remove(config_file)
logger.info('Client finished working')
NX_template = """<!DOCTYPE NXClientSettings>
<NXClientSettings application="nxclient" version="1.3" >
<group name="General" >
......@@ -125,4 +117,5 @@ NX_template = """<!DOCTYPE NXClientSettings>
RPD_template = """username:s:%(USERNAME)s
full address:s:%(HOST)s:%(PORT)s
authentication level:i:0
password 51:b:%(PASSWORD)s"""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment