Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ hardened general-purpose operating system distribution:
hashes (`--rescue-password-hash-file`), Wi-Fi credentials, Bluetooth link
keys (`bt-keys`), firmware dumps and NVRAM/NVDATA must never be committed to
Git.

The optional `i14-web` dashboard is disabled by default and serves plain HTTP
only on loopback (default `127.0.0.1:8080`). Supply a random bearer token
through `--token-file PATH`. The file must be a regular file owned by the
service user with owner-only permissions (for example, `0600`).
For remote access, forward the port with
`ssh -L 8080:127.0.0.1:8080 root@172.16.42.1` and open
`http://127.0.0.1:8080/` on the client. The explicit
`--allow-unauthenticated` option grants local clients access to service controls.
2 changes: 1 addition & 1 deletion rootfs/build-alpine-rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ chown -R 0:0 "$R/root" "$R/etc" "$R/usr/sbin"

# Services. sysinit: /dev is already populated by /i14init (no devtmpfs on 3.18).
for s in devfs dmesg mdev i14-splash; do ln -sf /etc/init.d/$s "$R/etc/runlevels/sysinit/$s"; done
for s in bootmisc hostname sysctl syslog seedrng i14-firewall; do
for s in bootmisc hostname sysctl syslog seedrng i14-zram i14-firewall; do
[ -e "$R/etc/init.d/$s" ] && ln -sf /etc/init.d/$s "$R/etc/runlevels/boot/$s"
done
for s in networking sshd chronyd crond i14-power i14-cpufreq i14-usbnet i14-wifi i14-netwatch unbound i14-ui local; do
Expand Down
9 changes: 9 additions & 0 deletions rootfs/overlay/etc/conf.d/i14-web
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The safest way to access the dashboard is to keep it on loopback and use SSH:
# ssh -L 8080:127.0.0.1:8080 root@172.16.42.1
# Then open http://127.0.0.1:8080/ on the SSH client.
I14_WEB_BIND="127.0.0.1:8080"

# Put a random token in this file on the phone and restrict it to the owner (0600).
I14_WEB_TOKEN_FILE="/mnt/data/media/0/i14-linux/web.token"
# Set to yes only for explicitly unauthenticated loopback access.
I14_WEB_ALLOW_UNAUTHENTICATED=no
4 changes: 4 additions & 0 deletions rootfs/overlay/etc/conf.d/i14-zram
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Compressed in-RAM swap (/dev/zram0), avoiding eMMC flash wear.
I14_ZRAM_SIZE_MB="512"
I14_ZRAM_PRIORITY="100"
I14_ZRAM_STREAMS="4"
25 changes: 25 additions & 0 deletions rootfs/overlay/etc/init.d/i14-web
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/sbin/openrc-run
description="I14 web dashboard"
command=/usr/libexec/i14-rs/i14-web
supervisor=supervise-daemon
respawn_delay=10

: "${I14_WEB_BIND:=127.0.0.1:8080}"
: "${I14_WEB_TOKEN_FILE:=/mnt/data/media/0/i14-linux/web.token}"
command_args='--bind "$I14_WEB_BIND"'
if [ "${I14_WEB_ALLOW_UNAUTHENTICATED:-no}" = yes ]; then
command_args="$command_args --allow-unauthenticated"
else
command_args="$command_args"' --token-file "$I14_WEB_TOKEN_FILE"'
fi

depend() {
after i14-usbnet i14-wifi
}

start_pre() {
[ "${I14_WEB_ALLOW_UNAUTHENTICATED:-no}" = yes ] && return 0
[ -f "$I14_WEB_TOKEN_FILE" ] && [ -r "$I14_WEB_TOKEN_FILE" ] && [ -s "$I14_WEB_TOKEN_FILE" ] && return 0
eerror "i14-web requires a readable, nonempty token file: $I14_WEB_TOKEN_FILE"
return 1
}
64 changes: 64 additions & 0 deletions rootfs/overlay/etc/init.d/i14-zram
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/sbin/openrc-run
description="I14: compressed in-RAM swap (/dev/zram0)"

: "${I14_ZRAM_SIZE_MB:=512}"
: "${I14_ZRAM_PRIORITY:=100}"
: "${I14_ZRAM_STREAMS:=4}"

