From f7bd28118c4ac34a9a444073b31ca8f2579188f3 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 29 Jul 2025 03:06:49 +0900 Subject: hst: configurable wait delay This is useful for programs that take a long time to clean up. Signed-off-by: Ophestra --- hst/container.go | 8 ++++++-- hst/template.go | 24 ++++++++++++------------ hst/template_test.go | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) (limited to 'hst') diff --git a/hst/container.go b/hst/container.go index 1ee9e839..c385344c 100644 --- a/hst/container.go +++ b/hst/container.go @@ -1,6 +1,8 @@ package hst import ( + "time" + "hakurei.app/container/seccomp" ) @@ -10,8 +12,10 @@ type ( // container hostname Hostname string `json:"hostname,omitempty"` - // do not interrupt and wait for initial process during termination - ImmediateTermination bool `json:"immediate_termination,omitempty"` + // duration to wait for after interrupting a container's initial process in nanoseconds; + // a negative value causes the container to be terminated immediately on cancellation + WaitDelay time.Duration `json:"wait_delay,omitempty"` + // extra seccomp flags SeccompFlags seccomp.ExportFlag `json:"seccomp_flags"` // extra seccomp presets diff --git a/hst/template.go b/hst/template.go index 60af2ebc..3ab9c277 100644 --- a/hst/template.go +++ b/hst/template.go @@ -57,18 +57,18 @@ func Template() *Config { Groups: []string{"video", "dialout", "plugdev"}, Container: &ContainerConfig{ - Hostname: "localhost", - Devel: true, - Userns: true, - Net: true, - Device: true, - ImmediateTermination: true, - SeccompFlags: seccomp.AllowMultiarch, - SeccompPresets: seccomp.PresetExt, - SeccompCompat: true, - Tty: true, - Multiarch: true, - MapRealUID: true, + Hostname: "localhost", + Devel: true, + Userns: true, + Net: true, + Device: true, + WaitDelay: -1, + SeccompFlags: seccomp.AllowMultiarch, + SeccompPresets: seccomp.PresetExt, + SeccompCompat: true, + Tty: true, + Multiarch: true, + MapRealUID: true, // example API credentials pulled from Google Chrome // DO NOT USE THESE IN A REAL BROWSER Env: map[string]string{ diff --git a/hst/template_test.go b/hst/template_test.go index a9b92262..8761b7d4 100644 --- a/hst/template_test.go +++ b/hst/template_test.go @@ -80,7 +80,7 @@ func TestTemplate(t *testing.T) { ], "container": { "hostname": "localhost", - "immediate_termination": true, + "wait_delay": -1, "seccomp_flags": 1, "seccomp_presets": 1, "seccomp_compat": true, -- cgit v1.3.1