Skip to content

Commit 32097fa

Browse files
committed
prevent using ./configure.sh directly which could brick
users' host machines.
1 parent 2583093 commit 32097fa

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ mkdir qemu/build && cd qemu/build && ../configure --target-list=x86_64-softmmu -
7979
cd scripts/create-image/ && ./create-image.sh && cd ../..
8080
~~~
8181

82+
Or if you prefer using docker to build your image:
83+
~~~
84+
cd scripts/create-image/
85+
docker build -t img .
86+
docker run -v $(pwd):/mnt --privileged --rm img
87+
~~~
88+
89+
Notice that `privileged` is necessary because we want to use `/dev/loop*` inside docker.
90+
8291
### Step 4: Install uv
8392
~~~
8493
pip install uv

scripts/create-image/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ RUN ./debootstrap.sh
3232

3333
# will copy the img file to /mnt. Need --privilege flag for docker run.
3434
COPY --chmod=0755 configure.sh /src/
35-
CMD ["bash", "-x", "./configure.sh"]
35+
CMD ["bash", "-c", "set -ex; source ./configure.sh"]
3636

scripts/create-image/configure.sh

100755100644
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22
# Copyright 2025 syzkaller project authors. All rights reserved.
33
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
44

5+
usage() {
6+
echo "Please use the ./create-image.sh instead." >&2
7+
exit 1
8+
}
9+
10+
# Prevent execution if not sourced
11+
(return 0 2>/dev/null) || {
12+
usage
13+
}
14+
15+
if [ -z "$DIR" ] || [ "$(realpath "$DIR")" = / ]; then
16+
usage
17+
fi
18+
519
# Set some defaults and enable promtless ssh to the machine for root.
620
sudo sed -i '/^root/ { s/:x:/::/ }' $DIR/etc/passwd
721
echo 'T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100' | sudo tee -a $DIR/etc/inittab

scripts/create-image/debootstrap.sh

100755100644
File mode changed.

0 commit comments

Comments
 (0)