summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt8
-rw-r--r--cmake/StaticBuild.cmake8
-rw-r--r--contrib/systemd/user/vncserver@.service26
-rwxr-xr-xunix/vncserver74
-rw-r--r--unix/vncserver.man8
-rw-r--r--unix/xserver/hw/vnc/Xvnc.man2
6 files changed, 109 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 08ef25cc..d788b602 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,12 +39,9 @@ if(MSVC)
message(FATAL_ERROR "TigerVNC cannot be built with Visual Studio. Please use MinGW")
endif()
-set(BUILD_TIMESTAMP "")
-execute_process(COMMAND "date" "+%Y-%m-%d %H:%M" OUTPUT_VARIABLE BUILD_TIMESTAMP)
-
if(NOT BUILD_TIMESTAMP)
set(BUILD_TIMESTAMP "")
-else()
+ execute_process(COMMAND "date" "+%Y-%m-%d %H:%M" OUTPUT_VARIABLE BUILD_TIMESTAMP)
string(REGEX REPLACE "\n" "" BUILD_TIMESTAMP ${BUILD_TIMESTAMP})
endif()
@@ -57,6 +54,7 @@ endif()
message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
message(STATUS "VERSION = ${VERSION}")
+message(STATUS "BUILD_TIMESTAMP = ${BUILD_TIMESTAMP}")
add_definitions(-DBUILD_TIMESTAMP="${BUILD_TIMESTAMP}")
# We want to keep our asserts even in release builds so remove NDEBUG
@@ -199,6 +197,8 @@ if(NOT FOUND_LIBJPEG_TURBO)
message(STATUS "WARNING: You are not using libjpeg-turbo. Performance will suffer.")
endif()
+include_directories(${JPEG_INCLUDE_DIR})
+
option(BUILD_JAVA "Build Java version of the TigerVNC Viewer" FALSE)
if(BUILD_JAVA)
add_subdirectory(java)
diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake
index 25c10777..5a3d9987 100644
--- a/cmake/StaticBuild.cmake
+++ b/cmake/StaticBuild.cmake
@@ -10,9 +10,14 @@
option(BUILD_STATIC
"Link statically against most libraries, if possible" OFF)
+option(BUILD_STATIC_GCC
+ "Link statically against only libgcc and libstdc++" OFF)
+
if(BUILD_STATIC)
message(STATUS "Attempting to link static binaries...")
+ set(BUILD_STATIC_GCC 1)
+
set(JPEG_LIBRARIES "-Wl,-Bstatic -ljpeg -Wl,-Bdynamic")
if(WIN32)
@@ -105,7 +110,9 @@ if(BUILD_STATIC)
set(X11_Xdamage_LIB "-Wl,-Bstatic -lXdamage -Wl,-Bdynamic")
endif()
endif()
+endif()
+if(BUILD_STATIC_GCC)
# This ensures that we don't depend on libstdc++ or libgcc_s
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nodefaultlibs")
set(STATIC_BASE_LIBRARIES "-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic")
@@ -122,5 +129,4 @@ if(BUILD_STATIC)
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lgcc -lgcc_eh -lc")
endif()
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${STATIC_BASE_LIBRARIES}")
-
endif()
diff --git a/contrib/systemd/user/vncserver@.service b/contrib/systemd/user/vncserver@.service
new file mode 100644
index 00000000..7797504b
--- /dev/null
+++ b/contrib/systemd/user/vncserver@.service
@@ -0,0 +1,26 @@
+#
+# /usr/lib/systemd/user/vncserver@.service
+#
+# 1. Switches for vncserver should be entered in ~/.vnc/config rather than
+# hard-coded into this unit file. See the vncserver(1) manpage.
+#
+# 2. Users wishing for the server to continue running after the owner logs
+# out MUST enable 'linger' with loginctl like this:
+# `loginctl enable-linger username`
+#
+# 3. The server can be enabled and started like this once configured:
+# `systemctl --user start vncserver@:<display>.service`
+# `systemctl --user enable vncserver@:<display>.service`
+
+[Unit]
+Description=Remote desktop service (VNC)
+After=syslog.target network.target
+
+[Service]
+Type=forking
+ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
+ExecStart=/usr/bin/vncserver %i
+ExecStop=/usr/bin/vncserver -kill %i
+
+[Install]
+WantedBy=default.target
diff --git a/unix/vncserver b/unix/vncserver
index 093d9acd..d7cd711e 100755
--- a/unix/vncserver
+++ b/unix/vncserver
@@ -82,6 +82,17 @@ $defaultXStartup
"xterm -geometry 80x24+10+10 -ls -title \"\$VNCDESKTOP Desktop\" &\n".
"twm &\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".
+ "## Several common ones are shown below. Uncomment and modify to your liking.\n".
+ "##\n".
+ "# securitytypes=vncauth,tlsvnc\n".
+ "# desktop=sandbox\n".
+ "# geometry=2000x1200\n".
+ "# localhost\n".
+ "# alwaysshared\n");
+
chop($host = `uname -n`);
if (-d "/etc/X11/fontpath.d") {
@@ -256,17 +267,48 @@ if ($opt{'-name'}) {
# Now start the X VNC Server
$cmd = $exedir."Xvnc :$displayNumber";
-$cmd .= " -desktop " . &quotedString($desktopName);
-$cmd .= " -httpd $vncJavaFiles" if ($vncJavaFiles);
-$cmd .= " -auth $xauthorityFile";
-$cmd .= " -geometry $geometry" if ($geometry);
-$cmd .= " -depth $depth" if ($depth);
-$cmd .= " -pixelformat $pixelformat" if ($pixelformat);
-$cmd .= " -rfbwait 30000";
-$cmd .= " -rfbauth $vncUserDir/passwd";
-$cmd .= " -rfbport $vncPort";
-$cmd .= " -fp $fontPath" if ($fontPath);
-$cmd .= " -pn";
+
+my %default_opts;
+my %config;
+
+$default_opts{desktop} = &quotedString($desktopName);
+$default_opts{httpd} = $vncJavaFiles if ($vncJavaFiles);
+$default_opts{auth} = $xauthorityFile;
+$default_opts{geometry} = $geometry if ($geometry);
+$default_opts{depth} = $depth if ($depth);
+$default_opts{pixelformat} = $pixelformat if ($pixelformat);
+$default_opts{rfbwait} = 30000;
+$default_opts{rfbauth} = "$vncUserDir/passwd";
+$default_opts{rfbport} = $vncPort;
+$default_opts{fp} = $fontPath if ($fontPath);
+$default_opts{pn} = "";
+
+# if a user configuration file already exists
+if(stat("$vncUserDir/config")) {
+
+ # loads and parses configuration file
+ if(open(IN, "$vncUserDir/config")) {
+ while(<IN>) {
+ next if /^#/;
+ if(my ($k, $v) = /^\s*(\w+)\s*=\s*(.+)$/) {
+ $config{$k} = $v;
+ } elsif ($_ =~ m/^\s*(\S+)/) {
+ $config{$1} = $k;
+ }
+ }
+ close(IN);
+ }
+}
+
+foreach my $k (sort keys %config) {
+ $cmd .= " -$k $config{$k}";
+ # user's option takes precedence
+ delete $default_opts{$k};
+}
+
+foreach my $k (sort keys %default_opts) {
+ $cmd .= " -$k $default_opts{$k}";
+}
# Add color database stuff here, e.g.:
#
@@ -327,6 +369,16 @@ if (! $skipxstartup) {
}
}
+# Create the user's config file if necessary.
+
+if (!(-e "$vncUserDir/config")) {
+ warn "Creating default config $vncUserDir/config\n";
+ open(XSTARTUP, ">$vncUserDir/config");
+ print XSTARTUP $defaultConfig;
+ close(XSTARTUP);
+ chmod 0644, "$vncUserDir/config";
+}
+
# Run the X startup script.
if (! $skipxstartup) {
diff --git a/unix/vncserver.man b/unix/vncserver.man
index c2e1419e..37fe315e 100644
--- a/unix/vncserver.man
+++ b/unix/vncserver.man
@@ -140,6 +140,14 @@ A shell script specifying X applications to be run when a VNC desktop is
started. If this file does not exist, then vncserver will create a default
xstartup script which attempts to launch your chosen window manager.
.TP
+$HOME/.vnc/config
+An optional server config file wherein options to be passed to Xvnc are listed
+to avoid hard-coding them to the physical invocation. List options in this file
+one per line. For those requiring an argument, simply separate the option from
+the argument with an equal sign, for example: "geometry=2000x1200" or
+"securitytypes=vncauth,tlsvnc". Options without an argument are simply listed
+as a single word, for example: "localhost" or "alwaysshared".
+.TP
$HOME/.vnc/passwd
The VNC password file.
.TP
diff --git a/unix/xserver/hw/vnc/Xvnc.man b/unix/xserver/hw/vnc/Xvnc.man
index 9e86fa4f..4a833157 100644
--- a/unix/xserver/hw/vnc/Xvnc.man
+++ b/unix/xserver/hw/vnc/Xvnc.man
@@ -48,7 +48,7 @@ next three green, and the least significant three represent red), the default
for depth 16 is RGB565 and for depth 24 is RGB888.
.
.TP
-.B \-interface \fIIP address\fP or \-i \fIIP address\fP
+.B \-interface \fIIP address\fP
Listen on interface. By default Xvnc listens on all available interfaces.
.
.TP