Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"encoding/pem"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -1055,22 +1056,26 @@ func testSecurityModeSysfs(t *testing.T, sb integration.Sandbox) {
require.NoError(t, err)
defer c.Close()

cg := "/sys/fs/cgroup/cpuset/securitytest" // cgroup v1
cg := "/sys/fs/cgroup/cpuset" // cgroup v1
if _, err := os.Stat("/sys/fs/cgroup/cpuset"); errors.Is(err, os.ErrNotExist) {
cg = "/sys/fs/cgroup/securitytest" // cgroup v2
cg = "/sys/fs/cgroup" // cgroup v2
}

command := "mkdir " + cg
// create temporary directory in cgroupfs to not interfere with subsequent runs
command := fmt.Sprintf("mktemp -d -p %s securitytest.XXXXXX", cg)
st := llb.Image("busybox:latest").
Run(llb.Shlex(command),
llb.Security(mode))
Run(llb.Shlex("sh -c 'ls -l /sys/fs/cgroup | grep securitytest > /out || true'")).
Run(llb.Shlex(command), llb.Security(mode))

def, err := st.Marshal(sb.Context())
require.NoError(t, err)

_, err = c.Solve(sb.Context(), def, SolveOpt{
AllowedEntitlements: allowedEntitlements,
Exports: []ExportEntry{{Type: "local", OutputDir: "/tmp/out"}},
}, nil)
b, _ := ioutil.ReadFile("/tmp/out/out")
t.Logf("FOOBAR %s", b)

if secMode == securitySandbox {
require.Error(t, err)
Expand Down