Browse Source

Don't use powershell scripts to install

AS it hangs when running on Win7/Win2088
master
Daniel Berteaud 5 months ago
parent
commit
a85f709121
3 changed files with 33 additions and 12 deletions
  1. 1
    1
      WAPT/control
  2. BIN
      openssh-events.man
  3. 32
    11
      setup.py

+ 1
- 1
WAPT/control View File

@@ -1,5 +1,5 @@
1 1
 package           : fws-openssh
2
-version           : 7.7.2.0-5
2
+version           : 7.7.2.0-6
3 3
 architecture      : all
4 4
 section           : base
5 5
 priority          : optional

BIN
openssh-events.man View File


+ 32
- 11
setup.py View File

@@ -7,30 +7,51 @@ uninstallkey = []
7 7
 def install():
8 8
     print('Installing OpenSSH')
9 9
     mkdirs(makepath(programfiles,'OpenSSH'))
10
+
10 11
     print('    Stoping the service')
11
-    if service_installed('sshd') and service_is_running('sshd'):
12
-        service_stop('sshd')
13
-        killalltasks('sshd.exe')
12
+    for service in ['sshd','ssh-agent']:
13
+        if service_installed(service) and service_is_running(service):
14
+            service_stop(service)
15
+        killalltasks('%s.exe' % service)
16
+
14 17
     print('    Extract OpenSSH archive')
15 18
     run('"%s" e -y -o"%s" OpenSSH-Win%s.zip' % (makepath(programfiles,'7-Zip','7z.exe'),makepath(programfiles,'OpenSSH'),'64' if iswin64() else '32'))
16
-    print('    Installing the service')
17
-    run(r'powershell.exe -ExecutionPolicy Bypass -File "%s\install-sshd.ps1"' % makepath(programfiles,'OpenSSH'))
19
+
20
+    print('    Installing the services')
21
+    run(r'sc.exe create sshd binPath= "%s" DisplayName= "OpenSSH Server" start= auto' % makepath(programfiles,'OpenSSH','sshd.exe'), accept_returncodes=[0,1073])
22
+    run(r'sc.exe privs sshd SeAssignPrimaryTokenPrivilege/SeTcbPrivilege/SeBackupPrivilege/SeRestorePrivilege/SeImpersonatePrivilege')
23
+    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])
24
+    run(r'sc.exe sdset ssh-agent "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;RP;;;AU)"')
25
+    run(r'sc.exe privs ssh-agent SeImpersonatePrivilege')
26
+    run(r'wevtutil.exe um "%s"' % makepath(programfiles,'OpenSSH','openssh-events.man'))
27
+    filecopyto('openssh-events.man',makepath(programfiles,'OpenSSH'))
28
+    run(r'wevtutil.exe im "%s"' % makepath(programfiles,'OpenSSH','openssh-events.man'))
29
+
18 30
     print('    Opening port 22 in the firewall')
19 31
     run_notfatal(r'netsh advfirewall firewall del rule name="OpenSSH Server"')
20 32
     run(r'netsh advfirewall firewall add rule name="OpenSSH Server" dir=in action=allow protocol=TCP localport=22 enable=yes')
33
+
21 34
     print('    Starting the service')
22 35
     service_start('sshd')
36
+
23 37
     print(r'    Enabling sshd service on boot')
24 38
     run('sc config sshd start= auto')
25 39
 
26 40
 def uninstall():
27 41
     print('Removing OpenSSH')
28
-    print('    Stoping the service')
29
-    if service_is_running('sshd'):
30
-        service_stop('sshd')
31
-        killalltasks('sshd.exe')
32
-    print('    Uninstalling the service')
33
-    run(r'powershell.exe -ExecutionPolicy Bypass -File "%s\uninstall-sshd.ps1"' % makepath(programfiles,'OpenSSH'))
42
+
43
+    for service in ['sshd','ssh-agent']:
44
+        print('    Stoping the services %s' % service)
45
+        if service_is_running(service):
46
+            service_stop(service)
47
+        killalltasks('%s.exe' % service)
48
+
49
+        print('    Uninstalling service %s' % service)
50
+        run(r'sc.exe delete %s' % service)
51
+
52
+    print('    Unregister events handler')
53
+    run(r'wevtutil um "%s"' % makepath(programfiles,'OpenSSH','openssh-events.man'))
54
+
34 55
     print('    Removing files')
35 56
     remove_tree(makepath(programfiles,'OpenSSH'))
36 57
 

Loading…
Cancel
Save