Skip to contentSkip to conversation

download: Add SFTP support and tests

PATCH In review Thomas Preston 2 participants 7 messages Apr 15, 2020 – Jan 6, 2022

lore
Share & tools
lore
#0 lore raw

v2 cover download: Add SFTP support and tests

Hi,
Back in October 2019 I submitted a patch adding an SFTP download method to Buildroot, however since there were no packages using SFTP the patch was rejected.

Yann E. MORIN suggested that it was a valid change however it required tests to avoid bitrot - since there was no way to verify the SFTP download method did not break over time without any packages using it.

In this series I have re-added the SFTP download method and also some test infrastructure which starts a local SSH server and uses SFTP to download some test packages in a br2-external project. I've also added tests for SCP! :D

For this, I had to update the Dockerfile from Debian Stretch to Buster which I explain a bit further in the patch. I'm not sure how to test if this breaks anything else. Will all the tests run in a clean container + Buildroot project clone?

You can run the tests like so:

	support/testing/run-tests -o output -d dl \
		tests.download.test_ssh.TestSFTP \
		tests.download.test_ssh.TestSCP

Thanks!
Thomas

Thomas Preston (5):
support/docker: Update to debian:buster-20200327 support/docker: Add openssh-server testing/infra: Add docstrings to base test classes
download: Add SFTP support (not FTPS) support/testing: Add download tests for SCP/SFTP

 .gitlab-ci.yml                                |   2 +
 Config.in                                     |   4 +
 package/pkg-download.mk                       |   1 +
 support/docker/Dockerfile                     |   3 +-
 support/docker/apt-sources.list               |   8 +-
 support/download/dl-wrapper                   |   2 +-
 support/download/sftp                         |  37 +++++
 support/testing/infra/basetest.py             |   2 +
 .../tests/download/br2-external/scp/Config.in |   0
 .../download/br2-external/scp/external.desc   |   1 +
 .../download/br2-external/scp/external.mk     |   4 +
 .../scp/package/scp-bad/scp-bad.hash          |   1 +
 .../scp/package/scp-bad/scp-bad.mk            |  17 +++
 .../scp/package/scp-good/scp-good.hash        |   1 +
 .../scp/package/scp-good/scp-good.mk          |  17 +++
 .../scp/package/scp-nohash/scp-nohash.mk      |  17 +++
 .../download/br2-external/sftp/Config.in      |   0
 .../download/br2-external/sftp/external.desc  |   1 +
 .../download/br2-external/sftp/external.mk    |   4 +
 .../sftp/package/sftp-bad/sftp-bad.hash       |   1 +
 .../sftp/package/sftp-bad/sftp-bad.mk         |  17 +++
 .../sftp/package/sftp-good/sftp-good.hash     |   1 +
 .../sftp/package/sftp-good/sftp-good.mk       |  17 +++
 .../sftp/package/sftp-nohash/sftp-nohash.mk   |  17 +++
 support/testing/tests/download/sshd.py        | 129 ++++++++++++++++++
 .../tests/download/sshd/ssh-test-1.0.tar.xz   | Bin 0 -> 232 bytes
 support/testing/tests/download/test_ssh.py    |  66 +++++++++
 27 files changed, 364 insertions(+), 6 deletions(-)
 create mode 100755 support/download/sftp
 create mode 100644 support/testing/tests/download/br2-external/scp/Config.in
 create mode 100644 support/testing/tests/download/br2-external/scp/external.desc
 create mode 100644 support/testing/tests/download/br2-external/scp/external.mk
 create mode 100644 support/testing/tests/download/br2-external/scp/package/scp-bad/scp-bad.hash
 create mode 100644 support/testing/tests/download/br2-external/scp/package/scp-bad/scp-bad.mk
 create mode 100644 support/testing/tests/download/br2-external/scp/package/scp-good/scp-good.hash
 create mode 100644 support/testing/tests/download/br2-external/scp/package/scp-good/scp-good.mk
 create mode 100644 support/testing/tests/download/br2-external/scp/package/scp-nohash/scp-nohash.mk
 create mode 100644 support/testing/tests/download/br2-external/sftp/Config.in
 create mode 100644 support/testing/tests/download/br2-external/sftp/external.desc
 create mode 100644 support/testing/tests/download/br2-external/sftp/external.mk
 create mode 100644 support/testing/tests/download/br2-external/sftp/package/sftp-bad/sftp-bad.hash
 create mode 100644 support/testing/tests/download/br2-external/sftp/package/sftp-bad/sftp-bad.mk
 create mode 100644 support/testing/tests/download/br2-external/sftp/package/sftp-good/sftp-good.hash
 create mode 100644 support/testing/tests/download/br2-external/sftp/package/sftp-good/sftp-good.mk
 create mode 100644 support/testing/tests/download/br2-external/sftp/package/sftp-nohash/sftp-nohash.mk
 create mode 100644 support/testing/tests/download/sshd.py
 create mode 100644 support/testing/tests/download/sshd/ssh-test-1.0.tar.xz
 create mode 100755 support/testing/tests/download/test_ssh.py
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/5 support/docker: Update to debian:buster-20200327

