sandbox: rename params struct
Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
7c063833e0
commit
d7eddd54a2
@ -54,7 +54,6 @@ type (
|
||||
// with behaviour identical to its [exec.Cmd] counterpart.
|
||||
ExtraFiles []*os.File
|
||||
|
||||
InitParams
|
||||
// Custom [exec.Cmd] initialisation function.
|
||||
CommandContext func(ctx context.Context) (cmd *exec.Cmd)
|
||||
|
||||
@ -72,9 +71,11 @@ type (
|
||||
|
||||
cmd *exec.Cmd
|
||||
ctx context.Context
|
||||
Params
|
||||
}
|
||||
|
||||
InitParams struct {
|
||||
// Params holds container configuration and is safe to serialise.
|
||||
Params struct {
|
||||
// Working directory in the container.
|
||||
Dir string
|
||||
// Initial process environment.
|
||||
@ -100,7 +101,7 @@ type (
|
||||
|
||||
Ops []Op
|
||||
Op interface {
|
||||
apply(params *InitParams) error
|
||||
apply(params *Params) error
|
||||
prefix() string
|
||||
|
||||
Is(op Op) bool
|
||||
@ -210,7 +211,7 @@ func (p *Container) Serve() error {
|
||||
p.setup = nil
|
||||
return setup.Encode(
|
||||
&initParams{
|
||||
p.InitParams,
|
||||
p.Params,
|
||||
syscall.Getuid(),
|
||||
syscall.Getgid(),
|
||||
len(p.ExtraFiles),
|
||||
@ -228,6 +229,6 @@ func (p *Container) String() string {
|
||||
|
||||
func New(ctx context.Context, name string, args ...string) *Container {
|
||||
return &Container{name: name, ctx: ctx,
|
||||
InitParams: InitParams{Args: append([]string{name}, args...), Dir: "/", Ops: new(Ops)},
|
||||
Params: Params{Args: append([]string{name}, args...), Dir: "/", Ops: new(Ops)},
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ const (
|
||||
)
|
||||
|
||||
type initParams struct {
|
||||
InitParams
|
||||
Params
|
||||
|
||||
HostUid, HostGid int
|
||||
// extra files count
|
||||
@ -148,7 +148,7 @@ func Init(prepare func(prefix string), setVerbose func(verbose bool)) {
|
||||
}
|
||||
|
||||
msg.Verbosef("%s %s", op.prefix(), op)
|
||||
if err := op.apply(¶ms.InitParams); err != nil {
|
||||
if err := op.apply(¶ms.Params); err != nil {
|
||||
msg.PrintBaseErr(err,
|
||||
fmt.Sprintf("cannot apply op %d:", i))
|
||||
msg.BeforeExit()
|
||||
|
@ -19,7 +19,7 @@ type BindMount struct {
|
||||
Flags int
|
||||
}
|
||||
|
||||
func (b *BindMount) apply(*InitParams) error {
|
||||
func (b *BindMount) apply(*Params) error {
|
||||
if !path.IsAbs(b.Source) || !path.IsAbs(b.Target) {
|
||||
return msg.WrapErr(syscall.EBADE,
|
||||
"path is not absolute")
|
||||
@ -45,7 +45,7 @@ func init() { gob.Register(new(MountProc)) }
|
||||
// MountProc mounts a private instance of proc.
|
||||
type MountProc string
|
||||
|
||||
func (p MountProc) apply(*InitParams) error {
|
||||
func (p MountProc) apply(*Params) error {
|
||||
v := string(p)
|
||||
|
||||
if !path.IsAbs(v) {
|
||||
@ -75,7 +75,7 @@ func init() { gob.Register(new(MountDev)) }
|
||||
// MountDev mounts part of host dev.
|
||||
type MountDev string
|
||||
|
||||
func (d MountDev) apply(params *InitParams) error {
|
||||
func (d MountDev) apply(params *Params) error {
|
||||
v := string(d)
|
||||
|
||||
if !path.IsAbs(v) {
|
||||
@ -156,7 +156,7 @@ func init() { gob.Register(new(MountMqueue)) }
|
||||
// MountMqueue mounts a private mqueue instance on container Path.
|
||||
type MountMqueue string
|
||||
|
||||
func (m MountMqueue) apply(*InitParams) error {
|
||||
func (m MountMqueue) apply(*Params) error {
|
||||
v := string(m)
|
||||
|
||||
if !path.IsAbs(v) {
|
||||
@ -190,7 +190,7 @@ type MountTmpfs struct {
|
||||
Perm os.FileMode
|
||||
}
|
||||
|
||||
func (t *MountTmpfs) apply(*InitParams) error {
|
||||
func (t *MountTmpfs) apply(*Params) error {
|
||||
if !path.IsAbs(t.Path) {
|
||||
return msg.WrapErr(syscall.EBADE,
|
||||
fmt.Sprintf("path %q is not absolute", t.Path))
|
||||
@ -215,7 +215,7 @@ func init() { gob.Register(new(Symlink)) }
|
||||
// Symlink creates a symlink in the container filesystem.
|
||||
type Symlink [2]string
|
||||
|
||||
func (l *Symlink) apply(*InitParams) error {
|
||||
func (l *Symlink) apply(*Params) error {
|
||||
// symlink target is an arbitrary path value, so only validate link name here
|
||||
if !path.IsAbs(l[1]) {
|
||||
return msg.WrapErr(syscall.EBADE,
|
||||
|
Loading…
Reference in New Issue
Block a user