Repository navigation
Expand file tree
/
Copy pathDockerfile.ubuntu
More file actions
75 lines (65 loc) · 3.01 KB
/
Copy pathDockerfile.ubuntu
File metadata and controls
75 lines (65 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Stage 1: build the arch-specific artifacts that must not ship with their build deps
FROM ubuntu:latest AS builder
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
busybox-static \
&& rm -rf /var/lib/apt/lists/*
COPY input/disableselinux.c /tmp/disableselinux.c
RUN mkdir /build \
&& gcc -shared -fPIC /tmp/disableselinux.c -o /build/libdisableselinux.so \
&& cp /bin/busybox /build/busybox
# Stage 2: the real rootfs — no build toolchain
FROM ubuntu:latest
ENV DEBIAN_FRONTEND=noninteractive
RUN printf '#!/bin/sh\nunset LD_PRELOAD\nunset LD_LIBRARY_PATH\nexport LIBGL_ALWAYS_SOFTWARE=1\n' \
> /etc/profile.d/userland.sh && chmod +x /etc/profile.d/userland.sh
# systemd + systemd-sysv are a hard requirement of the AVF backend, not a
# convenience: avf-init pivot_roots into /lib/systemd/systemd and runs it as
# PID 1 when present, which is what makes `systemctl` -- and therefore Docker,
# podman and any packaged .service unit -- work inside the VM. Without them
# avf-init falls back to a chroot in which the distro's own init never runs and
# systemctl reports "System has not been booted with systemd as init system".
# Requested explicitly rather than left to chance: debian shipped systemd *unit
# files* but not the binary, and ubuntu/kali only got it as an incidental
# transitive dep -- either could silently regress and break init for every VM
# session. systemd-sysv provides the /sbin/init -> systemd link avf-init execs.
RUN apt-get update && apt-get install -y --no-install-recommends \
systemd \
systemd-sysv \
sudo \
dropbear \
sshfs \
libgl1 \
libglx-mesa0 \
tightvncserver \
xterm \
xfonts-base \
twm \
expect \
wget \
curl \
ca-certificates \
pulseaudio \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# GNU coreutils instead of Ubuntu's default Rust uutils. uutils is one multicall
# binary that every utility is a hard link to, and it refuses to run when the
# utility named in argv[0] doesn't match the executable's own file name
# ("Security violation: Requested utility `mkdir` does not match executable
# name"). proot stores hard links as link2symlink stubs, so under proot every
# coreutils command failed that way -- startSSHServer.sh could not even mkdir
# /etc/dropbear, and SSH sessions never started.
RUN apt-get update && apt-get install -y --no-install-recommends --allow-remove-essential \
coreutils-from-gnu \
coreutils-from-uutils- \
rust-coreutils- \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
RUN sed -i 's/force_color_prompt=/#force_color_prompt=/g' /etc/skel/.bashrc
COPY --from=builder /build/busybox /support/busybox
COPY --from=builder /build/libdisableselinux.so /support/libdisableselinux.so
COPY assets/common/ /support/
RUN chmod a+x /support/busybox \
/support/libdisableselinux.so \
/support/nosudo \
/support/*.sh \
&& chmod a-w /support/* \
&& chmod a-w /support