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 0000000..7ee3e64 Binary files /dev/null and b/openssh-events.man differ 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'))