mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Pull in the latest code from Go's template packages (#11771)
Fixes #10707 Fixes #11507
This commit is contained in:
committed by
GitHub
parent
14d85ec136
commit
9f978d387f
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user