Repository navigation
Expand file tree
/
Copy pathDockerfile.ubuntu_lxde
More file actions
115 lines (102 loc) · 5.22 KB
/
Copy pathDockerfile.ubuntu_lxde
File metadata and controls
115 lines (102 loc) · 5.22 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# 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
# Locales for the app's languages, which it picks from to follow the phone's (input/locale).
COPY input/locale/locale.sh input/locale/keep-langpack.sh input/locale/setup.sh /usr/share/userland/
RUN chmod a+x /usr/share/userland/keep-langpack.sh \
&& sh /usr/share/userland/setup.sh \
&& rm /usr/share/userland/setup.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 \
expect \
wget \
curl \
ca-certificates \
pulseaudio \
&& apt-get install -y lxde dbus-x11 \
&& 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/*
# A polkit authentication agent only works where polkit can actually answer:
# it needs systemd-logind to own a session for the process and polkitd on the
# system bus. proot has no init, so neither exists, and lxpolkit greets every
# single login with a GTK error dialog reading "No session for pid <n>" --
# polkit's own message, from sd_pid_get_session() failing against an empty
# /run/systemd/sessions. XFCE never showed it because lxpolkit.desktop carries
# NotShowIn=...;XFCE;... and LXDE is not on that list.
#
# The same image also serves AVF/QEMU sessions, where systemd *is* running and
# the agent works normally, so this gates it at runtime rather than dropping it
# from the image. lxpolkit has two independent launchers -- lxsession's
# polkit/command and the XDG autostart entry -- and both must be routed through
# the wrapper or the other one still starts it.
RUN printf '%s\n' '#!/bin/sh' \
'[ -d /run/systemd/system ] || exit 0' \
'exec lxpolkit "$@"' > /usr/local/bin/lxpolkit-if-systemd \
&& chmod 755 /usr/local/bin/lxpolkit-if-systemd \
&& [ -f /etc/xdg/autostart/lxpolkit.desktop ] \
&& sed -i 's|^Exec=lxpolkit$|Exec=lxpolkit-if-systemd|; s|^TryExec=lxpolkit$|TryExec=lxpolkit-if-systemd|' \
/etc/xdg/autostart/lxpolkit.desktop \
&& [ -f /etc/xdg/lxsession/LXDE/desktop.conf ] \
&& if grep -q '^polkit/command=' /etc/xdg/lxsession/LXDE/desktop.conf; then \
sed -i 's|^polkit/command=.*|polkit/command=lxpolkit-if-systemd|' \
/etc/xdg/lxsession/LXDE/desktop.conf; \
else \
sed -i '/^\[Session\]/a polkit/command=lxpolkit-if-systemd' \
/etc/xdg/lxsession/LXDE/desktop.conf; \
fi
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
# Fonts for the app's languages, and GTK's translations on Ubuntu (input/locale)
COPY input/locale/desktop.sh /tmp/desktop.sh
RUN sh /tmp/desktop.sh && rm /tmp/desktop.sh
COPY assets/common/ /support/
COPY assets/lxde/ /support/
RUN chmod a+x /support/busybox \
/support/libdisableselinux.so \
/support/nosudo \
/support/*.sh \
&& chmod a-w /support/* \
&& chmod a-w /support