Skip to content

Commit

Permalink
Remove rootless functionality
Browse files Browse the repository at this point in the history
- [x] Read the [Contributing document](../blob/-/.github/CONTRIBUTING.md).

Summary
---------------
Remove rootless functionality

Context: cloudfoundry/garden-runc-release#196

Backward Compatibility
---------------
Breaking Change? **No**

Signed-off-by: Amin Jamali <[email protected]>
  • Loading branch information
MarcPaquette authored and winkingturtle-vmw committed Apr 19, 2024
1 parent 3ecff94 commit db123da
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 103 deletions.
1 change: 0 additions & 1 deletion devices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ var _ = Describe("Devices", func() {

Context("in a privileged container", func() {
BeforeEach(func() {
skipIfRootless()
privilegedContainer = true
})

Expand Down
17 changes: 0 additions & 17 deletions garden_integration_tests_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,22 +226,6 @@ func getKernelVersion() (int, int) {
return major, minor
}

func skipIfRootless() {
if rootless() {
Skip("behaviour being tested is either not relevant or not implemented in rootless")
}
}

func skipIfNotRootless() {
if !rootless() {
Skip("behaviour being tested is specific to rootless")
}
}

func rootless() bool {
return os.Getenv("ROOTLESS") != "false"
}

func skipIfWoot(reason string) {
if woot() {
Skip("Skipping this test because I am WOOT: " + reason)
Expand Down Expand Up @@ -274,7 +258,6 @@ func isContainerdForProcesses() bool {

func setPrivileged() {
privilegedContainer = true
skipIfRootless()
}

func runProcessWithIO(container garden.Container, processSpec garden.ProcessSpec, pio garden.ProcessIO) int {
Expand Down
20 changes: 0 additions & 20 deletions lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ var _ = Describe("Lifecycle", func() {
})

mappingSize := `0\s+4294967294\s+1\n\s+1\s+1\s+4294967293`
if rootless() {
mappingSize = `0\s+4294967294\s+1\n\s+1\s+65536\s+4294901758`
}
Expect(stdout).To(gbytes.Say(mappingSize))
}

Expand Down Expand Up @@ -1365,23 +1362,6 @@ done
})
})

Context("when running rootless", func() {
BeforeEach(func() {
if runtime.GOOS == "windows" {
Skip("pending for windows")
}
if !rootless() {
Skip("this behaviour only makes sense when rootless")
}
privilegedContainer = true
assertContainerCreate = false
})

It("cannot create privileged containers", func() {
Expect(containerCreateErr).To(MatchError("privileged container creation is disabled"))
})
})

It("streams in relative to the default run directory", func() {
err := container.StreamIn(garden.StreamInSpec{
User: regularUser,
Expand Down
1 change: 0 additions & 1 deletion networking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var _ = Describe("Networking", func() {
if runtime.GOOS == "windows" {
Skip("pending for windows")
}
skipIfRootless()
})

It("can be contacted after a NetIn", func() {
Expand Down
8 changes: 0 additions & 8 deletions process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,6 @@ var _ = Describe("Process", func() {
})

Context("when working directory does not exist", func() {
BeforeEach(func() {
skipIfRootless()
})

It("spawns the process", func() {
if runtime.GOOS == "windows" {
stdout := runForStdout(container, garden.ProcessSpec{
Expand Down Expand Up @@ -401,10 +397,6 @@ var _ = Describe("Process", func() {
})

Context("when working directory does not exist", func() {
BeforeEach(func() {
skipIfRootless()
})

It("should create the working directory, and succeed", func() {
exitCode, _, _ := runProcess(container, garden.ProcessSpec{
User: "alice",
Expand Down
33 changes: 6 additions & 27 deletions security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,34 +310,13 @@ var _ = Describe("Security", func() {
})

Context("when running a command as root", func() {
When("not rootless", func() {
BeforeEach(func() {
skipIfRootless()
})

It("executes with uid 0, gid 0, and supplementary gids from /etc/group", func() {
stdout := runForStdout(container, garden.ProcessSpec{
User: "root",
Path: "/bin/sh",
Args: []string{"-c", "id -u; id -g; id -G"},
})
Expect(stdout).To(gbytes.Say("0\n0\n0 10\n"))
})
})

When("rootless", func() {
BeforeEach(func() {
skipIfNotRootless()
})

It("executes with uid 0, gid 0, and no supplementary gids", func() {
stdout := runForStdout(container, garden.ProcessSpec{
User: "root",
Path: "/bin/sh",
Args: []string{"-c", "id -u; id -g; id -G"},
})
Expect(stdout).To(gbytes.Say("0\n0\n0\n"))
It("executes with uid 0, gid 0, and supplementary gids from /etc/group", func() {
stdout := runForStdout(container, garden.ProcessSpec{
User: "root",
Path: "/bin/sh",
Args: []string{"-c", "id -u; id -g; id -G"},
})
Expect(stdout).To(gbytes.Say("0\n0\n0 10\n"))
})

It("sets $HOME, $USER, and $PATH", func() {
Expand Down
35 changes: 6 additions & 29 deletions user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,37 +61,14 @@ var _ = Describe("users", func() {
imageRef.URI = "docker:///cloudfoundry/garden-rootfs"
})

When("not rootless", func() {
BeforeEach(func() {
skipIfRootless()
})

It("ignores inherited groups from gdn but includes supplementary groups", func() {
stdout := runForStdout(container, garden.ProcessSpec{
User: "alice",
Path: "cat",
Args: []string{"/proc/self/status"},
})

Expect(stdout).To(gbytes.Say(`Groups:(\s)*1010(\s)*1011(\s)*\n`))
})
})

When("running as rootless", func() {
BeforeEach(func() {
skipIfNotRootless()
})

It("ignores inherited groups from gdn and supplementary groups", func() {
stdout := runForStdout(container, garden.ProcessSpec{
User: "alice",
Path: "cat",
Args: []string{"/proc/self/status"},
})

Expect(stdout).To(gbytes.Say(`Groups:\s*\n`))
It("ignores inherited groups from gdn but includes supplementary groups", func() {
stdout := runForStdout(container, garden.ProcessSpec{
User: "alice",
Path: "cat",
Args: []string{"/proc/self/status"},
})

Expect(stdout).To(gbytes.Say(`Groups:(\s)*1010(\s)*1011(\s)*\n`))
})
})

Expand Down

0 comments on commit db123da

Please sign in to comment.