Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite in rust #5

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "exec-suid"
version = "0.1.0"
edition = "2021"

[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
strip = "symbols"

[dependencies]
nix = { version = "0.29", features = ["fs", "process", "user"] }
21 changes: 8 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
# syntax=docker/dockerfile:1

FROM alpine:latest AS builder

RUN apk add --no-cache gcc musl-dev

COPY exec-suid.c .

ENV CC="gcc -static -O3 -s"
RUN $CC -o /usr/bin/exec-suid exec-suid.c
FROM rust:latest AS builder
RUN apt-get update && apt-get install -y musl-tools && rm -rf /var/lib/apt/lists/*
RUN rustup target add x86_64-unknown-linux-musl
WORKDIR /usr/src/exec-suid
COPY Cargo.toml ./
COPY src ./src
RUN find . && cargo build --release --target x86_64-unknown-linux-musl

FROM python:latest

RUN pip install pytest pyyaml

RUN useradd -m hacker

COPY --from=builder --chown=0:0 --chmod=6755 /usr/bin/exec-suid /usr/bin/exec-suid

COPY --from=builder --chmod=6755 /usr/src/exec-suid/target/x86_64-unknown-linux-musl/release/exec-suid /usr/bin/exec-suid
COPY tests /tests

CMD ["pytest", "-v", "/tests"]
233 changes: 0 additions & 233 deletions exec-suid.c

This file was deleted.

Loading
Loading