Browse Source

Converted to python3

Squashed commit of the following:

commit 621e91d31ac04c7a692fb87a5cdf9235489e75b9
Author: Sven Velt <sven@velt.de>
Date:   Wed Nov 27 22:31:44 2019 +0100

    Decode byte strings to UTF-8

commit 92c878cc8f14d66f54b1ed9d4587f41902e4c537
Author: Sven Velt <sven@velt.de>
Date:   Wed Nov 27 16:02:54 2019 +0100

    2to3, interpreter changed

    Es werden aber binäre Strings ausgegeben :-/
Sven Velt 5 years ago
parent
commit
f8934c59f9
1 changed files with 6 additions and 6 deletions
  1. 6 6
      ssh-wrapper.py

+ 6 - 6
ssh-wrapper.py

@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import os
 import re
@@ -33,7 +33,7 @@ allowed = [
 
 cmdline = os.getenv('SSH_ORIGINAL_COMMAND')
 if not cmdline:
-	print 'This is just a wrapper, no command specified!'
+	print('This is just a wrapper, no command specified!')
 	sys.exit(3)
 
 for maybe in allowed:
@@ -42,13 +42,13 @@ for maybe in allowed:
 
 		try:
 			cmd = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
-		except Exception, exc:
-			print 'Could not execute plugin ("%s"): %s' % (' '.join(cmdline), exc)
+		except Exception as exc:
+			print('Could not execute plugin ("%s"): %s' % (' '.join(cmdline), exc))
 			sys.exit(3)
 		else:
-			print cmd.communicate()[0].rstrip()
+			print(cmd.communicate()[0].rstrip().decode('utf-8'))
 			sys.exit(cmd.returncode)
 
-print '%s: No allowed command found!' % sys.argv[0]
+print('%s: No allowed command found!' % sys.argv[0])
 sys.exit(3)