ZRAM_DEV="/dev/zram0"
ZRAM_SYS="/sys/block/zram0"

depend() {
after mdev sysctl
before localmount
}

start() {
ebegin "Starting I14 zram swap (${I14_ZRAM_SIZE_MB} MiB)"
case "$I14_ZRAM_SIZE_MB" in
''|*[!0-9]*|0)
eend 1 "I14_ZRAM_SIZE_MB must be a positive integer"
return 1
;;
esac
if [ ! -b "$ZRAM_DEV" ] || [ ! -w "$ZRAM_SYS/disksize" ]; then
eend 1 "zram device $ZRAM_DEV is not available"
return 1
fi
if grep -q "^${ZRAM_DEV}[[:space:]]" /proc/swaps 2>/dev/null; then
eend 0
return 0
fi
if [ -w "$ZRAM_SYS/reset" ]; then
echo 1 >"$ZRAM_SYS/reset" || { eend 1 "zram reset failed"; return 1; }
fi
if [ -w "$ZRAM_SYS/max_comp_streams" ]; then
echo "$I14_ZRAM_STREAMS" >"$ZRAM_SYS/max_comp_streams" 2>/dev/null || true
fi
bytes=$((I14_ZRAM_SIZE_MB * 1024 * 1024))
echo "$bytes" >"$ZRAM_SYS/disksize" || { eend 1 "zram disksize failed"; return 1; }
mkswap "$ZRAM_DEV" >/dev/null || {
echo 1 >"$ZRAM_SYS/reset" 2>/dev/null || true
eend 1 "mkswap failed"
return 1
}
if ! swapon -p "$I14_ZRAM_PRIORITY" "$ZRAM_DEV" 2>/dev/null; then
swapon "$ZRAM_DEV" || {
echo 1 >"$ZRAM_SYS/reset" 2>/dev/null || true
eend 1 "swapon failed"
return 1
}
fi
eend 0
}

stop() {
ebegin "Stopping I14 zram swap"
if grep -q "^${ZRAM_DEV}[[:space:]]" /proc/swaps 2>/dev/null; then
swapoff "$ZRAM_DEV" || { eend 1 "swapoff failed"; return 1; }
fi
if [ -w "$ZRAM_SYS/reset" ]; then
echo 1 >"$ZRAM_SYS/reset" 2>/dev/null || true
fi
eend 0
}
8 changes: 7 additions & 1 deletion rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ image integration and device acceptance.
| `i14-sys` | the only place with `unsafe`: framebuffer, evdev, pty, getrandom, uname |
| `i14-probe` | read-only check of Rust's runtime and those interfaces on the phone |
| `i14-config` | the shared settings file (`ui.json`, PIN) and the charge guard's status file |
| `i14-ui` | the interface (`i14-ui` binary) and the boot splash (`i14-splash` binary) |
| `i14-ui` | the touch interface (`i14-ui`), boot splash (`i14-splash`) and optional web dashboard (`i14-web`) |
| `i14-power` | the charge guard (`i14-battery-guard`, service `i14-power`) |
| `i14-cpufreq` | the screen-off CPU clock policy (`i14-cpufreq`) |
| `i14-netwatch` | the Wi-Fi watchdog (`i14-netwatch`) |
Expand All @@ -26,6 +26,12 @@ Rust uses `/usr/libexec/i14-rs/` and an `i14_impl` setting per migrated service.
using the same package set: building one package alone can select different Cargo
features, such as `serde_json`'s `float_roundtrip` from `i14-power`.

To use the optional dashboard, install the staged `i14-web` at
`/usr/libexec/i14-rs/i14-web`, provision the token described in
[`/etc/conf.d/i14-web`](../rootfs/overlay/etc/conf.d/i14-web), then run
`rc-service i14-web start`. Enable it at boot with `rc-update add i14-web default`
only if desired.

The pixel parity tests compare with the Python sources in `rootfs/overlay` and need
`python3` and `I14_FONTS` set to a directory with the phone's Terminus fonts
(`ter-118n`, `ter-120n`, `ter-124b`, `ter-132b` `.psf.gz` from `/usr/share/consolefonts`);
Expand Down
Loading