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:
27
internal/security/resources_windows.go
Normal file
27
internal/security/resources_windows.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// +build windows
|
||||
|
||||
package security
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// checkPlatformLimits returns resource limits for Windows
|
||||
func (rc *ResourceChecker) checkPlatformLimits() (*ResourceLimits, error) {
|
||||
limits := &ResourceLimits{
|
||||
Available: false, // Windows doesn't use Unix-style rlimits
|
||||
Platform: runtime.GOOS,
|
||||
}
|
||||
|
||||
// Windows doesn't have the same resource limit concept
|
||||
// Set reasonable defaults
|
||||
limits.MaxOpenFiles = 8192 // Windows default is typically much higher
|
||||
limits.MaxProcesses = 0 // Not applicable
|
||||
limits.MaxAddressSpace = 0 // Not applicable
|
||||
|
||||
rc.log.Debug("Resource limits not available on Windows", "platform", "windows")
|
||||
|
||||
return limits, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user