Skip to content

Commit

Permalink
harden xattrs errors (#2576)
Browse files Browse the repository at this point in the history
* harden xattrs errors

* increase lint timeout
  • Loading branch information
David Christofas authored Feb 22, 2022
1 parent 8cc813e commit 6e8cb77
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def lintStep():
"name": "lint",
"image": "registry.cern.ch/docker.io/golangci/golangci-lint:v1.42.1",
"commands": [
"golangci-lint run --timeout 2m0s",
"golangci-lint run --timeout 3m0s",
],
}

Expand Down
5 changes: 5 additions & 0 deletions changelog/unreleased/harden-xattrs-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Change: Harden xattrs errors

Unwrap the error to get the root error.

https://github.com/cs3org/reva/pull/2576
5 changes: 3 additions & 2 deletions pkg/storage/utils/decomposedfs/xattrs/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ package xattrs
import (
"syscall"

"github.com/pkg/errors"
"github.com/pkg/xattr"
)

// IsNotExist checks if there is a os not exists error buried inside the xattr error,
// as we cannot just use os.IsNotExist().
func IsNotExist(err error) bool {
if xerr, ok := err.(*xattr.Error); ok {
if xerr, ok := errors.Cause(err).(*xattr.Error); ok {
if serr, ok2 := xerr.Err.(syscall.Errno); ok2 {
return serr == syscall.ENOENT
}
Expand All @@ -38,7 +39,7 @@ func IsNotExist(err error) bool {
// IsAttrUnset checks the xattr.ENOATTR from the xattr package which redifines it as ENODATA on platforms that do not natively support it (eg. linux)
// see https://github.com/pkg/xattr/blob/8725d4ccc0fcef59c8d9f0eaf606b3c6f962467a/xattr_linux.go#L19-L22
func IsAttrUnset(err error) bool {
if xerr, ok := err.(*xattr.Error); ok {
if xerr, ok := errors.Cause(err).(*xattr.Error); ok {
if serr, ok2 := xerr.Err.(syscall.Errno); ok2 {
return serr == xattr.ENOATTR
}
Expand Down

0 comments on commit 6e8cb77

Please sign in to comment.