Description: Allows to change ssh server port
Author: Wolf Wiegand <wolf@kondancemilch.de>
Bug-Debian: http://bugs.debian.org/455245

--- a/ajaxterm.py
+++ b/ajaxterm.py
@@ -367,9 +367,10 @@
 		return r
 
 class Multiplex:
-	def __init__(self,cmd=None):
+	def __init__(self,cmd=None,serverport=None):
 		signal.signal(signal.SIGCHLD, signal.SIG_IGN)
 		self.cmd=cmd
+		self.serverport=serverport
 		self.proc={}
 		self.lock=threading.RLock()
 		self.thread=threading.Thread(target=self.loop)
@@ -403,7 +404,10 @@
 					cmd+=['-oPreferredAuthentications=keyboard-interactive,password']
 					cmd+=['-oNoHostAuthenticationForLocalhost=yes']
 					cmd+=['-oLogLevel=FATAL']
-					cmd+=['-F/dev/null','-l',login,'localhost']
+					cmd+=['-F/dev/null']
+					if self.serverport:
+						cmd+=['-p %s'%self.serverport]
+					cmd+=['-l', login, 'localhost']
 				else:
 					os._exit(0)
 			env={}
@@ -473,7 +477,7 @@
 				pass
 
 class AjaxTerm:
-	def __init__(self,cmd=None,index_file='ajaxterm.html'):
+	def __init__(self,cmd=None,index_file='ajaxterm.html',serverport=None):
 		self.files={}
 		for i in ['css','html','js']:
 			for j in glob.glob('*.%s'%i):
@@ -481,7 +485,7 @@
 		self.files['index']=file(index_file).read()
 		self.mime = mimetypes.types_map.copy()
 		self.mime['.html']= 'text/html; charset=UTF-8'
-		self.multi = Multiplex(cmd)
+		self.multi = Multiplex(cmd,serverport)
 		self.session = {}
 	def __call__(self, environ, start_response):
 		req = qweb.QWebRequest(environ, start_response,session=None)
@@ -528,6 +532,7 @@
 	parser.add_option("-P", "--pidfile",dest="pidfile",default="/var/run/ajaxterm.pid",help="set the pidfile (default: /var/run/ajaxterm.pid)")
 	parser.add_option("-i", "--index", dest="index_file", default="ajaxterm.html",help="default index file (default: ajaxterm.html)")
 	parser.add_option("-u", "--uid", dest="uid", help="Set the daemon's user id")
+	parser.add_option("-s", "--serverport", dest="serverport", help="Use a different port than 22 to connect to the ssh server")
 	(o, a) = parser.parse_args()
 	if o.daemon:
 		pid=os.fork()
@@ -553,7 +558,7 @@
 			sys.exit(0)
 	else:
 		print 'AjaxTerm at http://localhost:%s/' % o.port
-	at=AjaxTerm(o.cmd,o.index_file)
+	at=AjaxTerm(o.cmd,o.index_file,o.serverport)
 #	f=lambda:os.system('firefox http://localhost:%s/&'%o.port)
 #	qweb.qweb_wsgi_autorun(at,ip='localhost',port=int(o.port),threaded=0,log=o.log,callback_ready=None)
 	try:
--- a/ajaxterm.1
+++ b/ajaxterm.1
@@ -36,6 +36,10 @@
 .TP
 \fB\-u\fR UID, \fB\-\-uid\fR=\fIUID\fR
 Set the daemon's user id
+.TP
+\fB\-s\fR SERVERPORT, \fB\-\-serverport\fR=\fISERVERPORT\fR
+Use a different port than 22 to connect to the ssh
+server
 
 .SH AUTHOR
 Antony Lesuisse <al@udev.org>
