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
43 changes: 41 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,53 @@ jobs:
exit 1
fi
echo "Image: $IMG ($(stat -c%s "$IMG") bytes)"
# Dump partition table for debugging
sudo sfdisk --json "$IMG" | jq '.partitiontable.partitions[] | {type, start, size}'
# Select the root partition (x86-64 root GUID), not the ESP
eval "$(sudo sfdisk --json "$IMG" | jq -r '
.partitiontable.partitions[0] |
.partitiontable.partitions[] |
select(.type == "4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709") |
"PART_START=\(.start) PART_SIZE=\(.size)"')"
echo "Partition start=$PART_START size=$PART_SIZE (sectors)"
echo "Root partition start=$PART_START size=$PART_SIZE (sectors)"
sudo dd if="$IMG" of=rootfs_ext4.raw \
bs=512 skip="$PART_START" count="$PART_SIZE" status=progress
mv rootfs_ext4.raw rootfs.raw

- name: Configure rootfs image
working-directory: testdata
run: |
mkdir -p /tmp/rootfs-mnt
sudo mount -o loop rootfs.raw /tmp/rootfs-mnt
R=/tmp/rootfs-mnt

# Remove root password
sudo sed -i '/^root:/ s|^root:[^:]*:|root::|' $R/etc/shadow

# Generate SSH host keys
sudo ssh-keygen -A -f $R

# SSH config drop-in (in case mkosi.extra didn't copy it)
sudo mkdir -p $R/etc/ssh/sshd_config.d
echo -e "PermitRootLogin yes\nPermitEmptyPasswords yes" | sudo tee $R/etc/ssh/sshd_config.d/99-test.conf

# Enable services
sudo ln -sf /usr/lib/systemd/system/sshd.service $R/etc/systemd/system/multi-user.target.wants/sshd.service
sudo ln -sf /usr/lib/systemd/system/systemd-networkd.service $R/etc/systemd/system/multi-user.target.wants/systemd-networkd.service
sudo ln -sf /usr/lib/systemd/system/containerd.service $R/etc/systemd/system/multi-user.target.wants/containerd.service
sudo mkdir -p $R/etc/systemd/system/sockets.target.wants
sudo ln -sf /usr/lib/systemd/system/podman.socket $R/etc/systemd/system/sockets.target.wants/podman.socket

# Verify
echo "=== root shadow entry ==="
sudo grep '^root:' $R/etc/shadow
echo "=== SSH host keys ==="
ls -la $R/etc/ssh/ssh_host_*
echo "=== Enabled services ==="
ls -la $R/etc/systemd/system/multi-user.target.wants/
ls -la $R/etc/systemd/system/sockets.target.wants/

sudo umount /tmp/rootfs-mnt

- name: Create qcow2 overlay
working-directory: testdata
run: qemu-img create -o backing_file=rootfs.raw,backing_fmt=raw -f qcow2 rootfs.cow
Expand Down
3 changes: 3 additions & 0 deletions testdata/mkosi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Output=rootfs
OutputDirectory=mkosi.output

[Content]
Locale=C.UTF-8
Timezone=UTC
Hostname=schedctl-test
Packages=
base
openssh
Expand Down
2 changes: 2 additions & 0 deletions testdata/mkosi.extra/etc/ssh/sshd_config.d/99-test.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PermitRootLogin yes
PermitEmptyPasswords yes
6 changes: 3 additions & 3 deletions testdata/mkosi.postinst.chroot
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set -e
# Remove root password for passwordless SSH access (test environment only)
passwd -d root

# Configure SSH for root login with empty password
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
sed -i 's/#PermitEmptyPasswords no/PermitEmptyPasswords yes/' /etc/ssh/sshd_config
# SSH config is handled via drop-in at /etc/ssh/sshd_config.d/99-test.conf
# Pre-generate host keys so sshd can complete handshakes on first boot
ssh-keygen -A

# Enable required services
systemctl enable sshd systemd-networkd containerd podman.socket
1 change: 1 addition & 0 deletions testdata/mkosi.repart/00-root.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[Partition]
Type=root
Format=ext4
CopyFiles=/
SizeMinBytes=1536M
Loading