Skip to content

make diod work on alpine linux/musl libc#161

Merged
mergify[bot] merged 8 commits intochaos:masterfrom
garlick:alpine
Nov 7, 2025
Merged

make diod work on alpine linux/musl libc#161
mergify[bot] merged 8 commits intochaos:masterfrom
garlick:alpine

Conversation

@garlick
Copy link
Member

@garlick garlick commented Nov 7, 2025

This addresses a number of portability issues for diod on alpine linux.
make check runs clean on alpine 3.22.2 (aarch64) after these changes.

Fixes #160

Problem: on alpine linux, diodcli won't compile because basename(3)
is undefined.

Add missing include directive.
Problem: diod refuses to accept AF_UNIX connections on alpine linux.

The musl libc getnameinfo(3) fails with EAI_FAMILY when presented
with an AF_UNIX socket, unlike glibc which looks up the name as
"localhost" (NI_NUMERICHOST) or the local hostname.

Just set the client ID to one of the above when accepting an
AF_UNIX socket.
Problem: when test clients need to run as root, they use $SUDO -E to
ensure DIOD_ environment variables pass through, which is not only
tedious but makes it hard to redefine SUDO to an alternative like doas(8).

Redefine $SUDO to "sudo -E".
Updates tests to drop explicit -E flag.
Problem: on some systems like alpine linux and the BSDs,
doas(8) is preferred over sudo(8).

As long as doas(8) is configured for "keepenv" and "nopass",
allow it to be used.
Problem: on alpine linux, test_flock_single won't compile
because open(2) is undefined.

Add missing include directives.
Problem: the test suite uses umount --lazy, which fails on alpine linux.

Use umount -l instead.
Problem: stat -f on alpine/busybox cannot decode the 9p file system
type and reports UNKNOWN causing a test to fail there.

Use %t instead of %T to check the undecoded value instead.
Problem: a test that calls "mkdir -m 755 dir" as root on an
allsquash mount fails on alpine linux.

stracing "mkdir -m 755" shows that alpine calls
   mkdirat(AT_FDCWD, "/tmp/yyy", 0777)     = 0
   fchmodat(AT_FDCWD, "/tmp/yyy", 0755)    = 0

while glibc calls:
   mkdir("/tmp/zzz", 0755)                 = 0

Presumably the fchmodat is failing because, because root no longer
owns the file after the mkdirat due to the squashing.

In that test, perform the chmod separately as the squash user.
Copy link
Member

@grondo grondo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@garlick
Copy link
Member Author

garlick commented Nov 7, 2025

Thanks!

@mergify mergify bot added the queued label Nov 7, 2025
@mergify mergify bot merged commit 2cdeda5 into chaos:master Nov 7, 2025
7 checks passed
@mergify mergify bot removed the queued label Nov 7, 2025
@garlick garlick deleted the alpine branch November 7, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.1.0 fails to build on alpine linux

2 participants