diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0ce1f8a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.git +.gitignore +*.o +tr4mpass +.build-flags +tests/*.bin +tests/run_tests +tests/run_mock_tests +notes +research +*.md +!README-REPRO.md diff --git a/Dockerfile b/Dockerfile index 3e8ef63..90c3243 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,16 @@ # syntax=docker/dockerfile:1 # Reproducible build of tr4mpass with every dependency inside the image, so -# nothing is installed on the host. Debian trixie matches the development host. +# nothing gets installed on the host. Debian trixie matches the development +# host. The binary links against trixie's shared libraries, so it is meant to +# run inside this image, not to be copied out: on another machine it will fail +# with "cannot open shared object file". FROM debian:trixie-slim RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential pkg-config \ libimobiledevice-dev libirecovery-1.0-dev libusb-1.0-0-dev libplist-dev \ libssl-dev libcurl4-openssl-dev libssh2-1-dev \ - usbutils usbmuxd ca-certificates \ + usbutils \ && rm -rf /var/lib/apt/lists/* WORKDIR /build @@ -21,7 +24,9 @@ COPY tests ./tests RUN make clean && make -# The binary ends up at /build/tr4mpass. -# Running it needs direct USB access: -# podman run --rm -it --privileged -v /dev/bus/usb:/dev/bus/usb tr4mpass ./tr4mpass -v +# The binary ends up at /build/tr4mpass. Running it needs the real USB bus: +# podman run --rm -it --device-cgroup-rule='c 189:* rwm' \ +# -v /dev/bus/usb:/dev/bus/usb tr4mpass ./tr4mpass -v +# 189 is the USB major. Rootless podman cannot open those nodes (they are +# root:root 0664), so running needs rootful podman or a udev rule on the host. CMD ["/bin/bash"] diff --git a/README-REPRO.md b/README-REPRO.md index e098e04..a80783e 100644 --- a/README-REPRO.md +++ b/README-REPRO.md @@ -24,15 +24,28 @@ podman build -t tr4mpass . The Dockerfile (Debian trixie) installs `libimobiledevice-dev`, `libirecovery-1.0-dev`, `libusb-1.0-0-dev`, `libplist-dev`, `libssl-dev`, -`libcurl4-openssl-dev`, `libssh2-1-dev`, `pkg-config`, `build-essential`, -`usbutils` and `usbmuxd`, then builds the binary. +`libcurl4-openssl-dev`, `libssh2-1-dev`, `pkg-config` and `build-essential`, +then builds the binary. -Running inside the container needs the USB bus passed through: +### The binary is not portable + +It links against trixie's shared libraries. Copying `/build/tr4mpass` to another +machine fails with `cannot open shared object file`. The container is meant to +build and run the binary inside the image, not to produce a portable artifact. + +### Running with USB access + +The sequence drives EP0 directly through libusb, so it needs the real USB bus: ``` -podman run --rm -it --privileged -v /dev/bus/usb:/dev/bus/usb tr4mpass ./tr4mpass -v +podman run --rm -it --device-cgroup-rule='c 189:* rwm' \ + -v /dev/bus/usb:/dev/bus/usb tr4mpass ./tr4mpass -v ``` -Note: the sequence drives EP0 directly through libusb, so it needs the real USB -bus. Inside a container that means `--privileged` plus mounting `/dev/bus/usb`; -inside a VM or WSL it needs device passthrough as well. +189 is the USB major number. Two limits to be aware of: + +- Rootless podman cannot open the `/dev/bus/usb` nodes (they are `root:root` + 0664), so this needs rootful podman or a udev rule on the host. +- On macOS and Windows the Linux VM does not receive the USB device, so the + container route does not work there. On SELinux hosts you may need + `--security-opt label=disable`.