Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
Signed-off-by: jason yang <jasonyangshadow@gmail.com>
  • Loading branch information
JasonYangShadow committed May 24, 2024
1 parent bd7884e commit e9b003a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/pkg/runtime/launch/launcher_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (l *Launcher) Exec(ctx context.Context, image string, args []string, instan
var err error

var fakerootPath string
if l.cfg.Fakeroot {
if userNs, _ := namespaces.IsInsideUserNamespace(os.Getpid()); userNs && os.Getuid() == 0 {
if (l.uid == 0) && namespaces.IsUnprivileged() {
// Already running root-mapped unprivileged
l.cfg.Fakeroot = false
Expand Down Expand Up @@ -1067,7 +1067,7 @@ func (l *Launcher) setCgroups(instanceName string) error {
hidePid := hidepidProc()
// If we are an instance, always use a cgroup if possible, to enable stats.
// root can always create a cgroup.
useCG := l.uid == 0
useCG := l.uid == 0 && !l.cfg.Namespaces.User
// non-root needs cgroups v2 unified mode + systemd as cgroups manager.
if !useCG && lccgroups.IsCgroup2UnifiedMode() && l.engineConfig.File.SystemdCgroups && !l.cfg.Fakeroot && !hidePid {
if os.Getenv("XDG_RUNTIME_DIR") == "" || os.Getenv("DBUS_SESSION_BUS_ADDRESS") == "" {
Expand Down

0 comments on commit e9b003a

Please sign in to comment.