aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2021-10-07 12:28:55 +0000
committerGitHub <noreply@github.com>2021-10-07 12:28:55 +0000
commitda8e4cdeb440f0aa0cfb3d0a6eb2e88b89ddb4cb (patch)
tree643ebf150d8feefd72543f260ffbbb6daeb7b62d /vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
parentbfb904bb23c53773a4414ccf4b1f66cf05d9ee80 (diff)
downloadpodman-da8e4cdeb440f0aa0cfb3d0a6eb2e88b89ddb4cb.tar.gz
podman-da8e4cdeb440f0aa0cfb3d0a6eb2e88b89ddb4cb.tar.bz2
podman-da8e4cdeb440f0aa0cfb3d0a6eb2e88b89ddb4cb.zip
Bump github.com/opencontainers/selinux from 1.8.5 to 1.9.1
Bumps [github.com/opencontainers/selinux](https://github.com/opencontainers/selinux) from 1.8.5 to 1.9.1. - [Release notes](https://github.com/opencontainers/selinux/releases) - [Commits](https://github.com/opencontainers/selinux/compare/v1.8.5...v1.9.1) --- updated-dependencies: - dependency-name: github.com/opencontainers/selinux dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Diffstat (limited to 'vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go')
-rw-r--r--vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go68
1 files changed, 33 insertions, 35 deletions
diff --git a/vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go b/vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
index 295b2bc4e..b045843ad 100644
--- a/vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
+++ b/vendor/github.com/opencontainers/selinux/go-selinux/selinux_linux.go
@@ -9,6 +9,7 @@ import (
"fmt"
"io"
"io/ioutil"
+ "math/big"
"os"
"path"
"path/filepath"
@@ -16,7 +17,6 @@ import (
"strings"
"sync"
- "github.com/bits-and-blooms/bitset"
"golang.org/x/sys/unix"
)
@@ -44,7 +44,7 @@ type selinuxState struct {
type level struct {
sens uint
- cats *bitset.BitSet
+ cats *big.Int
}
type mlsRange struct {
@@ -455,8 +455,8 @@ func computeCreateContext(source string, target string, class string) (string, e
}
// catsToBitset stores categories in a bitset.
-func catsToBitset(cats string) (*bitset.BitSet, error) {
- bitset := &bitset.BitSet{}
+func catsToBitset(cats string) (*big.Int, error) {
+ bitset := new(big.Int)
catlist := strings.Split(cats, ",")
for _, r := range catlist {
@@ -471,14 +471,14 @@ func catsToBitset(cats string) (*bitset.BitSet, error) {
return nil, err
}
for i := catstart; i <= catend; i++ {
- bitset.Set(i)
+ bitset.SetBit(bitset, int(i), 1)
}
} else {
cat, err := parseLevelItem(ranges[0], category)
if err != nil {
return nil, err
}
- bitset.Set(cat)
+ bitset.SetBit(bitset, int(cat), 1)
}
}
@@ -548,37 +548,30 @@ func rangeStrToMLSRange(rangeStr string) (*mlsRange, error) {
// bitsetToStr takes a category bitset and returns it in the
// canonical selinux syntax
-func bitsetToStr(c *bitset.BitSet) string {
+func bitsetToStr(c *big.Int) string {
var str string
- i, e := c.NextSet(0)
- len := 0
- for e {
- if len == 0 {
+
+ length := 0
+ for i := int(c.TrailingZeroBits()); i < c.BitLen(); i++ {
+ if c.Bit(i) == 0 {
+ continue
+ }
+ if length == 0 {
if str != "" {
str += ","
}
- str += "c" + strconv.Itoa(int(i))
- }
-
- next, e := c.NextSet(i + 1)
- if e {
- // consecutive cats
- if next == i+1 {
- len++
- i = next
- continue
- }
+ str += "c" + strconv.Itoa(i)
}
- if len == 1 {
- str += ",c" + strconv.Itoa(int(i))
- } else if len > 1 {
- str += ".c" + strconv.Itoa(int(i))
+ if c.Bit(i+1) == 1 {
+ length++
+ continue
}
- if !e {
- break
+ if length == 1 {
+ str += ",c" + strconv.Itoa(i)
+ } else if length > 1 {
+ str += ".c" + strconv.Itoa(i)
}
- len = 0
- i = next
+ length = 0
}
return str
@@ -591,13 +584,16 @@ func (l1 *level) equal(l2 *level) bool {
if l1.sens != l2.sens {
return false
}
- return l1.cats.Equal(l2.cats)
+ if l2.cats == nil || l1.cats == nil {
+ return l2.cats == l1.cats
+ }
+ return l1.cats.Cmp(l2.cats) == 0
}
// String returns an mlsRange as a string.
func (m mlsRange) String() string {
low := "s" + strconv.Itoa(int(m.low.sens))
- if m.low.cats != nil && m.low.cats.Count() > 0 {
+ if m.low.cats != nil && m.low.cats.BitLen() > 0 {
low += ":" + bitsetToStr(m.low.cats)
}
@@ -606,7 +602,7 @@ func (m mlsRange) String() string {
}
high := "s" + strconv.Itoa(int(m.high.sens))
- if m.high.cats != nil && m.high.cats.Count() > 0 {
+ if m.high.cats != nil && m.high.cats.BitLen() > 0 {
high += ":" + bitsetToStr(m.high.cats)
}
@@ -656,10 +652,12 @@ func calculateGlbLub(sourceRange, targetRange string) (string, error) {
/* find the intersecting categories */
if s.low.cats != nil && t.low.cats != nil {
- outrange.low.cats = s.low.cats.Intersection(t.low.cats)
+ outrange.low.cats = new(big.Int)
+ outrange.low.cats.And(s.low.cats, t.low.cats)
}
if s.high.cats != nil && t.high.cats != nil {
- outrange.high.cats = s.high.cats.Intersection(t.high.cats)
+ outrange.high.cats = new(big.Int)
+ outrange.high.cats.And(s.high.cats, t.high.cats)
}
return outrange.String(), nil