diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..0a80fdce31f59c062e2abba28776e9521eddff30 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.gz filter=lfs diff=lfs merge=lfs -text diff --git a/.lfsconfig b/.lfsconfig new file mode 100644 index 0000000000000000000000000000000000000000..94ee72a5fddedece5629fb1adc49b56eead15521 --- /dev/null +++ b/.lfsconfig @@ -0,0 +1,2 @@ +[lfs] + url = https://artlfs.openeuler.openatom.cn/src-openEuler/tigervnc diff --git a/0001-Fix-some-translations-of-start-menu.patch b/0001-Fix-some-translations-of-start-menu.patch deleted file mode 100644 index 89909fe9eab47fcad66ba085fe0bc1958c764281..0000000000000000000000000000000000000000 --- a/0001-Fix-some-translations-of-start-menu.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 8c41423d0da811043b2b6f7c1d0f01030e9d5a98 Mon Sep 17 00:00:00 2001 -From: longcheng -Date: Wed, 16 Mar 2022 19:51:37 +0800 -Subject: [PATCH] Fix some translations of start menu - ---- - po/zh_CN.po | 18 +++++++++++++----- - 1 file changed, 13 insertions(+), 5 deletions(-) - -diff --git a/po/zh_CN.po b/po/zh_CN.po -index d22ebb5..7e172a2 100644 ---- a/po/zh_CN.po -+++ b/po/zh_CN.po -@@ -449,7 +449,7 @@ msgstr "连接信息...(&I)" - #: vncviewer/Viewport.cxx:746 - msgctxt "ContextMenu|" - msgid "About &TigerVNC viewer..." --msgstr "关于 &TigerVNC 查看器..." -+msgstr "关于 &VNC远程桌面客户端..." - - #: vncviewer/Viewport.cxx:749 - msgctxt "ContextMenu|" -@@ -566,14 +566,14 @@ msgid "" - "Copyright (C) 1999-%d TigerVNC Team and many others (see README.txt)\n" - "See http://www.tigervnc.org for information on TigerVNC." - msgstr "" --"TigerVNC 查看器 %d 位 v%s\n" -+"VNC远程桌面客户端 %d 位 v%s\n" - "构建于:%s\n" - "版权所有 1999-%d TigerVNC 团队及众多开发者(参见 README.txt)\n" - "访问 http://www.tigervnc.org 以获取更多关于 TigerVNC 的信息。" - - #: vncviewer/vncviewer.cxx:127 - msgid "About TigerVNC Viewer" --msgstr "关于 TigerVNC 查看器" -+msgstr "关于VNC远程桌面客户端" - - #: vncviewer/vncviewer.cxx:140 - msgid "Internal FLTK error. Exiting." -@@ -582,7 +582,7 @@ msgstr "FLTK 内部错误。现在将退出。" - #: vncviewer/vncviewer.cxx:158 vncviewer/vncviewer.cxx:170 - #, c-format - msgid "Error starting new TigerVNC Viewer: %s" --msgstr "启动 TigerVNC 查看器出错:%s" -+msgstr "启动VNC远程桌面客户端:%s" - - #: vncviewer/vncviewer.cxx:179 - #, c-format -@@ -591,7 +591,7 @@ msgstr "收到终端信号 %d 。TigerVNC 现在将退出。" - - #: vncviewer/vncviewer.cxx:271 - msgid "TigerVNC Viewer" --msgstr "TigerVNC 查看器" -+msgstr "VNC远程桌面客户端" - - #: vncviewer/vncviewer.cxx:279 - msgid "No" -@@ -659,6 +659,14 @@ msgstr "-listen 及 -via 参数不兼容" - msgid "Listening on port %d" - msgstr "正在监听端口 %d" - -+#: vncviewer/vncviewer.desktop.in.in:4 -+msgid "Remote Desktop Viewer" -+msgstr "VNC远程桌面客户端" -+ -+#: vncviewer/vncviewer.desktop.in.in:5 -+msgid "Connect to VNC server and display remote desktop" -+msgstr "连接到VNC远程服务器并展示远程桌面" -+ - #~ msgid "Unknown encoding %d" - #~ msgstr "未知编码 %d" - --- -2.27.0 - diff --git a/fix-clang-build-error.patch b/fix-clang-build-error.patch deleted file mode 100644 index e35f5527c3dc2ef54cbe8c08c436af6f3dffcd13..0000000000000000000000000000000000000000 --- a/fix-clang-build-error.patch +++ /dev/null @@ -1,25 +0,0 @@ -From d8479c6d68c571d7080462258f70652573306434 Mon Sep 17 00:00:00 2001 -From: luofeng -Date: Mon, 4 Mar 2024 11:08:35 +0800 -Subject: [PATCH] support clang build - ---- - unix/xserver/mi/miinitext.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/unix/xserver/mi/miinitext.c b/unix/xserver/mi/miinitext.c -index 688beff..6379b17 100644 ---- a/unix/xserver/mi/miinitext.c -+++ b/unix/xserver/mi/miinitext.c -@@ -108,7 +108,7 @@ SOFTWARE. - #include "globals.h" - - #ifdef TIGERVNC --extern void vncExtensionInit(INITARGS); -+extern void vncExtensionInit(); - #endif - - /* List of built-in (statically linked) extensions */ --- -2.19.1 - diff --git a/tigervnc-xserver120.patch b/tigervnc-xserver120.patch deleted file mode 100644 index 524e460dd2ca3e38d9466eab0bcd418225767b68..0000000000000000000000000000000000000000 --- a/tigervnc-xserver120.patch +++ /dev/null @@ -1,91 +0,0 @@ -diff -up a/unix/xserver/configure.ac.xserver116-rebased a/unix/xserver/configure.ac ---- a/unix/xserver/configure.ac.xserver116-rebased 2016-09-29 13:14:45.595441590 +0200 -+++ a/unix/xserver/configure.ac 2016-09-29 13:14:45.631442006 +0200 -@@ -74,6 +74,7 @@ dnl forcing an entire recompile.x - AC_CONFIG_HEADERS(include/version-config.h) - - AM_PROG_AS -+AC_PROG_CXX - AC_PROG_LN_S - LT_PREREQ([2.2]) - LT_INIT([disable-static win32-dll]) -@@ -1863,6 +1864,10 @@ if test "x$XVFB" = xyes; then - AC_SUBST([XVFB_SYS_LIBS]) - fi - -+dnl Xvnc DDX -+AC_SUBST([XVNC_CPPFLAGS], ["-DHAVE_DIX_CONFIG_H $XSERVER_CFLAGS"]) -+AC_SUBST([XVNC_LIBS], ["$FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $DRI3_LIB $PRESENT_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $MAIN_LIB"]) -+AC_SUBST([XVNC_SYS_LIBS], ["$GLX_SYS_LIBS"]) - - dnl Xnest DDX - -@@ -1898,6 +1903,8 @@ if test "x$XORG" = xauto; then - fi - AC_MSG_RESULT([$XORG]) - -+AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version]) -+ - if test "x$XORG" = xyes; then - XORG_DDXINCS='-I$(top_srcdir)/hw/xfree86 -I$(top_srcdir)/hw/xfree86/include -I$(top_srcdir)/hw/xfree86/common' - XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os' -@@ -2116,7 +2123,6 @@ if test "x$XORG" = xyes; then - AC_DEFINE(XORG_SERVER, 1, [Building Xorg server]) - AC_DEFINE(XORGSERVER, 1, [Building Xorg server]) - AC_DEFINE(XFree86Server, 1, [Building XFree86 server]) -- AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version]) - AC_DEFINE(NEED_XF86_TYPES, 1, [Need XFree86 typedefs]) - AC_DEFINE(NEED_XF86_PROTOTYPES, 1, [Need XFree86 helper functions]) - AC_DEFINE(__XSERVERNAME__, "Xorg", [Name of X server]) -@@ -2691,6 +2697,7 @@ hw/dmx/Makefile - hw/dmx/man/Makefile - hw/vfb/Makefile - hw/vfb/man/Makefile -+hw/vnc/Makefile - hw/xnest/Makefile - hw/xnest/man/Makefile - hw/xwin/Makefile -diff -up a/unix/xserver/hw/Makefile.am.xserver116-rebased a/unix/xserver/hw/Makefile.am ---- a/unix/xserver/hw/Makefile.am.xserver116-rebased 2016-09-29 13:14:45.601441659 +0200 -+++ a/unix/xserver/hw/Makefile.am 2016-09-29 13:14:45.631442006 +0200 -@@ -38,7 +38,8 @@ SUBDIRS = \ - $(DMX_SUBDIRS) \ - $(KDRIVE_SUBDIRS) \ - $(XQUARTZ_SUBDIRS) \ -- $(XWAYLAND_SUBDIRS) -+ $(XWAYLAND_SUBDIRS) \ -+ vnc - - DIST_SUBDIRS = dmx xfree86 vfb xnest xwin xquartz kdrive xwayland - -diff --git a/unix/xserver/mi/miinitext.c a/unix/xserver/mi/miinitext.c -index 5596e21..003fc3c 100644 ---- a/unix/xserver/mi/miinitext.c -+++ a/unix/xserver/mi/miinitext.c -@@ -107,8 +107,15 @@ SOFTWARE. - #include "os.h" - #include "globals.h" - -+#ifdef TIGERVNC -+extern void vncExtensionInit(INITARGS); -+#endif -+ - /* List of built-in (statically linked) extensions */ - static const ExtensionModule staticExtensions[] = { -+#ifdef TIGERVNC -+ {vncExtensionInit, "VNC-EXTENSION", NULL}, -+#endif - {GEExtensionInit, "Generic Event Extension", &noGEExtension}, - {ShapeExtensionInit, "SHAPE", NULL}, - #ifdef MITSHM ---- a/unix/xserver/include/os.h~ 2016-10-03 09:07:29.000000000 +0200 -+++ a/unix/xserver/include/os.h 2016-10-03 14:13:00.013654506 +0200 -@@ -621,7 +621,7 @@ - extern _X_EXPORT void - LogClose(enum ExitCode error); - extern _X_EXPORT Bool --LogSetParameter(LogParameter param, int value); -+LogSetParameter(enum _LogParameter param, int value); - extern _X_EXPORT void - LogVWrite(int verb, const char *f, va_list args) - _X_ATTRIBUTE_PRINTF(2, 0); diff --git a/tigervnc.spec b/tigervnc.spec index 462b841a13bef1bead30f95927da01641816f048..5d8d1d34cf4139966d752b08a176c8cb372bdc01 100644 --- a/tigervnc.spec +++ b/tigervnc.spec @@ -1,11 +1,10 @@ %global _hardened_build 1 %global selinuxtype targeted %global modulename vncsession -%global __cmake_in_source_build 1 Name: tigervnc -Version: 1.13.1 -Release: 4 +Version: 1.15.0 +Release: 1 Summary: A TigerVNC remote display system License: GPL-2.0-or-later @@ -18,16 +17,17 @@ Source4: xvnc.service Source5: xvnc.socket Source6: HOWTO.md -Patch0001: tigervnc-xserver120.patch -Patch0002: 0001-Fix-some-translations-of-start-menu.patch -Patch0003: fix-clang-build-error.patch - BuildRequires: make gcc-c++ systemd cmake automake autoconf gettext gettext-autopoint pixman-devel fltk-devel >= 1.3.3 BuildRequires: libX11-devel libtool libxkbfile-devel libpciaccess-devel libXinerama-devel libXfont2-devel BuildRequires: libXext-devel xorg-x11-server-source libXi-devel libXdmcp-devel libxshmfence-devel BuildRequires: xorg-x11-xtrans-devel xorg-x11-util-macros xorg-x11-server-devel libXtst-devel libdrm-devel libXt-devel BuildRequires: openssl-devel mesa-libGL-devel freetype-devel desktop-file-utils java-devel jpackage-utils pam-devel gnutls-devel libjpeg-turbo-devel selinux-policy-devel BuildRequires: xorg-x11-font-utils libselinux-devel libXdamage-devel libXfixes-devel libXrandr-devel libXrender-devel zlib-devel +BuildRequires: pkgconfig(libavcodec) +BuildRequires: pkgconfig(libavutil) +BuildRequires: pkgconfig(libswscale) +BuildRequires: pkgconfig(libsystemd) +BuildRequires: pkgconfig(pwquality) Requires: hicolor-icon-theme @@ -95,15 +95,14 @@ This package contains license of the Tigervnc suite %setup -q cp -r /usr/share/xorg-x11-server-source/* unix/xserver -%patch -P0001 -p1 -b .xserver120-rebased pushd unix/xserver for all in `find . -type f -perm -001`; do chmod -x "$all" done +patch -p1 < ../xserver120.patch +sed -i 's@TIGERVNC_BUILDDIR=${top_builddir}/\.\./\.\.@TIGERVNC_BUILDDIR=${TIGERVNC_SRCDIR}/%{__cmake_builddir}@g' hw/vnc/Makefile.am popd -%patch -P0002 -p1 -%patch -P0003 -p1 %build export CFLAGS="$RPM_OPT_FLAGS -fpic" @@ -117,18 +116,13 @@ autoreconf -fiv %configure \ --disable-xorg --disable-xnest --disable-xvfb --disable-dmx --disable-xwin --disable-xephyr --disable-kdrive --disable-xwayland \ --with-pic --disable-static --with-default-font-path="catalogue:%{_sysconfdir}/X11/fontpath.d,built-ins" \ - --with-fontdir=%{_datadir}/X11/fonts --with-xkb-output=%{_localstatedir}/lib/xkb --enable-install-libxf86config \ + --with-xkb-output=%{_localstatedir}/lib/xkb \ --enable-glx --disable-dri --enable-dri2 --disable-dri3 --disable-unit-tests --disable-config-hal --disable-config-udev \ - --with-dri-driver-path=%{_libdir}/dri --without-dtrace --disable-devel-docs --disable-selective-werror + --without-dtrace --disable-devel-docs --disable-selective-werror %make_build popd -# Build icons -pushd media -make -popd - # SElinux pushd unix/vncserver/selinux make @@ -187,8 +181,7 @@ install -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/X11/xorg.conf.d/10-libvnc.c install -m 644 %{SOURCE6} %{buildroot}%{_docdir}/tigervnc/HOWTO.md %check -pushd tests -%make_build +pushd %{__cmake_builddir}/tests ./unit/conv ./unit/convertlf ./unit/hostport @@ -242,6 +235,9 @@ popd %{_mandir}/man8/* %changelog +* Sun Jul 20 2025 Funda Wang - 1.15.0-1 +- update to 1.15.0 + * Mon Dec 23 2024 xinghe - 1.13.1-4 - Type:bugfix - ID:NA diff --git a/v1.13.1.tar.gz b/v1.13.1.tar.gz deleted file mode 100644 index 0b075da7190352acbf10082af3d72b16f7879348..0000000000000000000000000000000000000000 Binary files a/v1.13.1.tar.gz and /dev/null differ diff --git a/v1.15.0.tar.gz b/v1.15.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..8d2b7a76ecb8bc905e84ed1b0fe9535fdb354663 --- /dev/null +++ b/v1.15.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7f231906801e89f09a212e86701f3df1722e36767d6055a4e619390570548537 +size 2126369 diff --git a/vncserver b/vncserver index ffb65f46bad1d178ea7f36aa947196c71ec47e0b..33c7862e5b20d89971fd0686501d16363f433b69 100644 --- a/vncserver +++ b/vncserver @@ -21,40 +21,40 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, # USA. # - + # # vncserver - wrapper script to start an X VNC server. # - + # First make sure we're operating in a sane environment. $exedir = ""; $slashndx = rindex($0, "/"); if($slashndx>=0) { $exedir = substr($0, 0, $slashndx+1); } - + &SanityCheck(); - + &NotifyAboutDeprecation(); - + # # Global variables. You may want to configure some of these for # your site # - + $geometry = "1024x768"; #$depth = 16; - + $vncUserDir = "$ENV{HOME}/.vnc"; $vncUserConfig = "$vncUserDir/config"; - + $vncSystemConfigDir = "/etc/tigervnc"; $vncSystemConfigDefaultsFile = "$vncSystemConfigDir/vncserver-config-defaults"; $vncSystemConfigMandatoryFile = "$vncSystemConfigDir/vncserver-config-mandatory"; - + $skipxstartup = 0; $xauthorityFile = "$ENV{XAUTHORITY}" || "$ENV{HOME}/.Xauthority"; - + $xstartupFile = $vncUserDir . "/xstartup"; $defaultXStartup = ("#!/bin/sh\n\n". @@ -68,7 +68,7 @@ $defaultXStartup "if [ -e /usr/bin/gnome-session ]; then\n". " vncserver -kill \$DISPLAY\n". "fi\n"); - + $defaultConfig = ("## Supported server options to pass to vncserver upon invocation can be listed\n". "## in this file. See the following manpages for more: vncserver(1) Xvnc(1).\n". @@ -79,25 +79,25 @@ $defaultConfig "# geometry=2000x1200\n". "# localhost\n". "# alwaysshared\n"); - + chop($host = `uname -n`); - + if (-d "/etc/X11/fontpath.d") { $fontPath = "catalogue:/etc/X11/fontpath.d"; } - + @fontpaths = ('/usr/share/X11/fonts', '/usr/share/fonts', '/usr/share/fonts/X11/'); if (! -l "/usr/lib/X11") {push(@fontpaths, '/usr/lib/X11/fonts');} if (! -l "/usr/X11") {push(@fontpaths, '/usr/X11/lib/X11/fonts');} if (! -l "/usr/X11R6") {push(@fontpaths, '/usr/X11R6/lib/X11/fonts');} push(@fontpaths, '/usr/share/fonts/default'); - + @fonttypes = ('misc', '75dpi', '100dpi', 'Speedo', 'Type1'); - + foreach $_fpath (@fontpaths) { foreach $_ftype (@fonttypes) { if (-f "$_fpath/$_ftype/fonts.dir") { @@ -107,32 +107,32 @@ foreach $_fpath (@fontpaths) { } } } - + if ($defFontPath) { if (substr($defFontPath, -1, 1) == ',') { chop $defFontPath; } } - + if ($fontPath eq "") { $fontPath = $defFontPath; } - + # Check command line options - + &ParseOptions("-geometry",1,"-depth",1,"-pixelformat",1,"-name",1,"-kill",1, "-help",0,"-h",0,"--help",0,"-fp",1,"-list",0,"-fg",0,"-autokill",0,"-noxstartup",0,"-xstartup",1); - + &Usage() if ($opt{'-help'} || $opt{'-h'} || $opt{'--help'}); - + &Kill() if ($opt{'-kill'}); - + &List() if ($opt{'-list'}); - + # Uncomment this line if you want default geometry, depth and pixelformat # to match the current X display: # &GetXDisplayDefaults(); - + if ($opt{'-geometry'}) { $geometry = $opt{'-geometry'}; } @@ -153,16 +153,16 @@ if ($opt{'-fp'}) { $fontPath = $opt{'-fp'}; $fpArgSpecified = 1; } - + &CheckGeometryAndDepth(); - + # Create the user's vnc directory if necessary. if (!(-e $vncUserDir)) { if (!mkdir($vncUserDir,0755)) { die "$prog: Could not create $vncUserDir.\n"; } } - + # Find display number. if ((@ARGV > 0) && ($ARGV[0] =~ /^:(\d+)$/)) { $displayNumber = $1; @@ -175,18 +175,18 @@ if ((@ARGV > 0) && ($ARGV[0] =~ /^:(\d+)$/)) { } else { $displayNumber = &GetDisplayNumber(); } - + $vncPort = 5900 + $displayNumber; - + if ($opt{'-name'}) { $desktopName = $opt{'-name'}; } else { $desktopName = "$host:$displayNumber ($ENV{USER})"; } - + my %default_opts; my %config; - + # We set some reasonable defaults. Config file settings # override these where present. $default_opts{desktop} = "edString($desktopName); @@ -198,13 +198,13 @@ $default_opts{rfbauth} = "$vncUserDir/passwd"; $default_opts{rfbport} = $vncPort; $default_opts{fp} = $fontPath if ($fontPath); $default_opts{pn} = ""; - + # Load user-overrideable system defaults LoadConfig($vncSystemConfigDefaultsFile); - + # Then the user's settings LoadConfig($vncUserConfig); - + # And then override anything set above if mandatory settings exist. # WARNING: "Mandatory" is used loosely here! As the man page says, # there is nothing stopping someone from EASILY subverting the @@ -213,17 +213,17 @@ LoadConfig($vncUserConfig); # hard force policy in a non-subvertible way would require major # development work that touches Xvnc itself. LoadConfig($vncSystemConfigMandatoryFile, 1); - + # # Check whether VNC authentication is enabled, and if so, prompt the user to # create a VNC password if they don't already have one. # - + $securityTypeArgSpecified = 0; $vncAuthEnabled = 0; $passwordArgSpecified = 0; @vncAuthStrings = ("vncauth", "tlsvnc", "x509vnc"); - + # ...first we check our configuration files' settings if ($config{'securitytypes'}) { $securityTypeArgSpecified = 1; @@ -233,7 +233,7 @@ if ($config{'securitytypes'}) { } } } - + # ...and finally we check CLI args, which in the case of the topic at # hand (VNC auth or not), override anything found in configuration files # (even so-called "mandatory" settings). @@ -259,7 +259,7 @@ for ($i = 0; $i < @ARGV; ++$i) { $passwordArgSpecified = 1; } } - + if ((!$securityTypeArgSpecified || $vncAuthEnabled) && !$passwordArgSpecified) { ($z,$z,$mode) = stat("$vncUserDir/passwd"); if (!(-e "$vncUserDir/passwd") || ($mode & 077)) { @@ -270,10 +270,10 @@ if ((!$securityTypeArgSpecified || $vncAuthEnabled) && !$passwordArgSpecified) { } } } - + $desktopLog = "$vncUserDir/$host:$displayNumber.log"; unlink($desktopLog); - + # Make an X server cookie and set up the Xauthority file # mcookie is a part of util-linux, usually only GNU/Linux systems have it. $cookie = `mcookie`; @@ -293,40 +293,40 @@ if ($cookie eq "") { $cookie .= sprintf("%02x", int(rand(256)) % 256); } } - + open(XAUTH, "|xauth -f $xauthorityFile source -"); print XAUTH "add $host:$displayNumber . $cookie\n"; print XAUTH "add $host/unix:$displayNumber . $cookie\n"; close(XAUTH); - + # Now start the X VNC Server - + # We build up our Xvnc command with options $cmd = $exedir."Xvnc :$displayNumber"; - + foreach my $k (sort keys %config) { $cmd .= " -$k $config{$k}"; delete $default_opts{$k}; # file options take precedence } - + foreach my $k (sort keys %default_opts) { $cmd .= " -$k $default_opts{$k}"; } - + # Add color database stuff here, e.g.: # $cmd .= " -co /usr/lib/X11/rgb"; - + foreach $arg (@ARGV) { $cmd .= " " . "edString($arg); } $cmd .= " >> " . "edString($desktopLog) . " 2>&1"; - + # Run $cmd and record the process ID. $pidFile = "$vncUserDir/$host:$displayNumber.pid"; system("$cmd & echo \$! >$pidFile"); - + # Give Xvnc a chance to start up - + sleep(3); if ($fontPath ne $defFontPath) { unless (kill 0, `cat $pidFile`) { @@ -354,9 +354,9 @@ unless (kill 0, `cat $pidFile`) { close(LOG); die "\n"; } - + warn "\nNew '$desktopName' desktop is $host:$displayNumber\n\n"; - + # Create the user's xstartup script if necessary. if (! $skipxstartup) { if (!(-e "$xstartupFile")) { @@ -367,7 +367,7 @@ if (! $skipxstartup) { chmod 0755, "$xstartupFile"; } } - + # Create the user's config file if necessary. if (!(-e "$vncUserDir/config")) { warn "Creating default config $vncUserDir/config\n"; @@ -376,16 +376,16 @@ if (!(-e "$vncUserDir/config")) { close(VNCUSERCONFIG); chmod 0644, "$vncUserDir/config"; } - + # Run the X startup script. if (! $skipxstartup) { warn "Starting applications specified in $xstartupFile\n"; } warn "Log file is $desktopLog\n\n"; - + # If the unix domain socket exists then use that (DISPLAY=:n) otherwise use # TCP (DISPLAY=host:n) - + if (-e "/tmp/.X11-unix/X$displayNumber" || -e "/usr/spool/sockets/X11/$displayNumber") { @@ -394,7 +394,7 @@ if (-e "/tmp/.X11-unix/X$displayNumber" || $ENV{DISPLAY}= "$host:$displayNumber"; } $ENV{VNCDESKTOP}= $desktopName; - + if ($opt{'-fg'}) { if (! $skipxstartup) { system("$xstartupFile >> " . "edString($desktopLog) . " 2>&1"); @@ -416,13 +416,13 @@ if ($opt{'-fg'}) { } } } - + exit; - + ############################################################################### # Functions ############################################################################### - + # # Populate the global %config hash with settings from a specified # vncserver configuration file if it exists @@ -434,7 +434,7 @@ exit; sub LoadConfig { local ($configFile, $warnoverride) = @_; local ($toggle) = undef; - + if (stat($configFile)) { if (open(IN, $configFile)) { while () { @@ -461,38 +461,38 @@ sub LoadConfig { } } } - + # # CheckGeometryAndDepth simply makes sure that the geometry and depth values # are sensible. # - + sub CheckGeometryAndDepth { if ($geometry =~ /^(\d+)x(\d+)$/) { $width = $1; $height = $2; - + if (($width<1) || ($height<1)) { die "$prog: geometry $geometry is invalid\n"; } - + $geometry = "${width}x$height"; } else { die "$prog: geometry $geometry is invalid\n"; } - + if ($depth && (($depth < 8) || ($depth > 32))) { die "Depth must be between 8 and 32\n"; } } - - + + # # GetDisplayNumber gets the lowest available display number. A display number # n is taken if something is listening on the VNC server port (5900+n) or the # X server port (6000+n). # - + sub GetDisplayNumber { foreach $n (1..99) { @@ -500,21 +500,21 @@ sub GetDisplayNumber return $n+0; # Bruce Mah's workaround for bug in perl 5.005_02 } } - + die "$prog: no free display number on $host.\n"; } - - + + # # CheckDisplayNumber checks if the given display number is available. A # display number n is taken if something is listening on the VNC server port # (5900+n) or the X server port (6000+n). # - + sub CheckDisplayNumber { local ($n) = @_; - + socket(S, $AF_INET, $SOCK_STREAM, 0) || die "$prog: socket failed: $!\n"; eval 'setsockopt(S, &SOL_SOCKET, &SO_REUSEADDR, pack("l", 1))'; if (!bind(S, pack('S n x12', $AF_INET, 6000 + $n))) { @@ -522,7 +522,7 @@ sub CheckDisplayNumber return 0; } close(S); - + socket(S, $AF_INET, $SOCK_STREAM, 0) || die "$prog: socket failed: $!\n"; eval 'setsockopt(S, &SOL_SOCKET, &SO_REUSEADDR, pack("l", 1))'; if (!bind(S, pack('S n x12', $AF_INET, 5900 + $n))) { @@ -530,30 +530,30 @@ sub CheckDisplayNumber return 0; } close(S); - + if (-e "/tmp/.X$n-lock") { warn "\nWarning: $host:$n is taken because of /tmp/.X$n-lock\n"; warn "Remove this file if there is no X server $host:$n\n"; return 0; } - + if (-e "/tmp/.X11-unix/X$n") { warn "\nWarning: $host:$n is taken because of /tmp/.X11-unix/X$n\n"; warn "Remove this file if there is no X server $host:$n\n"; return 0; } - + if (-e "/usr/spool/sockets/X11/$n") { warn("\nWarning: $host:$n is taken because of ". "/usr/spool/sockets/X11/$n\n"); warn "Remove this file if there is no X server $host:$n\n"; return 0; } - + return 1; } - - + + # # GetXDisplayDefaults uses xdpyinfo to find out the geometry, depth and pixel # format of the current X display being used. If successful, it sets the @@ -563,35 +563,35 @@ sub CheckDisplayNumber # translate pixels when the desktop is being viewed on this X display (for # TrueColor displays anyway). # - + sub GetXDisplayDefaults { local (@lines, @matchlines, $width, $height, $defaultVisualId, $i, $red, $green, $blue); - + $wmDecorationWidth = 4; # a guess at typical size for window manager $wmDecorationHeight = 24; # decoration size - + return if (!defined($ENV{DISPLAY})); - + @lines = `xdpyinfo 2>/dev/null`; - + return if ($? != 0); - + @matchlines = grep(/dimensions/, @lines); if (@matchlines) { ($width, $height) = ($matchlines[0] =~ /(\d+)x(\d+) pixels/); - + $width -= $wmDecorationWidth; $height -= $wmDecorationHeight; - + $geometry = "${width}x$height"; } - + @matchlines = grep(/default visual id/, @lines); if (@matchlines) { ($defaultVisualId) = ($matchlines[0] =~ /id:\s+(\S+)/); - + for ($i = 0; $i < @lines; $i++) { if ($lines[$i] =~ /^\s*visual id:\s+$defaultVisualId$/) { if (($lines[$i+1] !~ /TrueColor/) || @@ -603,18 +603,18 @@ sub GetXDisplayDefaults last; } } - + return if ($i >= @lines); - + ($depth) = ($lines[$i+2] =~ /depth:\s+(\d+)/); ($red,$green,$blue) = ($lines[$i+4] =~ /masks:\s+0x([0-9a-f]+), 0x([0-9a-f]+), 0x([0-9a-f]+)/); - + $red = hex($red); $green = hex($green); $blue = hex($blue); - + if ($red > $blue) { $red = int(log($red) / log(2)) - int(log($green) / log(2)); $green = int(log($green) / log(2)) - int(log($blue) / log(2)); @@ -628,41 +628,41 @@ sub GetXDisplayDefaults } } } - - + + # # quotedString returns a string which yields the original string when parsed # by a shell. # - + sub quotedString { local ($in) = @_; - + $in =~ s/\'/\'\"\'\"\'/g; - + return "'$in'"; } - - + + # # removeSlashes turns slashes into underscores for use as a file name. # - + sub removeSlashes { local ($in) = @_; - + $in =~ s|/|_|g; - + return "$in"; } - - + + # # Usage # - + sub Usage { die("\nusage: $prog [:] [-name ] [-depth ]\n". @@ -678,12 +678,12 @@ sub Usage " $prog -kill \n\n". " $prog -list\n\n"); } - - + + # # List # - + sub List { opendir(dir, $vncUserDir); @@ -703,16 +703,16 @@ sub List } exit; } - - + + # # Kill # - + sub Kill { $opt{'-kill'} =~ s/(:\d+)\.\d+$/$1/; # e.g. turn :1.0 into :1 - + if ($opt{'-kill'} =~ /^:\d+$/) { $pidFile = "$vncUserDir/$host$opt{'-kill'}.pid"; } else { @@ -722,16 +722,16 @@ sub Kill } $pidFile = "$vncUserDir/$opt{'-kill'}.pid"; } - + if (! -r $pidFile) { die "\nCan't find file $pidFile\n". "You'll have to kill the Xvnc process manually\n\n"; } - + $SIG{'HUP'} = 'IGNORE'; chop($pid = `cat $pidFile`); warn "Killing Xvnc process ID $pid\n"; - + if (kill 0, $pid) { system("kill $pid"); sleep(1); @@ -741,11 +741,11 @@ sub Kill print "to clean up the socket files.\n"; exit } - + } else { warn "Xvnc process ID $pid already killed\n"; $opt{'-kill'} =~ s/://; - + if (-e "/tmp/.X11-unix/X$opt{'-kill'}") { print "Xvnc did not appear to shut down cleanly."; print " Removing /tmp/.X11-unix/X$opt{'-kill'}\n"; @@ -757,33 +757,33 @@ sub Kill unlink "/tmp/.X$opt{'-kill'}-lock"; } } - + unlink $pidFile; exit; } - - + + # # ParseOptions takes a list of possible options and a boolean indicating # whether the option has a value following, and sets up an associative array # %opt of the values of the options given on the command line. It removes all # the arguments it uses from @ARGV and returns them in @optArgs. # - + sub ParseOptions { local (@optval) = @_; local ($opt, @opts, %valFollows, @newargs); - + while (@optval) { $opt = shift(@optval); push(@opts,$opt); $valFollows{$opt} = shift(@optval); } - + @optArgs = (); %opt = (); - + arg: while (defined($arg = shift(@ARGV))) { foreach $opt (@opts) { if ($arg eq $opt) { @@ -802,23 +802,23 @@ sub ParseOptions } push(@newargs,$arg); } - + @ARGV = @newargs; } - - + + # Routine to make sure we're operating in a sane environment. sub SanityCheck { local ($cmd); - + # Get the program name ($prog) = ($0 =~ m|([^/]+)$|); - + # # Check we have all the commands we'll need on the path. # - + cmd: foreach $cmd ("uname","xauth") { for (split(/:/,$ENV{PATH})) { @@ -828,7 +828,7 @@ sub SanityCheck } die "$prog: couldn't find \"$cmd\" on your PATH.\n"; } - + if($exedir eq "") { cmd2: foreach $cmd ("Xvnc","vncpasswd") { @@ -851,11 +851,11 @@ sub SanityCheck die "$prog: couldn't find \"$cmd\".\n"; } } - + if (!defined($ENV{HOME})) { die "$prog: The HOME environment variable is not set.\n"; } - + # # Find socket constants. 'use Socket' is a perl5-ism, so we wrap it in an # eval, and if it fails we try 'require "sys/socket.ph"'. If this fails, @@ -864,10 +864,10 @@ sub SanityCheck # for your platform by looking in /usr/include/sys/socket.h and related # files. # - + chop($os = `uname`); chop($osrev = `uname -r`); - + eval 'use Socket'; if ($@) { eval 'require "sys/socket.ph"'; @@ -888,7 +888,7 @@ sub SanityCheck $SOCK_STREAM = &SOCK_STREAM; } } - + sub NotifyAboutDeprecation { warn "\nWARNING: vncserver has been replaced by a systemd unit and is now considered deprecated and removed in upstream.\n";