2021-03-19 17:17:44 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
2022-01-07 04:07:37 +00:00
|
|
|
, buildPackages
|
2021-03-19 17:17:44 +00:00
|
|
|
, coreutils
|
|
|
|
, pam
|
|
|
|
, groff
|
|
|
|
, sssd
|
|
|
|
, nixosTests
|
2020-04-24 23:36:52 +00:00
|
|
|
, sendmailPath ? "/run/wrappers/bin/sendmail"
|
|
|
|
, withInsults ? false
|
|
|
|
, withSssd ? false
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "sudo";
|
2022-11-04 12:27:35 +00:00
|
|
|
version = "1.9.12p1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://www.sudo.ws/dist/${pname}-${version}.tar.gz";
|
2022-11-04 12:27:35 +00:00
|
|
|
hash = "sha256-R1oYqOs9qLKRfOqwY6a69R6gkSjDxH4+DjOrdJe6t9g=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
prePatch = ''
|
|
|
|
# do not set sticky bit in nix store
|
|
|
|
substituteInPlace src/Makefile.in --replace 04755 0755
|
|
|
|
'';
|
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
"--with-env-editor"
|
|
|
|
"--with-editor=/run/current-system/sw/bin/nano"
|
|
|
|
"--with-rundir=/run/sudo"
|
|
|
|
"--with-vardir=/var/db/sudo"
|
|
|
|
"--with-logpath=/var/log/sudo.log"
|
|
|
|
"--with-iologdir=/var/log/sudo-io"
|
|
|
|
"--with-sendmail=${sendmailPath}"
|
|
|
|
"--enable-tmpfiles.d=no"
|
2022-10-30 15:09:59 +00:00
|
|
|
] ++ lib.optionals withInsults [
|
2020-04-24 23:36:52 +00:00
|
|
|
"--with-insults"
|
|
|
|
"--with-all-insults"
|
2022-10-30 15:09:59 +00:00
|
|
|
] ++ lib.optionals withSssd [
|
2020-04-24 23:36:52 +00:00
|
|
|
"--with-sssd"
|
|
|
|
"--with-sssd-lib=${sssd}/lib"
|
|
|
|
];
|
|
|
|
|
|
|
|
configureFlagsArray = [
|
2021-03-19 17:17:44 +00:00
|
|
|
"--with-passprompt=[sudo] password for %p: " # intentional trailing space
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postConfigure =
|
|
|
|
''
|
2021-03-19 17:17:44 +00:00
|
|
|
cat >> pathnames.h <<'EOF'
|
|
|
|
#undef _PATH_MV
|
|
|
|
#define _PATH_MV "${coreutils}/bin/mv"
|
|
|
|
EOF
|
|
|
|
makeFlags="install_uid=$(id -u) install_gid=$(id -g)"
|
|
|
|
installFlags="sudoers_uid=$(id -u) sudoers_gid=$(id -g) sysconfdir=$out/etc rundir=$TMPDIR/dummy vardir=$TMPDIR/dummy DESTDIR=/"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-01-07 04:07:37 +00:00
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [ groff ];
|
|
|
|
buildInputs = [ pam ];
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
doCheck = false; # needs root
|
|
|
|
|
2021-03-19 17:17:44 +00:00
|
|
|
postInstall = ''
|
|
|
|
rm $out/share/doc/sudo/ChangeLog
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-11 12:50:04 +00:00
|
|
|
passthru.tests = { inherit (nixosTests) sudo; };
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = {
|
|
|
|
description = "A command to run commands as root";
|
|
|
|
|
|
|
|
longDescription =
|
|
|
|
''
|
2021-03-19 17:17:44 +00:00
|
|
|
Sudo (su "do") allows a system administrator to delegate
|
|
|
|
authority to give certain users (or groups of users) the ability
|
|
|
|
to run some (or all) commands as root or another user while
|
|
|
|
providing an audit trail of the commands and their arguments.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
homepage = "https://www.sudo.ws/";
|
|
|
|
|
|
|
|
license = "https://www.sudo.ws/sudo/license.html";
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
maintainers = with lib.maintainers; [ eelco delroth ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
platforms = lib.platforms.linux;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|