[Ajaxterm] - Apply patches from Debian (fixes #635238, #544033, enables UTF-8) - Cleanup init script - Add a sy
Ruben Kerkhof
ruben at fedoraproject.org
Sun Oct 17 17:11:09 UTC 2010
commit f1477239c3eb8a0ddaea12deb14f79956d4e61d1
Author: Ruben <ruben at rubenkerkhof.com>
Date: Sun Oct 17 19:11:01 2010 +0200
- Apply patches from Debian (fixes #635238, #544033, enables UTF-8)
- Cleanup init script
- Add a sysconfig file
- Relocate pidfile to /var/run/ajaxterm/ajaxterm.pid
- Add a README.Fedora
- Add an example config for Apache
0001-01_bin_dir.diff-from-Debian.patch | 21 +
0001-Create-etc.patch | 24 +
0002-02_initd.diff-from-Debian.patch | 50 ++
0002-Fix-permissions-on-manfile.patch | 25 +
0003-03_fix_man.diff-from-Debian.patch | 42 ++
0003-Remove-shebang-line.patch | 22 +
0004-04_use-default-python.diff-from-Debian.patch | 22 +
0005-05_ssh-port.diff-from-Debian.patch | 75 +++
0006-06_fix-IOError.diff-from-Debian.patch | 25 +
0007-07_use_psyco.diff-from-Debian.patch | 47 ++
0008-10_hostname-login.diff-from-Debian.patch | 33 ++
0009-15_add-configure-file.diff-from-Debian.patch | 84 +++
...0_bugfixes-tweaks-by-blt.diff-from-Debian.patch | 189 +++++++
0011-25_CVE-2009-1629.diff-from-Debian.patch | 153 +++++
0012-30_utf8-support.diff-from-Debian.patch | 591 ++++++++++++++++++++
0013-35_fix-sarissa.diff-from-Debian.patch | 31 +
0014-40_more-ctrl-catches.diff-from-Debian.patch | 34 ++
Ajaxterm.apache | 28 +
Ajaxterm.init | 77 +++
Ajaxterm.spec | 88 ++-
Ajaxterm.sysconfig | 15 +
README.Fedora | 45 ++
22 files changed, 1696 insertions(+), 25 deletions(-)
---
diff --git a/0001-01_bin_dir.diff-from-Debian.patch b/0001-01_bin_dir.diff-from-Debian.patch
new file mode 100644
index 0000000..cd1d440
--- /dev/null
+++ b/0001-01_bin_dir.diff-from-Debian.patch
@@ -0,0 +1,21 @@
+From ba58ad8363c9e9225e432b01254eae2be3453438 Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 17:14:05 +0200
+Subject: [PATCH 01/14] 01_bin_dir.diff from Debian
+
+---
+ configure.ajaxterm.bin | 3 ++-
+ 1 files changed, 2 insertions(+), 1 deletions(-)
+
+diff --git a/configure.ajaxterm.bin b/configure.ajaxterm.bin
+index 4d1f5a9..875b12d 100644
+--- a/configure.ajaxterm.bin
++++ b/configure.ajaxterm.bin
+@@ -1,2 +1,3 @@
+ #!/bin/sh
+-PYTHONPATH=%(lib)s exec %(lib)s/ajaxterm.py $@
++PYTHONPATH=/usr/share/ajaxterm
++exec $PYTHONPATH/ajaxterm.py $@
+--
+1.7.3.1
+
diff --git a/0001-Create-etc.patch b/0001-Create-etc.patch
new file mode 100644
index 0000000..63b6db6
--- /dev/null
+++ b/0001-Create-etc.patch
@@ -0,0 +1,24 @@
+From 309e643b66e9b15f005109360c87f425c459e7b0 Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 18:09:25 +0200
+Subject: [PATCH] Create /etc
+
+---
+ configure.makefile | 1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+
+diff --git a/configure.makefile b/configure.makefile
+index c866804..aed7ca6 100644
+--- a/configure.makefile
++++ b/configure.makefile
+@@ -4,6 +4,7 @@ build:
+ install:
+ install -d "%(bin)s"
+ install -d "%(lib)s"
++ install -d "%(etc)s"
+ install ajaxterm.bin "%(bin)s/ajaxterm"
+ install -m 644 ajaxterm.css ajaxterm.html ajaxterm.js qweb.py sarissa.js sarissa_dhtml.js utf8-escape.js "%(lib)s"
+ install -m 644 ajaxterm.conf "%(etc)s"
+--
+1.7.3.1
+
diff --git a/0002-02_initd.diff-from-Debian.patch b/0002-02_initd.diff-from-Debian.patch
new file mode 100644
index 0000000..19528eb
--- /dev/null
+++ b/0002-02_initd.diff-from-Debian.patch
@@ -0,0 +1,50 @@
+From 41ea31a4b52add3023b9126b1d6278a3c23d2b22 Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 17:14:30 +0200
+Subject: [PATCH 02/14] 02_initd.diff from Debian
+
+---
+ configure | 8 --------
+ configure.makefile | 2 --
+ 2 files changed, 0 insertions(+), 10 deletions(-)
+
+diff --git a/configure b/configure
+index 45391f4..fbaff03 100755
+--- a/configure
++++ b/configure
+@@ -21,12 +21,4 @@ man=os.path.join(o.prefix,"share/man/man1")
+ file("ajaxterm.bin","w").write(file("configure.ajaxterm.bin").read()%locals())
+ file("Makefile","w").write(file("configure.makefile").read()%locals())
+
+-if os.path.isfile("/etc/gentoo-release"):
+- file("ajaxterm.initd","w").write(file("configure.initd.gentoo").read()%locals())
+-elif os.path.isfile("/etc/fedora-release") or os.path.isfile("/etc/redhat-release"):
+- file("ajaxterm.initd","w").write(file("configure.initd.redhat").read()%locals())
+-else:
+- file("ajaxterm.initd","w").write(file("configure.initd.debian").read()%locals())
+-
+ os.system("chmod a+x ajaxterm.bin")
+-os.system("chmod a+x ajaxterm.initd")
+diff --git a/configure.makefile b/configure.makefile
+index 6bd8085..b3c678f 100644
+--- a/configure.makefile
++++ b/configure.makefile
+@@ -5,7 +5,6 @@ install:
+ install -d "%(bin)s"
+ install -d "%(lib)s"
+ install ajaxterm.bin "%(bin)s/ajaxterm"
+- install ajaxterm.initd "%(etc)s/init.d/ajaxterm"
+ install -m 644 ajaxterm.css ajaxterm.html ajaxterm.js qweb.py sarissa.js sarissa_dhtml.js "%(lib)s"
+ install -m 755 ajaxterm.py "%(lib)s"
+ gzip --best -c ajaxterm.1 > ajaxterm.1.gz
+@@ -14,7 +13,6 @@ install:
+
+ clean:
+ rm ajaxterm.bin
+- rm ajaxterm.initd
+ rm ajaxterm.1.gz
+ rm Makefile
+
+--
+1.7.3.1
+
diff --git a/0002-Fix-permissions-on-manfile.patch b/0002-Fix-permissions-on-manfile.patch
new file mode 100644
index 0000000..e69868c
--- /dev/null
+++ b/0002-Fix-permissions-on-manfile.patch
@@ -0,0 +1,25 @@
+From ed60fd28185aacb7cb87d101daa62dca280fa735 Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 19:00:06 +0200
+Subject: [PATCH] Fix permissions on manfile
+
+---
+ configure.makefile | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/configure.makefile b/configure.makefile
+index aed7ca6..ca27732 100644
+--- a/configure.makefile
++++ b/configure.makefile
+@@ -12,7 +12,7 @@ install:
+ ln -s /etc/ajaxterm.conf "%(lib)s"/ajaxterm_config.js
+ gzip --best -c ajaxterm.1 > ajaxterm.1.gz
+ install -d "%(man)s"
+- install ajaxterm.1.gz "%(man)s"
++ install -pm 0644 ajaxterm.1.gz "%(man)s"
+
+ clean:
+ rm ajaxterm.bin
+--
+1.7.3.1
+
diff --git a/0003-03_fix_man.diff-from-Debian.patch b/0003-03_fix_man.diff-from-Debian.patch
new file mode 100644
index 0000000..1dc04ee
--- /dev/null
+++ b/0003-03_fix_man.diff-from-Debian.patch
@@ -0,0 +1,42 @@
+From a15c2fdf9fe2bdeb552d14026c7dfc664db10413 Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 17:15:01 +0200
+Subject: [PATCH 03/14] 03_fix_man.diff from Debian
+
+---
+ ajaxterm.1 | 12 ++++++------
+ 1 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/ajaxterm.1 b/ajaxterm.1
+index 46f2acb..8d0a942 100644
+--- a/ajaxterm.1
++++ b/ajaxterm.1
+@@ -1,4 +1,4 @@
+-.TH ajaxterm "1" "May 2006" "ajaxterm 0.5" "User commands"
++.TH ajaxterm "1" "Jul 2006" "ajaxterm 0.7" "User commands"
+ .SH NAME
+ ajaxterm \- Web based terminal written in python
+
+@@ -8,14 +8,14 @@ javascript for client side.
+ It can use almost any web browser and even works through firewalls.
+
+ .SH USAGE
+-\fBajaxterm.py\fR [options]
++\fBajaxterm\fR [options]
+
+ .SH OPTIONS
+ A summary of the options supported by \fBajaxterm\fR is included below.
+- \fB-h, --help\fR show this help message and exit
+- \fB-pPORT, --port=PORT\fR Set the TCP port (default: 8022)
+- \fB-cCMD, --command=CMD\fR set the command (default: /bin/login or ssh localhost)
+- \fB-l, --log\fR log requests to stderr (default: quiet mode)
++ \fB-h, \--help\fR show this help message and exit
++ \fB-pPORT, \--port=PORT\fR Set the TCP port (default: 8022)
++ \fB-cCMD, \--command=CMD\fR set the command (default: /bin/login or ssh localhost)
++ \fB-l, \--log\fR log requests to stderr (default: quiet mode)
+
+ .SH AUTHOR
+ Antony Lesuisse <al at udev.org>
+--
+1.7.3.1
+
diff --git a/0003-Remove-shebang-line.patch b/0003-Remove-shebang-line.patch
new file mode 100644
index 0000000..3e16925
--- /dev/null
+++ b/0003-Remove-shebang-line.patch
@@ -0,0 +1,22 @@
+From 7fa9b9aeba7cea832db688199c955baf57397841 Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 19:01:18 +0200
+Subject: [PATCH] Remove shebang line
+
+---
+ qweb.py | 2 --
+ 1 files changed, 0 insertions(+), 2 deletions(-)
+
+diff --git a/qweb.py b/qweb.py
+index 1541035..ef9ecaf 100644
+--- a/qweb.py
++++ b/qweb.py
+@@ -1,5 +1,3 @@
+-#!/usr/bin/env python
+-#
+ # vim:set et ts=4 fdc=0 fdn=2 fdl=0:
+ #
+ # There are no blank lines between blocks beacause i use folding from:
+--
+1.7.3.1
+
diff --git a/0004-04_use-default-python.diff-from-Debian.patch b/0004-04_use-default-python.diff-from-Debian.patch
new file mode 100644
index 0000000..37e63d7
--- /dev/null
+++ b/0004-04_use-default-python.diff-from-Debian.patch
@@ -0,0 +1,22 @@
+From 416891118e1770b2370238855f39babb3e22477f Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 17:15:27 +0200
+Subject: [PATCH 04/14] 04_use-default-python.diff from Debian
+
+---
+ qweb.py | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/qweb.py b/qweb.py
+index 20c5092..c658a6b 100644
+--- a/qweb.py
++++ b/qweb.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/python2.3
++#!/usr/bin/env python
+ #
+ # vim:set et ts=4 fdc=0 fdn=2 fdl=0:
+ #
+--
+1.7.3.1
+
diff --git a/0005-05_ssh-port.diff-from-Debian.patch b/0005-05_ssh-port.diff-from-Debian.patch
new file mode 100644
index 0000000..06b3acf
--- /dev/null
+++ b/0005-05_ssh-port.diff-from-Debian.patch
@@ -0,0 +1,75 @@
+From 8bbdcc6e084b59027cac6f2463968af1f33b1793 Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 17:16:14 +0200
+Subject: [PATCH 05/14] 05_ssh-port.diff from Debian
+
+---
+ ajaxterm.py | 15 ++++++++++-----
+ 1 files changed, 10 insertions(+), 5 deletions(-)
+
+diff --git a/ajaxterm.py b/ajaxterm.py
+index 8b3af37..63b0444 100755
+--- a/ajaxterm.py
++++ b/ajaxterm.py
+@@ -367,9 +367,10 @@ class SynchronizedMethod:
+ 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 @@ class Multiplex:
+ 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 @@ class Multiplex:
+ 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 @@ class AjaxTerm:
+ 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 @@ def main():
+ 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 @@ def main():
+ 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:
+--
+1.7.3.1
+
diff --git a/0006-06_fix-IOError.diff-from-Debian.patch b/0006-06_fix-IOError.diff-from-Debian.patch
new file mode 100644
index 0000000..7c82761
--- /dev/null
+++ b/0006-06_fix-IOError.diff-from-Debian.patch
@@ -0,0 +1,25 @@
+From 86a9366721a7736f9be28871b303d350bda1bd2c Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 17:16:49 +0200
+Subject: [PATCH 06/14] 06_fix-IOError.diff from Debian
+
+---
+ ajaxterm.py | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/ajaxterm.py b/ajaxterm.py
+index 63b0444..fe1fc6c 100755
+--- a/ajaxterm.py
++++ b/ajaxterm.py
+@@ -419,7 +419,7 @@ class Multiplex:
+ else:
+ fcntl.fcntl(fd, fcntl.F_SETFL, os.O_NONBLOCK)
+ # python bug http://python.org/sf/1112949 on amd64
+- fcntl.ioctl(fd, struct.unpack('i',struct.pack('I',termios.TIOCSWINSZ))[0], struct.pack("HHHH",h,w,0,0))
++ fcntl.ioctl(fd, termios.TIOCSWINSZ, struct.pack("HHHH",h,w,0,0))
+ self.proc[fd]={'pid':pid,'term':Terminal(w,h),'buf':'','time':time.time()}
+ return fd
+ def die(self):
+--
+1.7.3.1
+
diff --git a/0007-07_use_psyco.diff-from-Debian.patch b/0007-07_use_psyco.diff-from-Debian.patch
new file mode 100644
index 0000000..cd8b468
--- /dev/null
+++ b/0007-07_use_psyco.diff-from-Debian.patch
@@ -0,0 +1,47 @@
+From 22dd3fa44e3bcd83d6358cd8dea329509e79471b Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 17:18:03 +0200
+Subject: [PATCH 07/14] 07_use_psyco.diff from Debian
+
+---
+ ajaxterm.py | 6 ++++++
+ qweb.py | 6 ++++++
+ 2 files changed, 12 insertions(+), 0 deletions(-)
+
+diff --git a/ajaxterm.py b/ajaxterm.py
+index fe1fc6c..a3b928f 100755
+--- a/ajaxterm.py
++++ b/ajaxterm.py
+@@ -2,6 +2,12 @@
+
+ """ Ajaxterm """
+
++try:
++ import psyco
++ psyco.profile()
++except:
++ pass
++
+ import array,cgi,fcntl,glob,mimetypes,optparse,os,pty,random,re,signal,select,sys,threading,time,termios,struct,pwd
+
+ os.chdir(os.path.normpath(os.path.dirname(__file__)))
+diff --git a/qweb.py b/qweb.py
+index c658a6b..34529c2 100644
+--- a/qweb.py
++++ b/qweb.py
+@@ -116,6 +116,12 @@ try:
+ except ImportError:
+ import StringIO
+
++try:
++ import psyco
++ psyco.profile()
++except:
++ pass
++
+ #----------------------------------------------------------
+ # Qweb Xml t-raw t-esc t-if t-foreach t-set t-call t-trim
+ #----------------------------------------------------------
+--
+1.7.3.1
+
diff --git a/0008-10_hostname-login.diff-from-Debian.patch b/0008-10_hostname-login.diff-from-Debian.patch
new file mode 100644
index 0000000..6d56790
--- /dev/null
+++ b/0008-10_hostname-login.diff-from-Debian.patch
@@ -0,0 +1,33 @@
+From 40c8f7f1907805bce929500a751e2c8ae05a2836 Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 17:18:41 +0200
+Subject: [PATCH 08/14] 10_hostname-login.diff from Debian
+
+---
+ ajaxterm.py | 3 ++-
+ 1 files changed, 2 insertions(+), 1 deletions(-)
+
+diff --git a/ajaxterm.py b/ajaxterm.py
+index a3b928f..91d938d 100755
+--- a/ajaxterm.py
++++ b/ajaxterm.py
+@@ -15,6 +15,7 @@ os.chdir(os.path.normpath(os.path.dirname(__file__)))
+ sys.path[0:0]=glob.glob('../../python')
+
+ import qweb
++from socket import gethostname
+
+ class Terminal:
+ def __init__(self,width=80,height=24):
+@@ -403,7 +404,7 @@ class Multiplex:
+ elif os.getuid()==0:
+ cmd=['/bin/login']
+ else:
+- sys.stdout.write("Login: ")
++ sys.stdout.write(gethostname() + " login: ")
+ login=sys.stdin.readline().strip()
+ if re.match('^[0-9A-Za-z-_. ]+$',login):
+ cmd=['ssh']
+--
+1.7.3.1
+
diff --git a/0009-15_add-configure-file.diff-from-Debian.patch b/0009-15_add-configure-file.diff-from-Debian.patch
new file mode 100644
index 0000000..613bbee
--- /dev/null
+++ b/0009-15_add-configure-file.diff-from-Debian.patch
@@ -0,0 +1,84 @@
+From 28dc99ae657768f1724e0bd3a0f598acf1073407 Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 17:21:19 +0200
+Subject: [PATCH 09/14] 15_add-configure-file.diff from Debian
+
+---
+ ajaxterm.conf | 13 +++++++++++++
+ ajaxterm.html | 3 ++-
+ ajaxterm.js | 8 ++++++++
+ configure.makefile | 2 ++
+ 4 files changed, 25 insertions(+), 1 deletions(-)
+ create mode 100644 ajaxterm.conf
+
+diff --git a/ajaxterm.conf b/ajaxterm.conf
+new file mode 100644
+index 0000000..41bd097
+--- /dev/null
++++ b/ajaxterm.conf
+@@ -0,0 +1,13 @@
++// Ajaxterm configuration file
++//
++// This is a javascript snippet
++//
++// Don't forget to restart ajaxterm after editing this file
++
++
++// Sets the terminal width (default: 80)
++width=80;
++
++// Sets the terminal height (default: 25)
++height=25;
++
+diff --git a/ajaxterm.html b/ajaxterm.html
+index 9edf759..095e7d6 100644
+--- a/ajaxterm.html
++++ b/ajaxterm.html
+@@ -7,9 +7,10 @@
+ <script type="text/javascript" src="sarissa.js"></script>
+ <script type="text/javascript" src="sarissa_dhtml.js"></script>
+ <script type="text/javascript" src="ajaxterm.js"></script>
++ <script type="text/javascript" src="ajaxterm_config.js"></script>
+ <script type="text/javascript">
+ window.onload=function() {
+- t=ajaxterm.Terminal("term",80,25);
++ t=ajaxterm.Terminal("term",width,height);
+ };
+ </script>
+ </head>
+diff --git a/ajaxterm.js b/ajaxterm.js
+index 07eca3b..74eeb39 100644
+--- a/ajaxterm.js
++++ b/ajaxterm.js
+@@ -4,6 +4,14 @@ ajaxterm.Terminal_ctor=function(id,width,height) {
+ if(window.ActiveXObject)
+ ie=1;
+ var sid=""+Math.round(Math.random()*1000000000);
++
++ if (width==0) {
++ width=80;
++ }
++ if (height==0) {
++ height=25;
++ }
++
+ var query0="s="+sid+"&w="+width+"&h="+height;
+ var query1=query0+"&c=1&k=";
+ var buf="";
+diff --git a/configure.makefile b/configure.makefile
+index b3c678f..a30dc23 100644
+--- a/configure.makefile
++++ b/configure.makefile
+@@ -6,7 +6,9 @@ install:
+ install -d "%(lib)s"
+ install ajaxterm.bin "%(bin)s/ajaxterm"
+ install -m 644 ajaxterm.css ajaxterm.html ajaxterm.js qweb.py sarissa.js sarissa_dhtml.js "%(lib)s"
++ install -m 644 ajaxterm.conf "%(etc)s"
+ install -m 755 ajaxterm.py "%(lib)s"
++ ln -s /etc/ajaxterm.conf "%(lib)s"/ajaxterm_config.js
+ gzip --best -c ajaxterm.1 > ajaxterm.1.gz
+ install -d "%(man)s"
+ install ajaxterm.1.gz "%(man)s"
+--
+1.7.3.1
+
diff --git a/0010-20_bugfixes-tweaks-by-blt.diff-from-Debian.patch b/0010-20_bugfixes-tweaks-by-blt.diff-from-Debian.patch
new file mode 100644
index 0000000..e007359
--- /dev/null
+++ b/0010-20_bugfixes-tweaks-by-blt.diff-from-Debian.patch
@@ -0,0 +1,189 @@
+From a83984700c9ff46d467994724dff98f5ab10f5f5 Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 17:33:46 +0200
+Subject: [PATCH 10/14] 20_bugfixes-tweaks-by-blt.diff from Debian
+
+---
+ ajaxterm.js | 5 ++++-
+ ajaxterm.py | 45 ++++++++++++++++++++++++++++++++++-----------
+ qweb.py | 26 ++++++++++++++++++++++++++
+ 3 files changed, 64 insertions(+), 12 deletions(-)
+
+diff --git a/ajaxterm.js b/ajaxterm.js
+index 74eeb39..4edcb6c 100644
+--- a/ajaxterm.js
++++ b/ajaxterm.js
+@@ -1,8 +1,11 @@
+ ajaxterm={};
+ ajaxterm.Terminal_ctor=function(id,width,height) {
+ var ie=0;
++ var webkit=0;
+ if(window.ActiveXObject)
+ ie=1;
++ if (navigator.userAgent.indexOf("WebKit") >= 0)
++ webkit=1;
+ var sid=""+Math.round(Math.random()*1000000000);
+
+ if (width==0) {
+@@ -242,7 +245,7 @@ ajaxterm.Terminal_ctor=function(id,width,height) {
+ }
+ function keydown(ev) {
+ if (!ev) var ev=window.event;
+- if (ie) {
++ if (ie || webkit) {
+ // s="kd keyCode="+ev.keyCode+" which="+ev.which+" shiftKey="+ev.shiftKey+" ctrlKey="+ev.ctrlKey+" altKey="+ev.altKey;
+ // debug(s);
+ o={9:1,8:1,27:1,33:1,34:1,35:1,36:1,37:1,38:1,39:1,40:1,45:1,46:1,112:1,
+diff --git a/ajaxterm.py b/ajaxterm.py
+index 91d938d..962e685 100755
+--- a/ajaxterm.py
++++ b/ajaxterm.py
+@@ -9,6 +9,7 @@ except:
+ pass
+
+ import array,cgi,fcntl,glob,mimetypes,optparse,os,pty,random,re,signal,select,sys,threading,time,termios,struct,pwd
++from datetime import datetime
+
+ os.chdir(os.path.normpath(os.path.dirname(__file__)))
+ # Optional: Add QWeb in sys path
+@@ -17,6 +18,11 @@ sys.path[0:0]=glob.glob('../../python')
+ import qweb
+ from socket import gethostname
+
++
++def debug(str):
++ now = datetime.datetime.now()
++ print "%s - %s" % (now.isoformat(), str)
++
+ class Terminal:
+ def __init__(self,width=80,height=24):
+ self.width=width
+@@ -373,7 +379,23 @@ class SynchronizedMethod:
+ self.lock.release()
+ return r
+
++class Reaper:
++ WAKEUP_FREQUENCY=5
++
++ def __init__(self,multi):
++ self.multi = multi
++ self.thread = threading.Thread(target = self.reaper_thread)
++ self.thread.setDaemon(True)
++ self.thread.start()
++
++ def reaper_thread(self):
++ while True:
++ time.sleep(Reaper.WAKEUP_FREQUENCY)
++ self.multi.proc_kill_inactive()
++
+ class Multiplex:
++ INACTIVE_PROCESS_TIMEOUT=120 # I guess this is the IP max packet lifetime
++
+ def __init__(self,cmd=None,serverport=None):
+ signal.signal(signal.SIGCHLD, signal.SIG_IGN)
+ self.cmd=cmd
+@@ -435,19 +457,19 @@ class Multiplex:
+ return self.alive
+ def fds(self):
+ return self.proc.keys()
+- def proc_kill(self,fd):
+- if fd in self.proc:
+- self.proc[fd]['time']=0
++ def proc_kill(self, fd):
++ try:
++ os.close(fd)
++ os.kill(self.proc[fd]['pid'],signal.SIGHUP)
++ except (IOError,OSError):
++ pass
++ del self.proc[fd]
++ def proc_kill_inactive(self):
+ t=time.time()
+ for i in self.proc.keys():
+ t0=self.proc[i]['time']
+- if (t-t0)>120:
+- try:
+- os.close(i)
+- os.kill(self.proc[i]['pid'],signal.SIGTERM)
+- except (IOError,OSError):
+- pass
+- del self.proc[i]
++ if (t-t0)>Multiplex.INACTIVE_PROCESS_TIMEOUT:
++ self.proc_kill(i)
+ def proc_read(self,fd):
+ try:
+ t=self.proc[fd]['term']
+@@ -493,6 +515,7 @@ class AjaxTerm:
+ self.mime = mimetypes.types_map.copy()
+ self.mime['.html']= 'text/html; charset=UTF-8'
+ self.multi = Multiplex(cmd,serverport)
++ self.reaper = Reaper(self.multi)
+ self.session = {}
+ def __call__(self, environ, start_response):
+ req = qweb.QWebRequest(environ, start_response,session=None)
+@@ -569,7 +592,7 @@ def main():
+ # 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:
+- qweb.QWebWSGIServer(at,ip='localhost',port=int(o.port),threaded=0,log=o.log).serve_forever()
++ qweb.QWebWSGIServer(at,ip='localhost',port=int(o.port),threaded=1,log=o.log).serve_forever()
+ except KeyboardInterrupt,e:
+ sys.excepthook(*sys.exc_info())
+ at.multi.die()
+diff --git a/qweb.py b/qweb.py
+index 34529c2..1541035 100644
+--- a/qweb.py
++++ b/qweb.py
+@@ -1182,6 +1182,10 @@ class QWebRequest:
+ self.buffer=[zbuf]
+ self.response_headers['Content-Encoding']="gzip"
+ self.response_headers['Content-Length']=str(len(zbuf))
++ else:
++ datalen = sum(map(len, self.buffer))
++ self.response_headers['Content-Length']=str(datalen)
++
+ headers = self.response_headers.get()
+ if isinstance(self.SESSION, QWebSession):
+ headers.extend(self.SESSION.session_get_headers())
+@@ -1257,6 +1261,7 @@ class QWebWSGIHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+ self.write(buf.getvalue())
+ self.wfile_buf=0
+ def serve(self,type):
++ self.handleKeepalive()
+ path_info, parameters, query = urlparse.urlparse(self.path)[2:5]
+ environ = {
+ 'wsgi.version': (1,0),
+@@ -1287,10 +1292,31 @@ class QWebWSGIHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+ # Hack to avoid may TCP packets
+ self.bufferon()
+ appiter=self.server.wsgiapp(environ, self.start_response)
++ if self.close_connection == 0:
++ appiter.response_headers['Connection']='keep-alive'
++ appiter.response_headers['Keep-Alive']='timeout=10, max=100'
++
+ for data in appiter:
+ self.write(data)
+ self.bufferoff()
+ self.bufferoff()
++ def handleKeepalive(self):
++ base_version_number=self.request_version.split("/",1)[1]
++ version_number = base_version_number.split(".")
++ version_number = int(version_number[0]), int(version_number[1])
++ connection_header = self.headers.get("Connection", "").lower()
++ if version_number == (1,0):
++ if connection_header == "keepalive":
++ self.close_connection = 0
++ else:
++ self.close_connection = 1
++ elif version_number == (1,1):
++ if connection_header == "close":
++ self.close_connection=1
++ else:
++ self.close_connection=0
++ else:
++ self.close_connection=1
+ def do_GET(self):
+ self.serve('GET')
+ def do_POST(self):
+--
+1.7.3.1
+
diff --git a/0011-25_CVE-2009-1629.diff-from-Debian.patch b/0011-25_CVE-2009-1629.diff-from-Debian.patch
new file mode 100644
index 0000000..bc41a10
--- /dev/null
+++ b/0011-25_CVE-2009-1629.diff-from-Debian.patch
@@ -0,0 +1,153 @@
+From 66f2db86bf06d229a48bfa197cf93cb41e59953d Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 17:38:55 +0200
+Subject: [PATCH 11/14] 25_CVE-2009-1629.diff from Debian
+
+---
+ ajaxterm.js | 17 ++++++++++++++-
+ ajaxterm.py | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
+ 2 files changed, 74 insertions(+), 8 deletions(-)
+
+diff --git a/ajaxterm.js b/ajaxterm.js
+index 4edcb6c..2579a8f 100644
+--- a/ajaxterm.js
++++ b/ajaxterm.js
+@@ -6,7 +6,22 @@ ajaxterm.Terminal_ctor=function(id,width,height) {
+ ie=1;
+ if (navigator.userAgent.indexOf("WebKit") >= 0)
+ webkit=1;
+- var sid=""+Math.round(Math.random()*1000000000);
++ var sid="";
++
++ for (var i=0; i < 255; i++) {
++ var r = 0;
++ // now get a random number between 0 and 255
++ // numbers not in the range are intentionally discarded
++ // as it reduces the chance of predicting the seed, by not
++ // using all of the numbers generated by the PRNG
++ do {
++ r = Math.round(Math.random()*1000);
++ } while(r >= 255);
++ r = r.toString(16);
++ if (r.length == 1)
++ r = "0"+r;
++ sid += "%" + r;
++ }
+
+ if (width==0) {
+ width=80;
+diff --git a/ajaxterm.py b/ajaxterm.py
+index 962e685..8695590 100755
+--- a/ajaxterm.py
++++ b/ajaxterm.py
+@@ -8,8 +8,14 @@ try:
+ except:
+ pass
+
+-import array,cgi,fcntl,glob,mimetypes,optparse,os,pty,random,re,signal,select,sys,threading,time,termios,struct,pwd
+-from datetime import datetime
++import array,cgi,fcntl,glob,mimetypes,optparse,os,pty,random,re,signal,select,sys,threading,time,termios,struct,pwd,Cookie
++from datetime import datetime, timedelta
++
++try:
++ from hashlib import sha1
++except ImportError:
++ import sha
++ sha1 = sha.new
+
+ os.chdir(os.path.normpath(os.path.dirname(__file__)))
+ # Optional: Add QWeb in sys path
+@@ -517,30 +523,61 @@ class AjaxTerm:
+ self.multi = Multiplex(cmd,serverport)
+ self.reaper = Reaper(self.multi)
+ self.session = {}
++ self.session_ip = {}
++ self.sessions_limit = 20
++ self.sessions_user_limit = 4
++ m = sha1()
++ m.update(os.urandom(128))
++ self.cookie_name = m.hexdigest()
+ def __call__(self, environ, start_response):
+ req = qweb.QWebRequest(environ, start_response,session=None)
+ if req.PATH_INFO.endswith('/u'):
++ req.response_headers['Content-Type']='text/xml'
++ uid=""
++ if self.cookie_name not in req.request_cookies:
++ req.write('<?xml version="1.0"?><idem></idem>')
++ return req
++ uid = req.request_cookies[self.cookie_name].value
+ s=req.REQUEST["s"]
+ k=req.REQUEST["k"]
+ c=req.REQUEST["c"]
+ w=req.REQUEST.int("w")
+ h=req.REQUEST.int("h")
+- if s in self.session:
+- term=self.session[s]
++ ip="unknown"
++ if environ.has_key("REMOTE_ADDR"):
++ ip=environ['REMOTE_ADDR']
++ if ip == "127.0.0.1" and environ.has_key("HTTP_X_FORWARDED_FOR"):
++ ip=environ["HTTP_X_FORWARDED_FOR"]
++
++ if (uid+s) in self.session:
++ term=self.session[uid+s]
++ req.response_cookies.load(req.request_cookies[self.cookie_name].OutputString())
++ req.response_cookies[self.cookie_name]['expires'] = datetime.utcnow()+timedelta(seconds=60)
+ else:
+ if not (w>2 and w<256 and h>2 and h<100):
+ w,h=80,25
+- term=self.session[s]=self.multi.create(w,h)
++ # check if there aren't too many open sessions
++ if len(self.session) < self.sessions_limit:
++ count=0
++ for i in self.session_ip.keys():
++ if self.session_ip[i] == ip:
++ count+=1
++ if count <= self.sessions_user_limit:
++ term=self.session[uid+s]=self.multi.create(w,h)
++ self.session_ip[uid+s]=ip
++ else:
++ req.write('<?xml version="1.0"?><idem></idem>')
++ return req
+ if k:
+ self.multi.proc_write(term,k)
+ time.sleep(0.002)
+ dump=self.multi.dump(term,c)
+- req.response_headers['Content-Type']='text/xml'
+ if isinstance(dump,str):
+ req.write(dump)
+ req.response_gzencode=1
+ else:
+- del self.session[s]
++ del self.session[uid+s]
++ del self.session_ip[uid+s]
+ req.write('<?xml version="1.0"?><idem></idem>')
+ # print "sessions %r"%self.session
+ else:
+@@ -549,9 +586,23 @@ class AjaxTerm:
+ req.response_headers['Content-Type'] = self.mime.get(os.path.splitext(n)[1].lower(), 'application/octet-stream')
+ req.write(self.files[n])
+ else:
++ if self.cookie_name not in req.request_cookies:
++ self.genSidCookie(req)
+ req.response_headers['Content-Type'] = 'text/html; charset=UTF-8'
+ req.write(self.files['index'])
+ return req
++ def genSidCookie(self, req):
++ m = sha1()
++ m.update(os.urandom(160))
++ req.response_cookies[self.cookie_name] = m.hexdigest()
++ # try to set httponly if supported (added in 2.6)
++ try:
++ req.response_cookies[self.cookie_name]['httponly'] = 1
++ except (Cookie.CookieError):
++ pass
++ req.response_cookies[self.cookie_name]['path'] = req.PATH_INFO
++ req.response_cookies[self.cookie_name]['expires'] = datetime.utcnow()+timedelta(seconds=60)
++ return req
+
+ def main():
+ parser = optparse.OptionParser()
+--
+1.7.3.1
+
diff --git a/0012-30_utf8-support.diff-from-Debian.patch b/0012-30_utf8-support.diff-from-Debian.patch
new file mode 100644
index 0000000..0c7681f
--- /dev/null
+++ b/0012-30_utf8-support.diff-from-Debian.patch
@@ -0,0 +1,591 @@
+From d4b95f3ed4b8a0f47dab35a2560d76bb66117277 Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 17:50:39 +0200
+Subject: [PATCH 12/14] 30_utf8-support.diff from Debian
+
+---
+ README.txt | 240 ++++++++++++++++++++++++++--------------------------
+ ajaxterm.1 | 2 +
+ ajaxterm.html | 1 +
+ ajaxterm.js | 13 +++-
+ ajaxterm.py | 81 ++++++++----------
+ configure.makefile | 2 +-
+ utf8-escape.js | 80 +++++++++++++++++
+ 7 files changed, 251 insertions(+), 168 deletions(-)
+ create mode 100644 utf8-escape.js
+
+diff --git a/README.txt b/README.txt
+index 4b0ae99..05ae97f 100644
+--- a/README.txt
++++ b/README.txt
+@@ -1,120 +1,120 @@
+-= [http://antony.lesuisse.org/qweb/trac/wiki/AjaxTerm Ajaxterm] =
+-
+-Ajaxterm is a web based terminal. It was totally inspired and works almost
+-exactly like http://anyterm.org/ except it's much easier to install (see
+-comparaison with anyterm below).
+-
+-Ajaxterm written in python (and some AJAX javascript for client side) and depends only on python2.3 or better.[[BR]]
+-Ajaxterm is '''very simple to install''' on Linux, MacOS X, FreeBSD, Solaris, cygwin and any Unix that runs python2.3.[[BR]]
+-Ajaxterm was written by Antony Lesuisse (email: al AT udev.org), License Public Domain.
+-
+-Use the [/qweb/forum/viewforum.php?id=2 Forum], if you have any question or remark.
+-
+-== News ==
+-
+- * 2006-10-29: v0.10 allow space in login, cgi launch fix, redhat init
+- * 2006-07-12: v0.9 change uid, daemon fix (Daniel Fischer)
+- * 2006-07-04: v0.8 add login support to ssh (Sven Geggus), change max width to 256
+- * 2006-05-31: v0.7 minor fixes, daemon option
+- * 2006-05-23: v0.6 Applied debian and gentoo patches, renamed to Ajaxterm, default port 8022
+-
+-== Download and Install ==
+-
+- * Release: [/qweb/files/Ajaxterm-0.10.tar.gz Ajaxterm-0.10.tar.gz]
+- * Browse src: [/qweb/trac/browser/trunk/ajaxterm/ ajaxterm/]
+-
+-To install Ajaxterm issue the following commands:
+-{{{
+-wget http://antony.lesuisse.org/qweb/files/Ajaxterm-0.10.tar.gz
+-tar zxvf Ajaxterm-0.10.tar.gz
+-cd Ajaxterm-0.10
+-./ajaxterm.py
+-}}}
+-Then point your browser to this URL : http://localhost:8022/
+-
+-== Screenshot ==
+-
+-{{{
+-#!html
+-<center><img src="/qweb/trac/attachment/wiki/AjaxTerm/scr.png?format=raw" alt="ajaxterm screenshot" style=""/></center>
+-}}}
+-
+-== Documentation and Caveats ==
+-
+- * Ajaxterm only support latin1, if you use Ubuntu or any LANG==en_US.UTF-8 distribution don't forget to "unset LANG".
+-
+- * If run as root ajaxterm will run /bin/login, otherwise it will run ssh
+- localhost. To use an other command use the -c option.
+-
+- * By default Ajaxterm only listen at 127.0.0.1:8022. For remote access, it is
+- strongly recommended to use '''https SSL/TLS''', and that is simple to
+- configure if you use the apache web server using mod_proxy.[[BR]][[BR]]
+- Using ssl will also speed up ajaxterm (probably because of keepalive).[[BR]][[BR]]
+- Here is an configuration example:
+-
+-{{{
+- Listen 443
+- NameVirtualHost *:443
+-
+- <VirtualHost *:443>
+- ServerName localhost
+- SSLEngine On
+- SSLCertificateKeyFile ssl/apache.pem
+- SSLCertificateFile ssl/apache.pem
+-
+- ProxyRequests Off
+- <Proxy *>
+- Order deny,allow
+- Allow from all
+- </Proxy>
+- ProxyPass /ajaxterm/ http://localhost:8022/
+- ProxyPassReverse /ajaxterm/ http://localhost:8022/
+- </VirtualHost>
+-}}}
+-
+- * Using GET HTTP request seems to speed up ajaxterm, just click on GET in the
+- interface, but be warned that your keystrokes might be loggued (by apache or
+- any proxy). I usually enable it after the login.
+-
+- * Ajaxterm commandline usage:
+-
+-{{{
+-usage: ajaxterm.py [options]
+-
+-options:
+- -h, --help show this help message and exit
+- -pPORT, --port=PORT Set the TCP port (default: 8022)
+- -cCMD, --command=CMD set the command (default: /bin/login or ssh localhost)
+- -l, --log log requests to stderr (default: quiet mode)
+- -d, --daemon run as daemon in the background
+- -PPIDFILE, --pidfile=PIDFILE
+- set the pidfile (default: /var/run/ajaxterm.pid)
+- -iINDEX_FILE, --index=INDEX_FILE
+- default index file (default: ajaxterm.html)
+- -uUID, --uid=UID Set the daemon's user id
+-}}}
+-
+- * Ajaxterm was first written as a demo for qweb (my web framework), but
+- actually doesn't use many features of qweb.
+-
+- * Compared to anyterm:
+- * There are no partial updates, ajaxterm updates either all the screen or
+- nothing. That make the code simpler and I also think it's faster. HTTP
+- replies are always gzencoded. When used in 80x25 mode, almost all of
+- them are below the 1500 bytes (size of an ethernet frame) and we just
+- replace the screen with the reply (no javascript string handling).
+- * Ajaxterm polls the server for updates with an exponentially growing
+- timeout when the screen hasn't changed. The timeout is also resetted as
+- soon as a key is pressed. Anyterm blocks on a pending request and use a
+- parallel connection for keypresses. The anyterm approch is better
+- when there aren't any keypress.
+-
+- * Ajaxterm files are released in the Public Domain, (except [http://sarissa.sourceforge.net/doc/ sarissa*] which are LGPL).
+-
+-== TODO ==
+-
+- * insert mode ESC [ 4 h
+- * change size x,y from gui (sending signal)
+- * vt102 graphic codepage
+- * use innerHTML or prototype instead of sarissa
+-
++= [http://antony.lesuisse.org/qweb/trac/wiki/AjaxTerm Ajaxterm] =
++
++Ajaxterm is a web based terminal. It was totally inspired and works almost
++exactly like http://anyterm.org/ except it's much easier to install (see
++comparaison with anyterm below).
++
++Ajaxterm written in python (and some AJAX javascript for client side) and depends only on python2.3 or better.[[BR]]
++Ajaxterm is '''very simple to install''' on Linux, MacOS X, FreeBSD, Solaris, cygwin and any Unix that runs python2.3.[[BR]]
++Ajaxterm was written by Antony Lesuisse (email: al AT udev.org), License Public Domain.
++
++Use the [/qweb/forum/viewforum.php?id=2 Forum], if you have any question or remark.
++
++== News ==
++
++ * 2006-10-29: v0.10 allow space in login, cgi launch fix, redhat init
++ * 2006-07-12: v0.9 change uid, daemon fix (Daniel Fischer)
++ * 2006-07-04: v0.8 add login support to ssh (Sven Geggus), change max width to 256
++ * 2006-05-31: v0.7 minor fixes, daemon option
++ * 2006-05-23: v0.6 Applied debian and gentoo patches, renamed to Ajaxterm, default port 8022
++
++== Download and Install ==
++
++ * Release: [/qweb/files/Ajaxterm-0.10.tar.gz Ajaxterm-0.10.tar.gz]
++ * Browse src: [/qweb/trac/browser/trunk/ajaxterm/ ajaxterm/]
++
++To install Ajaxterm issue the following commands:
++{{{
++wget http://antony.lesuisse.org/qweb/files/Ajaxterm-0.10.tar.gz
++tar zxvf Ajaxterm-0.10.tar.gz
++cd Ajaxterm-0.10
++./ajaxterm.py
++}}}
++Then point your browser to this URL : http://localhost:8022/
++
++== Screenshot ==
++
++{{{
++#!html
++<center><img src="/qweb/trac/attachment/wiki/AjaxTerm/scr.png?format=raw" alt="ajaxterm screenshot" style=""/></center>
++}}}
++
++== Documentation and Caveats ==
++
++ * Ajaxterm only support utf8.
++
++ * If run as root ajaxterm will run /bin/login, otherwise it will run ssh
++ localhost. To use an other command use the -c option.
++
++ * By default Ajaxterm only listen at 127.0.0.1:8022. For remote access, it is
++ strongly recommended to use '''https SSL/TLS''', and that is simple to
++ configure if you use the apache web server using mod_proxy.[[BR]][[BR]]
++ Using ssl will also speed up ajaxterm (probably because of keepalive).[[BR]][[BR]]
++ Here is an configuration example:
++
++{{{
++ Listen 443
++ NameVirtualHost *:443
++
++ <VirtualHost *:443>
++ ServerName localhost
++ SSLEngine On
++ SSLCertificateKeyFile ssl/apache.pem
++ SSLCertificateFile ssl/apache.pem
++
++ ProxyRequests Off
++ <Proxy *>
++ Order deny,allow
++ Allow from all
++ </Proxy>
++ ProxyPass /ajaxterm/ http://localhost:8022/
++ ProxyPassReverse /ajaxterm/ http://localhost:8022/
++ </VirtualHost>
++}}}
++
++ * Using GET HTTP request seems to speed up ajaxterm, just click on GET in the
++ interface, but be warned that your keystrokes might be loggued (by apache or
++ any proxy). I usually enable it after the login.
++
++ * Ajaxterm commandline usage:
++
++{{{
++usage: ajaxterm.py [options]
++
++options:
++ -h, --help show this help message and exit
++ -pPORT, --port=PORT Set the TCP port (default: 8022)
++ -cCMD, --command=CMD set the command (default: /bin/login or ssh localhost)
++ -l, --log log requests to stderr (default: quiet mode)
++ -d, --daemon run as daemon in the background
++ -PPIDFILE, --pidfile=PIDFILE
++ set the pidfile (default: /var/run/ajaxterm.pid)
++ -iINDEX_FILE, --index=INDEX_FILE
++ default index file (default: ajaxterm.html)
++ -uUID, --uid=UID Set the daemon's user id
++}}}
++
++ * Ajaxterm was first written as a demo for qweb (my web framework), but
++ actually doesn't use many features of qweb.
++
++ * Compared to anyterm:
++ * There are no partial updates, ajaxterm updates either all the screen or
++ nothing. That make the code simpler and I also think it's faster. HTTP
++ replies are always gzencoded. When used in 80x25 mode, almost all of
++ them are below the 1500 bytes (size of an ethernet frame) and we just
++ replace the screen with the reply (no javascript string handling).
++ * Ajaxterm polls the server for updates with an exponentially growing
++ timeout when the screen hasn't changed. The timeout is also resetted as
++ soon as a key is pressed. Anyterm blocks on a pending request and use a
++ parallel connection for keypresses. The anyterm approch is better
++ when there aren't any keypress.
++
++ * Ajaxterm files are released in the Public Domain, (except [http://sarissa.sourceforge.net/doc/ sarissa*] which are LGPL).
++
++== TODO ==
++
++ * insert mode ESC [ 4 h
++ * change size x,y from gui (sending signal)
++ * vt102 graphic codepage
++ * use innerHTML or prototype instead of sarissa
++
+diff --git a/ajaxterm.1 b/ajaxterm.1
+index 8d0a942..29d8250 100644
+--- a/ajaxterm.1
++++ b/ajaxterm.1
+@@ -20,6 +20,8 @@ A summary of the options supported by \fBajaxterm\fR is included below.
+ .SH AUTHOR
+ Antony Lesuisse <al at udev.org>
+
++Adopted to UTF-8 by Sergej Pupykin <ps at lx-ltd.ru>
++
+ This manual page was written for the Debian system by
+ Julien Valroff <julien at kirya.net> (but may be used by others).
+
+diff --git a/ajaxterm.html b/ajaxterm.html
+index 095e7d6..2cc48ef 100644
+--- a/ajaxterm.html
++++ b/ajaxterm.html
+@@ -8,6 +8,7 @@
+ <script type="text/javascript" src="sarissa_dhtml.js"></script>
+ <script type="text/javascript" src="ajaxterm.js"></script>
+ <script type="text/javascript" src="ajaxterm_config.js"></script>
++ <script type="text/javascript" src="utf8-escape.js"></script>
+ <script type="text/javascript">
+ window.onload=function() {
+ t=ajaxterm.Terminal("term",width,height);
+diff --git a/ajaxterm.js b/ajaxterm.js
+index 2579a8f..b976a96 100644
+--- a/ajaxterm.js
++++ b/ajaxterm.js
+@@ -142,7 +142,16 @@ ajaxterm.Terminal_ctor=function(id,width,height) {
+ if (r.readyState==4) {
+ if(r.status==200) {
+ window.clearTimeout(error_timeout);
+- de=r.responseXML.documentElement;
++ if(ie)
++ {
++ var responseXMLdoc = new ActiveXObject("Microsoft.XMLDOM");
++ responseXMLdoc.loadXML(r.responseText);
++ de = responseXMLdoc.documentElement;
++ }
++ else
++ {
++ de=r.responseXML.documentElement;
++ }
+ if(de.tagName=="pre") {
+ if(ie) {
+ Sarissa.updateContentFromNode(de, dterm);
+@@ -250,7 +259,7 @@ ajaxterm.Terminal_ctor=function(id,width,height) {
+ if(k=="+") {
+ queue("%2B");
+ } else {
+- queue(escape(k));
++ queue(utf8Escape(k));
+ }
+ }
+ ev.cancelBubble=true;
+diff --git a/ajaxterm.py b/ajaxterm.py
+index 8695590..92bf67e 100755
+--- a/ajaxterm.py
++++ b/ajaxterm.py
+@@ -21,7 +21,9 @@ os.chdir(os.path.normpath(os.path.dirname(__file__)))
+ # Optional: Add QWeb in sys path
+ sys.path[0:0]=glob.glob('../../python')
+
+-import qweb
++import qweb, codecs
++utf8decoder = codecs.getincrementaldecoder('utf8')()
++
+ from socket import gethostname
+
+
+@@ -92,31 +94,14 @@ class Terminal:
+ for i in [i[4] for i in dir(self) if i.startswith('csi_') and len(i)==5]:
+ if not self.csi_seq.has_key(i):
+ self.csi_seq[i]=(getattr(self,'csi_'+i),[1])
+- # Init 0-256 to latin1 and html translation table
+- self.trl1=""
+- for i in range(256):
+- if i<32:
+- self.trl1+=" "
+- elif i<127 or i>160:
+- self.trl1+=chr(i)
+- else:
+- self.trl1+="?"
+- self.trhtml=""
+- for i in range(256):
+- if i==0x0a or (i>32 and i<127) or i>160:
+- self.trhtml+=chr(i)
+- elif i<=32:
+- self.trhtml+="\xa0"
+- else:
+- self.trhtml+="?"
+- def reset(self,s=""):
+- self.scr=array.array('i',[0x000700]*(self.width*self.height))
++ def reset(self,s=u""):
++ self.scr=array.array('l',[0x07000000]*(self.width*self.height))
+ self.st=0
+ self.sb=self.height-1
+ self.cx_bak=self.cx=0
+ self.cy_bak=self.cy=0
+ self.cl=0
+- self.sgr=0x000700
++ self.sgr=0x07000000
+ self.buf=""
+ self.outbuf=""
+ self.last_html=""
+@@ -127,7 +112,7 @@ class Terminal:
+ self.scr[pos:pos+len(s)]=s
+ def zero(self,y1,x1,y2,x2):
+ w=self.width*(y2-y1)+x2-x1+1
+- z=array.array('i',[0x000700]*w)
++ z=array.array('l',[0x07000000]*w)
+ self.scr[self.width*y1+x1:self.width*y2+x2+1]=z
+ def scroll_up(self,y1,y2):
+ self.poke(y1,0,self.peek(y1+1,0,y2,self.width))
+@@ -280,17 +265,17 @@ class Terminal:
+ def csi_m(self,l):
+ for i in l:
+ if i==0 or i==39 or i==49 or i==27:
+- self.sgr=0x000700
++ self.sgr=0x07000000
+ elif i==1:
+- self.sgr=(self.sgr|0x000800)
++ self.sgr=(self.sgr|0x08000000)
+ elif i==7:
+- self.sgr=0x070000
++ self.sgr=0x70000000
+ elif i>=30 and i<=37:
+ c=i-30
+- self.sgr=(self.sgr&0xff08ff)|(c<<8)
++ self.sgr=(self.sgr&0xf8ffffff)|(c<<24)
+ elif i>=40 and i<=47:
+ c=i-40
+- self.sgr=(self.sgr&0x00ffff)|(c<<16)
++ self.sgr=(self.sgr&0x0fffffff)|(c<<28)
+ # else:
+ # print "CSI sgr ignore",l,i
+ # print 'sgr: %r %x'%(l,self.sgr)
+@@ -320,12 +305,12 @@ class Terminal:
+ break
+ # if self.buf=='': print "ESC %r\n"%e
+ def write(self,s):
+- for i in s:
++ for i in utf8decoder.decode(s):
+ if len(self.buf) or (i in self.esc_seq):
+- self.buf+=i
++ self.buf+=chr(ord(i)&255)
+ self.escape()
+ elif i == '\x1b':
+- self.buf+=i
++ self.buf+=chr(ord(i)&255)
+ else:
+ self.echo(i)
+ def read(self):
+@@ -333,35 +318,41 @@ class Terminal:
+ self.outbuf=""
+ return b
+ def dump(self):
+- r=''
++ r=u''
+ for i in self.scr:
+- r+=chr(i&255)
++ r+=unichr(i&0xFFFFFF)
+ return r
+- def dumplatin1(self):
+- return self.dump().translate(self.trl1)
++ def dumputf8(self):
++ return self.dump().encode('utf8')
+ def dumphtml(self,color=1):
+ h=self.height
+ w=self.width
+ r=""
+- span=""
++ span=u""
+ span_bg,span_fg=-1,-1
+ for i in range(h*w):
+- q,c=divmod(self.scr[i],256)
++ q,c=divmod(self.scr[i],256*256*256)
+ if color:
+- bg,fg=divmod(q,256)
++ bg,fg=divmod(q,16)
++ bg &= 0x7
+ else:
+ bg,fg=0,7
+ if i==self.cy*w+self.cx:
+ bg,fg=1,7
+ if (bg!=span_bg or fg!=span_fg or i==h*w-1):
+ if len(span):
+- r+='<span class="f%d b%d">%s</span>'%(span_fg,span_bg,cgi.escape(span.translate(self.trhtml)))
+- span=""
++ r+='<span class="f%d b%d">%s</span>'%(span_fg,span_bg,cgi.escape(span.replace(u' ',u'\xa0').encode('utf8')))
++ span=u""
+ span_bg,span_fg=bg,fg
+- span+=chr(c)
++ if c == 0:
++ span+=u' '
++ elif c > 0x10000:
++ span+=u'?'
++ else:
++ span+=unichr(c&0xFFFF)
+ if i%w==w-1:
+- span+='\n'
+- r='<?xml version="1.0" encoding="ISO-8859-1"?><pre class="term">%s</pre>'%r
++ span+=u'\n'
++ r='<?xml version="1.0" encoding="utf8"?><pre class="term">%s</pre>'%r
+ if self.last_html==r:
+ return '<?xml version="1.0"?><idem></idem>'
+ else:
+@@ -369,8 +360,8 @@ class Terminal:
+ # print self
+ return r
+ def __repr__(self):
+- d=self.dumplatin1()
+- r=""
++ d=self.dumputf8()
++ r=u""
+ for i in range(self.height):
+ r+="|%s|\n"%d[self.width*i:self.width*(i+1)]
+ return r
+@@ -432,7 +423,7 @@ class Multiplex:
+ elif os.getuid()==0:
+ cmd=['/bin/login']
+ else:
+- sys.stdout.write(gethostname() + " login: ")
++ sys.stdout.write(gethostname() + u" login: ")
+ login=sys.stdin.readline().strip()
+ if re.match('^[0-9A-Za-z-_. ]+$',login):
+ cmd=['ssh']
+diff --git a/configure.makefile b/configure.makefile
+index a30dc23..c866804 100644
+--- a/configure.makefile
++++ b/configure.makefile
+@@ -5,7 +5,7 @@ install:
+ install -d "%(bin)s"
+ install -d "%(lib)s"
+ install ajaxterm.bin "%(bin)s/ajaxterm"
+- install -m 644 ajaxterm.css ajaxterm.html ajaxterm.js qweb.py sarissa.js sarissa_dhtml.js "%(lib)s"
++ install -m 644 ajaxterm.css ajaxterm.html ajaxterm.js qweb.py sarissa.js sarissa_dhtml.js utf8-escape.js "%(lib)s"
+ install -m 644 ajaxterm.conf "%(etc)s"
+ install -m 755 ajaxterm.py "%(lib)s"
+ ln -s /etc/ajaxterm.conf "%(lib)s"/ajaxterm_config.js
+diff --git a/utf8-escape.js b/utf8-escape.js
+new file mode 100644
+index 0000000..dfb8cb3
+--- /dev/null
++++ b/utf8-escape.js
+@@ -0,0 +1,80 @@
++var char2hex = new Array(
++ "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07",
++ "%08", "%09", "%0a", "%0b", "%0c", "%0d", "%0e", "%0f",
++ "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17",
++ "%18", "%19", "%1a", "%1b", "%1c", "%1d", "%1e", "%1f",
++ "%20", "%21", "%22", "%23", "%24", "%25", "%26", "%27",
++ "%28", "%29", "%2a", "%2b", "%2c", "%2d", "%2e", "%2f",
++ "%30", "%31", "%32", "%33", "%34", "%35", "%36", "%37",
++ "%38", "%39", "%3a", "%3b", "%3c", "%3d", "%3e", "%3f",
++ "%40", "%41", "%42", "%43", "%44", "%45", "%46", "%47",
++ "%48", "%49", "%4a", "%4b", "%4c", "%4d", "%4e", "%4f",
++ "%50", "%51", "%52", "%53", "%54", "%55", "%56", "%57",
++ "%58", "%59", "%5a", "%5b", "%5c", "%5d", "%5e", "%5f",
++ "%60", "%61", "%62", "%63", "%64", "%65", "%66", "%67",
++ "%68", "%69", "%6a", "%6b", "%6c", "%6d", "%6e", "%6f",
++ "%70", "%71", "%72", "%73", "%74", "%75", "%76", "%77",
++ "%78", "%79", "%7a", "%7b", "%7c", "%7d", "%7e", "%7f",
++ "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87",
++ "%88", "%89", "%8a", "%8b", "%8c", "%8d", "%8e", "%8f",
++ "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97",
++ "%98", "%99", "%9a", "%9b", "%9c", "%9d", "%9e", "%9f",
++ "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%a7",
++ "%a8", "%a9", "%aa", "%ab", "%ac", "%ad", "%ae", "%af",
++ "%b0", "%b1", "%b2", "%b3", "%b4", "%b5", "%b6", "%b7",
++ "%b8", "%b9", "%ba", "%bb", "%bc", "%bd", "%be", "%bf",
++ "%c0", "%c1", "%c2", "%c3", "%c4", "%c5", "%c6", "%c7",
++ "%c8", "%c9", "%ca", "%cb", "%cc", "%cd", "%ce", "%cf",
++ "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7",
++ "%d8", "%d9", "%da", "%db", "%dc", "%dd", "%de", "%df",
++ "%e0", "%e1", "%e2", "%e3", "%e4", "%e5", "%e6", "%e7",
++ "%e8", "%e9", "%ea", "%eb", "%ec", "%ed", "%ee", "%ef",
++ "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
++ "%f8", "%f9", "%fa", "%fb", "%fc", "%fd", "%fe", "%ff"
++ );
++
++function utf8Escape(s)
++{
++ var sbuf = "";
++ var i;
++
++ var len = s.length;
++ for (i = 0; i < len; i++)
++ {
++ var ch = s.charCodeAt(i);
++ if( (65 <= ch && ch <= 90) ||
++ (97 <= ch && ch <= 122) ||
++ (48 <= ch && ch <= 57) )
++ {
++ sbuf += String.fromCharCode(ch);
++ }
++ else if (ch == 32)
++ {
++ sbuf += '+';
++ }
++ else if (ch == 45 || ch == 95
++ || ch == 46 || ch == 33
++ || ch == 126 || ch == 42
++ || ch == 39 || ch == 40
++ || ch == 41)
++ {
++ sbuf += char2hex[ch];
++ }
++ else if (ch <= 0x007F)
++ {
++ sbuf += char2hex[ch];
++ }
++ else if (ch <= 0x07FF)
++ {
++ sbuf += char2hex[0xc0 | (ch >> 6)];
++ sbuf += char2hex[0x80 | (ch & 0x3F)];
++ }
++ else
++ {
++ sbuf += char2hex[0xe0 | (ch >> 12)];
++ sbuf += char2hex[0x80 | ((ch >> 6) & 0x3F)];
++ sbuf += char2hex[0x80 | (ch & 0x3F)];
++ }
++ }
++ return sbuf;
++}
+--
+1.7.3.1
+
diff --git a/0013-35_fix-sarissa.diff-from-Debian.patch b/0013-35_fix-sarissa.diff-from-Debian.patch
new file mode 100644
index 0000000..8c50670
--- /dev/null
+++ b/0013-35_fix-sarissa.diff-from-Debian.patch
@@ -0,0 +1,31 @@
+From 24d43c417df0fe729433060d409177c4669650ef Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 17:51:06 +0200
+Subject: [PATCH 13/14] 35_fix-sarissa.diff from Debian
+
+---
+ sarissa.js | 8 +++++++-
+ 1 files changed, 7 insertions(+), 1 deletions(-)
+
+diff --git a/sarissa.js b/sarissa.js
+index 220edb2..69e8797 100644
+--- a/sarissa.js
++++ b/sarissa.js
+@@ -265,7 +265,13 @@ else{ /* end IE initialization, try to deal with real browsers now ;-) */
+ * <li>3 == INTERACTIVE,</li>
+ * <li>4 == COMPLETED</li></ul>
+ */
+- XMLDocument.prototype.readyState = 0;
++ try {
++ XMLDocument.prototype.readyState = 0;
++ } catch(e) {
++ // XXX on some browsers (Firefox 3.6 at least) this fails,
++ // however I think this is rarely a problem so we just
++ // ignore it here...
++ };
+ /**
+ * <p>Emulate IE's parseError attribute</p>
+ */
+--
+1.7.3.1
+
diff --git a/0014-40_more-ctrl-catches.diff-from-Debian.patch b/0014-40_more-ctrl-catches.diff-from-Debian.patch
new file mode 100644
index 0000000..f59a297
--- /dev/null
+++ b/0014-40_more-ctrl-catches.diff-from-Debian.patch
@@ -0,0 +1,34 @@
+From 26f6ea060b541db74d4cb14b5b6f091b31eec3bd Mon Sep 17 00:00:00 2001
+From: Ruben <ruben at rubenkerkhof.com>
+Date: Sun, 17 Oct 2010 17:51:33 +0200
+Subject: [PATCH 14/14] 40_more-ctrl-catches.diff from Debian
+
+---
+ ajaxterm.js | 5 ++---
+ 1 files changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/ajaxterm.js b/ajaxterm.js
+index b976a96..98e3715 100644
+--- a/ajaxterm.js
++++ b/ajaxterm.js
+@@ -208,15 +208,14 @@ ajaxterm.Terminal_ctor=function(id,width,height) {
+ k=String.fromCharCode(27)+String.fromCharCode(kc);
+ }
+ } else if (ev.ctrlKey) {
+- if (kc>=65 && kc<=90) k=String.fromCharCode(kc-64); // Ctrl-A..Z
++ if (kc>=64 && kc<=95) k=String.fromCharCode(kc-64); // Ctrl-@,A..Z,[,\,^,],_
+ else if (kc>=97 && kc<=122) k=String.fromCharCode(kc-96); // Ctrl-A..Z
+ else if (kc==54) k=String.fromCharCode(30); // Ctrl-^
+ else if (kc==109) k=String.fromCharCode(31); // Ctrl-_
+ else if (kc==219) k=String.fromCharCode(27); // Ctrl-[
+ else if (kc==220) k=String.fromCharCode(28); // Ctrl-\
+ else if (kc==221) k=String.fromCharCode(29); // Ctrl-]
+- else if (kc==219) k=String.fromCharCode(29); // Ctrl-]
+- else if (kc==219) k=String.fromCharCode(0); // Ctrl-@
++ else if (kc==32) k=String.fromCharCode(0); // Ctrl-space
+ } else if (ev.which==0) {
+ if (kc==9) k=String.fromCharCode(9); // Tab
+ else if (kc==8) k=String.fromCharCode(127); // Backspace
+--
+1.7.3.1
+
diff --git a/Ajaxterm.apache b/Ajaxterm.apache
new file mode 100644
index 0000000..da35cc3
--- /dev/null
+++ b/Ajaxterm.apache
@@ -0,0 +1,28 @@
+# Sample apache configuration file for ajaxterm
+
+Listen 443
+NameVirtualHost *:443
+
+<VirtualHost *:443>
+ ServerName localhost
+ SSLEngine On
+ SSLCertificateKeyFile /etc/pki/tls/private/apache.pem
+ SSLCertificateFile /etc/pki/tls/certs/apache.pem
+
+ # Suppresses the Via header
+ ProxyVia Off
+ # Do not flood the log
+ #CustomLog /var/log/httpd/access.log combined env=!dontlog
+ #SetEnvIf Request_URI "^/ajaxterm/u" dontlog
+
+ ProxyRequests Off
+ <Proxy *>
+ Order deny,allow
+ Allow from all
+ </Proxy>
+
+ ProxyPass /ajaxterm/ http://localhost:8022/
+ ProxyPassReverse /ajaxterm/ http://localhost:8022/
+
+</VirtualHost>
+
diff --git a/Ajaxterm.init b/Ajaxterm.init
new file mode 100644
index 0000000..c9308e7
--- /dev/null
+++ b/Ajaxterm.init
@@ -0,0 +1,77 @@
+#!/bin/bash
+# ajaxterm Startup script for Ajaxterm
+#
+# chkconfig: - 99 99
+# description: Ajaxterm is a web-based terminal
+# processname: ajaxterm
+# pidfile: /var/run/ajaxterm/ajaxterm.pid
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+ajaxterm=/usr/bin/ajaxterm
+prog=ajaxterm
+
+PIDFILE=/var/run/ajaxterm/ajaxterm.pid
+LOCKFILE=/var/lock/subsys/ajaxterm
+PORT=8022
+USER=ajaxterm
+SERVERPORT=22
+
+if [ -f /etc/sysconfig/ajaxterm ]; then
+ . /etc/sysconfig/ajaxterm
+fi
+
+RETVAL=0
+
+
+start() {
+ echo -n $"Starting $prog: "
+ daemon $ajaxterm --daemon --port=$PORT --uid=$USER --pidfile=$PIDFILE --serverport=$SERVERPORT $OPTIONS
+ RETVAL=$?
+ echo
+ [ $RETVAL = 0 ] && touch ${LOCKFILE}
+ return $RETVAL
+}
+stop() {
+ echo -n $"Stopping $prog: "
+ killproc $ajaxterm
+ RETVAL=$?
+ echo
+ [ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
+}
+reload() {
+ echo -n $"Reloading $prog: "
+ killproc $ajaxterm -HUP
+ RETVAL=$?
+ echo
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ status $prog
+ RETVAL=$?
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ condrestart)
+ if [ -f ${PIDFILE} ] ; then
+ stop
+ start
+ fi
+ ;;
+ *)
+ echo $"Usage: $prog {start|stop|status|restart|condrestart}"
+ exit 1
+esac
+
+exit $RETVAL
diff --git a/Ajaxterm.spec b/Ajaxterm.spec
index 16ed856..4e68da7 100644
--- a/Ajaxterm.spec
+++ b/Ajaxterm.spec
@@ -1,14 +1,37 @@
Name: Ajaxterm
Version: 0.10
-Release: 11%{?dist}
+Release: 12%{?dist}
Summary: A web-based terminal
Group: Development/Languages
License: Public Domain and LGPLv2+
URL: http://antony.lesuisse.org/qweb/trac/wiki/AjaxTerm
Source0: http://antony.lesuisse.org/qweb/files/%{name}-%{version}.tar.gz
-Patch0: Ajaxterm-init.patch
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+Source1: Ajaxterm.init
+Source2: Ajaxterm.sysconfig
+Source3: README.Fedora
+Source4: Ajaxterm.apache
+
+# patches from Debian
+Patch1: 0001-01_bin_dir.diff-from-Debian.patch
+Patch2: 0002-02_initd.diff-from-Debian.patch
+Patch3: 0003-03_fix_man.diff-from-Debian.patch
+Patch4: 0004-04_use-default-python.diff-from-Debian.patch
+Patch5: 0005-05_ssh-port.diff-from-Debian.patch
+Patch6: 0006-06_fix-IOError.diff-from-Debian.patch
+Patch7: 0007-07_use_psyco.diff-from-Debian.patch
+Patch8: 0008-10_hostname-login.diff-from-Debian.patch
+Patch9: 0009-15_add-configure-file.diff-from-Debian.patch
+Patch10: 0010-20_bugfixes-tweaks-by-blt.diff-from-Debian.patch
+Patch11: 0011-25_CVE-2009-1629.diff-from-Debian.patch
+Patch12: 0012-30_utf8-support.diff-from-Debian.patch
+Patch13: 0013-35_fix-sarissa.diff-from-Debian.patch
+Patch14: 0014-40_more-ctrl-catches.diff-from-Debian.patch
+
+# our own patches
+Patch100: 0001-Create-etc.patch
+Patch101: 0002-Fix-permissions-on-manfile.patch
+Patch102: 0003-Remove-shebang-line.patch
BuildArch: noarch
BuildRequires: python
@@ -24,33 +47,38 @@ exactly like http://anyterm.org/ except it's much easier to install.
%prep
%setup -q
-%patch0 -p1 -b .orig
-sed -i 's|\r||' README.txt # fix eol encoding
-sed -i 's|bin/python2.3|bin/python|' qweb.py
-
-
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+%patch7 -p1
+%patch8 -p1
+%patch9 -p1
+%patch10 -p1
+%patch11 -p1
+%patch12 -p1
+%patch13 -p1
+%patch14 -p1
+
+%patch100 -p1
+%patch101 -p1
+%patch102 -p1
+
+install -pm 0644 %{SOURCE3} .
+install -Dp -m 0644 %{SOURCE4} examples/Ajaxterm.apache
%build
./configure --prefix=%{buildroot}%{_prefix} --confdir=%{buildroot}%{_sysconfdir}
%install
-rm -rf %{buildroot}
-mkdir -p %{buildroot}/%{_sysconfdir}/init.d
-mkdir -p %{buildroot}/%{_initrddir}
make install
+install -D -p -m 0755 %{SOURCE1} %{buildroot}/%{_initrddir}/ajaxterm
+install -D -p -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/ajaxterm
+install -d -m 0755 %{buildroot}%{_localstatedir}/run/ajaxterm
-mv %{buildroot}%{_sysconfdir}/init.d/ajaxterm %{buildroot}%{_initrddir}/ajaxterm
-rmdir %{buildroot}/%{_sysconfdir}/init.d
-chmod 0755 %{buildroot}%{_datadir}/ajaxterm/qweb.py
-chmod 0644 %{buildroot}%{_mandir}/man1/ajaxterm.1.gz
-cat <<EOF >%{buildroot}%{_bindir}/ajaxterm
-#!/bin/sh
-PYTHONPATH=/usr/share/ajaxterm exec /usr/share/ajaxterm/ajaxterm.py \$@
-EOF
-
-%clean
-rm -rf %{buildroot}
%pre
getent group ajaxterm >/dev/null || groupadd -r ajaxterm
@@ -77,14 +105,24 @@ fi
%files
%defattr(-,root,root,-)
-%doc README.txt
-%{_initrddir}/ajaxterm
+%doc README.txt README.Fedora examples
%{_bindir}/ajaxterm
%{_datadir}/ajaxterm
%{_mandir}/man1/ajaxterm.1.gz
-
+%{_initrddir}/ajaxterm
+%config(noreplace) %{_sysconfdir}/ajaxterm.conf
+%config(noreplace) %{_sysconfdir}/sysconfig/ajaxterm
+%dir %attr(0755, ajaxterm, ajaxterm) %{_localstatedir}/run/ajaxterm
%changelog
+* Sun Oct 17 2010 Ruben Kerkhof <ruben at rubenkerkhof.com> 0.10-12
+- Apply patches from Debian (fixes #635238, #544033, enables UTF-8)
+- Cleanup init script
+- Add a sysconfig file
+- Relocate pidfile to /var/run/ajaxterm/ajaxterm.pid
+- Add a README.Fedora
+- Add an example config for Apache
+
* Wed Aug 11 2010 David Malcolm <dmalcolm at redhat.com> - 0.10-11
- recompiling .py files against Python 2.7 (rhbz#623267)
diff --git a/Ajaxterm.sysconfig b/Ajaxterm.sysconfig
new file mode 100644
index 0000000..526926e
--- /dev/null
+++ b/Ajaxterm.sysconfig
@@ -0,0 +1,15 @@
+# Default start options for Ajaxterm
+
+# Set the daemon's user id (ajaxterm by default)
+# If run as root ajaxterm will run `/bin/login',
+# otherwise it will run `ssh localhost'.
+#USER="ajaxterm"
+
+# Allow to change the default port used by Ajaxterm
+#PORT="8022"
+
+# Allow to use a different port than 22 to connect to the ssh server
+#SERVERPORT="22"
+
+# extra options
+#OPTIONS=""
diff --git a/README.Fedora b/README.Fedora
new file mode 100644
index 0000000..9e02b82
--- /dev/null
+++ b/README.Fedora
@@ -0,0 +1,45 @@
+ajaxterm for Debian
+-------------------
+
+ * Ajaxterm only supports utf8.
+
+ * With the default settings, you have to install openssh-server and
+ allow password authentication. Open file /etc/ssh/sshd_config and
+ set:
+
+ PasswordAuthentication yes
+
+ As an alternative, you might choose to run ajaxterm as root. Change
+ the default daemon setting in file /etc/sysconfig/ajaxterm to:
+
+ USER="root"
+
+ Ajaxterm will then fall back to use /bin/login.
+
+ * Apache setup
+
+ By default Ajaxterm only listen at 127.0.0.1:8022. For remote
+ access, it is strongly recommended to use https SSL/TLS, and that is
+ simple to configure if you use the apache web server using
+ mod_proxy.
+
+ If apache is not already set up for for https SSL/TLS, ensure
+ openssl is installed to issue a self signed certificate (apache.pem):
+
+ export RANDFILE=/dev/random \
+ openssl req -new -x509 -days 365 -nodes \
+ -out /etc/pki/tls/certs/apache.pem \
+ -keyout /etc/pki/tls/private/apache.pem
+
+ copy the config file:
+
+ cp /usr/share/doc/Ajaxterm-*/examples/apache.conf \
+ /etc/httpd/conf.d/ajaxterm.conf
+
+ Edit it to suit your needs, and restart:
+
+ service httpd reload
+
+-- Ruben Kerkhof <ruben at fedoraproject.org> Sun Oct 17 18:44:52 CEST 2010
+
+Based on README.Debian by Julien Valroff <julien at kirya.net>
More information about the scm-commits
mailing list