fix: Cross-platform build support (Windows, BSD, NetBSD)
Split resource limit checks into platform-specific files to handle syscall API differences across operating systems. Changes: - Created resources_unix.go (Linux, macOS, FreeBSD, OpenBSD) - Created resources_windows.go (Windows stub implementation) - Created disk_check_netbsd.go (NetBSD stub - syscall.Statfs unavailable) - Modified resources.go to delegate to checkPlatformLimits() - Fixed BSD syscall.Rlimit int64/uint64 type conversions - Made RLIMIT_AS check Linux-only (unavailable on OpenBSD) Build Status: ✅ Linux (amd64, arm64, armv7) ✅ macOS (Intel, Apple Silicon) ✅ Windows (Intel, ARM) ✅ FreeBSD amd64 ✅ OpenBSD amd64 ✅ NetBSD amd64 (disk check returns safe defaults) All 10/10 platforms building successfully.
This commit is contained in:
18
internal/security/resources_linux.go
Normal file
18
internal/security/resources_linux.go
Normal file
@@ -0,0 +1,18 @@
|
||||
// go:build linux
|
||||
// +build linux
|
||||
|
||||
package security
|
||||
|
||||
import "syscall"
|
||||
|
||||
// checkVirtualMemoryLimit checks RLIMIT_AS (only available on Linux)
|
||||
func checkVirtualMemoryLimit(minVirtualMemoryMB uint64) error {
|
||||
var vmLimit syscall.Rlimit
|
||||
if err := syscall.Getrlimit(syscall.RLIMIT_AS, &vmLimit); err == nil {
|
||||
if vmLimit.Cur != syscall.RLIM_INFINITY && vmLimit.Cur < minVirtualMemoryMB*1024*1024 {
|
||||
return formatError("virtual memory limit too low: %s (minimum: %d MB)",
|
||||
formatBytes(uint64(vmLimit.Cur)), minVirtualMemoryMB)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user