Update the test container to debian:buster-20200327, because it contains the openssh-server package v7.9, which provides an updated ssh-keygen (since v7.6).

Specifically, the host key generation function in openssh-server v7.6 onwards now accepts a flag that allows us to specify a host tree prefix, instead of trying to create SSH host keys in /. This allows us to create SSH host keys and therefore run an SSH server as a non-root user. For example, to create host keys in prefix/host/etc/ssh:

ssh-keygen -A -f prefix/host

---
 support/docker/Dockerfile       | 2 +-
 support/docker/apt-sources.list | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
support/docker/Dockerfile +1 -1
index 03acde85d2..be795a18b4 100644
@@ -6,7 +6,7 @@
 # We use a specific tag for the base image *and* the corresponding date
 # for the repository., so do not forget to update the apt-sources.list
 # file that is shipped next to this Dockerfile.
-FROM debian:stretch-20171210
+FROM debian:buster-20200327
 
 LABEL maintainer="Buildroot mailing list <[email protected]>" \
       vendor="Buildroot" \
support/docker/apt-sources.list +4 -4
index 789fb8fc17..c13c4d03c4 100644
@@ -1,4 +1,4 @@
-# Latest just before 20171210T000000Z:
-deb [check-valid-until=no] http://snapshot.debian.org/archive/debian/20171209T220346Z/ stretch main
-deb [check-valid-until=no] http://snapshot.debian.org/archive/debian/20171209T220346Z/ stretch-updates main
-deb [check-valid-until=no] http://snapshot.debian.org/archive/debian-security/20171209T224618Z/ stretch/updates main
+# Latest just before 20200327T000000Z:
+deb [check-valid-until=no] http://snapshot.debian.org/archive/debian/20200326T221821Z/ buster main
+deb [check-valid-until=no] http://snapshot.debian.org/archive/debian/20200326T221821Z/ buster-updates main
+deb [check-valid-until=no] http://snapshot.debian.org/archive/debian-security/20200316T220151Z/ buster/updates main
Signature · 1 line
2.20.1
#2 lore raw

PATCH v2 2/5 support/docker: Add openssh-server

In reply to Thomas Preston

Install the openssh-server package into the test container. This package, as well as its dependency openssh-client, is required to test SCP and SFTP download methods on the localhost, as if these tools were already installed on the user's machine.

---
 support/docker/Dockerfile | 1 +
 1 file changed, 1 insertion(+)
support/docker/Dockerfile +1 -0
index be795a18b4..f44be230e6 100644
@@ -36,6 +36,7 @@ RUN apt-get install -y --no-install-recommends \
         libncurses5-dev \
         locales \
         mercurial \
+        openssh-server \
         python-flake8 \
         python-nose2 \
         python-pexpect \
Signature · 1 line
2.20.1
#3 lore raw

PATCH v2 3/5 testing/infra: Add docstrings to base test classes

In reply to Thomas Preston

It wasn't immediately obvious to me what the two Buildroot base test classes were for, so add docstrings to explain the differences between BRConfigTest and BRTest.

---
 support/testing/infra/basetest.py | 2 ++
 1 file changed, 2 insertions(+)
support/testing/infra/basetest.py +2 -0
index 5dc6034447..dec0ab7013 100644
@@ -29,6 +29,7 @@ MINIMAL_CONFIG = \
 
 
 class BRConfigTest(unittest.TestCase):
+    """Test up to the configure stage."""
     config = None
     br2_external = list()
     downloaddir = None
@@ -66,6 +67,7 @@ class BRConfigTest(unittest.TestCase):
 
 
 class BRTest(BRConfigTest):
+    """Test up to the build stage and instantiate an emulator."""
     def __init__(self, names):
         super(BRTest, self).__init__(names)
         self.emulator = None
Signature · 1 line
2.20.1
#4 lore raw

PATCH v2 4/5 download: Add SFTP support (not FTPS)

In reply to Thomas Preston

Add Secure File Transfer Program (SFTP) support using a simple wrapper. SFTP is a common protocol used to transfer files securely between enterprises, but it is not currently supported in Buildroot because all of the packages are usually available via HTTP, git or some other download method.

SFTP is similar to FTP but it preforms all operations over an encrypted SSH transport.

---
 Config.in                   |  4 ++++
 package/pkg-download.mk     |  1 +
 support/download/dl-wrapper |  2 +-
 support/download/sftp       | 37 +++++++++++++++++++++++++++++++++++++
 4 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100755 support/download/sftp
Config.in +4 -0
index 48fd36ff98..2050dd7a03 100644
@@ -114,6 +114,10 @@ config BR2_SCP
 	string "Secure copy (scp) command"
 	default "scp"
 
+config BR2_SFTP
+	string "Secure file transfer (sftp) command"
+	default "sftp"
+
 config BR2_HG
 	string "Mercurial (hg) command"
 	default "hg"
package/pkg-download.mk +1 -0
index de619ba90a..88790fe46e 100644
@@ -15,6 +15,7 @@ export BZR := $(call qstrip,$(BR2_BZR))
 export GIT := $(call qstrip,$(BR2_GIT))
 export HG := $(call qstrip,$(BR2_HG))
 export SCP := $(call qstrip,$(BR2_SCP))
+export SFTP := $(call qstrip,$(BR2_SFTP))
 export LOCALFILES := $(call qstrip,$(BR2_LOCALFILES))
 
 DL_WRAPPER = support/download/dl-wrapper
support/download/dl-wrapper +1 -1
index 3315bd410e..6cf0b89cba 100755
@@ -88,7 +88,7 @@ main() {
         backend_urlencode="${uri%%+*}"
         backend="${backend_urlencode%|*}"
         case "${backend}" in
-            git|svn|cvs|bzr|file|scp|hg) ;;
+            git|svn|cvs|bzr|file|scp|hg|sftp) ;;
             *) backend="wget" ;;
         esac
         uri=${uri#*+}
support/download/sftp new file +37 -0
new file mode 100755
index 0000000000..8aeb91e0e8
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+# We want to catch any unexpected failure, and exit immediately
+set -e
+
+# Download helper for sftp, to be called from the download wrapper script
+#
+# Options:
+#   -q          Be quiet.
+#   -o FILE     Copy to local file FILE.
+#   -f FILE     Copy from remote file FILE.
+#   -u URI      Download file at URI.
+#
+# Environment:
+#   SFTP      : the sftp command to call
+
+verbose=
+while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do
+    case "${OPT}" in
+    q)  verbose=-q;;
+    o)  output="${OPTARG}";;
+    f)  filename="${OPTARG}";;
+    u)  uri="${OPTARG}";;
+    :)  printf "option '%s' expects a mandatory argument\n" "${OPTARG}"; exit 1;;
+    \?) printf "unknown option '%s'\n" "${OPTARG}" >&2; exit 1;;
+    esac
+done
+
+shift $((OPTIND-1)) # Get rid of our options
+
+# Caller needs to single-quote its arguments to prevent them from
+# being expanded a second time (in case there are spaces in them)
+_sftp() {
+    eval ${SFTP} "${@}"
+}
+
+_sftp ${verbose} "${@}" "'${uri}/${filename}'" "'${output}'"
Signature · 1 line
2.20.1
#5 lore raw

