Skip to content

XNU as a loadable kernel module inside Linux (macOS personality for arm64 Linux)

C

System disk: Apple's stock /etc/group and /etc/passwd from the system template (system accounts only) instead of four hand-written lines; libinfo's file module answers getgrgid(-1) (nogroup) from it. The group database check CPython's test_grp makes passes in the hosted macOS (322 groups, 0 mismatches; a real Mac: 323, 0)

Heyang Zhou9bd10e2c3026
diff --git a/scripts/vm-sysdisk-launchd.sh b/scripts/vm-sysdisk-launchd.sh
index 6147801..fa0301e 100755
--- a/scripts/vm-sysdisk-launchd.sh
+++ b/scripts/vm-sysdisk-launchd.sh
@@ -69,8 +69,15 @@ GP
g wheel 0 root 0000; g daemon 1 root 0001; g nobody -2 "" FFFE; g staff 20 root 0014
sudo chmod -R go-rwx /mnt/sys/private/var/db/dslocal
# flat files for libinfo's file module
- printf 'root:*:0:0:System Administrator:/var/root:/bin/sh\ndaemon:*:1:1:System Services:/var/root:/usr/bin/false\nnobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false\n' | sudo tee /mnt/sys/private/etc/passwd >/dev/null
- printf 'wheel:*:0:root\ndaemon:*:1:root\nnobody:*:-2:\nstaff:*:20:root\n' | sudo tee /mnt/sys/private/etc/group >/dev/null
+ # Apple's stock flat files (system accounts only, from the system's own template): libinfo's file module answers lookups such as
+ # getgrgid(-1) (nogroup) from them, as on a real Mac
+ T=/mnt/sys/System/Library/Templates/Data/private/etc
+ if [ -f $T/group ] && [ -f $T/passwd ]; then
+ sudo cp $T/group $T/passwd /mnt/sys/private/etc/
+ else
+ printf 'root:*:0:0:System Administrator:/var/root:/bin/sh\ndaemon:*:1:1:System Services:/var/root:/usr/bin/false\nnobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false\n' | sudo tee /mnt/sys/private/etc/passwd >/dev/null
+ printf 'wheel:*:0:root\ndaemon:*:1:root\nnobody:*:-2:\nstaff:*:20:root\n' | sudo tee /mnt/sys/private/etc/group >/dev/null
+ fi
sudo tee /mnt/sys/System/Library/LaunchDaemons/xnulinux.hello.plist >/dev/null <<'PL'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
diff --git a/tools/hosted/tests/final1.sh b/tools/hosted/tests/final1.sh
new file mode 100644
index 0000000..5617b38
--- /dev/null
+++ b/tools/hosted/tests/final1.sh
@@ -0,0 +1,10 @@
+# Alamofire's own scheme (ThreadSanitizer on) on its offline test groups; then Stats from its unmodified project (icon step included)
+cd /var/root/src/Alamofire-5.10.2
+time launchctl asuser 0 xcodebuild -project Alamofire.xcodeproj -scheme "Alamofire macOS" -configuration Debug -destination "platform=macOS" -derivedDataPath /tmp/aftsan CODE_SIGNING_ALLOWED=NO MACOSX_DEPLOYMENT_TARGET=12.0 -only-testing:"Alamofire macOS Tests/URLEncodedFormEncoderTests" -only-testing:"Alamofire macOS Tests/HTTPHeadersTests" -only-testing:"Alamofire macOS Tests/JSONParameterEncoderTests" test > /tmp/aftsan.log 2>&1
+echo "AFTSAN rc=$?"; grep -a -E "Executed [0-9]+ tests|\*\* TEST" /tmp/aftsan.log | tail -2; grep -a -c "ThreadSanitizer\|enableThreadSanitizer\|libclang_rt.tsan" /tmp/aftsan.log; grep -a "FATAL\|incompatible with TSan" /tmp/aftsan.log | head -3
+cd /var/root/src/stats-master
+grep -c "Generate menu bar icon" Stats.xcodeproj/project.pbxproj
+time xcodebuild -project Stats.xcodeproj -scheme Stats -configuration Release -derivedDataPath /tmp/statsdd CODE_SIGNING_ALLOWED=NO build > /tmp/stats.log 2>&1
+echo "STATS rc=$?"; grep -a -E "\*\* BUILD (SUCCEEDED|FAILED) \*\*" /tmp/stats.log | tail -1; grep -a "error:" /tmp/stats.log | head -5
+grep -a "Generate menu bar icon\|ictool" /tmp/stats.log | head -3 | cut -c1-200
+ls -la /tmp/statsdd/Build/Products/Release/Stats.app/Contents/Resources/*.png 2>/dev/null | head -5
diff --git a/tools/hosted/tests/grpcheck.py b/tools/hosted/tests/grpcheck.py
new file mode 100644
index 0000000..7775c54
--- /dev/null
+++ b/tools/hosted/tests/grpcheck.py
@@ -0,0 +1,11 @@
+# The consistency CPython's test_grp checks: every getgrall() entry must round-trip through getgrgid/getgrnam
+import grp
+bad = 0
+for e in grp.getgrall():
+ try:
+ a = grp.getgrgid(e.gr_gid); b = grp.getgrnam(e.gr_name)
+ if a.gr_gid != e.gr_gid or b.gr_gid != e.gr_gid:
+ print("mismatch", e.gr_name, e.gr_gid, a.gr_name, a.gr_gid, b.gr_gid); bad += 1
+ except KeyError as x:
+ print("missing", e.gr_name, e.gr_gid, x); bad += 1
+print("groups", len(grp.getgrall()), "bad", bad)
diff --git a/tools/hosted/tests/statsfail.sh b/tools/hosted/tests/statsfail.sh
new file mode 100644
index 0000000..338c94d
--- /dev/null
+++ b/tools/hosted/tests/statsfail.sh
@@ -0,0 +1,2 @@
+grep -a -A8 "The following build commands failed" /tmp/stats.log | cut -c1-220
+grep -a -i -B2 -A6 "error\b\|fatal\|failed with\|Command .* failed" /tmp/stats.log | grep -av "^--$" | tail -25 | cut -c1-220