Compare commits

..

2 Commits

Author SHA1 Message Date
2cf3077c07
container: optionally isolate host abstract UNIX domain sockets via landlock
Some checks failed
Test / Create distribution (push) Failing after 32s
Test / Create distribution (pull_request) Failing after 35s
Test / Hakurei (push) Failing after 50s
Test / Hakurei (pull_request) Failing after 50s
Test / Hakurei (race detector) (push) Failing after 54s
Test / Sandbox (pull_request) Failing after 54s
Test / Hakurei (race detector) (pull_request) Failing after 57s
Test / Sandbox (push) Failing after 1m8s
Test / Sandbox (race detector) (pull_request) Failing after 1m6s
Test / Hpkg (pull_request) Failing after 1m8s
Test / Flake checks (pull_request) Has been skipped
Test / Sandbox (race detector) (push) Failing after 1m22s
Test / Hpkg (push) Failing after 1m24s
Test / Flake checks (push) Has been skipped
2025-08-18 11:57:21 +09:00
e4801d0e23
app: set up acl on X11 socket
The socket is typically owned by the priv-user, and inaccessible by the target user, so just allowing access to the directory is not enough. This change fixes this oversight and add checks that will also be useful for merging #1.

Signed-off-by: Ophestra <cat@gensokyo.uk>

# Conflicts:
#	test/sandbox/case/device.nix
#	test/sandbox/case/tty.nix
2025-08-18 11:56:18 +09:00

View File

@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"io"
"log"
"os"
"os/exec"
"runtime"
@ -14,6 +15,7 @@ import (
. "syscall"
"time"
"hakurei.app/container/landlock"
"hakurei.app/container/seccomp"
)
@ -92,6 +94,8 @@ type (
RetainSession bool
// Do not [syscall.CLONE_NEWNET].
HostNet bool
// Scope abstract UNIX domain sockets using LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET.
ScopeAbstract bool
// Retain CAP_SYS_ADMIN.
Privileged bool
}
@ -185,6 +189,12 @@ func (p *Container) Start() error {
"prctl(PR_SET_NO_NEW_PRIVS):")
}
if p.ScopeAbstract {
if err := landlock.ScopeAbstract(); err != nil {
log.Fatalf("could not scope abstract unix sockets: %v", err)
}
}
msg.Verbose("starting container init")
if err := p.cmd.Start(); err != nil {
return msg.WrapErr(err, err.Error())