feat: sync with latest woj_sandbox, allow to set write file limit (RLIMIT_FSIZE
)
This commit is contained in:
parent
5a5f4e75be
commit
54e83ec63e
@ -25,6 +25,7 @@ type ConfigRuntime struct {
|
|||||||
TimeLimit int `json:"TimeLimit"` // in ms
|
TimeLimit int `json:"TimeLimit"` // in ms
|
||||||
MemoryLimit int `json:"MemoryLimit"` // in mb
|
MemoryLimit int `json:"MemoryLimit"` // in mb
|
||||||
NProcLimit int `json:"NProcLimit"`
|
NProcLimit int `json:"NProcLimit"`
|
||||||
|
WriteFileLimit int `json:"WriteFileLimit"` // in mb
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -32,16 +33,19 @@ var (
|
|||||||
TimeLimit: 300000,
|
TimeLimit: 300000,
|
||||||
MemoryLimit: 256,
|
MemoryLimit: 256,
|
||||||
NProcLimit: 64,
|
NProcLimit: 64,
|
||||||
|
WriteFileLimit: 1,
|
||||||
}
|
}
|
||||||
DefaultCompileRuntime = ConfigRuntime{
|
DefaultCompileRuntime = ConfigRuntime{
|
||||||
TimeLimit: 60000,
|
TimeLimit: 60000,
|
||||||
MemoryLimit: 256,
|
MemoryLimit: 256,
|
||||||
NProcLimit: 64,
|
NProcLimit: 64,
|
||||||
|
WriteFileLimit: 64,
|
||||||
}
|
}
|
||||||
DefaultCheckRuntime = ConfigRuntime{
|
DefaultCheckRuntime = ConfigRuntime{
|
||||||
TimeLimit: 60000,
|
TimeLimit: 60000,
|
||||||
MemoryLimit: 128,
|
MemoryLimit: 128,
|
||||||
NProcLimit: 64,
|
NProcLimit: 64,
|
||||||
|
WriteFileLimit: 16,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -55,6 +59,9 @@ func (c *ConfigRuntime) Validate() error {
|
|||||||
if c.NProcLimit <= 0 {
|
if c.NProcLimit <= 0 {
|
||||||
return errors.New("nproc limit <= 0")
|
return errors.New("nproc limit <= 0")
|
||||||
}
|
}
|
||||||
|
if c.WriteFileLimit <= 0 {
|
||||||
|
return errors.New("write file limit <= 0")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ func (s *service) SandboxArgsBuilder(meta *JudgeMeta, id int) string {
|
|||||||
args = append(args, fmt.Sprintf("--memory_limit=%d", meta.Cfg.Lang.Runtime.Run.MemoryLimit))
|
args = append(args, fmt.Sprintf("--memory_limit=%d", meta.Cfg.Lang.Runtime.Run.MemoryLimit))
|
||||||
args = append(args, fmt.Sprintf("--nproc_limit=%d", meta.Cfg.Lang.Runtime.Run.NProcLimit))
|
args = append(args, fmt.Sprintf("--nproc_limit=%d", meta.Cfg.Lang.Runtime.Run.NProcLimit))
|
||||||
args = append(args, fmt.Sprintf("--time_limit=%d", meta.Cfg.Lang.Runtime.Run.TimeLimit))
|
args = append(args, fmt.Sprintf("--time_limit=%d", meta.Cfg.Lang.Runtime.Run.TimeLimit))
|
||||||
|
args = append(args, fmt.Sprintf("--fsize_limit=%d", meta.Cfg.Lang.Runtime.Run.WriteFileLimit))
|
||||||
args = append(args, fmt.Sprintf("--sandbox_template=%s", meta.Cfg.Lang.Lang))
|
args = append(args, fmt.Sprintf("--sandbox_template=%s", meta.Cfg.Lang.Lang))
|
||||||
args = append(args, fmt.Sprintf("--sandbox_action=%s", "ret"))
|
args = append(args, fmt.Sprintf("--sandbox_action=%s", "ret"))
|
||||||
args = append(args, fmt.Sprintf("--uid=%d", 1000))
|
args = append(args, fmt.Sprintf("--uid=%d", 1000))
|
||||||
|
Loading…
Reference in New Issue
Block a user