FROM gcc:12-bookworm@sha256:3d3af69c72edf0652bb3a829965142e81891899c7827d849bc3c0dbb9edd216a

WORKDIR /src
COPY . /src

RUN chmod +x configure tools/install.sh \
	&& sh ./configure \
		--prefix=/opt/musl \
		--syslibdir=/opt/musl/lib \
	&& make -s -j"$(nproc)" \
	&& make -s install

RUN /opt/musl/bin/musl-gcc \
	-O0 \
	-g \
	-Wall \
	-Wextra \
	-o /opt/putenv-self-uaf \
	/src/poc/linux/putenv-self-uaf.c

ENTRYPOINT []
CMD ["/bin/sh", "-c", "uname -a && file /opt/putenv-self-uaf && /opt/putenv-self-uaf"]
