summaryrefslogtreecommitdiffstats
path: root/pkgs/tools/networking/openvpn/openvpn-auth-ldap.nix
blob: 1abfe2af14a69e88055d517b7b1a7a49df2f0c20 (plain)
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
{
  lib,
  stdenv,
  fetchFromGitHub,
  fetchpatch2,
  autoreconfHook,
  gnustep-base,
  re2c,
  openldap,
  openssl,
  openvpn,
}:

stdenv.mkDerivation rec {
  pname = "openvpn-auth-ldap";
  version = "2.0.4";

  src = fetchFromGitHub {
    owner = "threerings";
    repo = "openvpn-auth-ldap";
    rev = "auth-ldap-${version}";
    sha256 = "1j30sygj8nm8wjqxzpb7pfzr3dxqxggswzxd7z5yk7y04c0yp1hb";
  };

  patches = [
    ./auth-ldap-fix-conftest.patch
    (fetchpatch2 {
      name = "fix-cve-2024-28820";
      url = "https://patch-diff.githubusercontent.com/raw/threerings/openvpn-auth-ldap/pull/92.patch";
      hash = "sha256-SXuo1D/WywKO5hCsmoeDdTsR7EelxFxJAKmlAQJ6vuE=";
    })
    (fetchpatch2 {
      name = "gcc-15-fix";
      url = "https://sources.debian.org/data/main/o/openvpn-auth-ldap/2.0.4-5/debian/patches/gcc-15.patch";
      hash = "sha256-VwUwRBBfxgxEO4PKC/97vEN4e6XcUG6esc0Khu+iDxM=";
    })
  ];

  # clang > 17 dropped support for `-export-dynamic` but `-rdynamic` does the
  # same thing
  postPatch = ''
    substituteInPlace platform.m4 \
      --replace-fail -export-dynamic -rdynamic
  '';

  nativeBuildInputs = [
    autoreconfHook
    re2c
  ];

  buildInputs = [
    openldap
    openssl
    openvpn
    gnustep-base
  ];

  configureFlags = [
    "--with-objc-runtime=GNU"
    "--with-openvpn=${openvpn}/include"
    "--libdir=$(out)/lib/openvpn"
  ];

  doCheck = true;

  preInstall = ''
    mkdir -p $out/lib/openvpn $out/share/doc/openvpn/examples
    cp README.md $out/share/doc/openvpn/
    cp auth-ldap.conf $out/share/doc/openvpn/examples/
  '';

  meta = {
    description = "LDAP authentication plugin for OpenVPN";
    homepage = "https://github.com/threerings/openvpn-auth-ldap";
    license = [
      lib.licenses.asl20
      lib.licenses.bsd3
    ];
    maintainers = [ lib.maintainers.benley ];
    platforms = lib.platforms.unix;
  };
}