PATCH v2 5/5 support/testing: Add download tests for SCP/SFTP

In reply to Thomas Preston

Add download test infrastructure which starts an OpenSSH server using the sshd binary installed on the Buildroot host. This server can then be used to test the expected usage of the SCP and SFTP download methods. The test creates new SSH keys for the server and client, so that the server can be run as a non-root user.

A new test module has been added called tests.download.sshd which contains helper methods to create the SSH keys and a class called OpenSSHDaemon which handles the sshd server component.

The tests download example packages in the br2-external project ssh. They check the following conditions for both SCP and SFTP download methods:
- Correct hash.
- Incorrect hash.
- No hash file.

The SSH download test infrastructure is based on test_git.py.

---
 .gitlab-ci.yml                                |   2 +
 .../tests/download/br2-external/scp/Config.in |   0
 .../download/br2-external/scp/external.desc   |   1 +
 .../download/br2-external/scp/external.mk     |   4 +
 .../scp/package/scp-bad/scp-bad.hash          |   1 +
 .../scp/package/scp-bad/scp-bad.mk            |  17 +++
 .../scp/package/scp-good/scp-good.hash        |   1 +
 .../scp/package/scp-good/scp-good.mk          |  17 +++
 .../scp/package/scp-nohash/scp-nohash.mk      |  17 +++
 .../download/br2-external/sftp/Config.in      |   0
 .../download/br2-external/sftp/external.desc  |   1 +
 .../download/br2-external/sftp/external.mk    |   4 +
 .../sftp/package/sftp-bad/sftp-bad.hash       |   1 +
 .../sftp/package/sftp-bad/sftp-bad.mk         |  17 +++
 .../sftp/package/sftp-good/sftp-good.hash     |   1 +
 .../sftp/package/sftp-good/sftp-good.mk       |  17 +++
 .../sftp/package/sftp-nohash/sftp-nohash.mk   |  17 +++
 support/testing/tests/download/sshd.py        | 129 ++++++++++++++++++
 .../tests/download/sshd/ssh-test-1.0.tar.xz   | Bin 0 -> 232 bytes
 support/testing/tests/download/test_ssh.py    |  66 +++++++++
 20 files changed, 313 insertions(+)
 create mode 100644 support/testing/tests/download/br2-external/scp/Config.in
 create mode 100644 support/testing/tests/download/br2-external/scp/external.desc
 create mode 100644 support/testing/tests/download/br2-external/scp/external.mk
 create mode 100644 support/testing/tests/download/br2-external/scp/package/scp-bad/scp-bad.hash
 create mode 100644 support/testing/tests/download/br2-external/scp/package/scp-bad/scp-bad.mk
 create mode 100644 support/testing/tests/download/br2-external/scp/package/scp-good/scp-good.hash
 create mode 100644 support/testing/tests/download/br2-external/scp/package/scp-good/scp-good.mk
 create mode 100644 support/testing/tests/download/br2-external/scp/package/scp-nohash/scp-nohash.mk
 create mode 100644 support/testing/tests/download/br2-external/sftp/Config.in
 create mode 100644 support/testing/tests/download/br2-external/sftp/external.desc
 create mode 100644 support/testing/tests/download/br2-external/sftp/external.mk
 create mode 100644 support/testing/tests/download/br2-external/sftp/package/sftp-bad/sftp-bad.hash
 create mode 100644 support/testing/tests/download/br2-external/sftp/package/sftp-bad/sftp-bad.mk
 create mode 100644 support/testing/tests/download/br2-external/sftp/package/sftp-good/sftp-good.hash
 create mode 100644 support/testing/tests/download/br2-external/sftp/package/sftp-good/sftp-good.mk
 create mode 100644 support/testing/tests/download/br2-external/sftp/package/sftp-nohash/sftp-nohash.mk
 create mode 100644 support/testing/tests/download/sshd.py
 create mode 100644 support/testing/tests/download/sshd/ssh-test-1.0.tar.xz
 create mode 100755 support/testing/tests/download/test_ssh.py
