Skip to content

Commit 413543e

Browse files
committed
NewFilter,filter.Merge: wrap the original error
Whenever we do not return the error code from a libseccomp call directly, embed it into our error (via %w), so that a user can still check for it using something like errors.Is(err, syscall.EINVAL). Acked-by: Tom Hromatka <[email protected]> Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent aa8bb55 commit 413543e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

seccomp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ func NewFilter(defaultAction ScmpAction) (*ScmpFilter, error) {
623623
// If the kernel does not support TSYNC, allow us to continue without error.
624624
if err := filter.setFilterAttr(filterAttrTsync, 0x1); err != nil && err != syscall.ENOTSUP {
625625
filter.Release()
626-
return nil, fmt.Errorf("could not create filter - error setting tsync bit: %v", err)
626+
return nil, fmt.Errorf("could not create filter: error setting tsync bit: %w", err)
627627
}
628628

629629
return filter, nil
@@ -702,7 +702,7 @@ func (f *ScmpFilter) Merge(src *ScmpFilter) error {
702702
if retCode := C.seccomp_merge(f.filterCtx, src.filterCtx); retCode != 0 {
703703
e := errRc(retCode)
704704
if e == syscall.EINVAL {
705-
return fmt.Errorf("filters could not be merged due to a mismatch in attributes or invalid filter")
705+
return fmt.Errorf("filters could not be merged due to a mismatch in attributes or invalid filter: %w", e)
706706
}
707707
return e
708708
}

0 commit comments

Comments
 (0)