From 4748ab4ef0b2cd94eaa3094ce1528f6925a62752 Mon Sep 17 00:00:00 2001 From: fheinecke <23390735+fheinecke@users.noreply.github.com> Date: Wed, 12 Jun 2024 05:33:10 -0500 Subject: [PATCH] Add support for building `fdpass-teleport` (#42731) * Add support for building `fdpass-teleport` * bumped e ref --- Makefile | 12 ++++++++++-- assets/aws/files/install-hardened.sh | 2 +- build.assets/Dockerfile | 2 +- build.assets/Dockerfile-arm | 1 + build.assets/build-package.sh | 6 +++--- e | 2 +- tool/fdpass-teleport/.cargo/config.toml | 2 ++ 7 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 tool/fdpass-teleport/.cargo/config.toml diff --git a/Makefile b/Makefile index b00c7042dc1c2..1144012980e47 100644 --- a/Makefile +++ b/Makefile @@ -101,10 +101,12 @@ RUST_TARGET_ARCH ?= $(CARGO_TARGET_$(OS)_$(ARCH)) CARGO_TARGET_darwin_amd64 := x86_64-apple-darwin CARGO_TARGET_darwin_arm64 := aarch64-apple-darwin +CARGO_TARGET_linux_arm := arm-unknown-linux-gnueabihf CARGO_TARGET_linux_arm64 := aarch64-unknown-linux-gnu +CARGO_TARGET_linux_386 := i686-unknown-linux-gnu CARGO_TARGET_linux_amd64 := x86_64-unknown-linux-gnu -CARGO_TARGET := --target=${CARGO_TARGET_${OS}_${ARCH}} +CARGO_TARGET := --target=$(RUST_TARGET_ARCH) # If set to 1, Windows RDP client is not built. RDPCLIENT_SKIP_BUILD ?= 0 @@ -198,7 +200,7 @@ endif # On Windows only build tsh. On all other platforms build teleport, tctl, # and tsh. -BINS_default = teleport tctl tsh tbot +BINS_default = teleport tctl tsh tbot fdpass-teleport BINS_windows = tsh BINS = $(or $(BINS_$(OS)),$(BINS_default)) BINARIES = $(addprefix $(BUILDDIR)/,$(BINS)) @@ -322,6 +324,11 @@ $(BUILDDIR)/tsh: $(BUILDDIR)/tbot: GOOS=$(OS) GOARCH=$(ARCH) $(CGOFLAG) go build -tags "$(FIPS_TAG)" -o $(BUILDDIR)/tbot $(BUILDFLAGS) ./tool/tbot +.PHONY: $(BUILDDIR)/fdpass-teleport +$(BUILDDIR)/fdpass-teleport: + cd tool/fdpass-teleport && cargo build --release --locked $(CARGO_TARGET) + install tool/fdpass-teleport/target/$(RUST_TARGET_ARCH)/release/fdpass-teleport $(BUILDDIR)/ + # # BPF support (IF ENABLED) # Requires a recent version of clang and libbpf installed. @@ -534,6 +541,7 @@ release-darwin: $(RELEASE_darwin_arm64) $(RELEASE_darwin_amd64) lipo -create -output $(BUILDDIR)/tctl $(BUILDDIR_arm64)/tctl $(BUILDDIR_amd64)/tctl lipo -create -output $(BUILDDIR)/tsh $(BUILDDIR_arm64)/tsh $(BUILDDIR_amd64)/tsh lipo -create -output $(BUILDDIR)/tbot $(BUILDDIR_arm64)/tbot $(BUILDDIR_amd64)/tbot + lipo -create -output $(BUILDDIR)/fdpass-teleport $(BUILDDIR_arm64)/fdpass-teleport $(BUILDDIR_amd64)/fdpass-teleport $(MAKE) ARCH=universal build-archive @if [ -f e/Makefile ]; then $(MAKE) -C e release; fi endif diff --git a/assets/aws/files/install-hardened.sh b/assets/aws/files/install-hardened.sh index 9f0294e3fd583..2fd099a28e8d2 100644 --- a/assets/aws/files/install-hardened.sh +++ b/assets/aws/files/install-hardened.sh @@ -27,7 +27,7 @@ install -d -m 0755 -o teleport -g adm /run/teleport /etc/teleport.d # Extract tarball to /tmp/teleport to get the binaries out mkdir /tmp/teleport tar -C /tmp/teleport -x -z -f /tmp/teleport.tar.gz --strip-components=1 -install -m 755 /tmp/teleport/{tctl,tsh,teleport,tbot} /usr/local/bin +install -m 755 /tmp/teleport/{tctl,tsh,teleport,tbot,fdpass-teleport} /usr/local/bin rm -rf /tmp/teleport /tmp/teleport.tar.gz if [[ "${TELEPORT_FIPS}" == 1 ]]; then diff --git a/build.assets/Dockerfile b/build.assets/Dockerfile index 1dc78cae16c87..c523a4dac1f74 100644 --- a/build.assets/Dockerfile +++ b/build.assets/Dockerfile @@ -226,7 +226,7 @@ RUN curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y --p rustc --version && \ rustup component add rustfmt clippy && \ rustup target add wasm32-unknown-unknown && \ - if [ "$BUILDARCH" = "amd64" ]; then rustup target add aarch64-unknown-linux-gnu; fi + if [ "$BUILDARCH" = "amd64" ]; then rustup target add aarch64-unknown-linux-gnu i686-unknown-linux-gnu; fi ARG WASM_PACK_VERSION # Install wasm-pack for targeting WebAssembly from Rust. diff --git a/build.assets/Dockerfile-arm b/build.assets/Dockerfile-arm index 4c13760e28afb..ff3ea1b656d27 100644 --- a/build.assets/Dockerfile-arm +++ b/build.assets/Dockerfile-arm @@ -93,6 +93,7 @@ RUN mkdir -p $RUSTUP_HOME && chmod a+w $RUSTUP_HOME && \ # will run builds using the Rust toolchains we install here. USER ci RUN curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain $RUST_VERSION && \ + rustup target add arm-unknown-linux-gnueabihf && \ rustup --version && \ cargo --version && \ rustc --version diff --git a/build.assets/build-package.sh b/build.assets/build-package.sh index 770b067c17dd3..bea782977f517 100755 --- a/build.assets/build-package.sh +++ b/build.assets/build-package.sh @@ -218,7 +218,7 @@ if [[ "${PACKAGE_TYPE}" == "pkg" ]]; then ARCH_TAG="-${PACKAGE_ARCH}" fi SIGN_PKG="true" - FILE_LIST="${TAR_PATH}/tsh ${TAR_PATH}/tctl ${TAR_PATH}/teleport ${TAR_PATH}/tbot" + FILE_LIST="${TAR_PATH}/tsh ${TAR_PATH}/tctl ${TAR_PATH}/teleport ${TAR_PATH}/tbot ${TAR_PATH}/fdpass-teleport" BUNDLE_ID="${b:-com.gravitational.teleport}" if [[ "${TELEPORT_TYPE}" == "ent" ]]; then PKG_FILENAME="teleport-ent-${TELEPORT_VERSION}${ARCH_TAG}.${PACKAGE_TYPE}" @@ -226,8 +226,8 @@ if [[ "${PACKAGE_TYPE}" == "pkg" ]]; then PKG_FILENAME="teleport-${TELEPORT_VERSION}${ARCH_TAG}.${PACKAGE_TYPE}" fi else - FILE_LIST="${TAR_PATH}/tsh ${TAR_PATH}/tctl ${TAR_PATH}/teleport ${TAR_PATH}/tbot ${TAR_PATH}/examples/systemd/teleport.service ${TAR_PATH}/examples/systemd/post-upgrade" - LINUX_BINARY_FILE_LIST="${TAR_PATH}/tsh ${TAR_PATH}/tctl ${TAR_PATH}/tbot ${TAR_PATH}/teleport" + FILE_LIST="${TAR_PATH}/tsh ${TAR_PATH}/tctl ${TAR_PATH}/teleport ${TAR_PATH}/tbot ${TAR_PATH}/fdpass-teleport ${TAR_PATH}/examples/systemd/teleport.service ${TAR_PATH}/examples/systemd/post-upgrade" + LINUX_BINARY_FILE_LIST="${TAR_PATH}/tsh ${TAR_PATH}/tctl ${TAR_PATH}/tbot ${TAR_PATH}/fdpass-teleport ${TAR_PATH}/teleport" LINUX_SYSTEMD_FILE_LIST="${TAR_PATH}/examples/systemd/teleport.service" EXTRA_DOCKER_OPTIONS="" RPM_SIGN_STANZA="" diff --git a/e b/e index 21a536be00a8f..d98bf221d5e46 160000 --- a/e +++ b/e @@ -1 +1 @@ -Subproject commit 21a536be00a8fe3233d813b1acf47f952f7f098b +Subproject commit d98bf221d5e4600a2424b5853263e2fdd63ff6f7 diff --git a/tool/fdpass-teleport/.cargo/config.toml b/tool/fdpass-teleport/.cargo/config.toml new file mode 100644 index 0000000000000..112515e79918e --- /dev/null +++ b/tool/fdpass-teleport/.cargo/config.toml @@ -0,0 +1,2 @@ +[target.arm-unknown-linux-gnueabihf] +linker = "arm-linux-gnueabihf-gcc"