mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
runsc: set gofer umask to 0.
PiperOrigin-RevId: 202185642 Change-Id: I2eefcc0b2ffadc6ef21d177a8a4ab0cda91f3399
This commit is contained in:
@@ -23,7 +23,6 @@ import (
|
||||
"runtime"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
gtime "time"
|
||||
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
@@ -270,7 +269,7 @@ func newProcess(spec *specs.Spec, conf *Config, ioFDs []int, console bool, creds
|
||||
Envv: spec.Process.Env,
|
||||
WorkingDirectory: spec.Process.Cwd,
|
||||
Credentials: creds,
|
||||
Umask: 0,
|
||||
Umask: 0022,
|
||||
Limits: ls,
|
||||
MaxSymlinkTraversals: linux.MaxSymlinkTraversals,
|
||||
UTSNamespace: utsns,
|
||||
@@ -296,10 +295,9 @@ func newProcess(spec *specs.Spec, conf *Config, ioFDs []int, console bool, creds
|
||||
// Use root user to configure mounts. The current user might not have
|
||||
// permission to do so.
|
||||
rootProcArgs := kernel.CreateProcessArgs{
|
||||
WorkingDirectory: "/",
|
||||
Credentials: auth.NewRootCredentials(creds.UserNamespace),
|
||||
// The sentry should run with a umask of 0.
|
||||
Umask: uint(syscall.Umask(0)),
|
||||
WorkingDirectory: "/",
|
||||
Credentials: auth.NewRootCredentials(creds.UserNamespace),
|
||||
Umask: 0022,
|
||||
MaxSymlinkTraversals: linux.MaxSymlinkTraversals,
|
||||
}
|
||||
rootCtx := rootProcArgs.NewContext(k)
|
||||
|
||||
@@ -107,6 +107,13 @@ func (b *Boot) Execute(_ context.Context, f *flag.FlagSet, args ...interface{})
|
||||
conf := args[0].(*boot.Config)
|
||||
waitStatus := args[1].(*syscall.WaitStatus)
|
||||
|
||||
// sentry should run with a umask of 0 when --file-access=direct, because we want
|
||||
// to preserve file modes exactly as set by the sentry, which will have applied
|
||||
// its own umask.
|
||||
if conf.FileAccess == boot.FileAccessDirect {
|
||||
syscall.Umask(0)
|
||||
}
|
||||
|
||||
if b.applyCaps {
|
||||
caps := spec.Process.Capabilities
|
||||
if conf.Platform == boot.PlatformPtrace {
|
||||
|
||||
@@ -17,6 +17,7 @@ package cmd
|
||||
import (
|
||||
"os"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
"context"
|
||||
"flag"
|
||||
@@ -66,6 +67,10 @@ func (g *Gofer) Execute(_ context.Context, f *flag.FlagSet, args ...interface{})
|
||||
return subcommands.ExitUsageError
|
||||
}
|
||||
|
||||
// fsgofer should run with a umask of 0, because we want to preserve file
|
||||
// modes exactly as sent by the sandbox, which will have applied its own umask.
|
||||
syscall.Umask(0)
|
||||
|
||||
spec, err := specutils.ReadSpec(g.bundleDir)
|
||||
if err != nil {
|
||||
Fatalf("error reading spec: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user