1.5.2-alt1

- 1.5-2
This commit is contained in:
Valery Inozemtsev 2017-07-19 07:39:44 +00:00 committed by Girar Builder pender robot
parent 5e361f9129
commit 2eab654383
37 changed files with 62091 additions and 879 deletions

View File

@ -1,2 +1,4 @@
copy: *.c
copy: *.hex
copy: *.patch copy: *.patch
tar.xz: vncterm name=vncterm tar.xz: vncterm name=vncterm

View File

@ -1,24 +0,0 @@
Fix a buffer overflow on platforms where sizeof(long) > sizeof(int).
https://bugs.gentoo.org/show_bug.cgi?id=329031
--- libvncserver/tightvnc-filetransfer/filetransfermsg.c
+++ libvncserver/tightvnc-filetransfer/filetransfermsg.c
@@ -393,7 +393,8 @@
CreateFileDownloadZeroSizeDataMsg(unsigned long mTime)
{
FileTransferMsg fileDownloadZeroSizeDataMsg;
- int length = sz_rfbFileDownloadDataMsg + sizeof(int);
+ uint32_t mTime32 = (uint32_t)mTime;
+ int length = sz_rfbFileDownloadDataMsg + sizeof(mTime32);
rfbFileDownloadDataMsg *pFDD = NULL;
char *pFollow = NULL;
@@ -413,7 +414,7 @@
pFDD->compressedSize = Swap16IfLE(0);
pFDD->realSize = Swap16IfLE(0);
- memcpy(pFollow, &mTime, sizeof(unsigned long));
+ memcpy(pFollow, &mTime, sizeof(mTime32));
fileDownloadZeroSizeDataMsg.data = pData;
fileDownloadZeroSizeDataMsg.length = length;

View File

@ -2,7 +2,7 @@
Name: pve-%sname Name: pve-%sname
Summary: VNC Terminal Emulator Summary: VNC Terminal Emulator
Version: 1.2 Version: 1.5.2
Release: alt1 Release: alt1
License: GPLv2 License: GPLv2
Group: Networking/WWW Group: Networking/WWW
@ -10,14 +10,11 @@ Url: https://git.proxmox.com/
Packager: Valery Inozemtsev <shrek@altlinux.ru> Packager: Valery Inozemtsev <shrek@altlinux.ru>
Source0: %sname.tar.xz Source0: %sname.tar.xz
Source1: libvncserver-memcpy.patch Source1: wchardata.c
Source2: unifont.hex
Patch0: %sname-alt.patch Patch0: %sname-alt.patch
Patch1: %sname-gnutls.patch
BuildRequires: libgnutls-devel libjpeg-devel perl-Pod-Usage zlib-devel libpng-devel
# Automatically added by buildreq on Mon Mar 21 2016
# optimized out: libp11-kit perl-Encode perl-Pod-Escapes perl-Pod-Simple perl-podlators xz
BuildRequires: libgnutls-devel libjpeg-devel perl-Pod-Usage zlib-devel
%description %description
With vncterm you can start commands and export its standard input and With vncterm you can start commands and export its standard input and
@ -26,18 +23,15 @@ output to any VNC client (simulating a xterm Terminal).
%prep %prep
%setup -q -n %sname %setup -q -n %sname
%patch0 -p1 %patch0 -p1
%patch1 -p1
cp %SOURCE1 vncpatches/ install -m0644 %SOURCE1 .
install -m0644 %SOURCE2 .
%build %build
make %sname %make
make %sname.1
%install %install
install -pD -m0755 %sname %buildroot%_bindir/%sname %make DESTDIR=%buildroot install
install -pD -m0644 %sname.1 %buildroot%_man1dir/%sname.1
install -pD -m0644 VncViewer.jar %buildroot%_datadir/%sname/VncViewer.jar
%files %files
%_bindir/%sname %_bindir/%sname
@ -45,6 +39,9 @@ install -pD -m0644 VncViewer.jar %buildroot%_datadir/%sname/VncViewer.jar
%_man1dir/%sname.1* %_man1dir/%sname.1*
%changelog %changelog
* Tue Jul 18 2017 Valery Inozemtsev <shrek@altlinux.ru> 1.5.2-alt1
- 1.5-2
* Mon Mar 21 2016 Valery Inozemtsev <shrek@altlinux.ru> 1.2-alt1 * Mon Mar 21 2016 Valery Inozemtsev <shrek@altlinux.ru> 1.2-alt1
- initial release - initial release

57086
unifont.hex Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,25 @@
--- vncterm/Makefile.alt 2016-03-21 11:31:51.727559534 +0000 --- vncterm/Makefile.alt 2017-06-07 14:53:50.000000000 +0300
+++ vncterm/Makefile 2016-03-21 11:51:50.857533517 +0000 +++ vncterm/Makefile 2017-07-19 10:37:11.678390381 +0300
@@ -33,11 +33,11 @@ ${VNCLIB} vnc: ${VNCSRC} @@ -18,7 +18,7 @@ SNAP=${PACKAGE}-${VERSION}-${CDATE}.tar.
all: vncterm
font.data: genfont2
- ./genfont2 -o font.data.tmp -i /usr/share/unifont/unifont.hex
+ ./genfont2 -o font.data.tmp -i unifont.hex
mv font.data.tmp font.data
genfont2: genfont2.c
@@ -30,11 +30,11 @@ ${VNCLIB}: ${VNCSRC}
rm -rf ${VNCDIR} rm -rf ${VNCDIR}
tar xf ${VNCSRC} tar xf ${VNCSRC}
ln -s ../vncpatches ${VNCDIR}/patches ln -s ../vncpatches ${VNCDIR}/patches
- cd ${VNCDIR}; quilt push -a - cd ${VNCDIR}; quilt push -a
+ cd ${VNCDIR}; patch -p1 < patches/tls-auth-pluging.patch; patch -p0 < patches/libvncserver-memcpy.patch + cd ${VNCDIR}; patch -p1 < patches/tls-auth-pluging.patch; patch -p1 < patches/remove-systemd-socket-activation.patch
cd ${VNCDIR}; ./configure; cd ${VNCDIR}; ./autogen.sh --without-ssl --without-websockets --without-tightvnc-filetransfer;
cd ${VNCDIR}; make cd ${VNCDIR}; $(MAKE)
-vncterm: vncterm.c glyphs.h ${VNCLIB} -vncterm: vncterm.c ${VNCLIB} wchardata.c
+vncterm: vncterm.c ${VNCLIB} +vncterm: vncterm.c ${VNCLIB} wchardata.c vncterm.1 font.data
gcc -O2 -g -o $@ vncterm.c -Wall -Wno-deprecated-declarations -D_GNU_SOURCE -I ${VNCDIR} ${VNCLIB} -lnsl -lpthread -lz -ljpeg -lutil -lgnutls gcc -O2 -g -o $@ vncterm.c wchardata.c -Wall -Wno-deprecated-declarations -D_GNU_SOURCE -I ${VNCDIR} ${VNCLIB} -lnsl -lpthread -lz -ljpeg -lutil -lgnutls -lpng
jar: tigervnc.org wchardata.c:

View File

@ -1,46 +0,0 @@
--- vncterm/vncterm.c.alt 2015-02-27 22:00:46.000000000 +0300
+++ vncterm/vncterm.c 2015-12-27 19:57:06.000000000 +0300
@@ -485,41 +485,8 @@
return;
}
- /* optimize for speed */
- static const int cipher_priority_performance[] = {
- GNUTLS_CIPHER_ARCFOUR_128,
- GNUTLS_CIPHER_AES_128_CBC,
- GNUTLS_CIPHER_3DES_CBC, 0
- };
-
- if ((ret = gnutls_cipher_set_priority(sd->session, cipher_priority_performance)) < 0) {
- rfbLog("gnutls_cipher_set_priority failed: %s\n", gnutls_strerror(ret));
- sd->session = NULL;
- rfbCloseClient(cl);
- return;
- }
-
- static const int kx_anon[] = {GNUTLS_KX_ANON_DH, 0};
- static const int kx_x509[] = {GNUTLS_KX_DHE_DSS, GNUTLS_KX_RSA, GNUTLS_KX_DHE_RSA, GNUTLS_KX_SRP, 0};
- if ((ret = gnutls_kx_set_priority(sd->session, use_x509 ? kx_x509 : kx_anon)) < 0) {
- rfbLog("gnutls_kx_set_priority failed: %s\n", gnutls_strerror(ret));
- sd->session = NULL;
- rfbCloseClient(cl);
- return;
- }
-
- static const int cert_type_priority[] = { GNUTLS_CRT_X509, 0 };
- if ((ret = gnutls_certificate_type_set_priority(sd->session, cert_type_priority)) < 0) {
- rfbLog("gnutls_certificate_type_set_priority failed: %s\n",
- gnutls_strerror(ret));
- sd->session = NULL;
- rfbCloseClient(cl);
- return;
- }
-
- static const int protocol_priority[]= { GNUTLS_TLS1_1, GNUTLS_TLS1_0, GNUTLS_SSL3, 0 };
- if ((ret = gnutls_protocol_set_priority(sd->session, protocol_priority)) < 0) {
- rfbLog("gnutls_protocol_set_priority failed: %s\n",
+ if ((ret = gnutls_priority_set_direct(sd->session, "NORMAL:+ANON-ECDH:+ANON-DH", NULL)) < 0) {
+ rfbLog("gnutls_priority_set_direct failed: %s\n",
gnutls_strerror(ret));
sd->session = NULL;
rfbCloseClient(cl);

Binary file not shown.

Binary file not shown.

View File

@ -1,76 +1,55 @@
RELEASE=4.0
PACKAGE=vncterm PACKAGE=vncterm
# Note: also change version in debian/control and debian/changelog # Note: also change version in debian/control and debian/changelog
VERSION=1.2 VERSION=1.5
PACKAGERELEASE=1 PACKAGERELEASE=2
ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH) ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
GITVERSION:=$(shell cat .git/refs/heads/master)
CDATE:=$(shell date +%F) CDATE:=$(shell date +%F)
VNCVER=0.9.7 VNCVER=0.9.11
VNCDIR=LibVNCServer-${VNCVER} VNCREL=LibVNCServer-${VNCVER}
VNCSRC=${VNCDIR}.tar.gz VNCDIR=libvncserver-${VNCREL}
VNCSRC=${VNCREL}.tar.gz
VNCLIB=${VNCDIR}/libvncserver/.libs/libvncserver.a VNCLIB=${VNCDIR}/libvncserver/.libs/libvncserver.a
TIGERVNCSRC=tigervnc-1.1.0.tgz
#TIGERVNCSRC=tigervnc-1.2.0.tgz
DEB=${PACKAGE}_${VERSION}-${PACKAGERELEASE}_${ARCH}.deb DEB=${PACKAGE}_${VERSION}-${PACKAGERELEASE}_${ARCH}.deb
SNAP=${PACKAGE}-${VERSION}-${CDATE}.tar.gz SNAP=${PACKAGE}-${VERSION}-${CDATE}.tar.gz
KEYSTORE=/home/dietmar/pve2-proxdev/proxmox-dev/comodo-for-java.keystore
all: vncterm all: vncterm
glyphs.h: genfont font.data: genfont2
./genfont > glyphs.h ./genfont2 -o font.data.tmp -i /usr/share/unifont/unifont.hex
mv font.data.tmp font.data
genfont: genfont.c genfont2: genfont2.c
gcc -g -O2 -o $@ genfont.c -Wall -D_GNU_SOURCE -lz gcc -g -O2 -o $@ genfont2.c -Wall -Wextra -D_GNU_SOURCE -lz
.PHONY: vnc .PHONY: vnc
${VNCLIB} vnc: ${VNCSRC} vnc: ${VNCLIB}
${VNCLIB}: ${VNCSRC}
rm -rf ${VNCDIR} rm -rf ${VNCDIR}
tar xf ${VNCSRC} tar xf ${VNCSRC}
ln -s ../vncpatches ${VNCDIR}/patches ln -s ../vncpatches ${VNCDIR}/patches
cd ${VNCDIR}; quilt push -a cd ${VNCDIR}; quilt push -a
cd ${VNCDIR}; ./configure; cd ${VNCDIR}; ./autogen.sh --without-ssl --without-websockets --without-tightvnc-filetransfer;
cd ${VNCDIR}; make cd ${VNCDIR}; $(MAKE)
vncterm: vncterm.c glyphs.h ${VNCLIB} vncterm: vncterm.c ${VNCLIB} wchardata.c
gcc -O2 -g -o $@ vncterm.c -Wall -Wno-deprecated-declarations -D_GNU_SOURCE -I ${VNCDIR} ${VNCLIB} -lnsl -lpthread -lz -ljpeg -lutil -lgnutls gcc -O2 -g -o $@ vncterm.c wchardata.c -Wall -Wno-deprecated-declarations -D_GNU_SOURCE -I ${VNCDIR} ${VNCLIB} -lnsl -lpthread -lz -ljpeg -lutil -lgnutls -lpng
jar: tigervnc.org wchardata.c:
if test ! -f /usr/share/icedtea-web/plugin.jar; then echo "please install package icedtea-netx-common"; exit 1; fi cp /usr/share/unifont/$@ $@
rm -rf tigervnc VncViewer.jar
rsync -av --exclude .svn --exclude .svnignore tigervnc.org/ tigervnc
ln -s ../tigerpatches tigervnc/patches
cd tigervnc; quilt push -a
cd tigervnc/java/src/com/tigervnc/vncviewer; make clean; make
jarsigner -keystore ${KEYSTORE} -signedjar VncViewer.jar tigervnc/java/src/com/tigervnc/vncviewer/VncViewer.jar "dc475d72-124a-11e4-a53f-005056c00008"
# this is for version 1.2
# ln -s ../newtigerpatches tigervnc/patches
# cd tigervnc/java;cmake -G "Unix Makefiles"; make
# jarsigner -keystore ${KEYSTORE} -signedjar VncViewer.jar tigervnc/java/VncViewer.jar proxmox
tigervnc.org: ${TIGERVNCSRC}
rm -rf tigervnc.org
tar xf ${TIGERVNCSRC}
download:
rm -rf tigervnc.org
svn co https://tigervnc.svn.sourceforge.net/svnroot/tigervnc/tags/1_1_0 tigervnc.org
tar cf ${TIGERVNCSRC} tigervnc.org
.PHONY: install .PHONY: install
install: vncterm vncterm.1 VncViewer.jar install: vncterm vncterm.1 font.data
mkdir -p ${DESTDIR}/usr/share/doc/${PACKAGE} mkdir -p ${DESTDIR}/usr/share/doc/${PACKAGE}
install -m 0644 copyright ${DESTDIR}/usr/share/doc/${PACKAGE}
mkdir -p ${DESTDIR}/usr/share/${PACKAGE}
install -m 0644 font.data ${DESTDIR}/usr/share/${PACKAGE}
mkdir -p ${DESTDIR}/usr/share/man/man1 mkdir -p ${DESTDIR}/usr/share/man/man1
install -m 0644 vncterm.1 ${DESTDIR}/usr/share/man/man1
mkdir -p ${DESTDIR}/usr/bin mkdir -p ${DESTDIR}/usr/bin
install -s -m 0755 vncterm ${DESTDIR}/usr/bin install -s -m 0755 vncterm ${DESTDIR}/usr/bin
mkdir -p ${DESTDIR}/usr/share/vncterm/
install -m 0644 VncViewer.jar ${DESTDIR}/usr/share/vncterm/
.PHONY: dinstall .PHONY: dinstall
dinstall: ${DEB} dinstall: ${DEB}
@ -81,42 +60,25 @@ vncterm.1: vncterm.pod
pod2man -n $< -s 1 -r ${VERSION} <$< >$@ pod2man -n $< -s 1 -r ${VERSION} <$< >$@
.PHONY: deb .PHONY: deb
${DEB} deb: deb: $(DEB)
make clean ${DEB}:
rm -rf dest $(MAKE) clean
mkdir dest rsync -a . --exclude build build
make DESTDIR=`pwd`/dest install echo "Architecture: ${ARCH}" >> build/debian/control
install -d -m 0755 dest/DEBIAN echo "git clone git://git.proxmox.com/git/vncterm.git\\ngit checkout ${GIVERSION}" > build/debian/SOURCE
install -m 0644 debian/control dest/DEBIAN cd build; dpkg-buildpackage -rfakeroot -b -us -uc
echo "Architecture: ${ARCH}" >>dest/DEBIAN/control
install -m 0644 debian/conffiles dest/DEBIAN
install -m 0644 copyright dest/usr/share/doc/${PACKAGE}
install -m 0644 vncterm.1 dest/usr/share/man/man1
install -m 0644 debian/changelog.Debian dest/usr/share/doc/${PACKAGE}
gzip --best dest/usr/share/man/*/*
gzip --best dest/usr/share/doc/${PACKAGE}/changelog.Debian
dpkg-deb --build dest
mv dest.deb ${DEB}
rm -rf dest
lintian ${DEB} lintian ${DEB}
.PHONY: upload .PHONY: upload
upload: ${DEB} upload: ${DEB}
umount /pve/${RELEASE}; mount /pve/${RELEASE} -o rw tar cf - ${DEB} | ssh -X repoman@repo.proxmox.com -- upload --product pmg,pve --dist stretch
mkdir -p /pve/${RELEASE}/extra
rm -f /pve/${RELEASE}/extra/${PACKAGE}_*.deb
rm -f /pve/${RELEASE}/extra/Packages*
cp ${DEB} /pve/${RELEASE}/extra
cd /pve/${RELEASE}/extra; dpkg-scanpackages . /dev/null > Packages; gzip -9c Packages > Packages.gz
umount /pve/${RELEASE}; mount /pve/${RELEASE} -o ro
.PHONY: clean .PHONY: clean
clean: clean:
rm -rf vncterm vncterm.1 vncterm_*.deb tigervnc *~ ${VNCDIR} vncterm-*.tar.gz rm -rf vncterm vncterm.1 vncterm_*.deb genfont genfont2 *~ ${VNCDIR} vncterm-*.tar.gz glyph.h.tmp build *.changes wchardata.c font.data.tmp font.data *.buildinfo
.PHONY: distclean .PHONY: distclean
distclean: clean distclean: clean
rm -rf tigervnc.org
.PHONY: dist .PHONY: dist
${SNAP} dist: distclean ${SNAP} dist: distclean

Binary file not shown.

View File

@ -1,3 +1,55 @@
vncterm (1.5-2) unstable; urgency=medium
* replaced pure plack cursor with a more visible pointer with white edges
-- Proxmox Support Team <support@proxmox.com> Wed, 07 Jun 2017 13:53:17 +0200
vncterm (1.5-1) unstable; urgency=medium
* use unifont to support more glyphs (range 0x0000..0xFFFF)
* support wide characters
* support combining glyphs
-- Proxmox Support Team <support@proxmox.com> Wed, 24 May 2017 13:12:55 +0200
vncterm (1.4-2) unstable; urgency=medium
* fix bound checking on cursor move
-- Proxmox Support Team <support@proxmox.com> Sat, 06 May 2017 08:09:29 +0200
vncterm (1.4-1) unstable; urgency=medium
* recompile for Debian Stretch / PVE 5
-- Proxmox Support Team <support@proxmox.com> Fri, 10 Mar 2017 10:19:48 +0100
vncterm (1.3-2) unstable; urgency=medium
* bound check utf8 characters
* detect empty first parameter of escape codes
-- Proxmox Support Team <support@proxmox.com> Fri, 10 Mar 2017 10:11:00 +0100
vncterm (1.3-1) unstable; urgency=low
* update cipher suites to GnuTLS's NORMAL
* allow building with GnuTLS 3.5
* update LibVNCServer to 0.9.11
-- Proxmox Support Team <support@proxmox.com> Fri, 3 Feb 2017 08:52:31 +0100
vncterm (1.2-1) unstable; urgency=low
* recompile for Debian Jessie / PVE 4
-- Proxmox Support Team <support@proxmox.com> Fri, 27 Feb 2015 20:00:46 +0100
vncterm (1.1-8) unstable; urgency=low vncterm (1.1-8) unstable; urgency=low
* update applet signature (new code signing cert) * update applet signature (new code signing cert)

1
vncterm/debian/compat Normal file
View File

@ -0,0 +1 @@
9

View File

@ -1,9 +1,19 @@
Source: vncterm
Maintainer: Proxmox Support Team <support@proxmox.com>
Build-Depends:
debhelper (>= 8.0.0),
zlib1g-dev,
libjpeg-dev,
libpng-dev,
libglib2.0-dev,
libgnutls28-dev,
unifont
Standards-Version: 3.9.3
Package: vncterm Package: vncterm
Version: 1.2-1
Section: x11 Section: x11
Priority: optional Priority: optional
Depends: libc6 (>= 2.7-18), libjpeg62, zlib1g (>= 1:1.2.1),libgnutls-deb0-28 Depends: libc6 (>= 2.7-18), libjpeg62, zlib1g (>= 1:1.2.1), libgnutls-deb0-28 | libgnutls30, libpng16-16, ${shlibs:Depends}
Maintainer: Proxmox Support Team <support@proxmox.com>
Description: VNC Terminal Emulator Description: VNC Terminal Emulator
With vncterm you can start commands and export its standard input and With vncterm you can start commands and export its standard input and
output to any VNC client (simulating a xterm Terminal). output to any VNC client (simulating a xterm Terminal).

1
vncterm/debian/docs Normal file
View File

@ -0,0 +1 @@
debian/SOURCE

4
vncterm/debian/rules Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/make -f
%:
dh $@

View File

@ -84,7 +84,7 @@ load_psf_font (const char *filename, int is_default)
{ {
struct psf_header psfhdr; struct psf_header psfhdr;
gzFile *f = gzopen (filename, "rb"); gzFile f = gzopen(filename, "rb");
if (f == NULL) { if (f == NULL) {
fprintf (stderr, "unable to read file %s\n", filename); fprintf (stderr, "unable to read file %s\n", filename);
exit(-1); exit(-1);

184
vncterm/genfont2.c Normal file
View File

@ -0,0 +1,184 @@
/*
Copyright (C) 2017 Proxmox Server Solutions GmbH
Copyright: vncterm is under GNU GPL, the GNU General Public License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 dated June, 1991.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
Author: Dominik Csapak <d.csapak@proxmox.com>
This tool converts the unifont.hex file format into
a binary format used in vncterm to render glyphs.
*/
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <errno.h>
#include <getopt.h>
#define NUMCODEPOINTS 0xFFFF
#define GLYPHLINES 16
#define INDEXLENGTH 4
/* parses strings like 00F0 to the integer */
long
parsehex(char *val, size_t length)
{
unsigned int value = 0;
for (size_t i = 0; i < length; i++) {
value *= 16;
if (val[i] >= '0' && val[i] <= '9') {
value += (val[i] - '0');
} else if (val[i] >= 'A' && val[i] <= 'F') {
value += (val[i] - 'A' + 10);
} else if (val[i] >= 'a' && val[i] <= 'f') {
value += (val[i] - 'a' + 10);
} else {
return -1;
}
}
return value;
}
void usage(char **argv) {
printf("Usage: %s [OPTION]...\n", argv[0]);
printf("Converts font data from hex format into binary format used by vncterm.\n");
printf("\n");
printf(" -o, --output file for output, if omitted, write to STDOUT\n");
printf(" -i, --input file for input, if omitted read from STDIN\n");
printf(" -h, --help display this help\n");
printf("\nThe input has to be formatted in the hex format of unifont.\n");
}
int
main (int argc, char** argv)
{
FILE *fd;
FILE *outfd;
char *line = NULL;
char *tmp = NULL;
char *fontfile = NULL;
char *outfile = NULL;
size_t linesize = 0;
uint8_t emptyglyph[GLYPHLINES*2] = { 0 };
uint8_t glyph[GLYPHLINES*2] = { 0 };
int nextcodepoint = 0;
int codepoint = 0;
int c;
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"output", required_argument, 0, 'o'},
{"input", required_argument, 0, 'i'},
{ 0 , 0, 0, 0}
};
int option_index = 0;
while((c = getopt_long(argc, argv, "hi:o:", long_options, &option_index)) != -1) {
switch (c) {
case 'h':
usage(argv);
exit(0);
break;
case 'o':
outfile = optarg;
break;
case 'i':
fontfile = optarg;
break;
default:
usage(argv);
exit(1);
}
}
if (fontfile != NULL){
fd = fopen(fontfile, "r");
if (fd == NULL) {
fprintf(stderr, "Error opening '%s'\n", fontfile);
perror(NULL);
exit(2);
}
} else {
fd = stdin;
}
if (outfile != NULL) {
outfd = fopen(outfile, "w");
if (outfd == NULL) {
fprintf(stderr, "Error opening '%s'\n", outfile);
perror(NULL);
exit(2);
}
} else {
outfd = stdout;
}
while (getline(&line, &linesize, fd) != -1) {
codepoint = parsehex(line, INDEXLENGTH);
if (codepoint == -1) {
fprintf(stderr, "Cannot parse codepoint index: '%s'\n", line);
free(line);
exit(4);
}
/* fill in missing codepoints with empty glyphs */
while (nextcodepoint++ < codepoint) {
fwrite(emptyglyph, sizeof(emptyglyph), 1, outfd);
}
tmp = line + INDEXLENGTH + 1;
size_t i = 0;
/* parse until end of line */
while (*(tmp+i*2) != '\n' && i < sizeof(glyph)) {
int value = parsehex(tmp+i*2, 2);
if (value == -1) {
fprintf(stderr, "Cannot parse glyph from line: '%s' at position %ld ('%s')\n", line, i*2, tmp+i*2);
free(line);
exit(4);
}
glyph[i++] = (uint8_t)value;
}
/* if we have a 1width glyph, fill the rest with zeroes */
while (i < sizeof(glyph)) {
glyph[i++] = 0;
}
fwrite(glyph, sizeof(glyph), 1, outfd);
}
if(errno) {
perror("Cannot not read line from file");
}
while (nextcodepoint++ <= NUMCODEPOINTS) {
fwrite(emptyglyph, sizeof(emptyglyph), 1, outfd);
}
free(line);
exit(0);
}

