aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-03-24 15:28:25 +0900
committerOphestra <cat@gensokyo.uk>2025-03-24 16:03:07 +0900
commitad3576c16467d8b36452307b005b6af0d0f0f9d2 (patch)
tree6db4bcd2590ac4054fe51b9f955490a2402fb9fd
parentb989a4601a386561103715187fde9400ad5b4e72 (diff)
sandbox: resolve tty name
Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--sandbox/container_test.go12
-rw-r--r--sandbox/init.go1
-rw-r--r--sandbox/sequential.go10
3 files changed, 12 insertions, 11 deletions
diff --git a/sandbox/container_test.go b/sandbox/container_test.go
index f6e6562d..f3d08543 100644
--- a/sandbox/container_test.go
+++ b/sandbox/container_test.go
@@ -57,12 +57,12 @@ func TestContainer(t *testing.T) {
Mqueue("/dev/mqueue"),
[]*vfs.MountInfoEntry{
e("/", "/dev", "rw,nosuid,nodev,relatime", "tmpfs", "devtmpfs", ignore),
- e("/null", "/dev/null", "ro,nosuid", "devtmpfs", "devtmpfs", ignore),
- e("/zero", "/dev/zero", "ro,nosuid", "devtmpfs", "devtmpfs", ignore),
- e("/full", "/dev/full", "ro,nosuid", "devtmpfs", "devtmpfs", ignore),
- e("/random", "/dev/random", "ro,nosuid", "devtmpfs", "devtmpfs", ignore),
- e("/urandom", "/dev/urandom", "ro,nosuid", "devtmpfs", "devtmpfs", ignore),
- e("/tty", "/dev/tty", "ro,nosuid", "devtmpfs", "devtmpfs", ignore),
+ e("/null", "/dev/null", "rw,nosuid", "devtmpfs", "devtmpfs", ignore),
+ e("/zero", "/dev/zero", "rw,nosuid", "devtmpfs", "devtmpfs", ignore),
+ e("/full", "/dev/full", "rw,nosuid", "devtmpfs", "devtmpfs", ignore),
+ e("/random", "/dev/random", "rw,nosuid", "devtmpfs", "devtmpfs", ignore),
+ e("/urandom", "/dev/urandom", "rw,nosuid", "devtmpfs", "devtmpfs", ignore),
+ e("/tty", "/dev/tty", "rw,nosuid", "devtmpfs", "devtmpfs", ignore),
e("/", "/dev/pts", "rw,nosuid,noexec,relatime", "devpts", "devpts", "rw,mode=620,ptmxmode=666"),
e("/", "/dev/mqueue", "rw,nosuid,nodev,noexec,relatime", "mqueue", "mqueue", "rw"),
}, ""},
diff --git a/sandbox/init.go b/sandbox/init.go
index cf7fd1b3..8c2918cb 100644
--- a/sandbox/init.go
+++ b/sandbox/init.go
@@ -239,7 +239,6 @@ func Init(prepare func(prefix string), setVerbose func(verbose bool)) {
cmd := exec.Command(params.Path)
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
- cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
cmd.Args = params.Args
cmd.Env = params.Env
cmd.ExtraFiles = extraFiles
diff --git a/sandbox/sequential.go b/sandbox/sequential.go
index f37567d9..d6967035 100644
--- a/sandbox/sequential.go
+++ b/sandbox/sequential.go
@@ -156,7 +156,7 @@ func (d MountDev) apply(params *Params) error {
if err := hostProc.bindMount(
toHost("/dev/"+name),
targetPath,
- syscall.MS_RDONLY,
+ 0,
true,
); err != nil {
return err
@@ -204,10 +204,12 @@ func (d MountDev) apply(params *Params) error {
if err := ensureFile(consolePath, 0444, 0755); err != nil {
return err
}
- if err := hostProc.bindMount(
- hostProc.stdout(),
+ if name, err := os.Readlink(hostProc.stdout()); err != nil {
+ return msg.WrapErr(err, err.Error())
+ } else if err = hostProc.bindMount(
+ toHost(name),
consolePath,
- syscall.MS_RDONLY,
+ 0,
false,
); err != nil {
return err