···1818, libedit
1919, pkg-config
2020, pam
2121+, libredirect
2122, etcDir ? null
2223, withKerberos ? !(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)
2324, libkrb5
2425, libfido2
2626+, hostname
2527, nixosTests
2628, withFIDO ? stdenv.hostPlatform.isUnix && !stdenv.hostPlatform.isMusl
2729, linkOpenssl ? true
···99101 enableParallelBuilding = true;
100102101103 hardeningEnable = [ "pie" ];
104104+105105+ doCheck = true;
106106+ checkInputs = optional (!stdenv.isDarwin) hostname;
107107+ preCheck = ''
108108+ # construct a dummy HOME
109109+ export HOME=$(realpath ../dummy-home)
110110+ mkdir -p ~/.ssh
111111+112112+ # construct a dummy /etc/passwd file for the sshd under test
113113+ # to use to look up the connecting user
114114+ DUMMY_PASSWD=$(realpath ../dummy-passwd)
115115+ cat > $DUMMY_PASSWD <<EOF
116116+ $(whoami)::$(id -u):$(id -g)::$HOME:$SHELL
117117+ EOF
118118+119119+ # we need to NIX_REDIRECTS /etc/passwd both for processes
120120+ # invoked directly and those invoked by the "remote" session
121121+ cat > ~/.ssh/environment.base <<EOF
122122+ NIX_REDIRECTS=/etc/passwd=$DUMMY_PASSWD
123123+ LD_PRELOAD=${libredirect}/lib/libredirect.so
124124+ EOF
125125+126126+ # use an ssh environment file to ensure environment is set
127127+ # up appropriately for build environment even when no shell
128128+ # is invoked by the ssh session. otherwise the PATH will
129129+ # only contain default unix paths like /bin which we don't
130130+ # have in our build environment
131131+ cat - regress/test-exec.sh > regress/test-exec.sh.new <<EOF
132132+ cp $HOME/.ssh/environment.base $HOME/.ssh/environment
133133+ echo "PATH=\$PATH" >> $HOME/.ssh/environment
134134+ EOF
135135+ mv regress/test-exec.sh.new regress/test-exec.sh
136136+137137+ # explicitly enable the PermitUserEnvironment feature
138138+ substituteInPlace regress/test-exec.sh \
139139+ --replace \
140140+ 'cat << EOF > $OBJ/sshd_config' \
141141+ $'cat << EOF > $OBJ/sshd_config\n\tPermitUserEnvironment yes'
142142+143143+ # some tests want to use files under /bin as example files
144144+ for f in regress/sftp-cmds.sh regress/forwarding.sh; do
145145+ substituteInPlace $f --replace '/bin' "$(dirname $(type -p ls))"
146146+ done
147147+148148+ # set up NIX_REDIRECTS for direct invocations
149149+ set -a; source ~/.ssh/environment.base; set +a
150150+ '';
151151+ # integration tests hard to get working on darwin with its shaky
152152+ # sandbox
153153+ checkTarget = optional (!stdenv.isDarwin) "t-exec"
154154+ # other tests are less demanding of the environment
155155+ ++ [ "unit" "file-tests" "interop-tests" ];
102156103157 postInstall = ''
104158 # Install ssh-copy-id, it's very useful.