.gitlab-ci.yml +2 -0
index 4b84a5b709..8061b50526 100644
@@ -349,6 +349,8 @@ tests.core.test_timezone.TestGlibcNonDefaultLimitedTimezone: { extends: .runtime
 tests.core.test_timezone.TestNoTimezone: { extends: .runtime_test }
 tests.download.test_git.TestGitHash: { extends: .runtime_test }
 tests.download.test_git.TestGitRefs: { extends: .runtime_test }
+tests.download.test_ssh.TestSCP: { extends: .runtime_test }
+tests.download.test_ssh.TestSFTP: { extends: .runtime_test }
 tests.fs.test_ext.TestExt2: { extends: .runtime_test }
 tests.fs.test_ext.TestExt2r1: { extends: .runtime_test }
 tests.fs.test_ext.TestExt3: { extends: .runtime_test }
support/testing/tests/download/br2-external/scp/Config.in new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
support/testing/tests/download/br2-external/scp/external.desc new file +1 -0
new file mode 100644
index 0000000000..0ca0389a32
@@ -0,0 +1 @@
+name: SCP
support/testing/tests/download/br2-external/scp/external.mk new file +4 -0
new file mode 100644
index 0000000000..49408f2f22
@@ -0,0 +1,4 @@
+include $(sort $(wildcard $(BR2_EXTERNAL_SCP_PATH)/package/*/*.mk))
+
+# Get the openssh-server port number from the test infra
+SSHD_PORT_NUMBER ?= 2222
support/testing/tests/download/br2-external/scp/package/scp-bad/scp-bad.hash new file +1 -0
new file mode 100644
index 0000000000..90b15b30c2
@@ -0,0 +1 @@
+sha256  0000000000000000000000000000000000000000000000000000000000000000  ssh-test-1.0.tar.xz
support/testing/tests/download/br2-external/scp/package/scp-bad/scp-bad.mk new file +17 -0
new file mode 100644
index 0000000000..5f6d55d940
@@ -0,0 +1,17 @@
+################################################################################
+#
+# scp-bad
+#
+################################################################################
+
+SCP_BAD_VERSION = 1.0
+SCP_BAD_SOURCE = ssh-test-$(SCP_BAD_VERSION).tar.xz
+SCP_BAD_SITE = scp://localhost:$(SSHD_TEST_DIR)
+SCP_BAD_DL_OPTS = \
+	-P $(SSHD_PORT_NUMBER) \
+	-i $(SSH_IDENTITY) \
+	-o "UserKnownHostsFile=/dev/null" \
+	-o "StrictHostKeyChecking=no" \
+	-o "CheckHostIP=no"
+
+$(eval $(generic-package))
support/testing/tests/download/br2-external/scp/package/scp-good/scp-good.hash new file +1 -0
new file mode 100644
index 0000000000..31353a88ba
@@ -0,0 +1 @@
+sha256  b457c1a37ba7405e8806b93f3d5cc82165db0b0cad25d203f112e32c7a30c0be  ssh-test-1.0.tar.xz
support/testing/tests/download/br2-external/scp/package/scp-good/scp-good.mk new file +17 -0
new file mode 100644
index 0000000000..eff455a470
@@ -0,0 +1,17 @@
+################################################################################
+#
+# scp-good
+#
+################################################################################
+
+SCP_GOOD_VERSION = 1.0
+SCP_GOOD_SOURCE = ssh-test-$(SCP_GOOD_VERSION).tar.xz
+SCP_GOOD_SITE = scp://localhost:$(SSHD_TEST_DIR)
+SCP_GOOD_DL_OPTS = \
+	-P $(SSHD_PORT_NUMBER) \
+	-i $(SSH_IDENTITY) \
+	-o "UserKnownHostsFile=/dev/null" \
+	-o "StrictHostKeyChecking=no" \
+	-o "CheckHostIP=no" \
+
+$(eval $(generic-package))
support/testing/tests/download/br2-external/scp/package/scp-nohash/scp-nohash.mk new file +17 -0
new file mode 100644
index 0000000000..f44c45fda3
@@ -0,0 +1,17 @@
+################################################################################
+#
+# scp-nohash
+#
+################################################################################
+
+SCP_NOHASH_VERSION = 1.0
+SCP_NOHASH_SOURCE = ssh-test-$(SCP_NOHASH_VERSION).tar.xz
+SCP_NOHASH_SITE = scp://localhost:$(SSHD_TEST_DIR)
+SCP_NOHASH_DL_OPTS = \
+	-P $(SSHD_PORT_NUMBER) \
+	-i $(SSH_IDENTITY) \
+	-o "UserKnownHostsFile=/dev/null" \
+	-o "StrictHostKeyChecking=no" \
+	-o "CheckHostIP=no" \
+
+$(eval $(generic-package))
support/testing/tests/download/br2-external/sftp/Config.in new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
support/testing/tests/download/br2-external/sftp/external.desc new file +1 -0
new file mode 100644
index 0000000000..ae3a2860cd
@@ -0,0 +1 @@
+name: SFTP
support/testing/tests/download/br2-external/sftp/external.mk new file +4 -0
new file mode 100644
index 0000000000..cd4a7c839e
@@ -0,0 +1,4 @@
+include $(sort $(wildcard $(BR2_EXTERNAL_SFTP_PATH)/package/*/*.mk))
+
+# Get the openssh-server port number from the test infra
+SSHD_PORT_NUMBER ?= 2222
support/testing/tests/download/br2-external/sftp/package/sftp-bad/sftp-bad.hash new file +1 -0
new file mode 100644
index 0000000000..90b15b30c2
@@ -0,0 +1 @@
+sha256  0000000000000000000000000000000000000000000000000000000000000000  ssh-test-1.0.tar.xz
support/testing/tests/download/br2-external/sftp/package/sftp-bad/sftp-bad.mk new file +17 -0
new file mode 100644
index 0000000000..fa83c2cd68
@@ -0,0 +1,17 @@
+################################################################################
+#
+# sftp-bad
+#
+################################################################################
+
+SFTP_BAD_VERSION = 1.0
+SFTP_BAD_SOURCE = ssh-test-$(SFTP_BAD_VERSION).tar.xz
+SFTP_BAD_SITE = sftp://localhost/$(SSHD_TEST_DIR)
+SFTP_BAD_DL_OPTS = \
+	-P $(SSHD_PORT_NUMBER) \
+	-i $(SSH_IDENTITY) \
+	-o "UserKnownHostsFile=/dev/null" \
+	-o "StrictHostKeyChecking=no" \
+	-o "CheckHostIP=no" \
+
+$(eval $(generic-package))
support/testing/tests/download/br2-external/sftp/package/sftp-good/sftp-good.hash new file +1 -0
new file mode 100644
index 0000000000..31353a88ba
@@ -0,0 +1 @@
+sha256  b457c1a37ba7405e8806b93f3d5cc82165db0b0cad25d203f112e32c7a30c0be  ssh-test-1.0.tar.xz
support/testing/tests/download/br2-external/sftp/package/sftp-good/sftp-good.mk new file +17 -0
new file mode 100644
index 0000000000..1cb5f22dbc
@@ -0,0 +1,17 @@
+################################################################################
+#
+# sftp-good
+#
+################################################################################
+
+SFTP_GOOD_VERSION = 1.0
+SFTP_GOOD_SOURCE = ssh-test-$(SFTP_GOOD_VERSION).tar.xz
+SFTP_GOOD_SITE = sftp://localhost/$(SSHD_TEST_DIR)
+SFTP_GOOD_DL_OPTS = \
+	-P $(SSHD_PORT_NUMBER) \
+	-i $(SSH_IDENTITY) \
+	-o "UserKnownHostsFile=/dev/null" \
+	-o "StrictHostKeyChecking=no" \
+	-o "CheckHostIP=no" \
+
+$(eval $(generic-package))
support/testing/tests/download/br2-external/sftp/package/sftp-nohash/sftp-nohash.mk new file +17 -0
new file mode 100644
index 0000000000..62a2c3d864
@@ -0,0 +1,17 @@
+################################################################################
+#
+# sftp-nohash
+#
+################################################################################
+
+SFTP_NOHASH_VERSION = 1.0
+SFTP_NOHASH_SOURCE = ssh-test-$(SFTP_NOHASH_VERSION).tar.xz
+SFTP_NOHASH_SITE = sftp://localhost/$(SSHD_TEST_DIR)
+SFTP_NOHASH_DL_OPTS = \
+	-P $(SSHD_PORT_NUMBER) \
+	-i $(SSH_IDENTITY) \
+	-o "UserKnownHostsFile=/dev/null" \
+	-o "StrictHostKeyChecking=no" \
+	-o "CheckHostIP=no" \
+
+$(eval $(generic-package))
support/testing/tests/download/sshd.py new file +129 -0

129 lines not on this page · raw message

support/testing/tests/download/sshd/ssh-test-1.0.tar.xz new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..bd83d0aff57569181d48e3c62ed24cf413349857
GIT binary patch

zcmV<E02lxLH+ooF000E$*0e?f03iVu0001VFXf})C;tGaT>v at ZoLY1;=#rcYU!vo{ zY*d180V}vZPgp1s8F;=V2;UVkreiQmd@~S!C7Cz<muCq&y&rU=#0Mnb>Go}p<~MWy zLlsZz<ezJHLQ+Zz;FM>Od$tuKG<#wIxTdaXt!(>CWqO6(9;!ET?+(Xp1W5kWc%A<b zSztIv+|VVwQHZ*%f;jPjmxo8t{;$zGJ!I)lpxo&x%+_rzrkKwYNz5s%Y8pC0001w i;7sIpNoptn0mA+Pyhh at 39RU`#Ao{g000001X)^l_h(@M

