2024-02-29 20:09:43 +00:00
|
|
|
{ lib, stdenv, buildPackages, fetchurl, fetchpatch
|
2023-11-16 04:20:00 +00:00
|
|
|
, flex, cracklib, db4, gettext, audit, libxcrypt
|
2021-01-05 17:05:55 +00:00
|
|
|
, nixosTests
|
2023-11-16 04:20:00 +00:00
|
|
|
, autoreconfHook269, pkg-config-unwrapped
|
2021-01-05 17:05:55 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "linux-pam";
|
2024-02-29 20:09:43 +00:00
|
|
|
version = "1.6.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2024-01-25 14:12:00 +00:00
|
|
|
url = "https://github.com/linux-pam/linux-pam/releases/download/v${version}/Linux-PAM-${version}.tar.xz";
|
2024-02-29 20:09:43 +00:00
|
|
|
hash = "sha256-//SjTlu+534ujxmS8nYx4jKby/igVj3etcM4m04xaa0=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
patches = [
|
|
|
|
./suid-wrapper-path.patch
|
2024-02-29 20:09:43 +00:00
|
|
|
|
|
|
|
# Backport fix for missing include breaking musl builds.
|
2023-11-16 04:20:00 +00:00
|
|
|
(fetchpatch {
|
2024-02-29 20:09:43 +00:00
|
|
|
name = "pam_namespace-stdint.h.patch";
|
|
|
|
url = "https://github.com/linux-pam/linux-pam/commit/cc9d40b7cdbd3e15ccaa324a0dda1680ef9dea13.patch";
|
|
|
|
hash = "sha256-tCnH2yPO4dBbJOZA0fP2gm1EavHRMEJyfzB5Vy7YjAA=";
|
2024-01-25 14:12:00 +00:00
|
|
|
})
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
# Resotre handling of empty passwords:
|
|
|
|
# https://github.com/linux-pam/linux-pam/pull/784
|
|
|
|
# TODO: drop upstreamed patch on 1.6.1 update.
|
|
|
|
(fetchpatch {
|
|
|
|
name = "revert-unconditional-helper.patch";
|
|
|
|
url = "https://github.com/linux-pam/linux-pam/commit/8d0c575336ad301cd14e16ad2fdec6fe621764b8.patch";
|
|
|
|
hash = "sha256-z9KfMxxqXQVnmNaixaVjLnQqaGsH8MBHhHbiP/8fvhE=";
|
|
|
|
})
|
2024-02-29 20:09:43 +00:00
|
|
|
];
|
2022-02-10 20:34:41 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
# Case-insensitivity workaround for https://github.com/linux-pam/linux-pam/issues/569
|
|
|
|
postPatch = if stdenv.buildPlatform.isDarwin && stdenv.buildPlatform != stdenv.hostPlatform then ''
|
|
|
|
rm CHANGELOG
|
|
|
|
touch ChangeLog
|
|
|
|
'' else null;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
outputs = [ "out" "doc" "man" /* "modules" */ ];
|
|
|
|
|
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
2024-02-29 20:09:43 +00:00
|
|
|
# autoreconfHook269 is needed for `suid-wrapper-path.patch` above.
|
2023-11-16 04:20:00 +00:00
|
|
|
# pkg-config-unwrapped is needed for `AC_CHECK_LIB` and `AC_SEARCH_LIBS`
|
|
|
|
nativeBuildInputs = [ flex autoreconfHook269 pkg-config-unwrapped ]
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.optional stdenv.buildPlatform.isDarwin gettext;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-27 19:17:25 +00:00
|
|
|
buildInputs = [ cracklib db4 libxcrypt ]
|
|
|
|
++ lib.optional stdenv.buildPlatform.isLinux audit;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
preConfigure = lib.optionalString (stdenv.hostPlatform.libc == "musl") ''
|
2020-04-24 23:36:52 +00:00
|
|
|
# export ac_cv_search_crypt=no
|
|
|
|
# (taken from Alpine linux, apparently insecure but also doesn't build O:))
|
|
|
|
# disable insecure modules
|
|
|
|
# sed -e 's/pam_rhosts//g' -i modules/Makefile.am
|
|
|
|
sed -e 's/pam_rhosts//g' -i modules/Makefile.in
|
|
|
|
'';
|
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
"--includedir=${placeholder "out"}/include/security"
|
|
|
|
"--enable-sconfigdir=/etc/security"
|
2024-01-25 14:12:00 +00:00
|
|
|
# The module is deprecated. We re-enable it explicitly until NixOS
|
|
|
|
# module stops using it.
|
|
|
|
"--enable-lastlog"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
installFlags = [
|
|
|
|
"SCONFIGDIR=${placeholder "out"}/etc/security"
|
|
|
|
];
|
|
|
|
|
|
|
|
doCheck = false; # fails
|
|
|
|
|
2021-01-05 17:05:55 +00:00
|
|
|
passthru.tests = {
|
2023-05-24 13:37:59 +00:00
|
|
|
inherit (nixosTests) pam-oath-login pam-u2f shadow sssd-ldap;
|
2021-01-05 17:05:55 +00:00
|
|
|
};
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "http://www.linux-pam.org/";
|
|
|
|
description = "Pluggable Authentication Modules, a flexible mechanism for authenticating user";
|
|
|
|
platforms = platforms.linux;
|
|
|
|
license = licenses.bsd3;
|
|
|
|
};
|
|
|
|
}
|