View File

@ -1,75 +0,0 @@
Index: new/java/com/tigervnc/rfb/CSecurityTLS.java
===================================================================
--- new.orig/java/com/tigervnc/rfb/CSecurityTLS.java 2013-04-18 11:56:22.000000000 +0200
+++ new/java/com/tigervnc/rfb/CSecurityTLS.java 2013-04-18 13:59:03.000000000 +0200
@@ -25,6 +25,7 @@
import java.io.File;
import java.io.InputStream;
import java.io.FileInputStream;
+import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.Collection;
import javax.swing.JOptionPane;
@@ -34,6 +35,9 @@
public class CSecurityTLS extends CSecurity {
+ public static StringParameter PVECert
+ = new StringParameter("PVECert",
+ "Proxmox VE CA certificate", "");
public static StringParameter x509ca
= new StringParameter("x509ca",
"X509 CA certificate", "");
@@ -92,6 +96,8 @@
{
anon = _anon;
setDefaults();
+
+ pvecert = PVECert.getData();
cafile = x509ca.getData();
crlfile = x509crl.getData();
}
@@ -170,10 +176,15 @@
CertificateFactory cf = CertificateFactory.getInstance("X.509");
try {
ks.load(null, null);
- File cacert = new File(cafile);
- if (!cacert.exists() || !cacert.canRead())
- return;
- InputStream caStream = new FileInputStream(cafile);
+ InputStream caStream;
+ if (pvecert != null) {
+ caStream = new ByteArrayInputStream(pvecert.getBytes("ISO-8859-1"));
+ } else {
+ File cacert = new File(cafile);
+ if (!cacert.exists() || !cacert.canRead())
+ return;
+ caStream = new FileInputStream(cafile);
+ }
X509Certificate ca = (X509Certificate)cf.generateCertificate(caStream);
ks.setCertificateEntry("CA", ca);
PKIXBuilderParameters params = new PKIXBuilderParameters(ks, new X509CertSelector());
@@ -241,6 +252,7 @@
private boolean anon;
private SSLSession session;
private String cafile, crlfile;
+ private String pvecert;
private InStream is;
private SSLSocket ssl;
Index: new/java/com/tigervnc/vncviewer/VncViewer.java
===================================================================
--- new.orig/java/com/tigervnc/vncviewer/VncViewer.java 2013-04-18 11:56:21.000000000 +0200
+++ new/java/com/tigervnc/vncviewer/VncViewer.java 2013-04-18 13:56:33.000000000 +0200
@@ -168,6 +168,11 @@
if (firstApplet) {
alwaysShowServerDialog.setParam(true);
Configuration.readAppletParams(this);
+ String tmpcert = this.getParameter("PVECert");
+ if (tmpcert != null) {
+ CSecurityTLS.PVECert.setParam(tmpcert.replace('|', '\n'));
+ }
+
String host = getCodeBase().getHost();
if (vncServerName.getValue() == null && vncServerPort.getValue() != 0) {
int port = vncServerPort.getValue();

View File

@ -1,50 +0,0 @@
Index: new/java/com/tigervnc/vncviewer/CConn.java
===================================================================
--- new.orig/java/com/tigervnc/vncviewer/CConn.java 2013-04-18 11:56:21.000000000 +0200
+++ new/java/com/tigervnc/vncviewer/CConn.java 2013-04-18 14:23:58.000000000 +0200
@@ -246,6 +246,16 @@
String passwordFileStr = viewer.passwordFile.getValue();
PasswdDialog dlg;
+ String usernameParam = viewer.usernameParam.getValue();
+ String passwordParam = viewer.passwordParam.getValue();
+ vlog.info("USERNAME: " + usernameParam);
+ vlog.info("PASSWORD: " + passwordParam);
+ if (usernameParam != null && passwordParam != null) {
+ user.append(usernameParam);
+ passwd.append(passwordParam);
+ return true;
+ }
+
if (user == null && passwordFileStr != "") {
InputStream fp = null;
try {
Index: new/java/com/tigervnc/vncviewer/VncViewer.java
===================================================================
--- new.orig/java/com/tigervnc/vncviewer/VncViewer.java 2013-04-18 13:56:33.000000000 +0200
+++ new/java/com/tigervnc/vncviewer/VncViewer.java 2013-04-19 07:52:32.000000000 +0200
@@ -168,6 +168,9 @@
if (firstApplet) {
alwaysShowServerDialog.setParam(true);
Configuration.readAppletParams(this);
+
+ System.err.print(Configuration.listParams());
+
String tmpcert = this.getParameter("PVECert");
if (tmpcert != null) {
CSecurityTLS.PVECert.setParam(tmpcert.replace('|', '\n'));
@@ -263,6 +266,14 @@
"Password file for VNC authentication", "");
AliasParameter passwd
= new AliasParameter("passwd", "Alias for PasswordFile", passwordFile);
+
+ StringParameter usernameParam
+ = new StringParameter("USERNAME",
+ "Username for VNC authentication", null);
+ StringParameter passwordParam
+ = new StringParameter("PASSWORD",
+ "Password for VNC authentication", null);
+
BoolParameter autoSelect
= new BoolParameter("AutoSelect",
"Auto select pixel format and encoding", true);

View File

@ -1,2 +0,0 @@
add-pvecert-parameter.patch
add-username-param.patch

View File

@ -1,43 +0,0 @@
Index: new/java/src/com/tigervnc/vncviewer/VncViewer.java
===================================================================
--- new.orig/java/src/com/tigervnc/vncviewer/VncViewer.java 2011-01-25 07:44:23.000000000 +0100
+++ new/java/src/com/tigervnc/vncviewer/VncViewer.java 2011-01-28 13:26:16.000000000 +0100
@@ -466,6 +466,38 @@
}
}
+ public void sendRefreshRequest()
+ {
+ if (rfb == null)
+ return;
+
+ try {
+ rfb.writeFramebufferUpdateRequest(0, 0, rfb.framebufferWidth,
+ rfb.framebufferHeight, false);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void sendCtrlAltDel()
+ {
+ if (rfb == null)
+ return;
+
+ int modifiers = InputEvent.CTRL_MASK | InputEvent.ALT_MASK;
+
+ try {
+ KeyEvent ctrlAltDelEvent =
+ new KeyEvent(this, KeyEvent.KEY_PRESSED, 0, modifiers, 127);
+ rfb.writeKeyEvent(ctrlAltDelEvent);
+
+ ctrlAltDelEvent =
+ new KeyEvent(this, KeyEvent.KEY_RELEASED, 0, modifiers, 127);
+ rfb.writeKeyEvent(ctrlAltDelEvent);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
//
// Show an authentication panel.

View File

@ -1,13 +0,0 @@
Index: new/java/src/com/tigervnc/vncviewer/Makefile
===================================================================
--- new.orig/java/src/com/tigervnc/vncviewer/Makefile 2013-04-20 15:24:59.000000000 +0200
+++ new/java/src/com/tigervnc/vncviewer/Makefile 2013-04-20 15:31:48.000000000 +0200
@@ -4,7 +4,7 @@
CP = cp
JC = javac
-JCFLAGS = -target 1.5 -classpath ../../../
+JCFLAGS = -target 1.7 -classpath ../../../
JAR = jar
ARCHIVE = VncViewer.jar
MANIFEST = MANIFEST.MF

View File

@ -1,35 +0,0 @@
Sources found at http://dogfeathers.com/mark/java7issue.html
Index: tigervnc.new/java/src/com/tigervnc/vncviewer/VncViewer.java
===================================================================
--- tigervnc.new.orig/java/src/com/tigervnc/vncviewer/VncViewer.java 2012-08-21 09:05:04.000000000 +0200
+++ tigervnc.new/java/src/com/tigervnc/vncviewer/VncViewer.java 2012-08-21 09:10:27.000000000 +0200
@@ -110,6 +110,28 @@
public void init() {
+ // fix focus traversal
+ Container topParent = null;
+ Container parent = this;
+ // The natural thing would be to call getParent() until it returns
+ // null, but then you would be looping for a long time, since
+ // PluginEmbeddedFrame's getParent() returns itself.
+ for (int k=0; k < 10; k++) {
+ topParent = parent;
+ parent = parent.getParent();
+ if (parent == null) break;
+ }
+
+ // If topParent isn't a KeyEventDispatcher then we must be in some
+ // Plugin version that doesn't need the workaround.
+ try {
+ KeyEventDispatcher ked = (KeyEventDispatcher)topParent;
+ KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ // You have to remove it twice, otherwise the problem isn't fixed
+ kfm.removeKeyEventDispatcher(ked);
+ kfm.removeKeyEventDispatcher(ked);
+ } catch (ClassCastException e) {}
+
readParameters();
refApplet = this;

View File

@ -1,111 +0,0 @@
Index: new/java/src/com/tigervnc/vncviewer/VncViewer.java
===================================================================
--- new.orig/java/src/com/tigervnc/vncviewer/VncViewer.java 2013-05-10 07:41:18.000000000 +0200
+++ new/java/src/com/tigervnc/vncviewer/VncViewer.java 2013-05-10 07:41:18.000000000 +0200
@@ -27,11 +27,15 @@
package com.tigervnc.vncviewer;
+import netscape.javascript.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
+import java.awt.Graphics;
+import java.applet.Applet;
+
public class VncViewer extends java.applet.Applet
implements java.lang.Runnable, WindowListener, ComponentListener {
@@ -94,6 +98,9 @@
String PVECert;
+ JSObject jswin;
+ String myid;
+
// Reference to this applet for inter-applet communication.
public static java.applet.Applet refApplet;
@@ -129,6 +136,11 @@
refApplet = this;
+ if (inAnApplet) {
+ jswin = JSObject.getWindow(this);
+ myid = getParameter("id");
+ }
+
if (inSeparateFrame) {
vncFrame = new Frame("TigerVNC");
if (!inAnApplet) {
@@ -159,6 +171,9 @@
rfbThread = new Thread(this);
rfbThread.start();
+
+ String[] myparam = { myid, "init"};
+ jswin.call("PVE_vnc_console_event", myparam);
}
public void update(Graphics g) {
@@ -1002,6 +1017,8 @@
if (inAnApplet) {
showMessage("Disconnected");
+ String[] myparam = { myid, "disconnect"};
+ jswin.call("PVE_vnc_console_event", myparam);
} else {
System.exit(0);
}
@@ -1019,6 +1036,8 @@
// vncContainer null, applet not inited,
// can not present the error to the user.
Thread.currentThread().stop();
+ String[] myparam = { myid, "error", str};
+ jswin.call("PVE_vnc_console_event", myparam);
} else {
System.exit(1);
}
@@ -1040,6 +1059,8 @@
rfb.close();
if (inAnApplet) {
+ String[] myparam = { myid, "error", str};
+ jswin.call("PVE_vnc_console_event", myparam);
showMessage(str);
} else {
System.exit(1);
@@ -1109,6 +1130,9 @@
rfb.close();
if (inSeparateFrame)
vncFrame.dispose();
+
+ String[] myparam = { myid, "destroy"};
+ jswin.call("PVE_vnc_console_event", myparam);
}
//
@@ -1157,6 +1181,8 @@
if (!inAnApplet) {
System.exit(0);
}
+ String[] myparam = { myid, "close"};
+ jswin.call("PVE_vnc_console_event", myparam);
}
//
Index: new/java/src/com/tigervnc/vncviewer/Makefile
===================================================================
--- new.orig/java/src/com/tigervnc/vncviewer/Makefile 2013-05-10 07:41:18.000000000 +0200
+++ new/java/src/com/tigervnc/vncviewer/Makefile 2013-05-10 07:43:17.000000000 +0200
@@ -4,7 +4,7 @@
CP = cp
JC = javac
-JCFLAGS = -target 1.7 -classpath ../../../
+JCFLAGS = -target 1.7 -classpath ../../../ -Djava.ext.dirs=/usr/share/icedtea-web/
JAR = jar
ARCHIVE = VncViewer.jar
MANIFEST = MANIFEST.MF

View File

@ -1,14 +0,0 @@
Index: new/java/src/com/tigervnc/vncviewer/RfbProto.java
===================================================================
--- new.orig/java/src/com/tigervnc/vncviewer/RfbProto.java 2011-01-20 08:14:34.000000000 +0100
+++ new/java/src/com/tigervnc/vncviewer/RfbProto.java 2011-01-20 08:19:20.000000000 +0100
@@ -938,6 +938,9 @@
int keyChar = evt.getKeyChar();
+ int test = evt.getKeyCode();
+ System.out.println("KEYCODE: " + evt.getKeyText(test));
+
//
// Ignore event if only modifiers were pressed.
//

View File

@ -1,11 +0,0 @@
Index: new/java/src/com/tigervnc/vncviewer/MANIFEST.MF
===================================================================
--- new.orig/java/src/com/tigervnc/vncviewer/MANIFEST.MF 2011-08-18 14:05:33.000000000 +0200
+++ new/java/src/com/tigervnc/vncviewer/MANIFEST.MF 2013-11-08 11:17:13.000000000 +0100
@@ -1,2 +1,6 @@
Manifest-Version: 1.0
Main-Class: com.tigervnc.vncviewer.VncViewer
+Permissions: all-permissions
+Application-Name: vncterm
+Codebase: *
+Caller-Allowable-Codebase: *

View File

@ -1,9 +0,0 @@
#keydebug.patch
#javascript-events.patch
export-ctrl-alt-delete.patch
trust-manager.patch
fix-makefiles.patch
username-param.patch
fix-tab-button.patch
modify-jar-manifest.patch
javascript-events.patch

View File

@ -1,190 +0,0 @@
Unfortunately the java certificate store does not correctly access
the browser certificate store (firefox, chrome). We also tunnel VNC
traffic from other cluster nodes.
So we implement our own trust manager, and allow to pass the server
certificate (or CA who signed the server certificate) as applet
parameter "PVECert" (newline encoded as '|').
Index: tigervnc/java/src/com/tigervnc/vncviewer/X509Tunnel.java
===================================================================
--- tigervnc.orig/java/src/com/tigervnc/vncviewer/X509Tunnel.java 2013-06-03 08:17:17.000000000 +0200
+++ tigervnc/java/src/com/tigervnc/vncviewer/X509Tunnel.java 2013-06-03 08:22:52.000000000 +0200
@@ -26,13 +26,23 @@
import javax.net.ssl.*;
import java.security.*;
import java.security.cert.*;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateFactory;
+import java.io.*;
public class X509Tunnel extends TLSTunnelBase
{
- public X509Tunnel (Socket sock_)
+ Certificate pvecert;
+
+ public X509Tunnel (Socket sock_, String certstr) throws CertificateException
{
super (sock_);
+
+ if (certstr != null) {
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ pvecert = cf.generateCertificate(new StringBufferInputStream(certstr));
+ }
}
protected void setParam (SSLSocket sock)
@@ -52,9 +62,48 @@
protected void initContext (SSLContext sc) throws java.security.
GeneralSecurityException
{
- TrustManager[] myTM = new TrustManager[]
- {
- new MyX509TrustManager ()};
+ TrustManager[] myTM;
+
+ if (pvecert != null) {
+ myTM = new TrustManager[] {
+ new X509TrustManager() {
+ public java.security.cert.X509Certificate[]
+ getAcceptedIssuers() {
+ return null;
+ }
+ public void checkClientTrusted(
+ java.security.cert.X509Certificate[] certs,
+ String authType) throws CertificateException {
+ throw new CertificateException("no clients");
+ }
+ public void checkServerTrusted(
+ java.security.cert.X509Certificate[] certs,
+ String authType) throws CertificateException {
+
+ if (certs == null || certs.length < 1) {
+ throw new CertificateException("no certs");
+ }
+ PublicKey cakey = pvecert.getPublicKey();
+
+ boolean ca_match;
+ try {
+ certs[0].verify(cakey);
+ ca_match = true;
+ } catch (Exception e) {
+ ca_match = false;
+ }
+
+ if (!ca_match && !pvecert.equals(certs[0])) {
+ throw new CertificateException("certificate does not match");
+ }
+ }
+ }
+ };
+ } else {
+ myTM = new TrustManager[] {
+ new MyX509TrustManager ()
+ };
+ }
sc.init (null, myTM, null);
}
@@ -100,4 +149,5 @@
return tm.getAcceptedIssuers ();
}
}
+
}
Index: tigervnc/java/src/com/tigervnc/vncviewer/RfbProto.java
===================================================================
--- tigervnc.orig/java/src/com/tigervnc/vncviewer/RfbProto.java 2013-06-03 08:17:17.000000000 +0200
+++ tigervnc/java/src/com/tigervnc/vncviewer/RfbProto.java 2013-06-03 08:19:05.000000000 +0200
@@ -411,7 +411,8 @@
}
void authenticateX509() throws Exception {
- X509Tunnel tunnel = new X509Tunnel(sock);
+
+ X509Tunnel tunnel = new X509Tunnel(sock, viewer.PVECert);
tunnel.setup (this);
}
Index: tigervnc/java/src/com/tigervnc/vncviewer/VncViewer.java
===================================================================
--- tigervnc.orig/java/src/com/tigervnc/vncviewer/VncViewer.java 2013-06-03 08:19:03.000000000 +0200
+++ tigervnc/java/src/com/tigervnc/vncviewer/VncViewer.java 2013-06-03 08:19:05.000000000 +0200
@@ -91,6 +91,8 @@
int debugStatsExcludeUpdates;
int debugStatsMeasureUpdates;
+ String PVECert;
+
// Reference to this applet for inter-applet communication.
public static java.applet.Applet refApplet;
@@ -263,7 +265,7 @@
fatalError(e.toString(), e);
}
}
-
+
}
//
@@ -299,7 +301,7 @@
// If the rfbThread is being stopped, ignore any exceptions,
// otherwise rethrow the exception so it can be handled.
//
-
+
void processNormalProtocol() throws Exception {
try {
vc.processNormalProtocol();
@@ -842,6 +844,11 @@
// SocketFactory.
socketFactory = readParameter("SocketFactory", false);
+
+ String tmpcert = readParameter("PVECert", false);
+ if (tmpcert != null) {
+ PVECert = tmpcert.replace('|', '\n');
+ }
}
//
@@ -991,7 +998,7 @@
}
synchronized public void fatalError(String str, Exception e) {
-
+
if (rfb != null && rfb.closed()) {
// Not necessary to show error message if the error was caused
// by I/O problems after the rfb.close() method call.
@@ -1084,11 +1091,11 @@
public void enableInput(boolean enable) {
vc.enableInput(enable);
}
-
+
//
// Resize framebuffer if autoScale is enabled.
//
-
+
public void componentResized(ComponentEvent e) {
if (e.getComponent() == vncFrame) {
if (options.autoScale) {
@@ -1100,11 +1107,11 @@
}
}
}
-
+
//
// Ignore component events we're not interested in.
//
-
+
public void componentShown(ComponentEvent e) { }
public void componentMoved(ComponentEvent e) { }
public void componentHidden(ComponentEvent e) { }

View File

@ -1,38 +0,0 @@
Index: new/java/src/com/tigervnc/vncviewer/VncViewer.java
===================================================================
--- new.orig/java/src/com/tigervnc/vncviewer/VncViewer.java 2011-01-28 13:26:51.000000000 +0100
+++ new/java/src/com/tigervnc/vncviewer/VncViewer.java 2011-01-28 13:27:04.000000000 +0100
@@ -86,6 +86,7 @@
String host;
int port;
String passwordParam;
+ String usernameParam;
boolean showControls;
boolean offerRelogin;
boolean showOfflineDesktop;
@@ -384,10 +385,12 @@
break;
case RfbProto.SecTypePlain:
showConnectionStatus("Plain authentication");
- {
- String user = askUser();
- String pw = askPassword();
- rfb.authenticatePlain(user,pw);
+ if (usernameParam != null && passwordParam != null) {
+ rfb.authenticatePlain(usernameParam, passwordParam);
+ } else {
+ String user = askUser();
+ String pw = askPassword();
+ rfb.authenticatePlain(user,pw);
}
break;
case RfbProto.SecTypeTLSNone:
@@ -822,6 +825,8 @@
// Read "ENCPASSWORD" or "PASSWORD" parameter if specified.
readPasswordParameters();
+ usernameParam = readParameter("USERNAME", false);
+
String str;
if (inAnApplet) {
str = readParameter("Open New Window", false);

Binary file not shown.

View File

@ -0,0 +1,227 @@
commit 25e3dfeab75b6febdb6c1157e991c3bcbeb3eb86
Author: Fabian Grünbichler <f.gruenbichler@proxmox.com>
AuthorDate: Thu Feb 2 11:22:35 2017 +0100
Commit: Fabian Grünbichler <f.gruenbichler@proxmox.com>
CommitDate: Thu Feb 2 11:22:35 2017 +0100
Revert "Support systemd socket activation"
unneeded extra build dep
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9424d8d..4c56635 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,7 +36,6 @@ find_package(GnuTLS)
find_package(Threads)
find_package(X11)
find_package(OpenSSL)
-find_package(PkgConfig)
find_library(LIBGCRYPT_LIBRARIES gcrypt)
# Check whether the version of libjpeg we found was libjpeg-turbo and print a
@@ -103,17 +102,6 @@ if(PNG_FOUND)
endif(PNG_FOUND)
option(LIBVNCSERVER_ALLOW24BPP "Allow 24 bpp" ON)
-pkg_check_modules(SYSTEMD "libsystemd")
-if(SYSTEMD_FOUND)
- option(LIBVNCSERVER_WITH_SYSTEMD "Build with systemd socket activation support" ON)
-endif(SYSTEMD_FOUND)
-
-if(LIBVNCSERVER_WITH_SYSTEMD)
- add_definitions(-DLIBVNCSERVER_WITH_SYSTEMD)
- include_directories(${SYSTEMD_INCLUDE_DIRS})
- set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${SYSTEMD_LIBRARIES})
-endif(LIBVNCSERVER_WITH_SYSTEMD)
-
if(GNUTLS_FOUND)
set(LIBVNCSERVER_WITH_CLIENT_TLS 1)
option(LIBVNCSERVER_WITH_WEBSOCKETS "Build with websockets support (gnutls)" ON)
diff --git a/configure.ac b/configure.ac
index f13edb4..3f4b29a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,9 +68,6 @@ if test ! -z "$with_ffmpeg"; then
fi
AM_CONDITIONAL(HAVE_MP3LAME, test "$HAVE_MP3LAME" = "true")
-PKG_CHECK_MODULES([LIBSYSTEMD], [libsystemd], [with_systemd=1], [with_systemd=0])
-AM_CONDITIONAL([WITH_SYSTEMD], [test $with_systemd -eq 1])
-
# Seem to need this dummy here to induce the 'checking for egrep... grep -E', etc.
# before it seemed to be inside the with_jpeg conditional.
AC_CHECK_HEADER(thenonexistentheader.h, HAVE_THENONEXISTENTHEADER_H="true")
diff --git a/libvncserver/Makefile.am b/libvncserver/Makefile.am
index e25784b..2f23e31 100644
--- a/libvncserver/Makefile.am
+++ b/libvncserver/Makefile.am
@@ -59,12 +59,6 @@ LIB_SRCS = main.c rfbserver.c rfbregion.c auth.c sockets.c $(WEBSOCKETSSRCS) \
libvncserver_la_SOURCES=$(LIB_SRCS)
libvncserver_la_LIBADD=$(WEBSOCKETSSSLLIBS)
-if WITH_SYSTEMD
-AM_CPPFLAGS += -DLIBVNCSERVER_WITH_SYSTEMD
-libvncserver_la_CFLAGS = $(LIBSYSTEMD_CFLAGS)
-libvncserver_la_LIBADD += $(LIBSYSTEMD_LIBS)
-endif
-
lib_LTLIBRARIES=libvncserver.la
libvncserver_la_LDFLAGS = -version-info 1:0:0
diff --git a/libvncserver/sockets.c b/libvncserver/sockets.c
index bbc3d90..6467b1c 100644
--- a/libvncserver/sockets.c
+++ b/libvncserver/sockets.c
@@ -77,10 +77,6 @@
#include "rfbssl.h"
#endif
-#ifdef LIBVNCSERVER_WITH_SYSTEMD
-#include <systemd/sd-daemon.h>
-#endif
-
#if defined(__linux__) && defined(NEED_TIMEVAL)
struct timeval
{
@@ -126,54 +122,6 @@ int deny_severity=LOG_WARNING;
int rfbMaxClientWait = 20000; /* time (ms) after which we decide client has
gone away - needed to stop us hanging */
-static rfbBool
-rfbNewConnectionFromSock(rfbScreenInfoPtr rfbScreen, int sock)
-{
- const int one = 1;
-#ifdef LIBVNCSERVER_IPv6
- struct sockaddr_storage addr;
-#else
- struct sockaddr_in addr;
-#endif
- socklen_t addrlen = sizeof(addr);
-
- getpeername(sock, (struct sockaddr *)&addr, &addrlen);
-
- if(!rfbSetNonBlocking(sock)) {
- rfbLogPerror("rfbCheckFds: setnonblock");
- closesocket(sock);
- return FALSE;
- }
-
- if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
- (char *)&one, sizeof(one)) < 0) {
- rfbLogPerror("rfbCheckFds: setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?");
- }
-
-#ifdef USE_LIBWRAP
- if(!hosts_ctl("vnc",STRING_UNKNOWN,inet_ntoa(addr.sin_addr),
- STRING_UNKNOWN)) {
- rfbLog("Rejected connection from client %s\n",
- inet_ntoa(addr.sin_addr));
- closesocket(sock);
- return FALSE;
- }
-#endif
-
-#ifdef LIBVNCSERVER_IPv6
- char host[1024];
- if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) {
- rfbLogPerror("rfbProcessNewConnection: error in getnameinfo");
- }
- rfbLog("Got connection from client %s\n", host);
-#else
- rfbLog("Got connection from client %s\n", inet_ntoa(addr.sin_addr));
-#endif
-
- rfbNewClient(rfbScreen,sock);
- return TRUE;
-}
-
/*
* rfbInitSockets sets up the TCP and UDP sockets to listen for RFB
* connections. It does nothing if called again.
@@ -190,20 +138,6 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen)
rfbScreen->socketState = RFB_SOCKET_READY;
-#ifdef LIBVNCSERVER_WITH_SYSTEMD
- if (sd_listen_fds(0) == 1)
- {
- int sock = SD_LISTEN_FDS_START + 0;
- if (sd_is_socket(sock, AF_UNSPEC, 0, 0))
- rfbNewConnectionFromSock(rfbScreen, sock);
- else if (sd_is_socket(sock, AF_UNSPEC, 0, 1))
- rfbProcessNewConnection(rfbScreen);
- return;
- }
- else
- rfbLog("Unable to establish connection with systemd socket\n");
-#endif
-
if (rfbScreen->inetdSock != -1) {
const int one = 1;
@@ -479,7 +413,14 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
rfbBool
rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen)
{
+ const int one = 1;
int sock = -1;
+#ifdef LIBVNCSERVER_IPv6
+ struct sockaddr_storage addr;
+#else
+ struct sockaddr_in addr;
+#endif
+ socklen_t addrlen = sizeof(addr);
fd_set listen_fds;
int chosen_listen_sock = -1;
@@ -500,12 +441,47 @@ rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen)
if (rfbScreen->listen6Sock >= 0 && FD_ISSET(rfbScreen->listen6Sock, &listen_fds))
chosen_listen_sock = rfbScreen->listen6Sock;
- if ((sock = accept(chosen_listen_sock, NULL, NULL)) < 0) {
+ if ((sock = accept(chosen_listen_sock,
+ (struct sockaddr *)&addr, &addrlen)) < 0) {
rfbLogPerror("rfbCheckFds: accept");
return FALSE;
}
- return rfbNewConnectionFromSock(rfbScreen, sock);
+ if(!rfbSetNonBlocking(sock)) {
+ closesocket(sock);
+ return FALSE;
+ }
+
+ if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
+ (char *)&one, sizeof(one)) < 0) {
+ rfbLogPerror("rfbCheckFds: setsockopt failed: can't set TCP_NODELAY flag, non TCP socket?");
+ }
+
+#ifdef USE_LIBWRAP
+ if(!hosts_ctl("vnc",STRING_UNKNOWN,inet_ntoa(addr.sin_addr),
+ STRING_UNKNOWN)) {
+ rfbLog("Rejected connection from client %s\n",
+ inet_ntoa(addr.sin_addr));
+ closesocket(sock);
+ return FALSE;
+ }
+#endif
+
+#ifdef LIBVNCSERVER_IPv6
+ {
+ char host[1024];
+ if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) {
+ rfbLogPerror("rfbProcessNewConnection: error in getnameinfo");
+ }
+ rfbLog("Got connection from client %s\n", host);
+ }
+#else
+ rfbLog("Got connection from client %s\n", inet_ntoa(addr.sin_addr));
+#endif
+
+ rfbNewClient(rfbScreen,sock);
+
+ return TRUE;
}

View File

@ -1 +1,2 @@
remove-systemd-socket-activation.patch
tls-auth-pluging.patch tls-auth-pluging.patch

View File

@ -1,14 +1,14 @@
Index: vnc/libvncserver/auth.c Index: vnc/libvncserver/auth.c
=================================================================== ===================================================================
@@ -270,8 +270,9 @@ @@ -300,8 +300,9 @@
int32_t securityType = rfbSecTypeInvalid; int32_t securityType = rfbSecTypeInvalid;
if (!cl->screen->authPasswdData || cl->reverseConnection) { if (!cl->screen->authPasswdData || cl->reverseConnection) {
- /* chk if this condition is valid or not. */ - /* chk if this condition is valid or not. */
- securityType = rfbSecTypeNone; - securityType = rfbSecTypeNone;
+ /* chk if this condition is valid or not. */ + /* chk if this condition is valid or not. */
+ /* we disable anonymous auth */ + /* we disable anonymous auth */
+ // securityType = rfbSecTypeNone; + // securityType = rfbSecTypeNone;
} else if (cl->screen->authPasswdData) { } else if (cl->screen->authPasswdData) {
securityType = rfbSecTypeVncAuth; securityType = rfbSecTypeVncAuth;
} }
@ -17,29 +17,28 @@ Index: vnc/libvncserver/sockets.c
=================================================================== ===================================================================
--- vnc.orig/libvncserver/sockets.c 2011-01-20 16:42:41.000000000 +0100 --- vnc.orig/libvncserver/sockets.c 2011-01-20 16:42:41.000000000 +0100
+++ vnc/libvncserver/sockets.c 2011-01-21 10:20:03.000000000 +0100 +++ vnc/libvncserver/sockets.c 2011-01-21 10:20:03.000000000 +0100
@@ -454,8 +454,12 @@ @@ -613,7 +613,11 @@ rfbReadExactTimeout(rfbClientPtr cl, char* buf, int len, int timeout)
fd_set fds; n = read(sock, buf, len);
struct timeval tv; }
#else
+
while (len > 0) {
- n = read(sock, buf, len); - n = read(sock, buf, len);
+ if (cl->sock_read_fn) + if (cl->sock_read_fn) {
+ n = cl->sock_read_fn(cl, buf, len); + n = cl->sock_read_fn(cl, buf, len);
+ else + } else {
+ n = read(sock, buf, len); + n = read(sock, buf, len);
+ }
#endif
if (n > 0) { if (n > 0) {
@@ -801,7 +805,11 @@ rfbWriteExact(rfbClientPtr cl,
@@ -538,7 +542,10 @@ n = rfbssl_write(cl, buf, len);
else
LOCK(cl->outputMutex); #endif
while (len > 0) { + if (cl->sock_write_fn) {
- n = write(sock, buf, len);
+ if (cl->sock_write_fn)
+ n = cl->sock_write_fn(cl, buf, len); + n = cl->sock_write_fn(cl, buf, len);
+ else + } else {
+ n = write(sock, buf, len); n = write(sock, buf, len);
+ }
if (n > 0) { if (n > 0) {

View File

@ -26,6 +26,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#include <rfb/rfb.h> #include <rfb/rfb.h>
@ -39,7 +42,6 @@
#include <locale.h> #include <locale.h>
#include "vncterm.h" #include "vncterm.h"
#include "glyphs.h"
#include <gnutls/gnutls.h> #include <gnutls/gnutls.h>
#include <gnutls/x509.h> #include <gnutls/x509.h>
@ -50,8 +52,17 @@
char *auth_path = "/"; char *auth_path = "/";
char *auth_perm = "Sys.Console"; char *auth_perm = "Sys.Console";
uint16_t screen_width = 744;
uint16_t screen_height = 400;
int use_x509 = 1; int use_x509 = 1;
extern int wcwidth (wchar_t wc);
unsigned char *fontdata;
#define FONTFILE "/usr/share/vncterm/font.data"
#define GLYPHLINES 16
static char * static char *
urlencode(char *buf, const char *value) urlencode(char *buf, const char *value)
{ {
@ -169,7 +180,7 @@ static void vnc_debug_gnutls_log(int level, const char* str) {
} }
#endif #endif
#define DH_BITS 1024 #define DH_BITS 2048
static gnutls_dh_params_t dh_params; static gnutls_dh_params_t dh_params;
typedef struct { typedef struct {
@ -256,7 +267,11 @@ tls_initialize_anon_cred(void)
return NULL; return NULL;
} }
#if GNUTLS_VERSION_NUMBER >= 0x030506
gnutls_anon_set_server_known_dh_params(anon_cred, GNUTLS_SEC_PARAM_MEDIUM);
#else
gnutls_anon_set_server_dh_params(anon_cred, dh_params); gnutls_anon_set_server_dh_params(anon_cred, dh_params);
#endif
return anon_cred; return anon_cred;
} }
@ -290,8 +305,13 @@ tls_initialize_x509_cred(void)
gnutls_certificate_free_credentials(x509_cred); gnutls_certificate_free_credentials(x509_cred);
return NULL; return NULL;
} }
#if GNUTLS_VERSION_NUMBER >= 0x030506
/* only available since GnuTLS 3.5.6, on previous versions see
* gnutls_certificate_set_dh_params(). */
gnutls_certificate_set_known_dh_params(x509_cred, GNUTLS_SEC_PARAM_MEDIUM);
#else
gnutls_certificate_set_dh_params (x509_cred, dh_params); gnutls_certificate_set_dh_params (x509_cred, dh_params);
#endif
return x509_cred; return x509_cred;
} }
@ -485,42 +505,10 @@ rfbVncAuthVencrypt(rfbClientPtr cl)
return; return;
} }
/* optimize for speed */ static const char *priority_str_x509 = "NORMAL";
static const int cipher_priority_performance[] = { static const char *priority_str_anon = "NORMAL:+ANON-ECDH:+ANON-DH";
GNUTLS_CIPHER_ARCFOUR_128, if ((ret = gnutls_priority_set_direct(sd->session, use_x509 ? priority_str_x509 : priority_str_anon, NULL)) < 0) {
GNUTLS_CIPHER_AES_128_CBC, rfbLog("gnutls_priority_set_direct failed: %s\n", gnutls_strerror(ret));
GNUTLS_CIPHER_3DES_CBC, 0
};
if ((ret = gnutls_cipher_set_priority(sd->session, cipher_priority_performance)) < 0) {
rfbLog("gnutls_cipher_set_priority failed: %s\n", gnutls_strerror(ret));
sd->session = NULL;
rfbCloseClient(cl);
return;
}
static const int kx_anon[] = {GNUTLS_KX_ANON_DH, 0};
static const int kx_x509[] = {GNUTLS_KX_DHE_DSS, GNUTLS_KX_RSA, GNUTLS_KX_DHE_RSA, GNUTLS_KX_SRP, 0};
if ((ret = gnutls_kx_set_priority(sd->session, use_x509 ? kx_x509 : kx_anon)) < 0) {
rfbLog("gnutls_kx_set_priority failed: %s\n", gnutls_strerror(ret));
sd->session = NULL;
rfbCloseClient(cl);
return;
}
static const int cert_type_priority[] = { GNUTLS_CRT_X509, 0 };
if ((ret = gnutls_certificate_type_set_priority(sd->session, cert_type_priority)) < 0) {
rfbLog("gnutls_certificate_type_set_priority failed: %s\n",
gnutls_strerror(ret));
sd->session = NULL;
rfbCloseClient(cl);
return;
}
static const int protocol_priority[]= { GNUTLS_TLS1_1, GNUTLS_TLS1_0, GNUTLS_SSL3, 0 };
if ((ret = gnutls_protocol_set_priority(sd->session, protocol_priority)) < 0) {
rfbLog("gnutls_protocol_set_priority failed: %s\n",
gnutls_strerror(ret));
sd->session = NULL; sd->session = NULL;
rfbCloseClient(cl); rfbCloseClient(cl);
return; return;
@ -649,21 +637,16 @@ ucs2_to_utf8 (unicode c, char *out)
static void static void
rfb_draw_char (rfbScreenInfoPtr rfbScreen, int x, int y, rfb_draw_char (rfbScreenInfoPtr rfbScreen, int x, int y,
unsigned short c, rfbPixel col) unicode c, rfbPixel col, short width)
{ {
if (c > vt_font_size) {
rfbLog ("undefined font glyph %d\n", c);
return;
}
int i,j; int i,j;
unsigned char *data= vt_font_data + c*16; unsigned char *data= fontdata + c*(GLYPHLINES*2);
unsigned char d=*data; unsigned char d=*data;
int rowstride=rfbScreen->paddedWidthInBytes; int rowstride=rfbScreen->paddedWidthInBytes;
char *colour=(char*)&col; char *colour=(char*)&col;
for(j = 0; j < 16; j++) { for(j = 0; j < GLYPHLINES; j++) {
for(i = 0; i < 8; i++) { for(i = 0; i < 8*width; i++) {
if ((i&7) == 0) { if ((i&7) == 0) {
d=*data; d=*data;
data++; data++;
@ -676,13 +659,16 @@ rfb_draw_char (rfbScreenInfoPtr rfbScreen, int x, int y,
} }
static void static void
draw_char_at (vncTerm *vt, int x, int y, unicode ch, TextAttributes attrib) draw_char_at (vncTerm *vt, int x, int y, unicode ch, TextAttributes attrib, short width, unicode combiningglyph)
{ {
if (x < 0 || y < 0 || x >= vt->width || y >= vt->height) { return; } if (x < 0 || y < 0 || x >= vt->width || y >= vt->height) { return; }
// non printable character
if (width < 1) return;
int rx = x*8; int rx = x*8;
int ry = y*16; int ry = y*16;
int rxe = x*8+8; int rxe = x*8+8*width;
int rye = y*16+16; int rye = y*16+16;
int fg, bg; int fg, bg;
@ -695,8 +681,6 @@ draw_char_at (vncTerm *vt, int x, int y, unicode ch, TextAttributes attrib)
fg = attrib.fgcol; fg = attrib.fgcol;
} }
int ec = vt_fontmap[ch];
rfbFillRect (vt->screen, rx, ry, rxe, rye, bg); rfbFillRect (vt->screen, rx, ry, rxe, rye, bg);
if (attrib.bold) { if (attrib.bold) {
@ -705,7 +689,11 @@ draw_char_at (vncTerm *vt, int x, int y, unicode ch, TextAttributes attrib)
// unsuported attributes = (attrib.blink || attrib.unvisible) // unsuported attributes = (attrib.blink || attrib.unvisible)
rfb_draw_char (vt->screen, rx, ry, ec, fg); rfb_draw_char (vt->screen, rx, ry, ch, fg, width);
if (combiningglyph) {
rfb_draw_char (vt->screen, rx, ry, combiningglyph, fg, 1);
}
if (attrib.uline) { if (attrib.uline) {
rfbDrawLine (vt->screen, rx, ry + 14, rxe, ry + 14, fg); rfbDrawLine (vt->screen, rx, ry + 14, rxe, ry + 14, fg);
@ -727,7 +715,7 @@ vncterm_update_xy (vncTerm *vt, int x, int y)
} }
if (y2 < vt->height) { if (y2 < vt->height) {
TextCell *c = &vt->cells[y1 * vt->width + x]; TextCell *c = &vt->cells[y1 * vt->width + x];
draw_char_at (vt, x, y2, c->ch, c->attrib); draw_char_at (vt, x, y2, c->ch, c->attrib, c->width, c->combiningglyph);
} }
} }
@ -747,8 +735,10 @@ vncterm_clear_xy (vncTerm *vt, int x, int y)
c->attrib = vt->default_attrib; c->attrib = vt->default_attrib;
c->attrib.fgcol = vt->cur_attrib.fgcol; c->attrib.fgcol = vt->cur_attrib.fgcol;
c->attrib.bgcol = vt->cur_attrib.bgcol; c->attrib.bgcol = vt->cur_attrib.bgcol;
c->width = 1;
c->combiningglyph = 0;
draw_char_at (vt, x, y, c->ch, c->attrib); draw_char_at (vt, x, y, c->ch, c->attrib, c->width, c->combiningglyph);
} }
} }
@ -773,9 +763,9 @@ vncterm_show_cursor (vncTerm *vt, int show)
if (show) { if (show) {
TextAttributes attrib = vt->default_attrib; TextAttributes attrib = vt->default_attrib;
attrib.invers = !(attrib.invers); /* invert fg and bg */ attrib.invers = !(attrib.invers); /* invert fg and bg */
draw_char_at (vt, x, y, c->ch, attrib); draw_char_at (vt, x, y, c->ch, attrib, c->width, c->combiningglyph);
} else { } else {
draw_char_at (vt, x, y, c->ch, c->attrib); draw_char_at (vt, x, y, c->ch, c->attrib, c->width, c->combiningglyph);
} }
} }
} }
@ -791,8 +781,8 @@ vncterm_refresh (vncTerm *vt)
for(y = 0; y < vt->height; y++) { for(y = 0; y < vt->height; y++) {
TextCell *c = vt->cells + y1 * vt->width; TextCell *c = vt->cells + y1 * vt->width;
for(x = 0; x < vt->width; x++) { for(x = 0; x < vt->width; x++) {
draw_char_at (vt, x, y, c->ch, c->attrib); draw_char_at (vt, x, y, c->ch, c->attrib, c->width, c->combiningglyph);
c++; c += c->width;
} }
if (++y1 == vt->total_height) if (++y1 == vt->total_height)
y1 = 0; y1 = 0;
@ -841,6 +831,8 @@ vncterm_scroll_down (vncTerm *vt, int top, int bottom, int lines)
for(j = 0; j < vt->width; j++) { for(j = 0; j < vt->width; j++) {
c->attrib = vt->default_attrib; c->attrib = vt->default_attrib;
c->ch = ' '; c->ch = ' ';
c->width = 1;
c->combiningglyph = 0;
c++; c++;
} }
} }
@ -890,6 +882,8 @@ vncterm_scroll_up (vncTerm *vt, int top, int bottom, int lines, int moveattr)
for(j = 0; j < vt->width; j++) { for(j = 0; j < vt->width; j++) {
c->attrib = vt->default_attrib; c->attrib = vt->default_attrib;
c->ch = ' '; c->ch = ' ';
c->width = 1;
c->combiningglyph = 0;
c++; c++;
} }
} }
@ -974,6 +968,8 @@ vncterm_put_lf (vncTerm *vt)
int x; int x;
for (x = 0; x < vt->width; x++) { for (x = 0; x < vt->width; x++) {
c->ch = ' '; c->ch = ' ';
c->width = 1;
c->combiningglyph = 0;
c->attrib = vt->default_attrib; c->attrib = vt->default_attrib;
c++; c++;
} }
@ -1196,9 +1192,7 @@ vncterm_gotoxy (vncTerm *vt, int x, int y)
if (x < 0) { if (x < 0) {
x = 0; x = 0;
} } else if (x >= vt->width) {
if (x >= vt->width) {
x = vt->width - 1; x = vt->width - 1;
} }
@ -1206,9 +1200,7 @@ vncterm_gotoxy (vncTerm *vt, int x, int y)
if (y < 0) { if (y < 0) {
y = 0; y = 0;
} } else if (y >= vt->height) {
if (y >= vt->height) {
y = vt->height - 1; y = vt->height - 1;
} }
@ -1377,6 +1369,7 @@ vncterm_putchar (vncTerm *vt, unicode ch)
} }
break; break;
} else if (ch == ';') { } else if (ch == ';') {
vt->esc_has_par = 1;
vt->esc_count++; vt->esc_count++;
break; break;
} else { } else {
@ -1427,10 +1420,7 @@ vncterm_putchar (vncTerm *vt, unicode ch)
if (vt->esc_buf[0] == 0) { if (vt->esc_buf[0] == 0) {
vt->esc_buf[0] = 1; vt->esc_buf[0] = 1;
} }
vt->cy -= vt->esc_buf[0]; vncterm_gotoxy (vt, vt->cx, vt->cy - vt->esc_buf[0]);
if (vt->cy < 0) {
vt->cy = 0;
}
break; break;
case 'B': case 'B':
case 'e': case 'e':
@ -1438,10 +1428,7 @@ vncterm_putchar (vncTerm *vt, unicode ch)
if (vt->esc_buf[0] == 0) { if (vt->esc_buf[0] == 0) {
vt->esc_buf[0] = 1; vt->esc_buf[0] = 1;
} }
vt->cy += vt->esc_buf[0]; vncterm_gotoxy (vt, vt->cx, vt->cy + vt->esc_buf[0]);
if (vt->cy >= vt->height) {
vt->cy = vt->height - 1;
}
break; break;
case 'C': case 'C':
case 'a': case 'a':
@ -1449,20 +1436,14 @@ vncterm_putchar (vncTerm *vt, unicode ch)
if (vt->esc_buf[0] == 0) { if (vt->esc_buf[0] == 0) {
vt->esc_buf[0] = 1; vt->esc_buf[0] = 1;
} }
vt->cx += vt->esc_buf[0]; vncterm_gotoxy (vt, vt->cx + vt->esc_buf[0], vt->cy);
if (vt->cx >= vt->width) {
vt->cx = vt->width - 1;
}
break; break;
case 'D': case 'D':
/* move cursor left */ /* move cursor left */
if (vt->esc_buf[0] == 0) { if (vt->esc_buf[0] == 0) {
vt->esc_buf[0] = 1; vt->esc_buf[0] = 1;
} }
vt->cx -= vt->esc_buf[0]; vncterm_gotoxy (vt, vt->cx - vt->esc_buf[0], vt->cy);
if (vt->cx < 0) {
vt->cx = 0;
}
break; break;
case 'G': case 'G':
case '`': case '`':
@ -1584,6 +1565,8 @@ vncterm_putchar (vncTerm *vt, unicode ch)
*dst = *src; *dst = *src;
vncterm_update_xy (vt, x + c, vt->cy); vncterm_update_xy (vt, x + c, vt->cy);
src->ch = ' '; src->ch = ' ';
src->width = 1;
src->combiningglyph = 0;
src->attrib = vt->default_attrib; src->attrib = vt->default_attrib;
vncterm_update_xy (vt, x, vt->cy); vncterm_update_xy (vt, x, vt->cy);
} }
@ -1622,6 +1605,8 @@ vncterm_putchar (vncTerm *vt, unicode ch)
*dst = *src; *dst = *src;
vncterm_update_xy (vt, x + c, vt->cy); vncterm_update_xy (vt, x + c, vt->cy);
src->ch = ' '; src->ch = ' ';
src->width = 1;
src->combiningglyph = 0;
src->attrib = vt->cur_attrib; src->attrib = vt->cur_attrib;
vncterm_update_xy (vt, x, vt->cy); vncterm_update_xy (vt, x, vt->cy);
} }
@ -1777,11 +1762,25 @@ vncterm_putchar (vncTerm *vt, unicode ch)
} }
int y1 = (vt->y_base + vt->cy) % vt->total_height; int y1 = (vt->y_base + vt->cy) % vt->total_height;
TextCell *c = &vt->cells[y1*vt->width + vt->cx]; int width = wcwidth(ch);
c->attrib = vt->cur_attrib; if (width > 0) {
c->ch = ch; // normal/wide character
vncterm_update_xy (vt, vt->cx, vt->cy); TextCell *c = &vt->cells[y1*vt->width + vt->cx];
vt->cx++; c->attrib = vt->cur_attrib;
c->ch = ch;
c->width = width;
c->combiningglyph = 0;
vncterm_update_xy (vt, vt->cx, vt->cy);
vt->cx += width;
} else if (width == 0) {
// combiningglyph
TextCell *c = &vt->cells[y1*vt->width + vt->cx - 1];
c->attrib = vt->cur_attrib;
c->combiningglyph = ch;
vncterm_update_xy (vt, vt->cx - 1, vt->cy);
} else {
// non printable character, so we do not save them
}
break; break;
} }
break; break;
@ -1812,7 +1811,11 @@ vncterm_puts (vncTerm *vt, const char *buf, int len)
vt->utf_char = (vt->utf_char << 6) | (c & 0x3f); vt->utf_char = (vt->utf_char << 6) | (c & 0x3f);
vt->utf_count--; vt->utf_count--;
if (vt->utf_count == 0) { if (vt->utf_count == 0) {
tc = vt->utf_char; if (vt->utf_char <= USHRT_MAX) {
tc = vt->utf_char;
} else {
tc = 0;
}
} else { } else {
continue; continue;
} }
@ -2198,6 +2201,63 @@ new_client (rfbClientPtr client)
static char *vncticket = NULL; static char *vncticket = NULL;
static void
MakeRichCursor(rfbScreenInfoPtr rfbScreen)
{
int w = 16,
h = 16;
rfbCursorPtr c = rfbScreen->cursor;
char bitmap[] =
" "
" x "
" xx "
" xxx "
" xxxx "
" xxxxx "
" xxxxxx "
" xxxxxxx "
" xxxxxxxx "
" xxxxxxxxx "
" xxxxxxxxxx "
" xxxx "
" xxx "
" xx "
" x "
" ";
char edge[] =
" "
" x "
" xx "
" x x "
" x x "
" x x "
" x x "
" x x "
" x x "
" x x "
" x xxxxxx "
" x x "
" x x "
" xx "
" x "
" ";
c = rfbScreen->cursor = rfbMakeXCursor(w,h,bitmap,bitmap);
c->richSource = (unsigned char*)calloc(w*h, 1);
c->cleanupRichSource = TRUE;
for(int j=0;j<h;j++) {
for(int i=0;i<w;i++) {
unsigned int pos = j*w+i;
if (edge[pos] == 'x') {
c->richSource[pos] = 15; // white
} else {
c->richSource[pos] = 0; // black
}
}
}
}
vncTerm * vncTerm *
create_vncterm (int argc, char** argv, int maxx, int maxy) create_vncterm (int argc, char** argv, int maxx, int maxy)
{ {
@ -2205,6 +2265,7 @@ create_vncterm (int argc, char** argv, int maxx, int maxy)
rfbScreenInfoPtr screen = rfbGetScreen (&argc, argv, maxx, maxy, 8, 1, 1); rfbScreenInfoPtr screen = rfbGetScreen (&argc, argv, maxx, maxy, 8, 1, 1);
screen->frameBuffer=(char*)calloc(maxx*maxy, 1); screen->frameBuffer=(char*)calloc(maxx*maxy, 1);
MakeRichCursor(screen);
char **passwds = calloc(sizeof(char**), 2); char **passwds = calloc(sizeof(char**), 2);
@ -2297,6 +2358,8 @@ main (int argc, char** argv)
int i; int i;
char **cmdargv = NULL; char **cmdargv = NULL;
char *command = "/bin/bash"; // execute normal shell as default char *command = "/bin/bash"; // execute normal shell as default
int fontfd;
struct stat sb;
int pid; int pid;
int master; int master;
char ptyname[1024]; char ptyname[1024];
@ -2304,6 +2367,8 @@ main (int argc, char** argv)
struct timeval tv, tv1; struct timeval tv, tv1;
time_t elapsed, cur_time; time_t elapsed, cur_time;
struct winsize dimensions; struct winsize dimensions;
unsigned long width = 0;
unsigned long height = 0;
if (gnutls_global_init () < 0) { if (gnutls_global_init () < 0) {
fprintf(stderr, "gnutls_global_init failed\n"); fprintf(stderr, "gnutls_global_init failed\n");
@ -2343,6 +2408,22 @@ main (int argc, char** argv)
CHECK_ARGC (argc, argv, i); CHECK_ARGC (argc, argv, i);
auth_perm = argv[i+1]; auth_perm = argv[i+1];
rfbPurgeArguments(&argc, &i, 2, argv); i--; rfbPurgeArguments(&argc, &i, 2, argv); i--;
} else if (!strcmp (argv[i], "-width")) {
CHECK_ARGC (argc, argv, i);
errno = 0;
width = strtoul(argv[i+1], NULL, 10);
if (errno == 0 && width >= 16 && width < 0xFFFF) {
screen_width = width;
}
rfbPurgeArguments(&argc, &i, 2, argv); i--;
} else if (!strcmp (argv[i], "-height")) {
CHECK_ARGC (argc, argv, i);
errno = 0;
height = strtoul(argv[i+1], NULL, 10);
if (errno == 0 && height >= 32 && height < 0xFFFF) {
screen_height = height;
}
rfbPurgeArguments(&argc, &i, 2, argv); i--;
} else if (!strcmp (argv[i], "-notls")) { } else if (!strcmp (argv[i], "-notls")) {
rfbPurgeArguments(&argc, &i, 1, argv); i--; rfbPurgeArguments(&argc, &i, 1, argv); i--;
if ((vncticket = getenv("PVE_VNC_TICKET")) == NULL) { if ((vncticket = getenv("PVE_VNC_TICKET")) == NULL) {
@ -2362,7 +2443,24 @@ main (int argc, char** argv)
rfbLogEnable (0); rfbLogEnable (0);
#endif #endif
vncTerm *vt = create_vncterm (argc, argv, 745, 400); // mmap font file
fontfd = open(FONTFILE, O_RDONLY);
if (fontfd == -1) {
perror("Error opening Fontfile 'FONTFILE'");
exit (-1);
}
if (fstat(fontfd, &sb) == -1) {
perror("Stat on 'FONTFILE' failed");
exit (-1);
}
fontdata = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fontfd, 0);
if (fontdata == MAP_FAILED) {
perror("Could not mmap 'FONTFILE'");
exit (-1);
}
close(fontfd);
vncTerm *vt = create_vncterm (argc, argv, screen_width, screen_height);
setlocale(LC_ALL, ""); // set from environment setlocale(LC_ALL, ""); // set from environment
@ -2462,9 +2560,12 @@ main (int argc, char** argv)
} }
} }
rfbScreenCleanup(vt->screen);
kill (pid, 9); kill (pid, 9);
int status; int status;
waitpid(pid, &status, 0); waitpid(pid, &status, 0);
munmap(fontdata, sb.st_size);
exit (0); exit (0);
} }

