summary refs log tree commit diff
path: root/pkgs/tools/admin/tightvnc/default.nix
blob: 3c8f56a650fecccbd3675575e8e855458667fd88 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{ lib
, stdenv
, fetchurl
, zlib
, libjpeg
, imake
, gccmakedep
, libXaw
, libXext
, libXmu
, libXp
, libXpm
, perl
, xauth
, fontDirectories
, openssh
}:

stdenv.mkDerivation rec {
  pname = "tightvnc";
  version = "1.3.10";

  src = fetchurl {
    url = "mirror://sourceforge/vnc-tight/tightvnc-${version}_unixsrc.tar.bz2";
    sha256 = "f48c70fea08d03744ae18df6b1499976362f16934eda3275cead87baad585c0d";
  };

  patches = [
    ./1.3.10-CVE-2019-15678.patch
    ./1.3.10-CVE-2019-15679.patch
    ./1.3.10-CVE-2019-15680.patch
    ./1.3.10-CVE-2019-8287.patch
  ];

  # for the builder script
  inherit fontDirectories;

  hardeningDisable = [ "format" ];

  buildInputs = [
    zlib
    libjpeg
    imake
    gccmakedep
    libXaw
    libXext
    libXmu
    libXp
    libXpm
    xauth
    openssh
  ];

  postPatch = ''
    fontPath=
    for i in $fontDirectories; do
      for j in $(find $i -name fonts.dir); do
        addToSearchPathWithCustomDelimiter "," fontPath $(dirname $j)
      done
    done

    sed -i "s@/usr/bin/ssh@${openssh}/bin/ssh@g" vncviewer/vncviewer.h

    sed -e 's@/usr/bin/perl@${perl}/bin/perl@' \
        -e 's@unix/:7100@'$fontPath'@' \
        -i vncserver

    sed -e 's@.* CppCmd .*@#define CppCmd		cpp@' -i Xvnc/config/cf/linux.cf
    sed -e 's@.* CppCmd .*@#define CppCmd		cpp@' -i Xvnc/config/cf/Imake.tmpl
    sed -i \
        -e 's@"uname","xauth","Xvnc","vncpasswd"@"uname","Xvnc","vncpasswd"@g' \
        -e "s@\<xauth\>@${xauth}/bin/xauth@g" \
        vncserver
  '';

  preInstall = ''
    mkdir -p $out/bin
    mkdir -p $out/share/man/man1
  '';

  installPhase = ''
    runHook preInstall

    ./vncinstall $out/bin $out/share/man

    runHook postInstall
  '';

  postInstall = ''
    # fix HTTP client:
    mkdir -p $out/share/tightvnc
    cp -r classes $out/share/tightvnc
    substituteInPlace $out/bin/vncserver \
      --replace /usr/local/vnc/classes $out/share/tightvnc/classes
  '';

  meta = {
    license = lib.licenses.gpl2Plus;
    homepage = "http://vnc-tight.sourceforge.net/";
    description = "Improved version of VNC";

    longDescription = ''
      TightVNC is an improved version of VNC, the great free
      remote-desktop tool. The improvements include bandwidth-friendly
      "tight" encoding, file transfers in the Windows version, enhanced
      GUI, many bugfixes, and more.
    '';

    maintainers = [];
    platforms = lib.platforms.unix;

    knownVulnerabilities = [ "CVE-2021-42785" ];
    # Unfortunately, upstream doesn't maintain the 1.3 branch anymore, and the
    # new 2.x branch is substantially different (requiring either Windows or Java)
  };
}