literal 0
HcmV?d00001

support/testing/tests/download/test_ssh.py new file +66 -0

66 lines not on this page · raw message

Signature · 1 line
2.20.1
#6 lore raw
In reply to Thomas Preston

Hi all,

I finally applied this series. Since Thomas is no longer with CodeThink this
is more for the others in Cc.

Quoted 25 lines · Thomas Preston

Hi,
Back in October 2019 I submitted a patch adding an SFTP download method to Buildroot, however since there were no packages using SFTP the patch was rejected.

Yann E. MORIN suggested that it was a valid change however it required tests to avoid bitrot - since there was no way to verify the SFTP download method did not break over time without any packages using it.

In this series I have re-added the SFTP download method and also some test infrastructure which starts a local SSH server and uses SFTP to download some test packages in a br2-external project. I've also added tests for SCP! :D

For this, I had to update the Dockerfile from Debian Stretch to Buster which I explain a bit further in the patch. I'm not sure how to test if this breaks anything else. Will all the tests run in a clean container + Buildroot project clone?

You can run the tests like so:

	support/testing/run-tests -o output -d dl \
		tests.download.test_ssh.TestSFTP \
		tests.download.test_ssh.TestSCP
Quoted 5 lines

Thanks!
Thomas

Thomas Preston (5):
support/docker: Update to debian:buster-20200327

