2024-04-28 15:42:10 +00:00
|
|
|
ARG BASE
|
|
|
|
FROM ${BASE}
|
|
|
|
|
2024-08-05 22:09:34 +00:00
|
|
|
ARG BASE
|
|
|
|
|
2024-05-29 17:51:50 +00:00
|
|
|
RUN echo "Install openssh, needed for scp."
|
2024-08-05 22:09:34 +00:00
|
|
|
RUN if echo "$BASE" | grep "ubuntu:"; then apt-get update -y && apt-get install -y openssh-client; fi
|
|
|
|
RUN if echo "$BASE" | grep "alpine:"; then apk add openssh; fi
|
2024-05-29 17:51:50 +00:00
|
|
|
|
2024-08-05 22:09:34 +00:00
|
|
|
# Note - on Ubuntu, we do not create the user's home directory, pam_mkhomedir will do that
|
2024-05-29 17:51:50 +00:00
|
|
|
# for us, and we want to test that PAM gets triggered by Tailscale SSH.
|
2024-08-05 22:09:34 +00:00
|
|
|
RUN if echo "$BASE" | grep "ubuntu:"; then groupadd -g 10000 groupone && groupadd -g 10001 grouptwo && useradd -g 10000 -G 10001 -u 10002 testuser; fi
|
|
|
|
# On Alpine, we can't configure pam_mkhomdir, so go ahead and create home directory.
|
|
|
|
RUN if echo "$BASE" | grep "alpine:"; then addgroup -g 10000 groupone && addgroup -g 10001 grouptwo && adduser -u 10002 -D testuser && addgroup testuser groupone && addgroup testuser grouptwo; fi
|
2024-04-28 15:42:10 +00:00
|
|
|
|
2024-08-05 22:09:34 +00:00
|
|
|
RUN if echo "$BASE" | grep "ubuntu:"; then \
|
|
|
|
echo "Set up pam_mkhomedir." && \
|
|
|
|
sed -i -e 's/Default: no/Default: yes/g' /usr/share/pam-configs/mkhomedir && \
|
|
|
|
cat /usr/share/pam-configs/mkhomedir && \
|
|
|
|
pam-auth-update --enable mkhomedir \
|
|
|
|
; fi
|
2024-04-28 15:42:10 +00:00
|
|
|
|
2024-05-29 17:51:50 +00:00
|
|
|
COPY tailscaled .
|
|
|
|
COPY tailssh.test .
|
|
|
|
|
|
|
|
RUN chmod 755 tailscaled
|
|
|
|
|
2024-06-14 18:28:39 +00:00
|
|
|
# RUN echo "First run tests normally."
|
|
|
|
RUN eval `ssh-agent -s` && TAILSCALED_PATH=`pwd`tailscaled ./tailssh.test -test.v -test.run TestSSHAgentForwarding
|
2024-08-05 22:09:34 +00:00
|
|
|
RUN if echo "$BASE" | grep "ubuntu:"; then rm -Rf /home/testuser; fi
|
2024-05-29 17:51:50 +00:00
|
|
|
RUN TAILSCALED_PATH=`pwd`tailscaled ./tailssh.test -test.v -test.run TestIntegrationSFTP
|
2024-08-05 22:09:34 +00:00
|
|
|
RUN if echo "$BASE" | grep "ubuntu:"; then rm -Rf /home/testuser; fi
|
2024-05-29 17:51:50 +00:00
|
|
|
RUN TAILSCALED_PATH=`pwd`tailscaled ./tailssh.test -test.v -test.run TestIntegrationSCP
|
2024-08-05 22:09:34 +00:00
|
|
|
RUN if echo "$BASE" | grep "ubuntu:"; then rm -Rf /home/testuser; fi
|
2024-05-29 17:51:50 +00:00
|
|
|
RUN TAILSCALED_PATH=`pwd`tailscaled ./tailssh.test -test.v -test.run TestIntegrationSSH
|
2024-04-28 15:42:10 +00:00
|
|
|
|
2024-05-29 17:51:50 +00:00
|
|
|
RUN echo "Then run tests as non-root user testuser and make sure tests still pass."
|
2024-04-28 15:42:10 +00:00
|
|
|
RUN chown testuser:groupone /tmp/tailscalessh.log
|
2024-06-14 18:28:39 +00:00
|
|
|
RUN TAILSCALED_PATH=`pwd`tailscaled eval `su -m testuser -c ssh-agent -s` && su -m testuser -c "./tailssh.test -test.v -test.run TestSSHAgentForwarding"
|
2024-05-29 17:51:50 +00:00
|
|
|
RUN TAILSCALED_PATH=`pwd`tailscaled su -m testuser -c "./tailssh.test -test.v -test.run TestIntegration TestDoDropPrivileges"
|
2024-06-12 23:02:54 +00:00
|
|
|
RUN chown root:root /tmp/tailscalessh.log
|
|
|
|
|
2024-08-05 22:09:34 +00:00
|
|
|
RUN if echo "$BASE" | grep "ubuntu:"; then \
|
|
|
|
echo "Then run tests in a system that's pretending to be SELinux in enforcing mode" && \
|
|
|
|
# Remove execute permissions for /usr/bin/login so that it fails.
|
|
|
|
mv /usr/bin/login /tmp/login_orig && \
|
|
|
|
# Use nonsense for /usr/bin/login so that it fails.
|
|
|
|
# It's not the same failure mode as in SELinux, but failure is good enough for test.
|
|
|
|
echo "adsfasdfasdf" > /usr/bin/login && \
|
|
|
|
chmod 755 /usr/bin/login && \
|
|
|
|
# Simulate getenforce command
|
|
|
|
printf "#!/bin/bash\necho 'Enforcing'" > /usr/bin/getenforce && \
|
|
|
|
chmod 755 /usr/bin/getenforce && \
|
|
|
|
eval `ssh-agent -s` && TAILSCALED_PATH=`pwd`tailscaled ./tailssh.test -test.v -test.run TestSSHAgentForwarding && \
|
|
|
|
TAILSCALED_PATH=`pwd`tailscaled ./tailssh.test -test.v -test.run TestIntegration && \
|
|
|
|
mv /tmp/login_orig /usr/bin/login && \
|
|
|
|
rm /usr/bin/getenforce \
|
|
|
|
; fi
|
2024-05-29 17:51:50 +00:00
|
|
|
|
|
|
|
RUN echo "Then remove the login command and make sure tests still pass."
|
|
|
|
RUN rm `which login`
|
2024-06-14 18:28:39 +00:00
|
|
|
RUN eval `ssh-agent -s` && TAILSCALED_PATH=`pwd`tailscaled ./tailssh.test -test.v -test.run TestSSHAgentForwarding
|
2024-08-05 22:09:34 +00:00
|
|
|
RUN if echo "$BASE" | grep "ubuntu:"; then rm -Rf /home/testuser; fi
|
2024-05-29 17:51:50 +00:00
|
|
|
RUN TAILSCALED_PATH=`pwd`tailscaled ./tailssh.test -test.v -test.run TestIntegrationSFTP
|
2024-08-05 22:09:34 +00:00
|
|
|
RUN if echo "$BASE" | grep "ubuntu:"; then rm -Rf /home/testuser; fi
|
2024-05-29 17:51:50 +00:00
|
|
|
RUN TAILSCALED_PATH=`pwd`tailscaled ./tailssh.test -test.v -test.run TestIntegrationSCP
|
2024-08-05 22:09:34 +00:00
|
|
|
RUN if echo "$BASE" | grep "ubuntu:"; then rm -Rf /home/testuser; fi
|
2024-05-29 17:51:50 +00:00
|
|
|
RUN TAILSCALED_PATH=`pwd`tailscaled ./tailssh.test -test.v -test.run TestIntegrationSSH
|
|
|
|
|
|
|
|
RUN echo "Then remove the su command and make sure tests still pass."
|
|
|
|
RUN chown root:root /tmp/tailscalessh.log
|
|
|
|
RUN rm `which su`
|
2024-06-14 18:28:39 +00:00
|
|
|
RUN eval `ssh-agent -s` && TAILSCALED_PATH=`pwd`tailscaled ./tailssh.test -test.v -test.run TestSSHAgentForwarding
|
2024-05-29 17:51:50 +00:00
|
|
|
RUN TAILSCALED_PATH=`pwd`tailscaled ./tailssh.test -test.v -test.run TestIntegration
|
|
|
|
|
|
|
|
RUN echo "Test doDropPrivileges"
|
|
|
|
RUN TAILSCALED_PATH=`pwd`tailscaled ./tailssh.test -test.v -test.run TestDoDropPrivileges
|