From a85f70912157fef1ed475c4a8aa2a03c528fc9fd Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Mon, 17 Dec 2018 22:02:21 +0100 Subject: [PATCH] Don't use powershell scripts to install AS it hangs when running on Win7/Win2088 --- WAPT/control | 2 +- openssh-events.man | Bin 0 -> 6310 bytes setup.py | 43 ++++++++++++++++++++++++++++++++----------- 3 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 openssh-events.man diff --git a/WAPT/control b/WAPT/control index 36d4496..5a0f5a6 100644 --- a/WAPT/control +++ b/WAPT/control @@ -1,5 +1,5 @@ package : fws-openssh -version : 7.7.2.0-5 +version : 7.7.2.0-6 architecture : all section : base priority : optional diff --git a/openssh-events.man b/openssh-events.man new file mode 100644 index 0000000000000000000000000000000000000000..7ee3e6417feb69b780305c08f497ce8d45b98e12 GIT binary patch literal 6310 zcmds6TTfF#5S~{|{13!Pq7N5w)An#?c4y|B>#je3N>!f7XX!{HlX5CY(v!Y?kQ3?3W4R|YQkDvSCqd~-6YpD~ zcBSp8`?4oBDS>MdJWpg*?#dnPNRGY?u-7N-%#{Oa;N$n*#&Z|X$DojF67nf?1>a41 zkGCCgJcq1iw2Ioi2lqfef^!=GV(vcl>|l>3WS)R>g53vrM~yq+9fH=y?<}mT$UL4Z z@(ABY&SvV@cQz6M{zVPCSWnGb&VG*(?YenQhUcD zRu}K9tS&>W9RjhT%;Eb4erTWLJ%gt=vJIc^MjkFXpD+T5brZB25%9PN4uI-_|P|DHK) z+sH@qlKM^7kq1v@L6&3#K3hN@SCGeZ_>>%F9nU3ML(VMXQ^H?M;HcqwUY7B@j0~#a zukUW}zI=h?LwG(JA-xA}n3#MGpYsM&-CQ}WhW z^cK7IQ4>m7-*%QVS`VSS%dBGV0~JZ z7{{luCjo}u$1@K5Y~A)Xo7I%L)dhE+SEeDM1+TF-a&LNrdwE`86;_}}4;-xCtjCGt z9Du8X_)74G&y1*9c!{yTXK376`-0r}s zVYe*io4}k=w=)LqS!esrqP+=3*u#2G*6qUi0P(hie6QoPH3sXsD`M@dA1iM>&?)G%{vy7xu)wh8QodC-Z+8^*RtgcG1pR#(L^@d0+#T{Hg4ZjeO41d9(OM zYx)LinivAtX1C~ydG>1k?&y#j`;L3EiEatQrYwmaG5%EkizI=W1e@XmhQnm=kLuDtoZ68 z!{5549Q2GmiSzEO2|p*WkEe5AZJ9SE%qzR5o>rCb_aMX9;2^=Da^nbL^!XYc`cql5 zGq>)rmTo2R4lqQarN*>;`LAJV&)r%0T3}DtmTo0nRetgGtFg%EwVB6AiS4!;$FzJ* z^!Zck5Yz0=SCyN0%b=xaIj%zo-!s!&vNCcYy#pzl%vhPUc5%I)Zz+6j^bLjjfxWg|G?@m_DI}! literal 0 HcmV?d00001 diff --git a/setup.py b/setup.py index b5a847b..a54313c 100644 --- a/setup.py +++ b/setup.py @@ -7,30 +7,51 @@ uninstallkey = [] def install(): print('Installing OpenSSH') mkdirs(makepath(programfiles,'OpenSSH')) + print(' Stoping the service') - if service_installed('sshd') and service_is_running('sshd'): - service_stop('sshd') - killalltasks('sshd.exe') + for service in ['sshd','ssh-agent']: + if service_installed(service) and service_is_running(service): + service_stop(service) + killalltasks('%s.exe' % service) + print(' Extract OpenSSH archive') run('"%s" e -y -o"%s" OpenSSH-Win%s.zip' % (makepath(programfiles,'7-Zip','7z.exe'),makepath(programfiles,'OpenSSH'),'64' if iswin64() else '32')) - print(' Installing the service') - run(r'powershell.exe -ExecutionPolicy Bypass -File "%s\install-sshd.ps1"' % makepath(programfiles,'OpenSSH')) + + print(' Installing the services') + run(r'sc.exe create sshd binPath= "%s" DisplayName= "OpenSSH Server" start= auto' % makepath(programfiles,'OpenSSH','sshd.exe'), accept_returncodes=[0,1073]) + run(r'sc.exe privs sshd SeAssignPrimaryTokenPrivilege/SeTcbPrivilege/SeBackupPrivilege/SeRestorePrivilege/SeImpersonatePrivilege') + run(r'sc.exe create ssh-agent binPath= "%s" DisplayName= "OpenSSH Authentication Agent" start= auto' % makepath(programfiles,'OpenSSH','ssh-agent.exe'), accept_returncodes=[0,1073]) + run(r'sc.exe sdset ssh-agent "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;RP;;;AU)"') + run(r'sc.exe privs ssh-agent SeImpersonatePrivilege') + run(r'wevtutil.exe um "%s"' % makepath(programfiles,'OpenSSH','openssh-events.man')) + filecopyto('openssh-events.man',makepath(programfiles,'OpenSSH')) + run(r'wevtutil.exe im "%s"' % makepath(programfiles,'OpenSSH','openssh-events.man')) + print(' Opening port 22 in the firewall') run_notfatal(r'netsh advfirewall firewall del rule name="OpenSSH Server"') run(r'netsh advfirewall firewall add rule name="OpenSSH Server" dir=in action=allow protocol=TCP localport=22 enable=yes') + print(' Starting the service') service_start('sshd') + print(r' Enabling sshd service on boot') run('sc config sshd start= auto') def uninstall(): print('Removing OpenSSH') - print(' Stoping the service') - if service_is_running('sshd'): - service_stop('sshd') - killalltasks('sshd.exe') - print(' Uninstalling the service') - run(r'powershell.exe -ExecutionPolicy Bypass -File "%s\uninstall-sshd.ps1"' % makepath(programfiles,'OpenSSH')) + + for service in ['sshd','ssh-agent']: + print(' Stoping the services %s' % service) + if service_is_running(service): + service_stop(service) + killalltasks('%s.exe' % service) + + print(' Uninstalling service %s' % service) + run(r'sc.exe delete %s' % service) + + print(' Unregister events handler') + run(r'wevtutil um "%s"' % makepath(programfiles,'OpenSSH','openssh-events.man')) + print(' Removing files') remove_tree(makepath(programfiles,'OpenSSH'))