Switch to github.com/golang/dep for vendoring
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
d6ab91be27
commit
8e5b17cf13
15431 changed files with 3971413 additions and 8881 deletions
20
vendor/github.com/syndtr/gocapability/capability/capability.go
generated
vendored
20
vendor/github.com/syndtr/gocapability/capability/capability.go
generated
vendored
|
@ -10,42 +10,42 @@ package capability
|
|||
type Capabilities interface {
|
||||
// Get check whether a capability present in the given
|
||||
// capabilities set. The 'which' value should be one of EFFECTIVE,
|
||||
// PERMITTED, INHERITABLE or BOUNDING.
|
||||
// PERMITTED, INHERITABLE, BOUNDING or AMBIENT.
|
||||
Get(which CapType, what Cap) bool
|
||||
|
||||
// Empty check whether all capability bits of the given capabilities
|
||||
// set are zero. The 'which' value should be one of EFFECTIVE,
|
||||
// PERMITTED, INHERITABLE or BOUNDING.
|
||||
// PERMITTED, INHERITABLE, BOUNDING or AMBIENT.
|
||||
Empty(which CapType) bool
|
||||
|
||||
// Full check whether all capability bits of the given capabilities
|
||||
// set are one. The 'which' value should be one of EFFECTIVE,
|
||||
// PERMITTED, INHERITABLE or BOUNDING.
|
||||
// PERMITTED, INHERITABLE, BOUNDING or AMBIENT.
|
||||
Full(which CapType) bool
|
||||
|
||||
// Set sets capabilities of the given capabilities sets. The
|
||||
// 'which' value should be one or combination (OR'ed) of EFFECTIVE,
|
||||
// PERMITTED, INHERITABLE or BOUNDING.
|
||||
// PERMITTED, INHERITABLE, BOUNDING or AMBIENT.
|
||||
Set(which CapType, caps ...Cap)
|
||||
|
||||
// Unset unsets capabilities of the given capabilities sets. The
|
||||
// 'which' value should be one or combination (OR'ed) of EFFECTIVE,
|
||||
// PERMITTED, INHERITABLE or BOUNDING.
|
||||
// PERMITTED, INHERITABLE, BOUNDING or AMBIENT.
|
||||
Unset(which CapType, caps ...Cap)
|
||||
|
||||
// Fill sets all bits of the given capabilities kind to one. The
|
||||
// 'kind' value should be one or combination (OR'ed) of CAPS or
|
||||
// BOUNDS.
|
||||
// 'kind' value should be one or combination (OR'ed) of CAPS,
|
||||
// BOUNDS or AMBS.
|
||||
Fill(kind CapType)
|
||||
|
||||
// Clear sets all bits of the given capabilities kind to zero. The
|
||||
// 'kind' value should be one or combination (OR'ed) of CAPS or
|
||||
// BOUNDS.
|
||||
// 'kind' value should be one or combination (OR'ed) of CAPS,
|
||||
// BOUNDS or AMBS.
|
||||
Clear(kind CapType)
|
||||
|
||||
// String return current capabilities state of the given capabilities
|
||||
// set as string. The 'which' value should be one of EFFECTIVE,
|
||||
// PERMITTED, INHERITABLE or BOUNDING.
|
||||
// PERMITTED, INHERITABLE BOUNDING or AMBIENT
|
||||
StringCap(which CapType) string
|
||||
|
||||
// String return current capabilities state as string.
|
||||
|
|
50
vendor/github.com/syndtr/gocapability/capability/capability_linux.go
generated
vendored
50
vendor/github.com/syndtr/gocapability/capability/capability_linux.go
generated
vendored
|
@ -235,9 +235,10 @@ func (c *capsV1) Apply(kind CapType) error {
|
|||
}
|
||||
|
||||
type capsV3 struct {
|
||||
hdr capHeader
|
||||
data [2]capData
|
||||
bounds [2]uint32
|
||||
hdr capHeader
|
||||
data [2]capData
|
||||
bounds [2]uint32
|
||||
ambient [2]uint32
|
||||
}
|
||||
|
||||
func (c *capsV3) Get(which CapType, what Cap) bool {
|
||||
|
@ -256,6 +257,8 @@ func (c *capsV3) Get(which CapType, what Cap) bool {
|
|||
return (1<<uint(what))&c.data[i].inheritable != 0
|
||||
case BOUNDING:
|
||||
return (1<<uint(what))&c.bounds[i] != 0
|
||||
case AMBIENT:
|
||||
return (1<<uint(what))&c.ambient[i] != 0
|
||||
}
|
||||
|
||||
return false
|
||||
|
@ -275,6 +278,9 @@ func (c *capsV3) getData(which CapType, dest []uint32) {
|
|||
case BOUNDING:
|
||||
dest[0] = c.bounds[0]
|
||||
dest[1] = c.bounds[1]
|
||||
case AMBIENT:
|
||||
dest[0] = c.ambient[0]
|
||||
dest[1] = c.ambient[1]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,6 +319,9 @@ func (c *capsV3) Set(which CapType, caps ...Cap) {
|
|||
if which&BOUNDING != 0 {
|
||||
c.bounds[i] |= 1 << uint(what)
|
||||
}
|
||||
if which&AMBIENT != 0 {
|
||||
c.ambient[i] |= 1 << uint(what)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,6 +345,9 @@ func (c *capsV3) Unset(which CapType, caps ...Cap) {
|
|||
if which&BOUNDING != 0 {
|
||||
c.bounds[i] &= ^(1 << uint(what))
|
||||
}
|
||||
if which&AMBIENT != 0 {
|
||||
c.ambient[i] &= ^(1 << uint(what))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,6 +365,10 @@ func (c *capsV3) Fill(kind CapType) {
|
|||
c.bounds[0] = 0xffffffff
|
||||
c.bounds[1] = 0xffffffff
|
||||
}
|
||||
if kind&AMBS == AMBS {
|
||||
c.ambient[0] = 0xffffffff
|
||||
c.ambient[1] = 0xffffffff
|
||||
}
|
||||
}
|
||||
|
||||
func (c *capsV3) Clear(kind CapType) {
|
||||
|
@ -369,6 +385,10 @@ func (c *capsV3) Clear(kind CapType) {
|
|||
c.bounds[0] = 0
|
||||
c.bounds[1] = 0
|
||||
}
|
||||
if kind&AMBS == AMBS {
|
||||
c.ambient[0] = 0
|
||||
c.ambient[1] = 0
|
||||
}
|
||||
}
|
||||
|
||||
func (c *capsV3) StringCap(which CapType) (ret string) {
|
||||
|
@ -410,6 +430,10 @@ func (c *capsV3) Load() (err error) {
|
|||
fmt.Sscanf(line[4:], "nd: %08x%08x", &c.bounds[1], &c.bounds[0])
|
||||
break
|
||||
}
|
||||
if strings.HasPrefix(line, "CapA") {
|
||||
fmt.Sscanf(line[4:], "mb: %08x%08x", &c.ambient[1], &c.ambient[0])
|
||||
break
|
||||
}
|
||||
}
|
||||
f.Close()
|
||||
|
||||
|
@ -442,7 +466,25 @@ func (c *capsV3) Apply(kind CapType) (err error) {
|
|||
}
|
||||
|
||||
if kind&CAPS == CAPS {
|
||||
return capset(&c.hdr, &c.data[0])
|
||||
err = capset(&c.hdr, &c.data[0])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if kind&AMBS == AMBS {
|
||||
for i := Cap(0); i <= CAP_LAST_CAP; i++ {
|
||||
action := pr_CAP_AMBIENT_LOWER
|
||||
if c.Get(AMBIENT, i) {
|
||||
action = pr_CAP_AMBIENT_RAISE
|
||||
}
|
||||
err := prctl(pr_CAP_AMBIENT, action, uintptr(i), 0, 0)
|
||||
// Ignore EINVAL as not supported on kernels before 4.3
|
||||
if errno, ok := err.(syscall.Errno); ok && errno == syscall.EINVAL {
|
||||
err = nil
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
|
83
vendor/github.com/syndtr/gocapability/capability/capability_test.go
generated
vendored
Normal file
83
vendor/github.com/syndtr/gocapability/capability/capability_test.go
generated
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
// Copyright (c) 2013, Suryandaru Triandana <syndtr@gmail.com>
|
||||
// All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package capability
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestState(t *testing.T) {
|
||||
testEmpty := func(name string, c Capabilities, whats CapType) {
|
||||
for i := CapType(1); i <= BOUNDING; i <<= 1 {
|
||||
if (i&whats) != 0 && !c.Empty(i) {
|
||||
t.Errorf(name+": capabilities set %q wasn't empty", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
testFull := func(name string, c Capabilities, whats CapType) {
|
||||
for i := CapType(1); i <= BOUNDING; i <<= 1 {
|
||||
if (i&whats) != 0 && !c.Full(i) {
|
||||
t.Errorf(name+": capabilities set %q wasn't full", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
testPartial := func(name string, c Capabilities, whats CapType) {
|
||||
for i := CapType(1); i <= BOUNDING; i <<= 1 {
|
||||
if (i&whats) != 0 && (c.Empty(i) || c.Full(i)) {
|
||||
t.Errorf(name+": capabilities set %q wasn't partial", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
testGet := func(name string, c Capabilities, whats CapType, max Cap) {
|
||||
for i := CapType(1); i <= BOUNDING; i <<= 1 {
|
||||
if (i & whats) == 0 {
|
||||
continue
|
||||
}
|
||||
for j := Cap(0); j <= max; j++ {
|
||||
if !c.Get(i, j) {
|
||||
t.Errorf(name+": capability %q wasn't found on %q", j, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
capf := new(capsFile)
|
||||
capf.data.version = 2
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
c Capabilities
|
||||
sets CapType
|
||||
max Cap
|
||||
}{
|
||||
{"v1", new(capsV1), EFFECTIVE | PERMITTED, CAP_AUDIT_CONTROL},
|
||||
{"v3", new(capsV3), EFFECTIVE | PERMITTED | BOUNDING, CAP_LAST_CAP},
|
||||
{"file_v1", new(capsFile), EFFECTIVE | PERMITTED, CAP_AUDIT_CONTROL},
|
||||
{"file_v2", capf, EFFECTIVE | PERMITTED, CAP_LAST_CAP},
|
||||
} {
|
||||
testEmpty(tc.name, tc.c, tc.sets)
|
||||
tc.c.Fill(CAPS | BOUNDS)
|
||||
testFull(tc.name, tc.c, tc.sets)
|
||||
testGet(tc.name, tc.c, tc.sets, tc.max)
|
||||
tc.c.Clear(CAPS | BOUNDS)
|
||||
testEmpty(tc.name, tc.c, tc.sets)
|
||||
for i := CapType(1); i <= BOUNDING; i <<= 1 {
|
||||
for j := Cap(0); j <= CAP_LAST_CAP; j++ {
|
||||
tc.c.Set(i, j)
|
||||
}
|
||||
}
|
||||
testFull(tc.name, tc.c, tc.sets)
|
||||
testGet(tc.name, tc.c, tc.sets, tc.max)
|
||||
for i := CapType(1); i <= BOUNDING; i <<= 1 {
|
||||
for j := Cap(0); j <= CAP_LAST_CAP; j++ {
|
||||
tc.c.Unset(i, j)
|
||||
}
|
||||
}
|
||||
testEmpty(tc.name, tc.c, tc.sets)
|
||||
tc.c.Set(PERMITTED, CAP_CHOWN)
|
||||
testPartial(tc.name, tc.c, PERMITTED)
|
||||
tc.c.Clear(CAPS | BOUNDS)
|
||||
testEmpty(tc.name, tc.c, tc.sets)
|
||||
}
|
||||
}
|
4
vendor/github.com/syndtr/gocapability/capability/enum.go
generated
vendored
4
vendor/github.com/syndtr/gocapability/capability/enum.go
generated
vendored
|
@ -20,6 +20,8 @@ func (c CapType) String() string {
|
|||
return "bounding"
|
||||
case CAPS:
|
||||
return "caps"
|
||||
case AMBIENT:
|
||||
return "ambient"
|
||||
}
|
||||
return "unknown"
|
||||
}
|
||||
|
@ -29,9 +31,11 @@ const (
|
|||
PERMITTED
|
||||
INHERITABLE
|
||||
BOUNDING
|
||||
AMBIENT
|
||||
|
||||
CAPS = EFFECTIVE | PERMITTED | INHERITABLE
|
||||
BOUNDS = BOUNDING
|
||||
AMBS = AMBIENT
|
||||
)
|
||||
|
||||
//go:generate go run enumgen/gen.go
|
||||
|
|
92
vendor/github.com/syndtr/gocapability/capability/enumgen/gen.go
generated
vendored
Normal file
92
vendor/github.com/syndtr/gocapability/capability/enumgen/gen.go
generated
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/format"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const fileName = "enum.go"
|
||||
const genName = "enum_gen.go"
|
||||
|
||||
type generator struct {
|
||||
buf bytes.Buffer
|
||||
caps []string
|
||||
}
|
||||
|
||||
func (g *generator) writeHeader() {
|
||||
g.buf.WriteString("// generated file; DO NOT EDIT - use go generate in directory with source\n")
|
||||
g.buf.WriteString("\n")
|
||||
g.buf.WriteString("package capability")
|
||||
}
|
||||
|
||||
func (g *generator) writeStringFunc() {
|
||||
g.buf.WriteString("\n")
|
||||
g.buf.WriteString("func (c Cap) String() string {\n")
|
||||
g.buf.WriteString("switch c {\n")
|
||||
for _, cap := range g.caps {
|
||||
fmt.Fprintf(&g.buf, "case %s:\n", cap)
|
||||
fmt.Fprintf(&g.buf, "return \"%s\"\n", strings.ToLower(cap[4:]))
|
||||
}
|
||||
g.buf.WriteString("}\n")
|
||||
g.buf.WriteString("return \"unknown\"\n")
|
||||
g.buf.WriteString("}\n")
|
||||
}
|
||||
|
||||
func (g *generator) writeListFunc() {
|
||||
g.buf.WriteString("\n")
|
||||
g.buf.WriteString("// List returns list of all supported capabilities\n")
|
||||
g.buf.WriteString("func List() []Cap {\n")
|
||||
g.buf.WriteString("return []Cap{\n")
|
||||
for _, cap := range g.caps {
|
||||
fmt.Fprintf(&g.buf, "%s,\n", cap)
|
||||
}
|
||||
g.buf.WriteString("}\n")
|
||||
g.buf.WriteString("}\n")
|
||||
}
|
||||
|
||||
func main() {
|
||||
fs := token.NewFileSet()
|
||||
parsedFile, err := parser.ParseFile(fs, fileName, nil, 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
var caps []string
|
||||
for _, decl := range parsedFile.Decls {
|
||||
decl, ok := decl.(*ast.GenDecl)
|
||||
if !ok || decl.Tok != token.CONST {
|
||||
continue
|
||||
}
|
||||
for _, spec := range decl.Specs {
|
||||
vspec := spec.(*ast.ValueSpec)
|
||||
name := vspec.Names[0].Name
|
||||
if strings.HasPrefix(name, "CAP_") {
|
||||
caps = append(caps, name)
|
||||
}
|
||||
}
|
||||
}
|
||||
g := &generator{caps: caps}
|
||||
g.writeHeader()
|
||||
g.writeStringFunc()
|
||||
g.writeListFunc()
|
||||
src, err := format.Source(g.buf.Bytes())
|
||||
if err != nil {
|
||||
fmt.Println("generated invalid Go code")
|
||||
fmt.Println(g.buf.String())
|
||||
log.Fatal(err)
|
||||
}
|
||||
fi, err := os.Stat(fileName)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := ioutil.WriteFile(genName, src, fi.Mode().Perm()); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
9
vendor/github.com/syndtr/gocapability/capability/syscall_linux.go
generated
vendored
9
vendor/github.com/syndtr/gocapability/capability/syscall_linux.go
generated
vendored
|
@ -38,6 +38,15 @@ func capset(hdr *capHeader, data *capData) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// not yet in syscall
|
||||
const (
|
||||
pr_CAP_AMBIENT = 47
|
||||
pr_CAP_AMBIENT_IS_SET = uintptr(1)
|
||||
pr_CAP_AMBIENT_RAISE = uintptr(2)
|
||||
pr_CAP_AMBIENT_LOWER = uintptr(3)
|
||||
pr_CAP_AMBIENT_CLEAR_ALL = uintptr(4)
|
||||
)
|
||||
|
||||
func prctl(option int, arg2, arg3, arg4, arg5 uintptr) (err error) {
|
||||
_, _, e1 := syscall.Syscall6(syscall.SYS_PRCTL, uintptr(option), arg2, arg3, arg4, arg5, 0)
|
||||
if e1 != 0 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue