mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-11 12:52:23 +00:00
rootless: RunningInUserNS() is now part of userns namespace
Previously part of the "system" namespace, the RunningInUserNS() has been moved to the "userns" namespace. Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
parent
b5293c5214
commit
c0f801c0c4
@ -30,7 +30,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/containernetworking/plugins/pkg/ns"
|
"github.com/containernetworking/plugins/pkg/ns"
|
||||||
"github.com/opencontainers/runc/libcontainer/system"
|
"github.com/opencontainers/runc/libcontainer/userns"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
@ -78,7 +78,7 @@ func isRootlessFunc() bool {
|
|||||||
if os.Geteuid() != 0 {
|
if os.Geteuid() != 0 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if system.RunningInUserNS() {
|
if userns.RunningInUserNS() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
SetRootless(false)
|
SetRootless(false)
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/opencontainers/runc/libcontainer/system"
|
"github.com/opencontainers/runc/libcontainer/userns"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ func TestIsRootless(t *testing.T) {
|
|||||||
if os.Getuid() != 0 {
|
if os.Getuid() != 0 {
|
||||||
rootless = true
|
rootless = true
|
||||||
} else {
|
} else {
|
||||||
rootless = system.RunningInUserNS()
|
rootless = userns.RunningInUserNS()
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(rootless, isRootlessFunc())
|
assert.Equal(rootless, isRootlessFunc())
|
||||||
|
Loading…
Reference in New Issue
Block a user