1{ lib, stdenv, buildPackages, fetchurl
2, flex, cracklib, db4, gettext, audit, libxcrypt
3, nixosTests
4, autoreconfHook269, pkg-config-unwrapped
5}:
6
7stdenv.mkDerivation rec {
8 pname = "linux-pam";
9 version = "1.6.1";
10
11 src = fetchurl {
12 url = "https://github.com/linux-pam/linux-pam/releases/download/v${version}/Linux-PAM-${version}.tar.xz";
13 hash = "sha256-+JI8dAFZBS1xnb/CovgZQtaN00/K9hxwagLJuA/u744=";
14 };
15
16 patches = [
17 ./suid-wrapper-path.patch
18 ];
19
20 # Case-insensitivity workaround for https://github.com/linux-pam/linux-pam/issues/569
21 postPatch = if stdenv.buildPlatform.isDarwin && stdenv.buildPlatform != stdenv.hostPlatform then ''
22 rm CHANGELOG
23 touch ChangeLog
24 '' else null;
25
26 outputs = [ "out" "doc" "man" /* "modules" */ ];
27
28 depsBuildBuild = [ buildPackages.stdenv.cc ];
29 # autoreconfHook269 is needed for `suid-wrapper-path.patch` above.
30 # pkg-config-unwrapped is needed for `AC_CHECK_LIB` and `AC_SEARCH_LIBS`
31 nativeBuildInputs = [ flex autoreconfHook269 pkg-config-unwrapped ]
32 ++ lib.optional stdenv.buildPlatform.isDarwin gettext;
33
34 buildInputs = [ cracklib db4 libxcrypt ]
35 ++ lib.optional stdenv.buildPlatform.isLinux audit;
36
37 enableParallelBuilding = true;
38
39 preConfigure = lib.optionalString (stdenv.hostPlatform.libc == "musl") ''
40 # export ac_cv_search_crypt=no
41 # (taken from Alpine linux, apparently insecure but also doesn't build O:))
42 # disable insecure modules
43 # sed -e 's/pam_rhosts//g' -i modules/Makefile.am
44 sed -e 's/pam_rhosts//g' -i modules/Makefile.in
45 '';
46
47 configureFlags = [
48 "--includedir=${placeholder "out"}/include/security"
49 "--enable-sconfigdir=/etc/security"
50 # The module is deprecated. We re-enable it explicitly until NixOS
51 # module stops using it.
52 "--enable-lastlog"
53 ];
54
55 installFlags = [
56 "SCONFIGDIR=${placeholder "out"}/etc/security"
57 ];
58
59 doCheck = false; # fails
60
61 passthru.tests = {
62 inherit (nixosTests) pam-oath-login pam-u2f shadow sssd-ldap;
63 };
64
65 meta = with lib; {
66 homepage = "http://www.linux-pam.org/";
67 description = "Pluggable Authentication Modules, a flexible mechanism for authenticating user";
68 platforms = platforms.linux;
69 license = licenses.bsd3;
70 };
71}