1{ stdenv
2, lib
3, fetchurl
4, fetchpatch
5, ncurses
6, perl
7, help2man
8, apparmorRulesFromClosure
9, libxcrypt
10}:
11
12stdenv.mkDerivation rec {
13 pname = "inetutils";
14 version = "2.4";
15
16 src = fetchurl {
17 url = "mirror://gnu/${pname}/${pname}-${version}.tar.xz";
18 sha256 = "sha256-F4nWsbGlff4qere1M+6fXf2cv1tZuxuzwmEu0I0PaLI=";
19 };
20
21 outputs = ["out" "apparmor"];
22
23 patches = [
24 # https://git.congatec.com/yocto/meta-openembedded/commit/3402bfac6b595c622e4590a8ff5eaaa854e2a2a3
25 ./inetutils-1_9-PATH_PROCNET_DEV.patch
26 (fetchpatch {
27 name = "CVE-2023-40303.patch";
28 url = "https://git.savannah.gnu.org/cgit/inetutils.git/patch/?id=e4e65c03f4c11292a3e40ef72ca3f194c8bffdd6";
29 hash = "sha256-I5skN537owfpFpAZr4vDKPHuERI6+oq5/hFW2RQeUxI=";
30 })
31 ];
32
33 strictDeps = true;
34 nativeBuildInputs = [ help2man perl /* for `whois' */ ];
35 buildInputs = [ ncurses /* for `talk' */ libxcrypt ];
36
37 env = lib.optionalAttrs stdenv.isDarwin {
38 # This is a temporary workaround for missing headers in the 10.12 SDK to avoid a mass rebuild.
39 # A commit to revert this change will be included in the fix PR targeting staging.
40 NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration";
41 };
42
43 # Don't use help2man if cross-compiling
44 # https://lists.gnu.org/archive/html/bug-sed/2017-01/msg00001.html
45 # https://git.congatec.com/yocto/meta-openembedded/blob/3402bfac6b595c622e4590a8ff5eaaa854e2a2a3/meta-networking/recipes-connectivity/inetutils/inetutils_1.9.1.bb#L44
46 preConfigure = let
47 isCross = stdenv.hostPlatform != stdenv.buildPlatform;
48 in lib.optionalString isCross ''
49 export HELP2MAN=true
50 '';
51
52 configureFlags = [ "--with-ncurses-include-dir=${ncurses.dev}/include" ]
53 ++ lib.optionals stdenv.hostPlatform.isMusl [ # Musl doesn't define rcmd
54 "--disable-rcp"
55 "--disable-rsh"
56 "--disable-rlogin"
57 "--disable-rexec"
58 ] ++ lib.optional stdenv.isDarwin "--disable-servers";
59
60 doCheck = true;
61
62 installFlags = [ "SUIDMODE=" ];
63
64 postInstall = ''
65 mkdir $apparmor
66 cat >$apparmor/bin.ping <<EOF
67 $out/bin/ping {
68 include <abstractions/base>
69 include <abstractions/consoles>
70 include <abstractions/nameservice>
71 include "${apparmorRulesFromClosure { name = "ping"; } [stdenv.cc.libc]}"
72 include <local/bin.ping>
73 capability net_raw,
74 network inet raw,
75 network inet6 raw,
76 mr $out/bin/ping,
77 }
78 EOF
79 '';
80
81 meta = with lib; {
82 description = "Collection of common network programs";
83
84 longDescription =
85 '' The GNU network utilities suite provides the
86 following tools: ftp(d), hostname, ifconfig, inetd, logger, ping, rcp,
87 rexec(d), rlogin(d), rsh(d), syslogd, talk(d), telnet(d), tftp(d),
88 traceroute, uucpd, and whois.
89 '';
90
91 homepage = "https://www.gnu.org/software/inetutils/";
92 license = licenses.gpl3Plus;
93
94 maintainers = with maintainers; [ matthewbauer ];
95 platforms = platforms.unix;
96 };
97}