-
Notifications
You must be signed in to change notification settings - Fork 0
bug: kernel version comparison in setup.sh is lexicographic, not numeric #50
Copy link
Copy link
Open
Labels
Description
Bug: String comparison for kernel version
File: scripts/setup.sh
The OpenShell prerequisite check compares the Linux kernel version as a string:
if [[ "$(uname -r | cut -d. -f1-2)" < "5.13" ]]; then
warn "Kernel $(uname -r) — Landlock needs >= 5.13"
fiBash's [[ < ]] operator performs lexicographic (alphabetical) comparison, not numeric comparison. This means:
| Kernel | cut output |
String comparison result | Correct? |
|---|---|---|---|
| 5.4 | 5.4 |
"5.4" < "5.13" → false (4 > 1) | ❌ should warn, doesn't |
| 5.9 | 5.9 |
"5.9" < "5.13" → false (9 > 1) | ❌ should warn, doesn't |
| 5.13 | 5.13 |
"5.13" < "5.13" → false | ✓ |
| 6.0 | 6.0 |
"6.0" < "5.13" → false | ✓ |
Kernels 5.4–5.12 (which don't support Landlock) will not trigger the warning, potentially leading to a broken OpenShell install.
Fix
kernel_maj=$(uname -r | cut -d. -f1)
kernel_min=$(uname -r | cut -d. -f2)
if (( kernel_maj < 5 || (kernel_maj == 5 && kernel_min < 13) )); then
warn "Kernel $(uname -r) — Landlock needs >= 5.13"
fiReactions are currently unavailable