diff --git a/pkgs/tools/networking/openssh/common.nix b/pkgs/tools/networking/openssh/common.nix index fefa80b9c4f6..ad807c915979 100644 --- a/pkgs/tools/networking/openssh/common.nix +++ b/pkgs/tools/networking/openssh/common.nix @@ -18,10 +18,12 @@ , libedit , pkg-config , pam +, libredirect , etcDir ? null , withKerberos ? !(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) , libkrb5 , libfido2 +, hostname , nixosTests , withFIDO ? stdenv.hostPlatform.isUnix && !stdenv.hostPlatform.isMusl , linkOpenssl ? true @@ -100,6 +102,58 @@ stdenv.mkDerivation rec { hardeningEnable = [ "pie" ]; + doCheck = true; + checkInputs = optional (!stdenv.isDarwin) hostname; + preCheck = '' + # construct a dummy HOME + export HOME=$(realpath ../dummy-home) + mkdir -p ~/.ssh + + # construct a dummy /etc/passwd file for the sshd under test + # to use to look up the connecting user + DUMMY_PASSWD=$(realpath ../dummy-passwd) + cat > $DUMMY_PASSWD < ~/.ssh/environment.base < regress/test-exec.sh.new <> $HOME/.ssh/environment + EOF + mv regress/test-exec.sh.new regress/test-exec.sh + + # explicitly enable the PermitUserEnvironment feature + substituteInPlace regress/test-exec.sh \ + --replace \ + 'cat << EOF > $OBJ/sshd_config' \ + $'cat << EOF > $OBJ/sshd_config\n\tPermitUserEnvironment yes' + + # some tests want to use files under /bin as example files + for f in regress/sftp-cmds.sh regress/forwarding.sh; do + substituteInPlace $f --replace '/bin' "$(dirname $(type -p ls))" + done + + # set up NIX_REDIRECTS for direct invocations + set -a; source ~/.ssh/environment.base; set +a + ''; + # integration tests hard to get working on darwin with its shaky + # sandbox + checkTarget = optional (!stdenv.isDarwin) "t-exec" + # other tests are less demanding of the environment + ++ [ "unit" "file-tests" "interop-tests" ]; + postInstall = '' # Install ssh-copy-id, it's very useful. cp contrib/ssh-copy-id $out/bin/