I skipped this one because in the meanwhile we already updated to a more
recent Debian.

Quoted 3 lines

support/docker: Add openssh-server testing/infra: Add docstrings to base test classes
download: Add SFTP support (not FTPS)

[Arnout:
- update documentation with sftp everywhere scp is mentioned;
- rename "verbose" variable to "quiet";
- print the sftp command, similar to wget and scp helpers.
]

Quoted 1 line

support/testing: Add download tests for SCP/SFTP

[Arnout:
- remove spurious end-of-line backslash;
- remove unnecessary executable bit;
- skip test instead of failing if sshd, ssh-keygen, scp or sftp are not found;
- decode the output of subprocess;
- use subprocess.check_output instead of subprocess.get_output;
- use subprocess.check_call instead of manually checking return code;
- don't set always-overridden SSHD_PORT_NUMBER in .mk file;
- explicitly set sshd options on commandline instead of relying on host /etc/sshd/sshd_config;
- let sshd listen only on localhost;
- user internal sftp server;
- disable BACKUP_SITE, no network is supposed to be accessed;
- remove the -bad and -nohash versions;
- rename {sftp,scp}-good to plain {sftp,scp};
- move the sftp and scp packages into a single "ssh" external.
]

Quoted 41 lines
  .gitlab-ci.yml                                |   2 +
  Config.in                                     |   4 +
  package/pkg-download.mk                       |   1 +
  support/docker/Dockerfile                     |   3 +-
  support/docker/apt-sources.list               |   8 +-
  support/download/dl-wrapper                   |   2 +-
  support/download/sftp                         |  37 +++++
  support/testing/infra/basetest.py             |   2 +
  .../tests/download/br2-external/scp/Config.in |   0
  .../download/br2-external/scp/external.desc   |   1 +
  .../download/br2-external/scp/external.mk     |   4 +
  .../scp/package/scp-bad/scp-bad.hash          |   1 +
  .../scp/package/scp-bad/scp-bad.mk            |  17 +++
  .../scp/package/scp-good/scp-good.hash        |   1 +
  .../scp/package/scp-good/scp-good.mk          |  17 +++
  .../scp/package/scp-nohash/scp-nohash.mk      |  17 +++
  .../download/br2-external/sftp/Config.in      |   0
  .../download/br2-external/sftp/external.desc  |   1 +
  .../download/br2-external/sftp/external.mk    |   4 +
  .../sftp/package/sftp-bad/sftp-bad.hash       |   1 +
  .../sftp/package/sftp-bad/sftp-bad.mk         |  17 +++
  .../sftp/package/sftp-good/sftp-good.hash     |   1 +
  .../sftp/package/sftp-good/sftp-good.mk       |  17 +++
  .../sftp/package/sftp-nohash/sftp-nohash.mk   |  17 +++
  support/testing/tests/download/sshd.py        | 129 ++++++++++++++++++
  .../tests/download/sshd/ssh-test-1.0.tar.xz   | Bin 0 -> 232 bytes
  support/testing/tests/download/test_ssh.py    |  66 +++++++++
  27 files changed, 364 insertions(+), 6 deletions(-)