View File

@ -17,6 +17,8 @@ typedef struct TextAttributes {
typedef struct TextCell { typedef struct TextCell {
unicode ch; unicode ch;
unicode combiningglyph;
short width;
TextAttributes attrib; TextAttributes attrib;
} TextCell; } TextCell;
@ -48,19 +50,19 @@ typedef struct vncTerm {
// cursor // cursor
TextAttributes cur_attrib; TextAttributes cur_attrib;
TextAttributes cur_attrib_saved; TextAttributes cur_attrib_saved;
int tty_state; // 0 - normal, 1 - ESC, 2 - CSI unsigned int tty_state; // 0 - normal, 1 - ESC, 2 - CSI
int cx; // cursor x position int cx; // cursor x position
int cy; // cursor y position int cy; // cursor y position
int cx_saved; // saved cursor x position int cx_saved; // saved cursor x position
int cy_saved; // saved cursor y position int cy_saved; // saved cursor y position
int esc_buf[MAX_ESC_PARAMS]; unsigned int esc_buf[MAX_ESC_PARAMS];
int esc_count; unsigned int esc_count;
int esc_ques; unsigned int esc_ques;
int esc_has_par; unsigned int esc_has_par;
char osc_textbuf[4096]; char osc_textbuf[4096];
char osc_cmd; char osc_cmd;
int region_top; unsigned int region_top;
int region_bottom; unsigned int region_bottom;
unsigned int charset:1; // G0 or G1 unsigned int charset:1; // G0 or G1
unsigned int charset_saved:1; // G0 or G1 unsigned int charset_saved:1; // G0 or G1

4235
wchardata.c Normal file

File diff suppressed because it is too large Load Diff