Skip to content

Commit

Permalink
Move AccessFSSet validation to accessfs.go
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoack committed Aug 28, 2021
1 parent fd8c035 commit e80545a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions landlock/accessfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,9 @@ func (a AccessFSSet) intersect(b AccessFSSet) AccessFSSet {
func (a AccessFSSet) isEmpty() bool {
return a == 0
}

// valid returns true iff the given AccessFSSet is supported by this
// version of go-landlock.
func (a AccessFSSet) valid() bool {
return a.isSubset(highestKnownABIVersion.supportedAccessFS)
}
3 changes: 1 addition & 2 deletions landlock/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ type Config struct {
// validate returns success when the given config is supported by
// go-landlock. (It may still be unsupported by your kernel though.)
func (c Config) validate() error {
safs := highestKnownABIVersion.supportedAccessFS
if !c.HandledAccessFS.isSubset(safs) {
if !c.HandledAccessFS.valid() {
return errors.New("unsupported HandledAccessFS value")
}
return nil
Expand Down

0 comments on commit e80545a

Please sign in to comment.