create mode 100755 support/download/sftp
create mode 100644 support/testing/tests/download/br2-external/scp/Config.in
create mode 100644 support/testing/tests/download/br2-external/scp/external.desc create mode 100644 support/testing/tests/download/br2-external/scp/external.mk create mode 100644 support/testing/tests/download/br2-external/scp/package/scp-bad/scp-bad.hash create mode 100644 support/testing/tests/download/br2-external/scp/package/scp-bad/scp-bad.mk create mode 100644 support/testing/tests/download/br2-external/scp/package/scp-good/scp-good.hash create mode 100644 support/testing/tests/download/br2-external/scp/package/scp-good/scp-good.mk create mode 100644 support/testing/tests/download/br2-external/scp/package/scp-nohash/scp-nohash.mk create mode 100644 support/testing/tests/download/br2-external/sftp/Config.in create mode 100644 support/testing/tests/download/br2-external/sftp/external.desc create mode 100644 support/testing/tests/download/br2-external/sftp/external.mk

Quoted 9 lines

create mode 100644 support/testing/tests/download/br2-external/sftp/package/sftp-bad/sftp-bad.hash create mode 100644 support/testing/tests/download/br2-external/sftp/package/sftp-bad/sftp-bad.mk create mode 100644 support/testing/tests/download/br2-external/sftp/package/sftp-good/sftp-good.hash create mode 100644 support/testing/tests/download/br2-external/sftp/package/sftp-good/sftp-good.mk create mode 100644 support/testing/tests/download/br2-external/sftp/package/sftp-nohash/sftp-nohash.mk create mode 100644 support/testing/tests/download/sshd.py
create mode 100644 support/testing/tests/download/sshd/ssh-test-1.0.tar.xz
create mode 100755 support/testing/tests/download/test_ssh.py

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot