init: support Chimera Linux guests (#1778)

* init: properly support Chimera Linux guests

https://chimera-linux.org

* init: add some basic doas(1) support

This is an alternative to sudo(1) originating from OpenBSD and also
ported to Linux; base configuration on Chimera Linux where this will be
used.

* init: also support FreeBSD-style stat(1) syntax for rootful check

These system utils are largely used on Chimera Linux (as chimerautils):
  + stat -c %u /run/host/etc/shadow
  stat: unrecognized option: c
  usage: stat [-FLnq] [-f format | -l | -r | -s | -x] [-t timefmt] [file|handle ...]

* docs: Chimera Linux compatability tested as host and guest
This commit is contained in:
Jami Kettunen
2025-08-24 12:22:30 +02:00
committed by GitHub
parent f1e87d30f5
commit f36ccd7720
2 changed files with 40 additions and 1 deletions
+38 -1
View File
@@ -234,7 +234,7 @@ fi
# if /run/.nopasswd is present, let's treat the init as rootless, this is not
# a good thing, users behold!
if stat /run/host/etc/shadow > /dev/null &&
[ "$(stat -c "%u" /run/host/etc/shadow)" = "0" ] &&
{ [ "$(stat -c "%u" /run/host/etc/shadow)" = "0" ] || [ "$(stat -f "%u" /run/host/etc/shadow)" = "0" ]; } &&
[ ! -e /run/.nopasswd ]; then
rootful=1
fi
@@ -658,6 +658,30 @@ setup_apk()
$(apk search -q mesa-dri)
$(apk search -q mesa-vulkan)
"
elif apk add base-bootstrap; then
# Prevent "ADB schema error" while installing tzdb in rootful container on currently old image
apk upgrade -Ua
# Prevent "fchownat() of /tmp failed: Operation not permitted" from sd-tools trigger script
sed -i '' '/^q \/tmp/ s/^/#/' /usr/lib/tmpfiles.d/tmp.conf
# Setup rest of packages while also allowing install of extras from user repo
apk add chimera-repo-user
apk update
deps="
base-core-man
bash-completion
bc-gh
gtar
libarchive-progs
libcap-progs
lsof
mesa-dri
ncurses-term
opendoas
openssh
util-linux-mount
vte
wget2
"
fi
deps="${deps:-}
${shell_pkg}
@@ -2311,6 +2335,15 @@ Defaults !fqdn
%sudo ALL=(ALL:ALL) ALL
%root ALL=(ALL:ALL) ALL
EOF
# ditto for doas
if [ -e /etc/doas.conf ]; then
cat << EOF > /etc/doas.conf
permit persist :root
permit persist :wheel
permit nopass root
permit nopass keepenv setenv { PATH } root as root
EOF
fi
# PAM config for "su" command
if [ ! -e /etc/pam.d/su ]; then
@@ -2336,6 +2369,10 @@ fi
if [ "${container_user_uid}" -ne 0 ] && [ "${rootful}" -eq 0 ]; then
# Ensure passwordless sudo is set up for user
printf "\"%s\" ALL = (root) NOPASSWD:ALL\n" "${container_user_name}" >> /etc/sudoers.d/sudoers
# ditto for doas
if [ -e /etc/doas.conf ]; then
printf "permit %s\n" "${container_user_name}" >> /etc/doas.conf
fi
fi
###############################################################################
+2
View File
@@ -53,6 +53,7 @@ Distrobox has been successfully tested on:
| Arch Linux | | `distrobox` is available in the `extra` repository and `distrobox-git` is available in the AUR (thanks [M0Rf30](https://github.com/M0Rf30)!). <br> To setup rootless podman, look [HERE](https://wiki.archlinux.org/title/Podman) |
| Bazzite | 38 | `distrobox-git` is preinstalled. |
| CentOS | 8 <br> 8 Stream <br> 9 Stream | `distrobox` is available in epel repos. (thanks [alcir](https://github.com/alcir)!) |
| Chimera Linux | | `distrobox` is available in `chimera-repo-user`. |
| ChromeOS | Debian 11 (docker with make-shared workaround #non-shared-mounts) <br> Debian 12 (podman) | using built-in Linux on ChromeOS mode which is debian-based, which can be [upgraded](https://wiki.debian.org/DebianUpgrade) from 11 bullseye to 12 bookworm (in fact 12 is recommended) |
| Debian | 11 <br> 12 <br> Testing <br> Unstable | `distrobox` is available in default repos starting from version 12 (thanks [michel-slm!](https://github.com/michel-slm!)!) |
| deepin | 23 <br> Testing <br> Unstable | `distrobox` is available in default repos in `testing` and `unstable` |
@@ -137,6 +138,7 @@ Distrobox guests tested successfully with the following container images:
| Blackarch | | docker.io/blackarchlinux/blackarch:latest |
| CentOS Stream | 8 <br> 9 <br> 10 | quay.io/centos/centos:stream8 <br> quay.io/centos/centos:stream9 <br> quay.io/centos/centos:stream10 |
| Chainguard Wolfi | | cgr.dev/chainguard/wolfi-base:latest |
| Chimera Linux | | docker.io/chimeralinux/chimera:latest |
| ClearLinux | | docker.io/library/clearlinux:latest <br> docker.io/library/clearlinux:base |
| Crystal Linux | | registry.gitlab.com/crystal-linux/misc/docker:latest |
| Debian | 7 <br> 8 <br> 9 <br> 10 <br> 11 <br> 12 <br> 13 | docker.io/debian/eol:wheezy <br> docker.io/debian/eol:buster <br> docker.io/debian/eol:bullseye <br> docker.io/library/debian:bookworm-backports <br> docker.io/library/debian:stable-backports |