Add support for building RPM packages for RHEL 7 derivatives
diff --git a/contrib/packages/rpm/el7/SOURCES/10-libvnc.conf b/contrib/packages/rpm/el7/SOURCES/10-libvnc.conf
new file mode 100644
index 0000000..a053a7d
--- /dev/null
+++ b/contrib/packages/rpm/el7/SOURCES/10-libvnc.conf
@@ -0,0 +1,19 @@
+# This file contains configuration of libvnc.so module
+#
+# To get libvnc.so module working, do this:
+# 1. run "vncpasswd" from tigervnc-server package as root user
+# 2. uncomment configuration lines below
+#
+# Please note you can specify any option which Xvnc accepts.
+# Refer to `Xvnc -help` output for detailed list of options.
+
+#Section "Module"
+# Load "vnc"
+#EndSection
+
+#Section "Screen"
+# Identifier "Screen0
+# DefaultDepth 16
+# Option "SecurityTypes" "VncAuth"
+# Option "PasswordFile" "/root/.vnc/passwd"
+#EndSection
diff --git a/contrib/packages/rpm/el7/SOURCES/tigervnc-cookie.patch b/contrib/packages/rpm/el7/SOURCES/tigervnc-cookie.patch
new file mode 100644
index 0000000..c066a5f
--- /dev/null
+++ b/contrib/packages/rpm/el7/SOURCES/tigervnc-cookie.patch
@@ -0,0 +1,37 @@
+diff -up tigervnc-1.0.90-20091221svn3929/unix/vncserver.cookie tigervnc-1.0.90-20091221svn3929/unix/vncserver
+--- tigervnc-1.0.90-20091221svn3929/unix/vncserver.cookie 2009-11-12 11:39:54.000000000 +0100
++++ tigervnc-1.0.90-20091221svn3929/unix/vncserver 2009-12-21 16:15:01.907799091 +0100
+@@ -189,27 +189,12 @@ $vncPort = 5900 + $displayNumber;
+ $desktopLog = "$vncUserDir/$host:$displayNumber.log";
+ unlink($desktopLog);
+
+-# Make an X server cookie - use /dev/urandom on systems that have it,
+-# otherwise use perl's random number generator, seeded with the sum
+-# of the current time, our PID and part of the encrypted form of the password.
+-
+-my $cookie = "";
+-if (open(URANDOM, '<', '/dev/urandom')) {
+- my $randata;
+- if (sysread(URANDOM, $randata, 16) == 16) {
+- $cookie = unpack 'h*', $randata;
+- }
+- close(URANDOM);
+-}
+-if ($cookie eq "") {
+- srand(time+$$+unpack("L",`cat $vncUserDir/passwd`));
+- for (1..16) {
+- $cookie .= sprintf("%02x", int(rand(256)) % 256);
+- }
+-}
+-
+-system("xauth -f $xauthorityFile add $host:$displayNumber . $cookie");
+-system("xauth -f $xauthorityFile add $host/unix:$displayNumber . $cookie");
++# Make an X server cookie - use mcookie
++$cookie = `/usr/bin/mcookie`;
++open (XAUTH, "|xauth -f $xauthorityFile source -");
++print XAUTH "add $host:$displayNumber . $cookie\n";
++print XAUTH "add $host/unix:$displayNumber . $cookie\n";
++close XAUTH;
+
+ if ($opt{'-name'}) {
+ $desktopName = $opt{'-name'};
diff --git a/contrib/packages/rpm/el7/SOURCES/tigervnc-shebang.patch b/contrib/packages/rpm/el7/SOURCES/tigervnc-shebang.patch
new file mode 100644
index 0000000..f76af87
--- /dev/null
+++ b/contrib/packages/rpm/el7/SOURCES/tigervnc-shebang.patch
@@ -0,0 +1,9 @@
+diff -up tigervnc-1.3.0/unix/vncserver.shebang tigervnc-1.3.0/unix/vncserver
+--- tigervnc-1.3.0/unix/vncserver.shebang 2013-07-24 12:22:34.962158378 +0100
++++ tigervnc-1.3.0/unix/vncserver 2013-07-24 12:22:41.593188190 +0100
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env perl
++#!/usr/bin/perl
+ #
+ # Copyright (C) 2009-2010 D. R. Commander. All Rights Reserved.
+ # Copyright (C) 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
diff --git a/contrib/packages/rpm/el7/SOURCES/vncserver.service b/contrib/packages/rpm/el7/SOURCES/vncserver.service
new file mode 100644
index 0000000..4cec744
--- /dev/null
+++ b/contrib/packages/rpm/el7/SOURCES/vncserver.service
@@ -0,0 +1,45 @@
+# The vncserver service unit file
+#
+# Quick HowTo:
+# 1. Copy this file to /etc/systemd/system/vncserver@.service
+# 2. Edit <USER> and vncserver parameters appropriately
+# ("runuser -l <USER> -c /usr/bin/vncserver %i -arg1 -arg2")
+# 3. Run `systemctl daemon-reload`
+# 4. Run `systemctl enable vncserver@:<display>.service`
+#
+# DO NOT RUN THIS SERVICE if your local area network is
+# untrusted! For a secure way of using VNC, you should
+# limit connections to the local host and then tunnel from
+# the machine you want to view VNC on (host A) to the machine
+# whose VNC output you want to view (host B)
+#
+# [user@hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB
+#
+# this will open a connection on port 590N of your hostA to hostB's port 590M
+# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).
+# See the ssh man page for details on port forwarding)
+#
+# You can then point a VNC client on hostA at vncdisplay N of localhost and with
+# the help of ssh, you end up seeing what hostB makes available on port 590M
+#
+# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
+#
+# Use "-localhost" to prevent remote VNC clients connecting except when
+# doing so through a secure tunnel. See the "-via" option in the
+# `man vncviewer' manual page.
+
+
+[Unit]
+Description=Remote desktop service (VNC)
+After=syslog.target network.target
+
+[Service]
+Type=forking
+# Clean any existing files in /tmp/.X11-unix environment
+ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
+ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
+PIDFile=/home/<USER>/.vnc/%H%i.pid
+ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
+
+[Install]
+WantedBy=multi-user.target
diff --git a/contrib/packages/rpm/el7/SOURCES/vncserver.sysconfig b/contrib/packages/rpm/el7/SOURCES/vncserver.sysconfig
new file mode 100644
index 0000000..4d0489b
--- /dev/null
+++ b/contrib/packages/rpm/el7/SOURCES/vncserver.sysconfig
@@ -0,0 +1 @@
+# THIS FILE HAS BEEN REPLACED BY /lib/systemd/system/vncserver@.service
diff --git a/contrib/packages/rpm/el7/SOURCES/vncviewer.desktop b/contrib/packages/rpm/el7/SOURCES/vncviewer.desktop
new file mode 100644
index 0000000..fab46f0
--- /dev/null
+++ b/contrib/packages/rpm/el7/SOURCES/vncviewer.desktop
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Name=TigerVNC Viewer
+Name[fr]=Visionneur TigerVNC
+Comment=Connect to VNC server and display remote desktop
+Comment[fr]=Se connecter à un serveur VNC et afficher le bureau distant
+Exec=/usr/bin/vncviewer
+Icon=tigervnc
+Terminal=false
+Type=Application
+StartupWMClass=TigerVNC Viewer: Connection Details
+Categories=Network;RemoteAccess;