diff options
Diffstat (limited to 'tpl/internal/go_templates/testenv/testenv_unix.go')
-rw-r--r-- | tpl/internal/go_templates/testenv/testenv_unix.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tpl/internal/go_templates/testenv/testenv_unix.go b/tpl/internal/go_templates/testenv/testenv_unix.go index abb89eeca..296eefc7a 100644 --- a/tpl/internal/go_templates/testenv/testenv_unix.go +++ b/tpl/internal/go_templates/testenv/testenv_unix.go @@ -7,6 +7,8 @@ package testenv import ( + "errors" + "io/fs" "syscall" ) @@ -15,6 +17,27 @@ import ( var Sigquit = syscall.SIGQUIT func syscallIsNotSupported(err error) bool { - // Removed by Hugo (not supported in Go 1.20) + if err == nil { + return false + } + + var errno syscall.Errno + if errors.As(err, &errno) { + switch errno { + case syscall.EPERM, syscall.EROFS: + // User lacks permission: either the call requires root permission and the + // user is not root, or the call is denied by a container security policy. + return true + case syscall.EINVAL: + // Some containers return EINVAL instead of EPERM if a system call is + // denied by security policy. + return true + } + } + + if errors.Is(err, fs.ErrPermission) { + return true + } + return false } |