aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/spfinal.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-10-19 02:58:46 +0900
committerOphestra <cat@gensokyo.uk>2025-10-19 02:58:46 +0900
commitc0e860000a53f0fd44f4fa233cafa8a317623aa0 (patch)
tree40f523a33f55c4181190eaad47f79e88f8df5159 /internal/app/spfinal.go
parentd87020f0ca6897fbc1ba815fc1d9d048795e8749 (diff)
internal/app: remove spfinal
This no longer needs to be an independent outcomeOp since spFilesystemOp is moved late. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/spfinal.go')
-rw-r--r--internal/app/spfinal.go67
1 files changed, 0 insertions, 67 deletions
diff --git a/internal/app/spfinal.go b/internal/app/spfinal.go
deleted file mode 100644
index 7e444168..00000000
--- a/internal/app/spfinal.go
+++ /dev/null
@@ -1,67 +0,0 @@
-package app
-
-import (
- "encoding/gob"
- "fmt"
- "slices"
- "strings"
- "syscall"
-
- "hakurei.app/container/fhs"
- "hakurei.app/hst"
- "hakurei.app/system"
- "hakurei.app/system/acl"
-)
-
-func init() { gob.Register(spFinalOp{}) }
-
-// spFinalOp is a transitional op destined for removal after #3, #8, #9 has been resolved.
-// It exists to avoid reordering the expected entries in test cases.
-type spFinalOp struct{}
-
-func (s spFinalOp) toSystem(state *outcomeStateSys) error {
- // append ExtraPerms last
- for i := range state.extraPerms {
- p := &state.extraPerms[i]
- if p.Path == nil {
- continue
- }
-
- if p.Ensure {
- state.sys.Ensure(p.Path, 0700)
- }
-
- perms := make(acl.Perms, 0, 3)
- if p.Read {
- perms = append(perms, acl.Read)
- }
- if p.Write {
- perms = append(perms, acl.Write)
- }
- if p.Execute {
- perms = append(perms, acl.Execute)
- }
- state.sys.UpdatePermType(system.User, p.Path, perms...)
- }
- return nil
-}
-
-func (s spFinalOp) toContainer(state *outcomeStateParams) error {
- // TODO(ophestra): move this to spFilesystemOp after #8 and #9
-
- // mount root read-only as the final setup Op
- state.params.Remount(fhs.AbsRoot, syscall.MS_RDONLY)
-
- state.params.Env = make([]string, 0, len(state.env))
- for key, value := range state.env {
- if strings.IndexByte(key, '=') != -1 {
- return &hst.AppError{Step: "flatten environment", Err: syscall.EINVAL,
- Msg: fmt.Sprintf("invalid environment variable %s", key)}
- }
- state.params.Env = append(state.params.Env, key+"="+value)
- }
- // range over map has randomised order
- slices.Sort(state.params.Env)
-
- return nil
-}