initramfs: fix rootless perms for etc/zinit and add diagnostics
Some checks failed
Build Zero OS Initramfs / build (push) Has been cancelled
Build Zero OS Initramfs / test-matrix (qemu, basic) (push) Has been cancelled
Build Zero OS Initramfs / test-matrix (qemu, serial) (push) Has been cancelled

• Ensure host/rootless traversal for zinit configs: make etc/zinit and etc/zinit/init 755 prior to recursive normalization; then set dirs=755, files=644, and mark *.sh executable in [bash.initramfs_setup_zinit()](scripts/lib/initramfs.sh:12)

• Add pre-CPIO sanity logs to catch empty/mis-scoped archives: top-level ls, file count, and essential presence checks in [bash.initramfs_create_cpio()](scripts/lib/initramfs.sh:658)

• Add validation-time sanity snapshot of top-level and entry count in [bash.initramfs_validate()](scripts/lib/initramfs.sh:754)
This commit is contained in:
2025-09-09 11:32:08 +02:00
parent ae5eea5b2f
commit 8465f00590
5 changed files with 38 additions and 8 deletions

View File

@@ -1,3 +1,3 @@
Zero-OS \r \m
Built on \l
Welcome to Alpine Linux 3.22
Kernel \r on \m (\l)

View File

@@ -1,8 +1,10 @@
Welcome to Alpine!
Welcome to Zero-OS!
The Alpine Wiki contains a large amount of how-to guides and general
information about administrating Alpine systems.
See <https://wiki.alpinelinux.org/>.
This is a minimal operating system designed for decentralized infrastructure.
Built on Alpine Linux with ThreeFold components.
You can setup the system with the command: setup-alpine
For more information: https://github.com/threefoldtech/zos
You may change this message by editing /etc/motd.

View File

@@ -1,4 +1,4 @@
root::0:0:root:/root:/bin/sh
root:x:0:0:root:/root:/bin/sh
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

View File

@@ -1 +1,2 @@
nameserver 169.254.1.1
nameserver 192.168.64.254

View File

@@ -38,7 +38,12 @@ function initramfs_setup_zinit() {
# Ensure proper permissions
safe_execute chmod 755 "${initramfs_dir}/sbin/zinit"
safe_execute chmod -R 644 "${initramfs_dir}/etc/zinit"
# Make top-level zinit config dirs traversable before recursive fixes (rootless host visibility)
safe_execute chmod 755 "${initramfs_dir}/etc/zinit"
safe_execute chmod 755 "${initramfs_dir}/etc/zinit/init" 2>/dev/null || true
# Directories must be executable; set dirs 755 and files 644, then re-mark scripts executable
safe_execute find "${initramfs_dir}/etc/zinit" -type d -exec chmod 755 {} \;
safe_execute find "${initramfs_dir}/etc/zinit" -type f -exec chmod 644 {} \;
safe_execute find "${initramfs_dir}/etc/zinit" -name "*.sh" -exec chmod 755 {} \;
# Create zinit working directories
@@ -707,6 +712,21 @@ function initramfs_create_cpio() {
log_warn "Customization check: /var/lib/ntp missing"
fi
# Pre-CPIO sanity diagnostics
log_info "Pre-CPIO sanity: listing top-level entries in ${initramfs_dir}"
safe_execute ls -la "${initramfs_dir}"
local pre_cpio_file_count
pre_cpio_file_count=$(find "${initramfs_dir}" -mindepth 1 | wc -l || echo "0")
log_info "Pre-CPIO sanity: ${pre_cpio_file_count} files under ${initramfs_dir}"
local _essential_items=("init" "sbin/zinit" "bin/busybox" "etc/zinit" "lib" "usr/bin" "var" "tmp" "proc" "sys" "dev")
for _item in "${_essential_items[@]}"; do
if [[ -e "${initramfs_dir}/${_item}" ]]; then
log_debug "pre-cpio OK: ${_item}"
else
log_error "pre-cpio missing: ${_item}"
fi
done
# Change to initramfs directory for relative paths
safe_execute cd "$initramfs_dir"
@@ -757,6 +777,13 @@ function initramfs_validate() {
section_header "Validating initramfs contents"
local errors=0
# Sanity snapshot to aid debugging when validation fails
log_info "Validation sanity: top-level of ${initramfs_dir}:"
safe_execute ls -la "${initramfs_dir}" || true
local _count_sanity
_count_sanity=$(find "${initramfs_dir}" -mindepth 1 | wc -l || echo "0")
log_info "Validation sanity: ${_count_sanity} total entries under ${initramfs_dir}"
# Check essential files and directories
local essential_items=(